diff --git a/talk/media/webrtc/fakewebrtccall.cc b/talk/media/webrtc/fakewebrtccall.cc index e7e268cee6..00f1864c18 100644 --- a/talk/media/webrtc/fakewebrtccall.cc +++ b/talk/media/webrtc/fakewebrtccall.cc @@ -39,6 +39,10 @@ FakeAudioReceiveStream::FakeAudioReceiveStream( : 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 @@ webrtc::Call::NetworkState FakeCall::GetNetworkState() const { 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 b9e75c5c0a..22b805b8ad 100644 --- a/talk/media/webrtc/fakewebrtccall.h +++ b/talk/media/webrtc/fakewebrtccall.h @@ -42,6 +42,8 @@ class FakeAudioReceiveStream : public webrtc::AudioReceiveStream { 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 @@ class FakeCall : public webrtc::Call, public webrtc::PacketReceiver { 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 6f431a88a7..c68d2647f2 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 #include #include -#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 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 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 0000000000..4ad15d6836 --- /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 +#include + +#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 extensions; + } rtp; + + rtc::scoped_ptr 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 6ad716dff8..ac11794ca2 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 @@ class Call { 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 @@ class Call { 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 @@ class Call { 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 de77f1b261..f5383f4319 100644 --- a/webrtc/video/audio_receive_stream.cc +++ b/webrtc/video/audio_receive_stream.cc @@ -63,6 +63,10 @@ AudioReceiveStream::AudioReceiveStream( } } +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 a321ec27a5..9935117d0f 100644 --- a/webrtc/video/audio_receive_stream.h +++ b/webrtc/video/audio_receive_stream.h @@ -26,6 +26,8 @@ class AudioReceiveStream : public webrtc::AudioReceiveStream { 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 bd9673421a..cde41bc77a 100644 --- a/webrtc/video/call.cc +++ b/webrtc/video/call.cc @@ -72,6 +72,10 @@ class Call : public webrtc::Call, public PacketReceiver { 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 @@ Call::~Call() { 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");