VoE2 API draft
BUG=4690
R=jmarusic@webrtc.org, kwiberg@webrtc.org, mflodman@webrtc.org, pbos@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/50029004
Cr-Commit-Position: refs/heads/master@{#9392}
diff --git a/talk/media/webrtc/fakewebrtccall.cc b/talk/media/webrtc/fakewebrtccall.cc
index e7e268c..00f1864 100644
--- a/talk/media/webrtc/fakewebrtccall.cc
+++ b/talk/media/webrtc/fakewebrtccall.cc
@@ -39,6 +39,10 @@
: config_(config), received_packets_(0) {
}
+webrtc::AudioReceiveStream::Stats FakeAudioReceiveStream::GetStats() const {
+ return webrtc::AudioReceiveStream::Stats();
+}
+
const webrtc::AudioReceiveStream::Config&
FakeAudioReceiveStream::GetConfig() const {
return config_;
@@ -230,6 +234,14 @@
return network_state_;
}
+webrtc::AudioSendStream* FakeCall::CreateAudioSendStream(
+ const webrtc::AudioSendStream::Config& config) {
+ return nullptr;
+}
+
+void FakeCall::DestroyAudioSendStream(webrtc::AudioSendStream* send_stream) {
+}
+
webrtc::AudioReceiveStream* FakeCall::CreateAudioReceiveStream(
const webrtc::AudioReceiveStream::Config& config) {
audio_receive_streams_.push_back(new FakeAudioReceiveStream(config));
diff --git a/talk/media/webrtc/fakewebrtccall.h b/talk/media/webrtc/fakewebrtccall.h
index b9e75c5..22b805b 100644
--- a/talk/media/webrtc/fakewebrtccall.h
+++ b/talk/media/webrtc/fakewebrtccall.h
@@ -42,6 +42,8 @@
explicit FakeAudioReceiveStream(
const webrtc::AudioReceiveStream::Config& config);
+ webrtc::AudioReceiveStream::Stats GetStats() const override;
+
const webrtc::AudioReceiveStream::Config& GetConfig() const;
int received_packets() const { return received_packets_; }
@@ -137,6 +139,10 @@
void SetStats(const webrtc::Call::Stats& stats);
private:
+ webrtc::AudioSendStream* CreateAudioSendStream(
+ const webrtc::AudioSendStream::Config& config) override;
+ void DestroyAudioSendStream(webrtc::AudioSendStream* send_stream) override;
+
webrtc::AudioReceiveStream* CreateAudioReceiveStream(
const webrtc::AudioReceiveStream::Config& config) override;
void DestroyAudioReceiveStream(
diff --git a/webrtc/audio_receive_stream.h b/webrtc/audio_receive_stream.h
index 6f431a8..c68d264 100644
--- a/webrtc/audio_receive_stream.h
+++ b/webrtc/audio_receive_stream.h
@@ -11,37 +11,50 @@
#ifndef WEBRTC_AUDIO_RECEIVE_STREAM_H_
#define WEBRTC_AUDIO_RECEIVE_STREAM_H_
+#include <map>
#include <string>
#include <vector>
-#include "webrtc/common_types.h"
#include "webrtc/config.h"
+#include "webrtc/typedefs.h"
namespace webrtc {
+class AudioDecoder;
+
class AudioReceiveStream {
public:
+ struct Stats {};
+
struct Config {
- Config() {}
std::string ToString() const;
// Receive-stream specific RTP settings.
struct Rtp {
- Rtp() : remote_ssrc(0) {}
std::string ToString() const;
// Synchronization source (stream identifier) to be received.
- uint32_t remote_ssrc;
+ uint32_t remote_ssrc = 0;
+
+ // Sender SSRC used for sending RTCP (such as receiver reports).
+ uint32_t local_ssrc = 0;
// RTP header extensions used for the received stream.
std::vector<RtpExtension> extensions;
} rtp;
+
+ // Decoders for every payload that we can receive. Call owns the
+ // AudioDecoder instances once the Config is submitted to
+ // Call::CreateReceiveStream().
+ // TODO(solenberg): Use unique_ptr<> once our std lib fully supports C++11.
+ std::map<uint8_t, AudioDecoder*> decoder_map;
};
+ virtual Stats GetStats() const = 0;
+
protected:
virtual ~AudioReceiveStream() {}
};
-
} // namespace webrtc
#endif // WEBRTC_AUDIO_RECEIVE_STREAM_H_
diff --git a/webrtc/audio_send_stream.h b/webrtc/audio_send_stream.h
new file mode 100644
index 0000000..4ad15d6
--- /dev/null
+++ b/webrtc/audio_send_stream.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef WEBRTC_AUDIO_SEND_STREAM_H_
+#define WEBRTC_AUDIO_SEND_STREAM_H_
+
+#include <string>
+#include <vector>
+
+#include "webrtc/base/scoped_ptr.h"
+#include "webrtc/config.h"
+#include "webrtc/modules/audio_coding/codecs/audio_encoder.h"
+#include "webrtc/typedefs.h"
+
+namespace webrtc {
+
+class AudioSendStream {
+ public:
+ struct Stats {};
+
+ struct Config {
+ std::string ToString() const;
+
+ // Receive-stream specific RTP settings.
+ struct Rtp {
+ std::string ToString() const;
+
+ // Sender SSRC.
+ uint32_t ssrc = 0;
+
+ // RTP header extensions used for the received stream.
+ std::vector<RtpExtension> extensions;
+ } rtp;
+
+ rtc::scoped_ptr<AudioEncoder> encoder;
+ int cng_payload_type = -1; // pt, or -1 to disable Comfort Noise Generator.
+ int red_payload_type = -1; // pt, or -1 to disable REDundant coding.
+ };
+
+ virtual Stats GetStats() const = 0;
+
+ protected:
+ virtual ~AudioSendStream() {}
+};
+} // namespace webrtc
+
+#endif // WEBRTC_AUDIO_SEND_STREAM_H_
diff --git a/webrtc/call.h b/webrtc/call.h
index 6ad716d..ac11794 100644
--- a/webrtc/call.h
+++ b/webrtc/call.h
@@ -15,12 +15,16 @@
#include "webrtc/common_types.h"
#include "webrtc/audio_receive_stream.h"
+#include "webrtc/audio_send_stream.h"
#include "webrtc/video_receive_stream.h"
#include "webrtc/video_send_stream.h"
namespace webrtc {
+class AudioDeviceModule;
+class AudioProcessing;
class VoiceEngine;
+class VoiceEngineObserver;
const char* Version();
@@ -76,6 +80,8 @@
static const int kDefaultStartBitrateBps;
+ // TODO(solenberg): Need to add media type to the interface for outgoing
+ // packets too.
newapi::Transport* send_transport;
// VoiceEngine used for audio/video synchronization for this Call.
@@ -96,6 +102,12 @@
int start_bitrate_bps;
int max_bitrate_bps;
} bitrate_config;
+
+ struct AudioConfig {
+ AudioDeviceModule* audio_device_manager;
+ AudioProcessing* audio_processing;
+ VoiceEngineObserver* voice_engine_observer;
+ } audio_config;
};
struct Stats {
@@ -113,6 +125,10 @@
static Call* Create(const Call::Config& config);
+ virtual AudioSendStream* CreateAudioSendStream(
+ const AudioSendStream::Config& config) = 0;
+ virtual void DestroyAudioSendStream(AudioSendStream* send_stream) = 0;
+
virtual AudioReceiveStream* CreateAudioReceiveStream(
const AudioReceiveStream::Config& config) = 0;
virtual void DestroyAudioReceiveStream(
diff --git a/webrtc/video/audio_receive_stream.cc b/webrtc/video/audio_receive_stream.cc
index de77f1b..f5383f4 100644
--- a/webrtc/video/audio_receive_stream.cc
+++ b/webrtc/video/audio_receive_stream.cc
@@ -63,6 +63,10 @@
}
}
+webrtc::AudioReceiveStream::Stats AudioReceiveStream::GetStats() const {
+ return webrtc::AudioReceiveStream::Stats();
+}
+
bool AudioReceiveStream::DeliverRtcp(const uint8_t* packet, size_t length) {
return false;
}
diff --git a/webrtc/video/audio_receive_stream.h b/webrtc/video/audio_receive_stream.h
index a321ec2..9935117 100644
--- a/webrtc/video/audio_receive_stream.h
+++ b/webrtc/video/audio_receive_stream.h
@@ -26,6 +26,8 @@
const webrtc::AudioReceiveStream::Config& config);
~AudioReceiveStream() override {}
+ webrtc::AudioReceiveStream::Stats GetStats() const override;
+
bool DeliverRtcp(const uint8_t* packet, size_t length);
bool DeliverRtp(const uint8_t* packet, size_t length);
diff --git a/webrtc/video/call.cc b/webrtc/video/call.cc
index bd96734..cde41bc 100644
--- a/webrtc/video/call.cc
+++ b/webrtc/video/call.cc
@@ -72,6 +72,10 @@
PacketReceiver* Receiver() override;
+ webrtc::AudioSendStream* CreateAudioSendStream(
+ const webrtc::AudioSendStream::Config& config) override;
+ void DestroyAudioSendStream(webrtc::AudioSendStream* send_stream) override;
+
webrtc::AudioReceiveStream* CreateAudioReceiveStream(
const webrtc::AudioReceiveStream::Config& config) override;
void DestroyAudioReceiveStream(
@@ -196,6 +200,14 @@
PacketReceiver* Call::Receiver() { return this; }
+webrtc::AudioSendStream* Call::CreateAudioSendStream(
+ const webrtc::AudioSendStream::Config& config) {
+ return nullptr;
+}
+
+void Call::DestroyAudioSendStream(webrtc::AudioSendStream* send_stream) {
+}
+
webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream(
const webrtc::AudioReceiveStream::Config& config) {
TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream");