From b071a19019a0a2173cc139c960d6ef6946a1c581 Mon Sep 17 00:00:00 2001 From: Fredrik Solenberg Date: Thu, 17 Sep 2015 16:42:56 +0200 Subject: [PATCH] Full use of NnChannel::SetSendParameters and NnChannel::SetRecvParameters. SetOptions(), SetMaxBandwidth(), Set[Send|Recv]RtpHeaderExtensions(), Set[Send|Recv]Codecs() are now private. BUG=webrtc:4690 R=pbos@webrtc.org, pthatcher@webrtc.org Review URL: https://codereview.webrtc.org/1327933002 . Cr-Commit-Position: refs/heads/master@{#9973} --- talk/app/webrtc/statscollector_unittest.cc | 9 +- talk/media/base/fakemediaengine.h | 217 +-- talk/media/base/mediachannel.h | 73 +- talk/media/base/rtpdataengine.cc | 9 + talk/media/base/rtpdataengine.h | 12 +- talk/media/base/rtpdataengine_unittest.cc | 62 +- talk/media/base/videoengine_unittest.h | 141 +- talk/media/sctp/sctpdataengine.cc | 8 + talk/media/sctp/sctpdataengine.h | 18 +- talk/media/webrtc/webrtcvideoengine2.cc | 12 +- talk/media/webrtc/webrtcvideoengine2.h | 22 +- .../webrtc/webrtcvideoengine2_unittest.cc | 614 ++++---- talk/media/webrtc/webrtcvoiceengine.cc | 8 +- talk/media/webrtc/webrtcvoiceengine.h | 22 +- .../webrtc/webrtcvoiceengine_unittest.cc | 1246 ++++++++--------- talk/session/media/channel_unittest.cc | 72 +- 16 files changed, 1194 insertions(+), 1351 deletions(-) diff --git a/talk/app/webrtc/statscollector_unittest.cc b/talk/app/webrtc/statscollector_unittest.cc index 9950a77b4f..9b037c4149 100644 --- a/talk/app/webrtc/statscollector_unittest.cc +++ b/talk/app/webrtc/statscollector_unittest.cc @@ -94,16 +94,15 @@ class MockWebRtcSession : public webrtc::WebRtcSession { class MockVideoMediaChannel : public cricket::FakeVideoMediaChannel { public: - MockVideoMediaChannel() : cricket::FakeVideoMediaChannel(NULL) {} - - // MOCK_METHOD0(transport_channel, cricket::TransportChannel*()); + MockVideoMediaChannel() : + cricket::FakeVideoMediaChannel(NULL, cricket::VideoOptions()) {} MOCK_METHOD1(GetStats, bool(cricket::VideoMediaInfo*)); }; class MockVoiceMediaChannel : public cricket::FakeVoiceMediaChannel { public: - MockVoiceMediaChannel() : cricket::FakeVoiceMediaChannel(NULL) { - } + MockVoiceMediaChannel() : + cricket::FakeVoiceMediaChannel(NULL, cricket::AudioOptions()) {} MOCK_METHOD1(GetStats, bool(cricket::VoiceMediaInfo*)); }; diff --git a/talk/media/base/fakemediaengine.h b/talk/media/base/fakemediaengine.h index d4dcefb37c..3c48aed8df 100644 --- a/talk/media/base/fakemediaengine.h +++ b/talk/media/base/fakemediaengine.h @@ -103,16 +103,6 @@ template class RtpHelper : public Base { } bool CheckNoRtp() { return rtp_packets_.empty(); } bool CheckNoRtcp() { return rtcp_packets_.empty(); } - virtual bool SetRecvRtpHeaderExtensions( - const std::vector& extensions) { - recv_extensions_ = extensions; - return true; - } - virtual bool SetSendRtpHeaderExtensions( - const std::vector& extensions) { - send_extensions_ = extensions; - return true; - } void set_fail_set_send_codecs(bool fail) { fail_set_send_codecs_ = fail; } void set_fail_set_recv_codecs(bool fail) { fail_set_recv_codecs_ = fail; } virtual bool AddSendStream(const StreamParams& sp) { @@ -180,12 +170,14 @@ template class RtpHelper : public Base { protected: bool MuteStream(uint32 ssrc, bool mute) { - if (!HasSendStream(ssrc) && ssrc != 0) + if (!HasSendStream(ssrc) && ssrc != 0) { return false; - if (mute) + } + if (mute) { muted_streams_.insert(ssrc); - else + } else { muted_streams_.erase(ssrc); + } return true; } bool set_sending(bool send) { @@ -193,6 +185,16 @@ template class RtpHelper : public Base { return true; } void set_playout(bool playout) { playout_ = playout; } + bool SetRecvRtpHeaderExtensions( + const std::vector& extensions) { + recv_extensions_ = extensions; + return true; + } + bool SetSendRtpHeaderExtensions( + const std::vector& extensions) { + send_extensions_ = extensions; + return true; + } virtual void OnPacketReceived(rtc::Buffer* packet, const rtc::PacketTime& packet_time) { rtp_packets_.push_back(std::string(packet->data(), packet->size())); @@ -235,7 +237,8 @@ class FakeVoiceMediaChannel : public RtpHelper { int duration; int flags; }; - explicit FakeVoiceMediaChannel(FakeVoiceEngine* engine) + explicit FakeVoiceMediaChannel(FakeVoiceEngine* engine, + const AudioOptions& options) : engine_(engine), fail_set_send_(false), ringback_tone_ssrc_(0), @@ -243,6 +246,7 @@ class FakeVoiceMediaChannel : public RtpHelper { ringback_tone_loop_(false), time_since_last_typing_(-1) { output_scalings_[0] = OutputScaling(); // For default channel. + SetOptions(options); } ~FakeVoiceMediaChannel(); const std::vector& recv_codecs() const { return recv_codecs_; } @@ -257,21 +261,16 @@ class FakeVoiceMediaChannel : public RtpHelper { bool ringback_tone_play() const { return ringback_tone_play_; } bool ringback_tone_loop() const { return ringback_tone_loop_; } - virtual bool SetRecvCodecs(const std::vector& codecs) { - if (fail_set_recv_codecs()) { - // Fake the failure in SetRecvCodecs. - return false; - } - recv_codecs_ = codecs; - return true; + virtual bool SetSendParameters(const AudioSendParameters& params) { + return (SetSendCodecs(params.codecs) && + SetSendRtpHeaderExtensions(params.extensions) && + SetMaxSendBandwidth(params.max_bandwidth_bps) && + SetOptions(params.options)); } - virtual bool SetSendCodecs(const std::vector& codecs) { - if (fail_set_send_codecs()) { - // Fake the failure in SetSendCodecs. - return false; - } - send_codecs_ = codecs; - return true; + + virtual bool SetRecvParameters(const AudioRecvParameters& params) { + return (SetRecvCodecs(params.codecs) && + SetRecvRtpHeaderExtensions(params.extensions)); } virtual bool SetPlayout(bool playout) { set_playout(playout); @@ -297,7 +296,6 @@ class FakeVoiceMediaChannel : public RtpHelper { } return true; } - virtual bool SetMaxSendBandwidth(int bps) { return true; } virtual bool AddRecvStream(const StreamParams& sp) { if (!RtpHelper::AddRecvStream(sp)) return false; @@ -399,12 +397,6 @@ class FakeVoiceMediaChannel : public RtpHelper { VoiceMediaChannel::SignalMediaError(ssrc, error); } - virtual bool SetOptions(const AudioOptions& options) { - // Does a "merge" of current options and set options. - options_.SetAll(options); - return true; - } - private: struct OutputScaling { OutputScaling() : left(1.0), right(1.0) {} @@ -436,6 +428,28 @@ class FakeVoiceMediaChannel : public RtpHelper { AudioRenderer* renderer_; }; + bool SetRecvCodecs(const std::vector& codecs) { + if (fail_set_recv_codecs()) { + // Fake the failure in SetRecvCodecs. + return false; + } + recv_codecs_ = codecs; + return true; + } + bool SetSendCodecs(const std::vector& codecs) { + if (fail_set_send_codecs()) { + // Fake the failure in SetSendCodecs. + return false; + } + send_codecs_ = codecs; + return true; + } + bool SetMaxSendBandwidth(int bps) { return true; } + bool SetOptions(const AudioOptions& options) { + // Does a "merge" of current options and set options. + options_.SetAll(options); + return true; + } bool SetLocalRenderer(uint32 ssrc, AudioRenderer* renderer) { auto it = local_renderers_.find(ssrc); if (renderer) { @@ -479,11 +493,14 @@ inline bool CompareDtmfInfo(const FakeVoiceMediaChannel::DtmfInfo& info, class FakeVideoMediaChannel : public RtpHelper { public: - explicit FakeVideoMediaChannel(FakeVideoEngine* engine) + explicit FakeVideoMediaChannel(FakeVideoEngine* engine, + const VideoOptions& options) : engine_(engine), sent_intra_frame_(false), requested_intra_frame_(false), - max_bps_(-1) {} + max_bps_(-1) { + SetOptions(options); + } ~FakeVideoMediaChannel(); @@ -510,7 +527,17 @@ class FakeVideoMediaChannel : public RtpHelper { send_formats_[ssrc] = format; return true; } + virtual bool SetSendParameters(const VideoSendParameters& params) { + return (SetSendCodecs(params.codecs) && + SetSendRtpHeaderExtensions(params.extensions) && + SetMaxSendBandwidth(params.max_bandwidth_bps) && + SetOptions(params.options)); + } + virtual bool SetRecvParameters(const VideoRecvParameters& params) { + return (SetRecvCodecs(params.codecs) && + SetRecvRtpHeaderExtensions(params.extensions)); + } virtual bool AddSendStream(const StreamParams& sp) { if (!RtpHelper::AddSendStream(sp)) { return false; @@ -523,27 +550,6 @@ class FakeVideoMediaChannel : public RtpHelper { return RtpHelper::RemoveSendStream(ssrc); } - virtual bool SetRecvCodecs(const std::vector& codecs) { - if (fail_set_recv_codecs()) { - // Fake the failure in SetRecvCodecs. - return false; - } - recv_codecs_ = codecs; - return true; - } - virtual bool SetSendCodecs(const std::vector& codecs) { - if (fail_set_send_codecs()) { - // Fake the failure in SetSendCodecs. - return false; - } - send_codecs_ = codecs; - - for (std::vector::const_iterator it = send_streams().begin(); - it != send_streams().end(); ++it) { - SetSendStreamDefaultFormat(it->first_ssrc()); - } - return true; - } virtual bool GetSendCodec(VideoCodec* send_codec) { if (send_codecs_.empty()) { return false; @@ -573,9 +579,8 @@ class FakeVideoMediaChannel : public RtpHelper { } if (!mute && options) { return SetOptions(*options); - } else { - return true; } + return true; } virtual bool SetCapturer(uint32 ssrc, VideoCapturer* capturer) { capturers_[ssrc] = capturer; @@ -584,10 +589,6 @@ class FakeVideoMediaChannel : public RtpHelper { bool HasCapturer(uint32 ssrc) const { return capturers_.find(ssrc) != capturers_.end(); } - virtual bool SetMaxSendBandwidth(int bps) { - max_bps_ = bps; - return true; - } virtual bool AddRecvStream(const StreamParams& sp) { if (!RtpHelper::AddRecvStream(sp)) return false; @@ -610,10 +611,6 @@ class FakeVideoMediaChannel : public RtpHelper { requested_intra_frame_ = true; return true; } - virtual bool SetOptions(const VideoOptions& options) { - options_ = options; - return true; - } virtual void UpdateAspectRatio(int ratio_w, int ratio_h) {} void set_sent_intra_frame(bool v) { sent_intra_frame_ = v; } bool sent_intra_frame() const { return sent_intra_frame_; } @@ -621,6 +618,36 @@ class FakeVideoMediaChannel : public RtpHelper { bool requested_intra_frame() const { return requested_intra_frame_; } private: + bool SetRecvCodecs(const std::vector& codecs) { + if (fail_set_recv_codecs()) { + // Fake the failure in SetRecvCodecs. + return false; + } + recv_codecs_ = codecs; + return true; + } + bool SetSendCodecs(const std::vector& codecs) { + if (fail_set_send_codecs()) { + // Fake the failure in SetSendCodecs. + return false; + } + send_codecs_ = codecs; + + for (std::vector::const_iterator it = send_streams().begin(); + it != send_streams().end(); ++it) { + SetSendStreamDefaultFormat(it->first_ssrc()); + } + return true; + } + bool SetOptions(const VideoOptions& options) { + options_ = options; + return true; + } + bool SetMaxSendBandwidth(int bps) { + max_bps_ = bps; + return true; + } + // Be default, each send stream uses the first send codec format. void SetSendStreamDefaultFormat(uint32 ssrc) { if (!send_codecs_.empty()) { @@ -645,7 +672,7 @@ class FakeVideoMediaChannel : public RtpHelper { class FakeDataMediaChannel : public RtpHelper { public: - explicit FakeDataMediaChannel(void* unused) + explicit FakeDataMediaChannel(void* unused, const DataOptions& options) : send_blocked_(false), max_bps_(-1) {} ~FakeDataMediaChannel() {} const std::vector& recv_codecs() const { return recv_codecs_; } @@ -653,31 +680,18 @@ class FakeDataMediaChannel : public RtpHelper { const std::vector& codecs() const { return send_codecs(); } int max_bps() const { return max_bps_; } - virtual bool SetRecvCodecs(const std::vector& codecs) { - if (fail_set_recv_codecs()) { - // Fake the failure in SetRecvCodecs. - return false; - } - recv_codecs_ = codecs; - return true; + virtual bool SetSendParameters(const DataSendParameters& params) { + return (SetSendCodecs(params.codecs) && + SetMaxSendBandwidth(params.max_bandwidth_bps)); } - virtual bool SetSendCodecs(const std::vector& codecs) { - if (fail_set_send_codecs()) { - // Fake the failure in SetSendCodecs. - return false; - } - send_codecs_ = codecs; - return true; + virtual bool SetRecvParameters(const DataRecvParameters& params) { + return SetRecvCodecs(params.codecs); } virtual bool SetSend(bool send) { return set_sending(send); } virtual bool SetReceive(bool receive) { set_playout(receive); return true; } - virtual bool SetMaxSendBandwidth(int bps) { - max_bps_ = bps; - return true; - } virtual bool AddRecvStream(const StreamParams& sp) { if (!RtpHelper::AddRecvStream(sp)) return false; @@ -708,6 +722,27 @@ class FakeDataMediaChannel : public RtpHelper { void set_send_blocked(bool blocked) { send_blocked_ = blocked; } private: + bool SetRecvCodecs(const std::vector& codecs) { + if (fail_set_recv_codecs()) { + // Fake the failure in SetRecvCodecs. + return false; + } + recv_codecs_ = codecs; + return true; + } + bool SetSendCodecs(const std::vector& codecs) { + if (fail_set_send_codecs()) { + // Fake the failure in SetSendCodecs. + return false; + } + send_codecs_ = codecs; + return true; + } + bool SetMaxSendBandwidth(int bps) { + max_bps_ = bps; + return true; + } + std::vector recv_codecs_; std::vector send_codecs_; SendDataParams last_sent_data_params_; @@ -780,8 +815,7 @@ class FakeVoiceEngine : public FakeBaseEngine { return nullptr; } - FakeVoiceMediaChannel* ch = new FakeVoiceMediaChannel(this); - ch->SetOptions(options); + FakeVoiceMediaChannel* ch = new FakeVoiceMediaChannel(this, options); channels_.push_back(ch); return ch; } @@ -892,8 +926,7 @@ class FakeVideoEngine : public FakeBaseEngine { return NULL; } - FakeVideoMediaChannel* ch = new FakeVideoMediaChannel(this); - ch->SetOptions(options); + FakeVideoMediaChannel* ch = new FakeVideoMediaChannel(this, options); channels_.push_back(ch); return ch; } @@ -1035,7 +1068,7 @@ class FakeDataEngine : public DataEngineInterface { virtual DataMediaChannel* CreateChannel(DataChannelType data_channel_type) { last_channel_type_ = data_channel_type; - FakeDataMediaChannel* ch = new FakeDataMediaChannel(this); + FakeDataMediaChannel* ch = new FakeDataMediaChannel(this, DataOptions()); channels_.push_back(ch); return ch; } diff --git a/talk/media/base/mediachannel.h b/talk/media/base/mediachannel.h index 1ba89dccff..ec11694e71 100644 --- a/talk/media/base/mediachannel.h +++ b/talk/media/base/mediachannel.h @@ -566,17 +566,10 @@ class MediaChannel : public sigslot::has_slots<> { // multiple SSRCs. virtual bool RemoveRecvStream(uint32 ssrc) = 0; - // Sets the RTP extension headers and IDs to use when sending RTP. - virtual bool SetRecvRtpHeaderExtensions( - const std::vector& extensions) = 0; - virtual bool SetSendRtpHeaderExtensions( - const std::vector& extensions) = 0; // Returns the absoulte sendtime extension id value from media channel. virtual int GetRtpSendTimeExtnId() const { return -1; } - // Sets the maximum allowed bandwidth to use when sending data. - virtual bool SetMaxSendBandwidth(int bps) = 0; // Base method to send packet using NetworkInterface. bool SendPacket(rtc::Buffer* packet) { @@ -1070,26 +1063,8 @@ class VoiceMediaChannel : public MediaChannel { VoiceMediaChannel() {} virtual ~VoiceMediaChannel() {} - // TODO(pthatcher): Remove SetSendCodecs, - // SetSendRtpHeaderExtensions, SetMaxSendBandwidth, and SetOptions - // once all implementations implement SetSendParameters. - virtual bool SetSendParameters(const AudioSendParameters& params) { - return (SetSendCodecs(params.codecs) && - SetSendRtpHeaderExtensions(params.extensions) && - SetMaxSendBandwidth(params.max_bandwidth_bps) && - SetOptions(params.options)); - } - // TODO(pthatcher): Remove SetRecvCodecs and - // SetRecvRtpHeaderExtensions once all implementations implement - // SetRecvParameters. - virtual bool SetRecvParameters(const AudioRecvParameters& params) { - return (SetRecvCodecs(params.codecs) && - SetRecvRtpHeaderExtensions(params.extensions)); - } - // Sets the codecs/payload types to be used for incoming media. - virtual bool SetRecvCodecs(const std::vector& codecs) = 0; - // Sets the codecs/payload types to be used for outgoing media. - virtual bool SetSendCodecs(const std::vector& codecs) = 0; + virtual bool SetSendParameters(const AudioSendParameters& params) = 0; + virtual bool SetRecvParameters(const AudioRecvParameters& params) = 0; // Starts or stops playout of received audio. virtual bool SetPlayout(bool playout) = 0; // Starts or stops sending (and potentially capture) of local audio. @@ -1131,8 +1106,6 @@ class VoiceMediaChannel : public MediaChannel { ASSERT(error != NULL); *error = ERROR_NONE; } - // Sets the media options to use. - virtual bool SetOptions(const AudioOptions& options) = 0; // Signal errors from MediaChannel. Arguments are: // ssrc(uint32), and error(VoiceMediaChannel::Error). @@ -1164,26 +1137,9 @@ class VideoMediaChannel : public MediaChannel { VideoMediaChannel() : renderer_(NULL) {} virtual ~VideoMediaChannel() {} - // TODO(pthatcher): Remove SetSendCodecs, - // SetSendRtpHeaderExtensions, SetMaxSendBandwidth, and SetOptions - // once all implementations implement SetSendParameters. - virtual bool SetSendParameters(const VideoSendParameters& params) { - return (SetSendCodecs(params.codecs) && - SetSendRtpHeaderExtensions(params.extensions) && - SetMaxSendBandwidth(params.max_bandwidth_bps) && - SetOptions(params.options)); - } - // TODO(pthatcher): Remove SetRecvCodecs and - // SetRecvRtpHeaderExtensions once all implementations implement - // SetRecvParameters. - virtual bool SetRecvParameters(const VideoRecvParameters& params) { - return (SetRecvCodecs(params.codecs) && - SetRecvRtpHeaderExtensions(params.extensions)); - } - // Sets the codecs/payload types to be used for incoming media. - virtual bool SetRecvCodecs(const std::vector& codecs) = 0; - // Sets the codecs/payload types to be used for outgoing media. - virtual bool SetSendCodecs(const std::vector& codecs) = 0; + + virtual bool SetSendParameters(const VideoSendParameters& params) = 0; + virtual bool SetRecvParameters(const VideoRecvParameters& params) = 0; // Gets the currently set codecs/payload types to be used for outgoing media. virtual bool GetSendCodec(VideoCodec* send_codec) = 0; // Sets the format of a specified outgoing stream. @@ -1207,8 +1163,6 @@ class VideoMediaChannel : public MediaChannel { virtual bool SendIntraFrame() = 0; // Reuqest each of the remote senders to send an intra frame. virtual bool RequestIntraFrame() = 0; - // Sets the media options to use. - virtual bool SetOptions(const VideoOptions& options) = 0; virtual void UpdateAspectRatio(int ratio_w, int ratio_h) = 0; // Signal errors from MediaChannel. Arguments are: @@ -1320,21 +1274,8 @@ class DataMediaChannel : public MediaChannel { virtual ~DataMediaChannel() {} - // TODO(pthatcher): Remove SetSendCodecs, - // SetSendRtpHeaderExtensions, SetMaxSendBandwidth, and SetOptions - // once all implementations implement SetSendParameters. - virtual bool SetSendParameters(const DataSendParameters& params) { - return (SetSendCodecs(params.codecs) && - SetMaxSendBandwidth(params.max_bandwidth_bps)); - } - // TODO(pthatcher): Remove SetRecvCodecs and - // SetRecvRtpHeaderExtensions once all implementations implement - // SetRecvParameters. - virtual bool SetRecvParameters(const DataRecvParameters& params) { - return SetRecvCodecs(params.codecs); - } - virtual bool SetSendCodecs(const std::vector& codecs) = 0; - virtual bool SetRecvCodecs(const std::vector& codecs) = 0; + virtual bool SetSendParameters(const DataSendParameters& params) = 0; + virtual bool SetRecvParameters(const DataRecvParameters& params) = 0; // TODO(pthatcher): Implement this. virtual bool GetStats(DataMediaInfo* info) { return true; } diff --git a/talk/media/base/rtpdataengine.cc b/talk/media/base/rtpdataengine.cc index 8cc4dac458..02e4b7c06f 100644 --- a/talk/media/base/rtpdataengine.cc +++ b/talk/media/base/rtpdataengine.cc @@ -155,6 +155,15 @@ bool RtpDataMediaChannel::SetSendCodecs(const std::vector& codecs) { return true; } +bool RtpDataMediaChannel::SetSendParameters(const DataSendParameters& params) { + return (SetSendCodecs(params.codecs) && + SetMaxSendBandwidth(params.max_bandwidth_bps)); +} + +bool RtpDataMediaChannel::SetRecvParameters(const DataRecvParameters& params) { + return SetRecvCodecs(params.codecs); +} + bool RtpDataMediaChannel::AddSendStream(const StreamParams& stream) { if (!stream.has_ssrcs()) { return false; diff --git a/talk/media/base/rtpdataengine.h b/talk/media/base/rtpdataengine.h index 6f47c5b4bb..211b0dc91d 100644 --- a/talk/media/base/rtpdataengine.h +++ b/talk/media/base/rtpdataengine.h @@ -96,13 +96,8 @@ class RtpDataMediaChannel : public DataMediaChannel { timing_ = timing; } - virtual bool SetMaxSendBandwidth(int bps); - virtual bool SetRecvRtpHeaderExtensions( - const std::vector& extensions) { return true; } - virtual bool SetSendRtpHeaderExtensions( - const std::vector& extensions) { return true; } - virtual bool SetSendCodecs(const std::vector& codecs); - virtual bool SetRecvCodecs(const std::vector& codecs); + virtual bool SetSendParameters(const DataSendParameters& params); + virtual bool SetRecvParameters(const DataRecvParameters& params); virtual bool AddSendStream(const StreamParams& sp); virtual bool RemoveSendStream(uint32 ssrc); virtual bool AddRecvStream(const StreamParams& sp); @@ -127,6 +122,9 @@ class RtpDataMediaChannel : public DataMediaChannel { private: void Construct(rtc::Timing* timing); + bool SetMaxSendBandwidth(int bps); + bool SetSendCodecs(const std::vector& codecs); + bool SetRecvCodecs(const std::vector& codecs); bool sending_; bool receiving_; diff --git a/talk/media/base/rtpdataengine_unittest.cc b/talk/media/base/rtpdataengine_unittest.cc index 3682320433..53648df3fa 100644 --- a/talk/media/base/rtpdataengine_unittest.cc +++ b/talk/media/base/rtpdataengine_unittest.cc @@ -176,22 +176,29 @@ TEST_F(RtpDataMediaChannelTest, SetUnknownCodecs) { unknown_codec.id = 104; unknown_codec.name = "unknown-data"; - std::vector known_codecs; - known_codecs.push_back(known_codec); + cricket::DataSendParameters send_parameters_known; + send_parameters_known.codecs.push_back(known_codec); + cricket::DataRecvParameters recv_parameters_known; + recv_parameters_known.codecs.push_back(known_codec); - std::vector unknown_codecs; - unknown_codecs.push_back(unknown_codec); + cricket::DataSendParameters send_parameters_unknown; + send_parameters_unknown.codecs.push_back(unknown_codec); + cricket::DataRecvParameters recv_parameters_unknown; + recv_parameters_unknown.codecs.push_back(unknown_codec); - std::vector mixed_codecs; - mixed_codecs.push_back(known_codec); - mixed_codecs.push_back(unknown_codec); + cricket::DataSendParameters send_parameters_mixed; + send_parameters_mixed.codecs.push_back(known_codec); + send_parameters_mixed.codecs.push_back(unknown_codec); + cricket::DataRecvParameters recv_parameters_mixed; + recv_parameters_mixed.codecs.push_back(known_codec); + recv_parameters_mixed.codecs.push_back(unknown_codec); - EXPECT_TRUE(dmc->SetSendCodecs(known_codecs)); - EXPECT_FALSE(dmc->SetSendCodecs(unknown_codecs)); - EXPECT_TRUE(dmc->SetSendCodecs(mixed_codecs)); - EXPECT_TRUE(dmc->SetRecvCodecs(known_codecs)); - EXPECT_FALSE(dmc->SetRecvCodecs(unknown_codecs)); - EXPECT_FALSE(dmc->SetRecvCodecs(mixed_codecs)); + EXPECT_TRUE(dmc->SetSendParameters(send_parameters_known)); + EXPECT_FALSE(dmc->SetSendParameters(send_parameters_unknown)); + EXPECT_TRUE(dmc->SetSendParameters(send_parameters_mixed)); + EXPECT_TRUE(dmc->SetRecvParameters(recv_parameters_known)); + EXPECT_FALSE(dmc->SetRecvParameters(recv_parameters_unknown)); + EXPECT_FALSE(dmc->SetRecvParameters(recv_parameters_mixed)); } TEST_F(RtpDataMediaChannelTest, AddRemoveSendStream) { @@ -260,9 +267,9 @@ TEST_F(RtpDataMediaChannelTest, SendData) { cricket::DataCodec codec; codec.id = 103; codec.name = cricket::kGoogleRtpDataCodecName; - std::vector codecs; - codecs.push_back(codec); - ASSERT_TRUE(dmc->SetSendCodecs(codecs)); + cricket::DataSendParameters parameters; + parameters.codecs.push_back(codec); + ASSERT_TRUE(dmc->SetSendParameters(parameters)); // Length too large; std::string x10000(10000, 'x'); @@ -324,10 +331,10 @@ TEST_F(RtpDataMediaChannelTest, SendDataMultipleClocks) { cricket::DataCodec codec; codec.id = 103; codec.name = cricket::kGoogleRtpDataCodecName; - std::vector codecs; - codecs.push_back(codec); - ASSERT_TRUE(dmc1->SetSendCodecs(codecs)); - ASSERT_TRUE(dmc2->SetSendCodecs(codecs)); + cricket::DataSendParameters parameters; + parameters.codecs.push_back(codec); + ASSERT_TRUE(dmc1->SetSendParameters(parameters)); + ASSERT_TRUE(dmc2->SetSendParameters(parameters)); cricket::SendDataParams params1; params1.ssrc = 41; @@ -371,9 +378,9 @@ TEST_F(RtpDataMediaChannelTest, SendDataRate) { cricket::DataCodec codec; codec.id = 103; codec.name = cricket::kGoogleRtpDataCodecName; - std::vector codecs; - codecs.push_back(codec); - ASSERT_TRUE(dmc->SetSendCodecs(codecs)); + cricket::DataSendParameters parameters; + parameters.codecs.push_back(codec); + ASSERT_TRUE(dmc->SetSendParameters(parameters)); cricket::StreamParams stream; stream.add_ssrc(42); @@ -388,7 +395,8 @@ TEST_F(RtpDataMediaChannelTest, SendDataRate) { // With rtp overhead of 32 bytes, each one of our packets is 36 // bytes, or 288 bits. So, a limit of 872bps will allow 3 packets, // but not four. - dmc->SetMaxSendBandwidth(872); + parameters.max_bandwidth_bps = 872; + ASSERT_TRUE(dmc->SetSendParameters(parameters)); EXPECT_TRUE(dmc->SendData(params, payload, &result)); EXPECT_TRUE(dmc->SendData(params, payload, &result)); @@ -436,9 +444,9 @@ TEST_F(RtpDataMediaChannelTest, ReceiveData) { cricket::DataCodec codec; codec.id = 103; codec.name = cricket::kGoogleRtpDataCodecName; - std::vector codecs; - codecs.push_back(codec); - ASSERT_TRUE(dmc->SetRecvCodecs(codecs)); + cricket::DataRecvParameters parameters; + parameters.codecs.push_back(codec); + ASSERT_TRUE(dmc->SetRecvParameters(parameters)); // Unknown stream dmc->OnPacketReceived(&packet, rtc::PacketTime()); diff --git a/talk/media/base/videoengine_unittest.h b/talk/media/base/videoengine_unittest.h index 9e6b227011..1e79d7fa61 100644 --- a/talk/media/base/videoengine_unittest.h +++ b/talk/media/base/videoengine_unittest.h @@ -469,7 +469,9 @@ class VideoMediaChannelTest : public testing::Test, network_interface_.SetDestination(channel_.get()); channel_->SetInterface(&network_interface_); media_error_ = cricket::VideoMediaChannel::ERROR_NONE; - channel_->SetRecvCodecs(engine_.codecs()); + cricket::VideoRecvParameters parameters; + parameters.codecs = engine_.codecs(); + channel_->SetRecvParameters(parameters); EXPECT_TRUE(channel_->AddSendStream(DefaultSendStreamParams())); video_capturer_.reset(CreateFakeVideoCapturer()); cricket::VideoFormat format(640, 480, @@ -530,9 +532,6 @@ class VideoMediaChannelTest : public testing::Test, return SetOneCodec(cricket::VideoCodec(pt, name, w, h, fr, 0)); } bool SetOneCodec(const cricket::VideoCodec& codec) { - std::vector codecs; - codecs.push_back(codec); - cricket::VideoFormat capture_format(codec.width, codec.height, cricket::VideoFormat::FpsToInterval(codec.framerate), cricket::FOURCC_I420); @@ -546,10 +545,14 @@ class VideoMediaChannelTest : public testing::Test, bool sending = channel_->sending(); bool success = SetSend(false); - if (success) - success = channel_->SetSendCodecs(codecs); - if (success) + if (success) { + cricket::VideoSendParameters parameters; + parameters.codecs.push_back(codec); + success = channel_->SetSendParameters(parameters); + } + if (success) { success = SetSend(sending); + } return success; } bool SetSend(bool send) { @@ -860,9 +863,10 @@ class VideoMediaChannelTest : public testing::Test, void GetStatsMultipleRecvStreams() { cricket::FakeVideoRenderer renderer1, renderer2; EXPECT_TRUE(SetOneCodec(DefaultCodec())); - cricket::VideoOptions vmo; - vmo.conference_mode.Set(true); - EXPECT_TRUE(channel_->SetOptions(vmo)); + cricket::VideoSendParameters parameters; + parameters.codecs.push_back(DefaultCodec()); + parameters.options.conference_mode.Set(true); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_TRUE(SetSend(true)); EXPECT_TRUE(channel_->AddRecvStream( cricket::StreamParams::CreateLegacy(1))); @@ -908,9 +912,10 @@ class VideoMediaChannelTest : public testing::Test, // Normal setup; note that we set the SSRC explicitly to ensure that // it will come first in the senders map. EXPECT_TRUE(SetOneCodec(DefaultCodec())); - cricket::VideoOptions vmo; - vmo.conference_mode.Set(true); - EXPECT_TRUE(channel_->SetOptions(vmo)); + cricket::VideoSendParameters parameters; + parameters.codecs.push_back(DefaultCodec()); + parameters.options.conference_mode.Set(true); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_TRUE(channel_->AddRecvStream( cricket::StreamParams::CreateLegacy(kSsrc))); EXPECT_TRUE(channel_->SetRenderer(kSsrc, &renderer_)); @@ -975,8 +980,12 @@ class VideoMediaChannelTest : public testing::Test, // Test that we can set the bandwidth. void SetSendBandwidth() { - EXPECT_TRUE(channel_->SetMaxSendBandwidth(-1)); // <= 0 means unlimited. - EXPECT_TRUE(channel_->SetMaxSendBandwidth(128 * 1024)); + cricket::VideoSendParameters parameters; + parameters.codecs.push_back(DefaultCodec()); + parameters.max_bandwidth_bps = -1; // <= 0 means unlimited. + EXPECT_TRUE(channel_->SetSendParameters(parameters)); + parameters.max_bandwidth_bps = 128 * 1024; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); } // Test that we can set the SSRC for the default send source. void SetSendSsrc() { @@ -1082,33 +1091,13 @@ class VideoMediaChannelTest : public testing::Test, EXPECT_EQ(789u, ssrc); } - // Tests adding streams already exists returns false. - void AddRecvStreamsAlreadyExist() { - cricket::VideoOptions vmo; - vmo.conference_mode.Set(true); - EXPECT_TRUE(channel_->SetOptions(vmo)); - - EXPECT_FALSE(channel_->AddRecvStream( - cricket::StreamParams::CreateLegacy(0))); - - EXPECT_TRUE(channel_->AddRecvStream( - cricket::StreamParams::CreateLegacy(1))); - EXPECT_FALSE(channel_->AddRecvStream( - cricket::StreamParams::CreateLegacy(1))); - - EXPECT_TRUE(channel_->RemoveRecvStream(1)); - EXPECT_FALSE(channel_->AddRecvStream( - cricket::StreamParams::CreateLegacy(0))); - EXPECT_TRUE(channel_->AddRecvStream( - cricket::StreamParams::CreateLegacy(1))); - } - // Tests setting up and configuring multiple incoming streams. void AddRemoveRecvStreams() { cricket::FakeVideoRenderer renderer1, renderer2; - cricket::VideoOptions vmo; - vmo.conference_mode.Set(true); - EXPECT_TRUE(channel_->SetOptions(vmo)); + cricket::VideoSendParameters parameters; + parameters.codecs.push_back(DefaultCodec()); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); + // Ensure we can't set the renderer on a non-existent stream. EXPECT_FALSE(channel_->SetRenderer(1, &renderer1)); EXPECT_FALSE(channel_->SetRenderer(2, &renderer2)); @@ -1238,9 +1227,10 @@ class VideoMediaChannelTest : public testing::Test, void SimulateConference() { cricket::FakeVideoRenderer renderer1, renderer2; EXPECT_TRUE(SetDefaultCodec()); - cricket::VideoOptions vmo; - vmo.conference_mode.Set(true); - EXPECT_TRUE(channel_->SetOptions(vmo)); + cricket::VideoSendParameters parameters; + parameters.codecs.push_back(DefaultCodec()); + parameters.options.conference_mode.Set(true); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_TRUE(SetSend(true)); EXPECT_TRUE(channel_->SetRender(true)); EXPECT_TRUE(channel_->AddRecvStream( @@ -1758,10 +1748,10 @@ class VideoMediaChannelTest : public testing::Test, // Tests that we can send and receive frames with early receive. void TwoStreamsSendAndUnsignalledRecv(const cricket::VideoCodec& codec) { - cricket::VideoOptions vmo; - vmo.conference_mode.Set(true); - vmo.unsignalled_recv_stream_limit.Set(1); - EXPECT_TRUE(channel_->SetOptions(vmo)); + cricket::VideoSendParameters parameters; + parameters.options.conference_mode.Set(true); + parameters.options.unsignalled_recv_stream_limit.Set(1); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); SetUpSecondStreamWithNoRecv(); // Test sending and receiving on first stream. EXPECT_TRUE(channel_->SetRender(true)); @@ -1788,65 +1778,6 @@ class VideoMediaChannelTest : public testing::Test, EXPECT_EQ_WAIT(1, renderer2_.num_rendered_frames(), kTimeout); } - // Tests that we cannot receive key frames with unsignalled recv disabled. - void TwoStreamsSendAndFailUnsignalledRecv(const cricket::VideoCodec& codec) { - cricket::VideoOptions vmo; - vmo.conference_mode.Set(true); - vmo.unsignalled_recv_stream_limit.Set(0); - EXPECT_TRUE(channel_->SetOptions(vmo)); - SetUpSecondStreamWithNoRecv(); - // Test sending and receiving on first stream. - EXPECT_TRUE(channel_->SetRender(true)); - Send(codec); - EXPECT_EQ_WAIT(2, NumRtpPackets(), kTimeout); - rtc::Thread::Current()->ProcessMessages(100); - EXPECT_EQ_WAIT(1, renderer_.num_rendered_frames(), kTimeout); - EXPECT_EQ_WAIT(0, renderer2_.num_rendered_frames(), kTimeout); - // Give a chance for the decoder to process before adding the receiver. - rtc::Thread::Current()->ProcessMessages(10); - // Test sending and receiving on second stream. - EXPECT_TRUE(channel_->AddRecvStream( - cricket::StreamParams::CreateLegacy(kSsrc + 2))); - EXPECT_TRUE(channel_->SetRenderer(kSsrc + 2, &renderer2_)); - SendFrame(); - EXPECT_TRUE_WAIT(renderer_.num_rendered_frames() >= 1, kTimeout); - EXPECT_EQ_WAIT(4, NumRtpPackets(), kTimeout); - // We dont expect any frames here, because the key frame would have been - // lost in the earlier packet. This is the case we want to solve with early - // receive. - EXPECT_EQ(0, renderer2_.num_rendered_frames()); - } - - // Tests that we drop key frames when conference mode is disabled and we - // receive rtp packets on unsignalled streams. - void TwoStreamsSendAndFailUnsignalledRecvInOneToOne( - const cricket::VideoCodec& codec) { - cricket::VideoOptions vmo; - vmo.conference_mode.Set(false); - vmo.unsignalled_recv_stream_limit.Set(1); - EXPECT_TRUE(channel_->SetOptions(vmo)); - SetUpSecondStreamWithNoRecv(); - // Test sending and receiving on first stream. - EXPECT_TRUE(channel_->SetRender(true)); - Send(codec); - EXPECT_EQ_WAIT(2, NumRtpPackets(), kTimeout); - // In one-to-one mode, we deliver frames to the default channel if there - // is no registered recv channel for the ssrc. - EXPECT_TRUE_WAIT(renderer_.num_rendered_frames() >= 1, kTimeout); - // Give a chance for the decoder to process before adding the receiver. - rtc::Thread::Current()->ProcessMessages(100); - // Test sending and receiving on second stream. - EXPECT_TRUE(channel_->AddRecvStream( - cricket::StreamParams::CreateLegacy(kSsrc + 2))); - EXPECT_TRUE(channel_->SetRenderer(kSsrc + 2, &renderer2_)); - SendFrame(); - EXPECT_TRUE_WAIT(renderer_.num_rendered_frames() >= 1, kTimeout); - EXPECT_EQ_WAIT(4, NumRtpPackets(), kTimeout); - // We dont expect any frames here, because the key frame would have been - // delivered to default channel. - EXPECT_EQ(0, renderer2_.num_rendered_frames()); - } - // Tests that we drop key frames when conference mode is enabled and we // receive rtp packets on unsignalled streams. Removal of a unsignalled recv // stream is successful. diff --git a/talk/media/sctp/sctpdataengine.cc b/talk/media/sctp/sctpdataengine.cc index 693fbecb15..1ead8e0f2e 100644 --- a/talk/media/sctp/sctpdataengine.cc +++ b/talk/media/sctp/sctpdataengine.cc @@ -563,6 +563,14 @@ bool SctpDataMediaChannel::SetReceive(bool receive) { return true; } +bool SctpDataMediaChannel::SetSendParameters(const DataSendParameters& params) { + return SetSendCodecs(params.codecs); +} + +bool SctpDataMediaChannel::SetRecvParameters(const DataRecvParameters& params) { + return SetRecvCodecs(params.codecs); +} + bool SctpDataMediaChannel::AddSendStream(const StreamParams& stream) { return AddStream(stream); } diff --git a/talk/media/sctp/sctpdataengine.h b/talk/media/sctp/sctpdataengine.h index 010175b34e..451c00d5ba 100644 --- a/talk/media/sctp/sctpdataengine.h +++ b/talk/media/sctp/sctpdataengine.h @@ -148,6 +148,8 @@ class SctpDataMediaChannel : public DataMediaChannel, // Unless SetReceive(true) is called, received packets will be discarded. virtual bool SetReceive(bool receive); + virtual bool SetSendParameters(const DataSendParameters& params); + virtual bool SetRecvParameters(const DataRecvParameters& params); virtual bool AddSendStream(const StreamParams& sp); virtual bool RemoveSendStream(uint32 ssrc); virtual bool AddRecvStream(const StreamParams& sp); @@ -169,21 +171,8 @@ class SctpDataMediaChannel : public DataMediaChannel, // Exposed to allow Post call from c-callbacks. rtc::Thread* worker_thread() const { return worker_thread_; } - // TODO(ldixon): add a DataOptions class to mediachannel.h - virtual bool SetOptions(int options) { return false; } - // Many of these things are unused by SCTP, but are needed to fulfill // the MediaChannel interface. - // TODO(pthatcher): Cleanup MediaChannel interface, or at least - // don't try calling these and return false. Right now, things - // don't work if we return false. - virtual bool SetMaxSendBandwidth(int bps) { return true; } - virtual bool SetRecvRtpHeaderExtensions( - const std::vector& extensions) { return true; } - virtual bool SetSendRtpHeaderExtensions( - const std::vector& extensions) { return true; } - virtual bool SetSendCodecs(const std::vector& codecs); - virtual bool SetRecvCodecs(const std::vector& codecs); virtual void OnRtcpReceived(rtc::Buffer* packet, const rtc::PacketTime& packet_time) {} virtual void OnReadyToSend(bool ready) {} @@ -198,6 +187,9 @@ class SctpDataMediaChannel : public DataMediaChannel, private: sockaddr_conn GetSctpSockAddr(int port); + bool SetSendCodecs(const std::vector& codecs); + bool SetRecvCodecs(const std::vector& codecs); + // Creates the socket and connects. Sets sending_ to true. bool Connect(); // Closes the socket. Sets sending_ to false. diff --git a/talk/media/webrtc/webrtcvideoengine2.cc b/talk/media/webrtc/webrtcvideoengine2.cc index 85e67c4c6c..7cd5c0622e 100644 --- a/talk/media/webrtc/webrtcvideoengine2.cc +++ b/talk/media/webrtc/webrtcvideoengine2.cc @@ -602,10 +602,8 @@ WebRtcVideoChannel2* WebRtcVideoEngine2::CreateChannel( const VideoOptions& options) { RTC_DCHECK(initialized_); LOG(LS_INFO) << "CreateChannel. Options: " << options.ToString(); - WebRtcVideoChannel2* channel = new WebRtcVideoChannel2(call, options, + return new WebRtcVideoChannel2(call, options, video_codecs_, external_encoder_factory_, external_decoder_factory_); - channel->SetRecvCodecs(video_codecs_); - return channel; } const std::vector& WebRtcVideoEngine2::codecs() const { @@ -764,6 +762,7 @@ std::vector WebRtcVideoEngine2::GetSupportedCodecs() const { WebRtcVideoChannel2::WebRtcVideoChannel2( webrtc::Call* call, const VideoOptions& options, + const std::vector& recv_codecs, WebRtcVideoEncoderFactory* external_encoder_factory, WebRtcVideoDecoderFactory* external_decoder_factory) : call_(call), @@ -777,6 +776,7 @@ WebRtcVideoChannel2::WebRtcVideoChannel2( rtcp_receiver_report_ssrc_ = kDefaultRtcpReceiverReportSsrc; sending_ = false; default_send_ssrc_ = 0; + SetRecvCodecs(recv_codecs); } void WebRtcVideoChannel2::SetDefaultOptions() { @@ -1574,7 +1574,11 @@ bool WebRtcVideoChannel2::SetMaxSendBandwidth(int max_bitrate_bps) { if (max_bitrate_bps == bitrate_config_.max_bitrate_bps) return true; - if (max_bitrate_bps <= 0) { + if (max_bitrate_bps < 0) { + // Option not set. + return true; + } + if (max_bitrate_bps == 0) { // Unsetting max bitrate. max_bitrate_bps = -1; } diff --git a/talk/media/webrtc/webrtcvideoengine2.h b/talk/media/webrtc/webrtcvideoengine2.h index 144d1c4cee..acd9a1bcea 100644 --- a/talk/media/webrtc/webrtcvideoengine2.h +++ b/talk/media/webrtc/webrtcvideoengine2.h @@ -161,6 +161,7 @@ class WebRtcVideoChannel2 : public rtc::MessageHandler, public: WebRtcVideoChannel2(webrtc::Call* call, const VideoOptions& options, + const std::vector& recv_codecs, WebRtcVideoEncoderFactory* external_encoder_factory, WebRtcVideoDecoderFactory* external_decoder_factory); ~WebRtcVideoChannel2() override; @@ -168,8 +169,6 @@ class WebRtcVideoChannel2 : public rtc::MessageHandler, // VideoMediaChannel implementation bool SetSendParameters(const VideoSendParameters& params) override; bool SetRecvParameters(const VideoRecvParameters& params) override; - bool SetRecvCodecs(const std::vector& codecs) override; - bool SetSendCodecs(const std::vector& codecs) override; bool GetSendCodec(VideoCodec* send_codec) override; bool SetSendStreamFormat(uint32 ssrc, const VideoFormat& format) override; bool SetRender(bool render) override; @@ -192,15 +191,6 @@ class WebRtcVideoChannel2 : public rtc::MessageHandler, void OnRtcpReceived(rtc::Buffer* packet, const rtc::PacketTime& packet_time) override; void OnReadyToSend(bool ready) override; - - // Set send/receive RTP header extensions. This must be done before creating - // streams as it only has effect on future streams. - bool SetRecvRtpHeaderExtensions( - const std::vector& extensions) override; - bool SetSendRtpHeaderExtensions( - const std::vector& extensions) override; - bool SetMaxSendBandwidth(int bps) override; - bool SetOptions(const VideoOptions& options) override; void SetInterface(NetworkInterface* iface) override; void UpdateAspectRatio(int ratio_w, int ratio_h) override; @@ -216,6 +206,16 @@ class WebRtcVideoChannel2 : public rtc::MessageHandler, private: bool MuteStream(uint32 ssrc, bool mute); class WebRtcVideoReceiveStream; + + bool SetSendCodecs(const std::vector& codecs); + bool SetSendRtpHeaderExtensions( + const std::vector& extensions); + bool SetMaxSendBandwidth(int bps); + bool SetOptions(const VideoOptions& options); + bool SetRecvCodecs(const std::vector& codecs); + bool SetRecvRtpHeaderExtensions( + const std::vector& extensions); + void ConfigureReceiverRtp(webrtc::VideoReceiveStream::Config* config, const StreamParams& sp) const; bool CodecIsExternallySupported(const std::string& name) const; diff --git a/talk/media/webrtc/webrtcvideoengine2_unittest.cc b/talk/media/webrtc/webrtcvideoengine2_unittest.cc index da16d2b551..d90a6a16ef 100644 --- a/talk/media/webrtc/webrtcvideoengine2_unittest.cc +++ b/talk/media/webrtc/webrtcvideoengine2_unittest.cc @@ -277,19 +277,18 @@ TEST_F(WebRtcVideoEngine2Test, CVOSetHeaderExtensionBeforeCapturer) { cricket::FakeWebRtcVideoEncoderFactory encoder_factory; encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); - std::vector codecs; - codecs.push_back(kVp8Codec); + cricket::VideoSendParameters parameters; + parameters.codecs.push_back(kVp8Codec); rtc::scoped_ptr channel( - SetUpForExternalEncoderFactory(&encoder_factory, codecs)); + SetUpForExternalEncoderFactory(&encoder_factory, parameters.codecs)); EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(kSsrc))); // Add CVO extension. const int id = 1; - std::vector extensions; - extensions.push_back( + parameters.extensions.push_back( cricket::RtpHeaderExtension(kRtpVideoRotationHeaderExtension, id)); - EXPECT_TRUE(channel->SetSendRtpHeaderExtensions(extensions)); + EXPECT_TRUE(channel->SetSendParameters(parameters)); // Set capturer. EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer)); @@ -298,8 +297,8 @@ TEST_F(WebRtcVideoEngine2Test, CVOSetHeaderExtensionBeforeCapturer) { EXPECT_FALSE(capturer.GetApplyRotation()); // Verify removing header extension turns on applying rotation. - extensions.clear(); - EXPECT_TRUE(channel->SetSendRtpHeaderExtensions(extensions)); + parameters.extensions.clear(); + EXPECT_TRUE(channel->SetSendParameters(parameters)); EXPECT_TRUE(capturer.GetApplyRotation()); } @@ -308,11 +307,11 @@ TEST_F(WebRtcVideoEngine2Test, CVOSetHeaderExtensionAfterCapturer) { cricket::FakeWebRtcVideoEncoderFactory encoder_factory; encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); - std::vector codecs; - codecs.push_back(kVp8Codec); + cricket::VideoSendParameters parameters; + parameters.codecs.push_back(kVp8Codec); rtc::scoped_ptr channel( - SetUpForExternalEncoderFactory(&encoder_factory, codecs)); + SetUpForExternalEncoderFactory(&encoder_factory, parameters.codecs)); EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(kSsrc))); // Set capturer. @@ -320,17 +319,16 @@ TEST_F(WebRtcVideoEngine2Test, CVOSetHeaderExtensionAfterCapturer) { // Add CVO extension. const int id = 1; - std::vector extensions; - extensions.push_back( + parameters.extensions.push_back( cricket::RtpHeaderExtension(kRtpVideoRotationHeaderExtension, id)); - EXPECT_TRUE(channel->SetSendRtpHeaderExtensions(extensions)); + EXPECT_TRUE(channel->SetSendParameters(parameters)); // Verify capturer has turned off applying rotation. EXPECT_FALSE(capturer.GetApplyRotation()); // Verify removing header extension turns on applying rotation. - extensions.clear(); - EXPECT_TRUE(channel->SetSendRtpHeaderExtensions(extensions)); + parameters.extensions.clear(); + EXPECT_TRUE(channel->SetSendParameters(parameters)); EXPECT_TRUE(capturer.GetApplyRotation()); } @@ -359,11 +357,11 @@ TEST_F(WebRtcVideoEngine2Test, GetStatsWithoutSendCodecsSetDoesNotCrash) { TEST_F(WebRtcVideoEngine2Test, UseExternalFactoryForVp8WhenSupported) { cricket::FakeWebRtcVideoEncoderFactory encoder_factory; encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); - std::vector codecs; - codecs.push_back(kVp8Codec); + cricket::VideoSendParameters parameters; + parameters.codecs.push_back(kVp8Codec); rtc::scoped_ptr channel( - SetUpForExternalEncoderFactory(&encoder_factory, codecs)); + SetUpForExternalEncoderFactory(&encoder_factory, parameters.codecs)); EXPECT_TRUE( channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); @@ -385,7 +383,7 @@ TEST_F(WebRtcVideoEngine2Test, UseExternalFactoryForVp8WhenSupported) { // Setting codecs of the same type should not reallocate any encoders // (expecting a no-op). - EXPECT_TRUE(channel->SetSendCodecs(codecs)); + EXPECT_TRUE(channel->SetSendParameters(parameters)); EXPECT_EQ(num_created_encoders, encoder_factory.GetNumCreatedEncoders()); // Remove stream previously added to free the external encoder instance. @@ -531,7 +529,9 @@ VideoMediaChannel* WebRtcVideoEngine2Test::SetUpForExternalEncoderFactory( VideoMediaChannel* channel = engine_.CreateChannel(call_.get(), cricket::VideoOptions()); - EXPECT_TRUE(channel->SetSendCodecs(codecs)); + cricket::VideoSendParameters parameters; + parameters.codecs = codecs; + EXPECT_TRUE(channel->SetSendParameters(parameters)); return channel; } @@ -544,7 +544,9 @@ VideoMediaChannel* WebRtcVideoEngine2Test::SetUpForExternalDecoderFactory( VideoMediaChannel* channel = engine_.CreateChannel(call_.get(), cricket::VideoOptions()); - EXPECT_TRUE(channel->SetRecvCodecs(codecs)); + cricket::VideoRecvParameters parameters; + parameters.codecs = codecs; + EXPECT_TRUE(channel->SetRecvParameters(parameters)); return channel; } @@ -602,10 +604,9 @@ TEST_F(WebRtcVideoEngine2Test, ChannelWithExternalH264CanChangeToInternalVp8) { channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); ASSERT_EQ(1u, encoder_factory.encoders().size()); - codecs.clear(); - codecs.push_back(kVp8Codec); - EXPECT_TRUE(channel->SetSendCodecs(codecs)); - + cricket::VideoSendParameters parameters; + parameters.codecs.push_back(kVp8Codec); + EXPECT_TRUE(channel->SetSendParameters(parameters)); ASSERT_EQ(0u, encoder_factory.encoders().size()); } @@ -727,18 +728,18 @@ TEST_F(WebRtcVideoEngine2Test, ReportSupportedExternalCodecs) { TEST_F(WebRtcVideoEngine2Test, RegisterExternalDecodersIfSupported) { cricket::FakeWebRtcVideoDecoderFactory decoder_factory; decoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8); - std::vector codecs; - codecs.push_back(kVp8Codec); + cricket::VideoRecvParameters parameters; + parameters.codecs.push_back(kVp8Codec); rtc::scoped_ptr channel( - SetUpForExternalDecoderFactory(&decoder_factory, codecs)); + SetUpForExternalDecoderFactory(&decoder_factory, parameters.codecs)); EXPECT_TRUE( channel->AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrc))); ASSERT_EQ(1u, decoder_factory.decoders().size()); // Setting codecs of the same type should not reallocate the decoder. - EXPECT_TRUE(channel->SetRecvCodecs(codecs)); + EXPECT_TRUE(channel->SetRecvParameters(parameters)); EXPECT_EQ(1, decoder_factory.GetNumCreatedDecoders()); // Remove stream previously added to free the external decoder instance. @@ -903,7 +904,9 @@ class WebRtcVideoChannel2Test : public WebRtcVideoEngine2Test { channel_.reset( engine_.CreateChannel(fake_call_.get(), cricket::VideoOptions())); last_ssrc_ = 123; - ASSERT_TRUE(channel_->SetSendCodecs(engine_.codecs())); + send_parameters_.codecs = engine_.codecs(); + recv_parameters_.codecs = engine_.codecs(); + ASSERT_TRUE(channel_->SetSendParameters(send_parameters_)); } protected: @@ -947,12 +950,13 @@ class WebRtcVideoChannel2Test : public WebRtcVideoEngine2Test { int expected_start_bitrate_bps, const char* max_bitrate_kbps, int expected_max_bitrate_bps) { - std::vector codecs; + auto& codecs = send_parameters_.codecs; + codecs.clear(); codecs.push_back(kVp8Codec); codecs[0].params[kCodecParamMinBitrate] = min_bitrate_kbps; codecs[0].params[kCodecParamStartBitrate] = start_bitrate_kbps; codecs[0].params[kCodecParamMaxBitrate] = max_bitrate_kbps; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); EXPECT_EQ(expected_min_bitrate_bps, fake_call_->GetConfig().bitrate_config.min_bitrate_bps); @@ -966,10 +970,10 @@ class WebRtcVideoChannel2Test : public WebRtcVideoEngine2Test { const std::string& webrtc_ext) { // Enable extension. const int id = 1; - std::vector extensions; - extensions.push_back(cricket::RtpHeaderExtension(cricket_ext, id)); - EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); - + cricket::VideoSendParameters parameters = send_parameters_; + parameters.extensions.push_back( + cricket::RtpHeaderExtension(cricket_ext, id)); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); FakeVideoSendStream* send_stream = AddSendStream(cricket::StreamParams::CreateLegacy(123)); @@ -978,7 +982,7 @@ class WebRtcVideoChannel2Test : public WebRtcVideoEngine2Test { EXPECT_EQ(id, send_stream->GetConfig().rtp.extensions[0].id); EXPECT_EQ(webrtc_ext, send_stream->GetConfig().rtp.extensions[0].name); // Verify call with same set of extensions returns true. - EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); // Verify that SetSendRtpHeaderExtensions doesn't implicitly add them for // receivers. EXPECT_TRUE(AddRecvStream(cricket::StreamParams::CreateLegacy(123)) @@ -986,15 +990,14 @@ class WebRtcVideoChannel2Test : public WebRtcVideoEngine2Test { .rtp.extensions.empty()); // Verify that existing RTP header extensions can be removed. - std::vector empty_extensions; - EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(empty_extensions)); + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size()); send_stream = fake_call_->GetVideoSendStreams()[0]; EXPECT_TRUE(send_stream->GetConfig().rtp.extensions.empty()); // Verify that adding receive RTP header extensions adds them for existing // streams. - EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); send_stream = fake_call_->GetVideoSendStreams()[0]; ASSERT_EQ(1u, send_stream->GetConfig().rtp.extensions.size()); EXPECT_EQ(id, send_stream->GetConfig().rtp.extensions[0].id); @@ -1005,9 +1008,10 @@ class WebRtcVideoChannel2Test : public WebRtcVideoEngine2Test { const std::string& webrtc_ext) { // Enable extension. const int id = 1; - std::vector extensions; - extensions.push_back(cricket::RtpHeaderExtension(cricket_ext, id)); - EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions)); + cricket::VideoRecvParameters parameters = recv_parameters_; + parameters.extensions.push_back( + cricket::RtpHeaderExtension(cricket_ext, id)); + EXPECT_TRUE(channel_->SetRecvParameters(parameters)); FakeVideoReceiveStream* recv_stream = AddRecvStream(cricket::StreamParams::CreateLegacy(123)); @@ -1017,7 +1021,7 @@ class WebRtcVideoChannel2Test : public WebRtcVideoEngine2Test { EXPECT_EQ(id, recv_stream->GetConfig().rtp.extensions[0].id); EXPECT_EQ(webrtc_ext, recv_stream->GetConfig().rtp.extensions[0].name); // Verify call with same set of extensions returns true. - EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions)); + EXPECT_TRUE(channel_->SetRecvParameters(parameters)); // Verify that SetRecvRtpHeaderExtensions doesn't implicitly add them for // senders. @@ -1026,15 +1030,14 @@ class WebRtcVideoChannel2Test : public WebRtcVideoEngine2Test { .rtp.extensions.empty()); // Verify that existing RTP header extensions can be removed. - std::vector empty_extensions; - EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(empty_extensions)); + EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); ASSERT_EQ(1u, fake_call_->GetVideoReceiveStreams().size()); recv_stream = fake_call_->GetVideoReceiveStreams()[0]; EXPECT_TRUE(recv_stream->GetConfig().rtp.extensions.empty()); // Verify that adding receive RTP header extensions adds them for existing // streams. - EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions)); + EXPECT_TRUE(channel_->SetRecvParameters(parameters)); recv_stream = fake_call_->GetVideoReceiveStreams()[0]; ASSERT_EQ(1u, recv_stream->GetConfig().rtp.extensions.size()); EXPECT_EQ(id, recv_stream->GetConfig().rtp.extensions[0].id); @@ -1046,10 +1049,11 @@ class WebRtcVideoChannel2Test : public WebRtcVideoEngine2Test { void TestReceiveUnsignalledSsrcPacket(uint8_t payload_type, bool expect_created_receive_stream); - FakeVideoSendStream* SetDenoisingOption(bool enabled) { - VideoOptions options; - options.video_noise_reduction.Set(enabled); - channel_->SetOptions(options); + FakeVideoSendStream* SetDenoisingOption( + const cricket::VideoSendParameters& parameters, bool enabled) { + cricket::VideoSendParameters params = parameters; + params.options.video_noise_reduction.Set(enabled); + channel_->SetSendParameters(params); return fake_call_->GetVideoSendStreams().back(); } @@ -1075,6 +1079,8 @@ class WebRtcVideoChannel2Test : public WebRtcVideoEngine2Test { rtc::scoped_ptr fake_call_; rtc::scoped_ptr channel_; + cricket::VideoSendParameters send_parameters_; + cricket::VideoRecvParameters recv_parameters_; uint32 last_ssrc_; }; @@ -1093,11 +1099,12 @@ TEST_F(WebRtcVideoChannel2Test, SetsSyncGroupFromSyncLabel) { } TEST_F(WebRtcVideoChannel2Test, RecvStreamWithSimAndRtx) { - EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); + cricket::VideoSendParameters parameters; + parameters.codecs = engine_.codecs(); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_TRUE(channel_->SetSend(true)); - cricket::VideoOptions options; - options.conference_mode.Set(true); - EXPECT_TRUE(channel_->SetOptions(options)); + parameters.options.conference_mode.Set(true); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); // Send side. const std::vector ssrcs = MAKE_VECTOR(kSsrcs1); @@ -1184,15 +1191,14 @@ TEST_F(WebRtcVideoChannel2Test, IdenticalSendExtensionsDoesntRecreateStream) { const int kTOffsetId = 1; const int kAbsSendTimeId = 2; const int kVideoRotationId = 3; - std::vector extensions; - extensions.push_back(cricket::RtpHeaderExtension( + send_parameters_.extensions.push_back(cricket::RtpHeaderExtension( kRtpAbsoluteSenderTimeHeaderExtension, kAbsSendTimeId)); - extensions.push_back(cricket::RtpHeaderExtension( + send_parameters_.extensions.push_back(cricket::RtpHeaderExtension( kRtpTimestampOffsetHeaderExtension, kTOffsetId)); - extensions.push_back(cricket::RtpHeaderExtension( + send_parameters_.extensions.push_back(cricket::RtpHeaderExtension( kRtpVideoRotationHeaderExtension, kVideoRotationId)); - EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); FakeVideoSendStream* send_stream = AddSendStream(cricket::StreamParams::CreateLegacy(123)); @@ -1201,14 +1207,15 @@ TEST_F(WebRtcVideoChannel2Test, IdenticalSendExtensionsDoesntRecreateStream) { // Setting the same extensions (even if in different order) shouldn't // reallocate the stream. - std::reverse(extensions.begin(), extensions.end()); - EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); + std::reverse(send_parameters_.extensions.begin(), + send_parameters_.extensions.end()); + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); EXPECT_EQ(1, fake_call_->GetNumCreatedSendStreams()); // Setting different extensions should recreate the stream. - extensions.resize(1); - EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); + send_parameters_.extensions.resize(1); + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); EXPECT_EQ(2, fake_call_->GetNumCreatedSendStreams()); } @@ -1217,15 +1224,14 @@ TEST_F(WebRtcVideoChannel2Test, IdenticalRecvExtensionsDoesntRecreateStream) { const int kTOffsetId = 1; const int kAbsSendTimeId = 2; const int kVideoRotationId = 3; - std::vector extensions; - extensions.push_back(cricket::RtpHeaderExtension( + recv_parameters_.extensions.push_back(cricket::RtpHeaderExtension( kRtpAbsoluteSenderTimeHeaderExtension, kAbsSendTimeId)); - extensions.push_back(cricket::RtpHeaderExtension( + recv_parameters_.extensions.push_back(cricket::RtpHeaderExtension( kRtpTimestampOffsetHeaderExtension, kTOffsetId)); - extensions.push_back(cricket::RtpHeaderExtension( + recv_parameters_.extensions.push_back(cricket::RtpHeaderExtension( kRtpVideoRotationHeaderExtension, kVideoRotationId)); - EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions)); + EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); FakeVideoReceiveStream* recv_stream = AddRecvStream(cricket::StreamParams::CreateLegacy(123)); @@ -1234,14 +1240,15 @@ TEST_F(WebRtcVideoChannel2Test, IdenticalRecvExtensionsDoesntRecreateStream) { // Setting the same extensions (even if in different order) shouldn't // reallocate the stream. - std::reverse(extensions.begin(), extensions.end()); - EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions)); + std::reverse(recv_parameters_.extensions.begin(), + recv_parameters_.extensions.end()); + EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); EXPECT_EQ(1, fake_call_->GetNumCreatedReceiveStreams()); // Setting different extensions should recreate the stream. - extensions.resize(1); - EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions)); + recv_parameters_.extensions.resize(1); + EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); EXPECT_EQ(2, fake_call_->GetNumCreatedReceiveStreams()); } @@ -1251,12 +1258,11 @@ TEST_F(WebRtcVideoChannel2Test, const int kUnsupportedId = 1; const int kTOffsetId = 2; - std::vector extensions; - extensions.push_back( + send_parameters_.extensions.push_back( cricket::RtpHeaderExtension(kUnsupportedExtensionName, kUnsupportedId)); - extensions.push_back( + send_parameters_.extensions.push_back( cricket::RtpHeaderExtension(webrtc::RtpExtension::kTOffset, kTOffsetId)); - EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); FakeVideoSendStream* send_stream = AddSendStream(cricket::StreamParams::CreateLegacy(123)); @@ -1272,12 +1278,11 @@ TEST_F(WebRtcVideoChannel2Test, const int kUnsupportedId = 1; const int kTOffsetId = 2; - std::vector extensions; - extensions.push_back( + recv_parameters_.extensions.push_back( cricket::RtpHeaderExtension(kUnsupportedExtensionName, kUnsupportedId)); - extensions.push_back( + recv_parameters_.extensions.push_back( cricket::RtpHeaderExtension(webrtc::RtpExtension::kTOffset, kTOffsetId)); - EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions)); + EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); FakeVideoReceiveStream* recv_stream = AddRecvStream(cricket::StreamParams::CreateLegacy(123)); @@ -1291,10 +1296,9 @@ TEST_F(WebRtcVideoChannel2Test, TEST_F(WebRtcVideoChannel2Test, SetSendRtpHeaderExtensionsRejectsIncorrectIds) { const int kIncorrectIds[] = {-2, -1, 0, 15, 16}; for (size_t i = 0; i < arraysize(kIncorrectIds); ++i) { - std::vector extensions; - extensions.push_back(cricket::RtpHeaderExtension( + send_parameters_.extensions.push_back(cricket::RtpHeaderExtension( webrtc::RtpExtension::kTOffset, kIncorrectIds[i])); - EXPECT_FALSE(channel_->SetSendRtpHeaderExtensions(extensions)) + EXPECT_FALSE(channel_->SetSendParameters(send_parameters_)) << "Bad extension id '" << kIncorrectIds[i] << "' accepted."; } } @@ -1302,46 +1306,43 @@ TEST_F(WebRtcVideoChannel2Test, SetSendRtpHeaderExtensionsRejectsIncorrectIds) { TEST_F(WebRtcVideoChannel2Test, SetRecvRtpHeaderExtensionsRejectsIncorrectIds) { const int kIncorrectIds[] = {-2, -1, 0, 15, 16}; for (size_t i = 0; i < arraysize(kIncorrectIds); ++i) { - std::vector extensions; - extensions.push_back(cricket::RtpHeaderExtension( + recv_parameters_.extensions.push_back(cricket::RtpHeaderExtension( webrtc::RtpExtension::kTOffset, kIncorrectIds[i])); - EXPECT_FALSE(channel_->SetRecvRtpHeaderExtensions(extensions)) + EXPECT_FALSE(channel_->SetRecvParameters(recv_parameters_)) << "Bad extension id '" << kIncorrectIds[i] << "' accepted."; } } TEST_F(WebRtcVideoChannel2Test, SetSendRtpHeaderExtensionsRejectsDuplicateIds) { const int id = 1; - std::vector extensions; - extensions.push_back( + send_parameters_.extensions.push_back( cricket::RtpHeaderExtension(webrtc::RtpExtension::kTOffset, id)); - extensions.push_back( + send_parameters_.extensions.push_back( cricket::RtpHeaderExtension(kRtpAbsoluteSenderTimeHeaderExtension, id)); - EXPECT_FALSE(channel_->SetSendRtpHeaderExtensions(extensions)); + EXPECT_FALSE(channel_->SetSendParameters(send_parameters_)); // Duplicate entries are also not supported. - extensions.clear(); - extensions.push_back( + send_parameters_.extensions.clear(); + send_parameters_.extensions.push_back( cricket::RtpHeaderExtension(webrtc::RtpExtension::kTOffset, id)); - extensions.push_back(extensions.back()); - EXPECT_FALSE(channel_->SetSendRtpHeaderExtensions(extensions)); + send_parameters_.extensions.push_back(send_parameters_.extensions.back()); + EXPECT_FALSE(channel_->SetSendParameters(send_parameters_)); } TEST_F(WebRtcVideoChannel2Test, SetRecvRtpHeaderExtensionsRejectsDuplicateIds) { const int id = 1; - std::vector extensions; - extensions.push_back( + recv_parameters_.extensions.push_back( cricket::RtpHeaderExtension(webrtc::RtpExtension::kTOffset, id)); - extensions.push_back( + recv_parameters_.extensions.push_back( cricket::RtpHeaderExtension(kRtpAbsoluteSenderTimeHeaderExtension, id)); - EXPECT_FALSE(channel_->SetRecvRtpHeaderExtensions(extensions)); + EXPECT_FALSE(channel_->SetRecvParameters(recv_parameters_)); // Duplicate entries are also not supported. - extensions.clear(); - extensions.push_back( + recv_parameters_.extensions.clear(); + recv_parameters_.extensions.push_back( cricket::RtpHeaderExtension(webrtc::RtpExtension::kTOffset, id)); - extensions.push_back(extensions.back()); - EXPECT_FALSE(channel_->SetRecvRtpHeaderExtensions(extensions)); + recv_parameters_.extensions.push_back(recv_parameters_.extensions.back()); + EXPECT_FALSE(channel_->SetRecvParameters(recv_parameters_)); } TEST_F(WebRtcVideoChannel2Test, DISABLED_LeakyBucketTest) { @@ -1376,16 +1377,17 @@ TEST_F(WebRtcVideoChannel2Test, RembCanBeEnabledAndDisabled) { EXPECT_TRUE(stream->GetConfig().rtp.remb); // Verify that REMB is turned off when send(!) codecs without REMB are set. - std::vector codecs; - codecs.push_back(kVp8Codec); - EXPECT_TRUE(codecs[0].feedback_params.params().empty()); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::VideoSendParameters parameters; + parameters.codecs.push_back(kVp8Codec); + EXPECT_TRUE(parameters.codecs[0].feedback_params.params().empty()); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); stream = fake_call_->GetVideoReceiveStreams()[0]; EXPECT_FALSE(stream->GetConfig().rtp.remb); // Verify that REMB is turned on when setting default codecs since the // default codecs have REMB enabled. - EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); + parameters.codecs = engine_.codecs(); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); stream = fake_call_->GetVideoReceiveStreams()[0]; EXPECT_TRUE(stream->GetConfig().rtp.remb); } @@ -1393,7 +1395,9 @@ TEST_F(WebRtcVideoChannel2Test, RembCanBeEnabledAndDisabled) { TEST_F(WebRtcVideoChannel2Test, NackIsEnabledByDefault) { VerifyCodecHasDefaultFeedbackParams(default_codec_); - EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); + cricket::VideoSendParameters parameters; + parameters.codecs = engine_.codecs(); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_TRUE(channel_->SetSend(true)); // Send side. @@ -1419,10 +1423,10 @@ TEST_F(WebRtcVideoChannel2Test, NackCanBeEnabledAndDisabled) { EXPECT_GT(send_stream->GetConfig().rtp.nack.rtp_history_ms, 0); // Verify that NACK is turned off when send(!) codecs without NACK are set. - std::vector codecs; - codecs.push_back(kVp8Codec); - EXPECT_TRUE(codecs[0].feedback_params.params().empty()); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::VideoSendParameters parameters; + parameters.codecs.push_back(kVp8Codec); + EXPECT_TRUE(parameters.codecs[0].feedback_params.params().empty()); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); recv_stream = fake_call_->GetVideoReceiveStreams()[0]; EXPECT_EQ(0, recv_stream->GetConfig().rtp.nack.rtp_history_ms); send_stream = fake_call_->GetVideoSendStreams()[0]; @@ -1430,7 +1434,8 @@ TEST_F(WebRtcVideoChannel2Test, NackCanBeEnabledAndDisabled) { // Verify that NACK is turned on when setting default codecs since the // default codecs have NACK enabled. - EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); + parameters.codecs = engine_.codecs(); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); recv_stream = fake_call_->GetVideoReceiveStreams()[0]; EXPECT_GT(recv_stream->GetConfig().rtp.nack.rtp_history_ms, 0); send_stream = fake_call_->GetVideoSendStreams()[0]; @@ -1476,12 +1481,10 @@ TEST_F(WebRtcVideoChannel2Test, DISABLED_SetBandwidthInConference) { TEST_F(WebRtcVideoChannel2Test, UsesCorrectSettingsForScreencast) { static const int kScreenshareMinBitrateKbps = 800; cricket::VideoCodec codec = kVp8Codec360p; - std::vector codecs; - codecs.push_back(codec); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); - VideoOptions options; - options.screencast_min_bitrate.Set(kScreenshareMinBitrateKbps); - channel_->SetOptions(options); + cricket::VideoSendParameters parameters; + parameters.codecs.push_back(codec); + parameters.options.screencast_min_bitrate.Set(kScreenshareMinBitrateKbps); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); AddSendStream(); @@ -1534,9 +1537,8 @@ TEST_F(WebRtcVideoChannel2Test, ConferenceModeScreencastConfiguresTemporalLayer) { static const int kConferenceScreencastTemporalBitrateBps = ScreenshareLayerConfig::GetDefault().tl0_bitrate_kbps * 1000; - VideoOptions options; - options.conference_mode.Set(true); - channel_->SetOptions(options); + send_parameters_.options.conference_mode.Set(true); + channel_->SetSendParameters(send_parameters_); AddSendStream(); @@ -1582,15 +1584,14 @@ TEST_F(WebRtcVideoChannel2Test, SuspendBelowMinBitrateDisabledByDefault) { } TEST_F(WebRtcVideoChannel2Test, SetOptionsWithSuspendBelowMinBitrate) { - VideoOptions options; - options.suspend_below_min_bitrate.Set(true); - channel_->SetOptions(options); + send_parameters_.options.suspend_below_min_bitrate.Set(true); + channel_->SetSendParameters(send_parameters_); FakeVideoSendStream* stream = AddSendStream(); EXPECT_TRUE(stream->GetConfig().suspend_below_min_bitrate); - options.suspend_below_min_bitrate.Set(false); - channel_->SetOptions(options); + send_parameters_.options.suspend_below_min_bitrate.Set(false); + channel_->SetSendParameters(send_parameters_); stream = fake_call_->GetVideoSendStreams()[0]; EXPECT_FALSE(stream->GetConfig().suspend_below_min_bitrate); @@ -1604,9 +1605,9 @@ TEST_F(WebRtcVideoChannel2Test, Vp8DenoisingEnabledByDefault) { } TEST_F(WebRtcVideoChannel2Test, VerifyVp8SpecificSettings) { - std::vector codecs; - codecs.push_back(kVp8Codec720p); - ASSERT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::VideoSendParameters parameters; + parameters.codecs.push_back(kVp8Codec720p); + ASSERT_TRUE(channel_->SetSendParameters(parameters)); // Single-stream settings should apply with RTX as well (verifies that we // check number of regular SSRCs and not StreamParams::ssrcs which contains @@ -1622,7 +1623,7 @@ TEST_F(WebRtcVideoChannel2Test, VerifyVp8SpecificSettings) { EXPECT_TRUE(capturer.CaptureFrame()); - stream = SetDenoisingOption(false); + stream = SetDenoisingOption(parameters, false); webrtc::VideoCodecVP8 vp8_settings; ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; @@ -1630,7 +1631,7 @@ TEST_F(WebRtcVideoChannel2Test, VerifyVp8SpecificSettings) { EXPECT_TRUE(vp8_settings.automaticResizeOn); EXPECT_TRUE(vp8_settings.frameDroppingOn); - stream = SetDenoisingOption(true); + stream = SetDenoisingOption(parameters, true); ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; EXPECT_TRUE(vp8_settings.denoisingOn); @@ -1652,7 +1653,7 @@ TEST_F(WebRtcVideoChannel2Test, VerifyVp8SpecificSettings) { // In screen-share mode, denoising is forced off and simulcast disabled. capturer.SetScreencast(true); EXPECT_TRUE(capturer.CaptureFrame()); - stream = SetDenoisingOption(false); + stream = SetDenoisingOption(parameters, false); EXPECT_EQ(1, stream->GetVideoStreams().size()); ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; @@ -1661,7 +1662,7 @@ TEST_F(WebRtcVideoChannel2Test, VerifyVp8SpecificSettings) { EXPECT_FALSE(vp8_settings.automaticResizeOn); EXPECT_FALSE(vp8_settings.frameDroppingOn); - stream = SetDenoisingOption(true); + stream = SetDenoisingOption(parameters, true); ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; EXPECT_FALSE(vp8_settings.denoisingOn); @@ -1688,16 +1689,16 @@ class Vp9SettingsTest : public WebRtcVideoChannel2Test { void TearDown() override { // Remove references to encoder_factory_ since this will be destroyed // before channel_ and engine_. - ASSERT_TRUE(channel_->SetSendCodecs(engine_.codecs())); + ASSERT_TRUE(channel_->SetSendParameters(send_parameters_)); } cricket::FakeWebRtcVideoEncoderFactory encoder_factory_; }; TEST_F(Vp9SettingsTest, VerifyVp9SpecificSettings) { - std::vector codecs; - codecs.push_back(kVp9Codec); - ASSERT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::VideoSendParameters parameters; + parameters.codecs.push_back(kVp9Codec); + ASSERT_TRUE(channel_->SetSendParameters(parameters)); FakeVideoSendStream* stream = SetUpSimulcast(false, false); @@ -1710,7 +1711,7 @@ TEST_F(Vp9SettingsTest, VerifyVp9SpecificSettings) { EXPECT_TRUE(capturer.CaptureFrame()); - stream = SetDenoisingOption(false); + stream = SetDenoisingOption(parameters, false); webrtc::VideoCodecVP9 vp9_settings; ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set."; @@ -1718,7 +1719,7 @@ TEST_F(Vp9SettingsTest, VerifyVp9SpecificSettings) { // Frame dropping always on for real time video. EXPECT_TRUE(vp9_settings.frameDroppingOn); - stream = SetDenoisingOption(true); + stream = SetDenoisingOption(parameters, true); ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set."; EXPECT_TRUE(vp9_settings.denoisingOn); @@ -1727,14 +1728,14 @@ TEST_F(Vp9SettingsTest, VerifyVp9SpecificSettings) { // In screen-share mode, denoising is forced off. capturer.SetScreencast(true); EXPECT_TRUE(capturer.CaptureFrame()); - stream = SetDenoisingOption(false); + stream = SetDenoisingOption(parameters, false); ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set."; EXPECT_FALSE(vp9_settings.denoisingOn); // Frame dropping always off for screen sharing. EXPECT_FALSE(vp9_settings.frameDroppingOn); - stream = SetDenoisingOption(false); + stream = SetDenoisingOption(parameters, false); ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set."; EXPECT_FALSE(vp9_settings.denoisingOn); @@ -1766,15 +1767,12 @@ TEST_F(WebRtcVideoChannel2Test, DoesNotAdaptOnOveruseWhenScreensharing) { void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse, bool is_screenshare) { cricket::VideoCodec codec = kVp8Codec720p; - std::vector codecs; - codecs.push_back(codec); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); - + cricket::VideoSendParameters parameters; + parameters.codecs.push_back(codec); if (!enable_overuse) { - VideoOptions options; - options.cpu_overuse_detection.Set(false); - channel_->SetOptions(options); + parameters.options.cpu_overuse_detection.Set(false); } + EXPECT_TRUE(channel_->SetSendParameters(parameters)); AddSendStream(); @@ -1822,7 +1820,7 @@ TEST_F(WebRtcVideoChannel2Test, EstimatesNtpStartTimeAndElapsedTimeCorrectly) { static const uint32_t kInitialTimestamp = 0xFFFFFFFFu; static const int64_t kInitialNtpTimeMs = 1247891230; static const int kFrameOffsetMs = 20; - EXPECT_TRUE(channel_->SetRecvCodecs(engine_.codecs())); + EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); FakeVideoReceiveStream* stream = AddRecvStream(); cricket::FakeVideoRenderer renderer; @@ -1858,7 +1856,7 @@ TEST_F(WebRtcVideoChannel2Test, EstimatesNtpStartTimeAndElapsedTimeCorrectly) { } TEST_F(WebRtcVideoChannel2Test, SetDefaultSendCodecs) { - ASSERT_TRUE(channel_->SetSendCodecs(engine_.codecs())); + ASSERT_TRUE(channel_->SetSendParameters(send_parameters_)); VideoCodec codec; EXPECT_TRUE(channel_->GetSendCodec(&codec)); @@ -1883,9 +1881,9 @@ TEST_F(WebRtcVideoChannel2Test, SetDefaultSendCodecs) { } TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithoutFec) { - std::vector codecs; - codecs.push_back(kVp8Codec); - ASSERT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::VideoSendParameters parameters; + parameters.codecs.push_back(kVp8Codec); + ASSERT_TRUE(channel_->SetSendParameters(parameters)); FakeVideoSendStream* stream = AddSendStream(); webrtc::VideoSendStream::Config config = stream->GetConfig(); @@ -1896,43 +1894,43 @@ TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithoutFec) { TEST_F(WebRtcVideoChannel2Test, SetSendCodecRejectsRtxWithoutAssociatedPayloadType) { - std::vector codecs; + cricket::VideoSendParameters parameters; cricket::VideoCodec rtx_codec(96, "rtx", 0, 0, 0, 0); - codecs.push_back(rtx_codec); - EXPECT_FALSE(channel_->SetSendCodecs(codecs)) + parameters.codecs.push_back(rtx_codec); + EXPECT_FALSE(channel_->SetSendParameters(parameters)) << "RTX codec without associated payload type should be rejected."; } TEST_F(WebRtcVideoChannel2Test, SetSendCodecRejectsRtxWithoutMatchingVideoCodec) { - std::vector codecs; + cricket::VideoSendParameters parameters; cricket::VideoCodec rtx_codec = cricket::VideoCodec::CreateRtxCodec(96, kVp8Codec.id); - codecs.push_back(kVp8Codec); - codecs.push_back(rtx_codec); - ASSERT_TRUE(channel_->SetSendCodecs(codecs)); + parameters.codecs.push_back(kVp8Codec); + parameters.codecs.push_back(rtx_codec); + ASSERT_TRUE(channel_->SetSendParameters(parameters)); cricket::VideoCodec rtx_codec2 = cricket::VideoCodec::CreateRtxCodec(96, kVp8Codec.id + 1); - codecs.pop_back(); - codecs.push_back(rtx_codec2); - EXPECT_FALSE(channel_->SetSendCodecs(codecs)) + parameters.codecs.pop_back(); + parameters.codecs.push_back(rtx_codec2); + EXPECT_FALSE(channel_->SetSendParameters(parameters)) << "RTX without matching video codec should be rejected."; } TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithoutFecDisablesFec) { - std::vector codecs; - codecs.push_back(kVp8Codec); - codecs.push_back(kUlpfecCodec); - ASSERT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::VideoSendParameters parameters; + parameters.codecs.push_back(kVp8Codec); + parameters.codecs.push_back(kUlpfecCodec); + ASSERT_TRUE(channel_->SetSendParameters(parameters)); FakeVideoSendStream* stream = AddSendStream(); webrtc::VideoSendStream::Config config = stream->GetConfig(); EXPECT_EQ(kUlpfecCodec.id, config.rtp.fec.ulpfec_payload_type); - codecs.pop_back(); - ASSERT_TRUE(channel_->SetSendCodecs(codecs)); + parameters.codecs.pop_back(); + ASSERT_TRUE(channel_->SetSendParameters(parameters)); stream = fake_call_->GetVideoSendStreams()[0]; ASSERT_TRUE(stream != NULL); config = stream->GetConfig(); @@ -1941,9 +1939,9 @@ TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithoutFecDisablesFec) { } TEST_F(WebRtcVideoChannel2Test, SetSendCodecsChangesExistingStreams) { - std::vector codecs; - codecs.push_back(kVp8Codec720p); - ASSERT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::VideoSendParameters parameters; + parameters.codecs.push_back(kVp8Codec720p); + ASSERT_TRUE(channel_->SetSendParameters(parameters)); channel_->SetSend(true); FakeVideoSendStream* stream = AddSendStream(); @@ -1958,9 +1956,9 @@ TEST_F(WebRtcVideoChannel2Test, SetSendCodecsChangesExistingStreams) { EXPECT_EQ(kVp8Codec720p.width, streams[0].width); EXPECT_EQ(kVp8Codec720p.height, streams[0].height); - codecs.clear(); - codecs.push_back(kVp8Codec360p); - ASSERT_TRUE(channel_->SetSendCodecs(codecs)); + parameters.codecs.clear(); + parameters.codecs.push_back(kVp8Codec360p); + ASSERT_TRUE(channel_->SetSendParameters(parameters)); streams = fake_call_->GetVideoSendStreams()[0]->GetVideoStreams(); EXPECT_EQ(kVp8Codec360p.width, streams[0].width); EXPECT_EQ(kVp8Codec360p.height, streams[0].height); @@ -1990,17 +1988,17 @@ TEST_F(WebRtcVideoChannel2Test, SetSendCodecsCapsMinAndStartBitrate) { } TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectsMaxLessThanMinBitrate) { - std::vector video_codecs = engine_.codecs(); - video_codecs[0].params[kCodecParamMinBitrate] = "300"; - video_codecs[0].params[kCodecParamMaxBitrate] = "200"; - EXPECT_FALSE(channel_->SetSendCodecs(video_codecs)); + send_parameters_.codecs[0].params[kCodecParamMinBitrate] = "300"; + send_parameters_.codecs[0].params[kCodecParamMaxBitrate] = "200"; + EXPECT_FALSE(channel_->SetSendParameters(send_parameters_)); } TEST_F(WebRtcVideoChannel2Test, SetMaxSendBandwidthShouldPreserveOtherBitrates) { SetSendCodecsShouldWorkForBitrates("100", 100000, "150", 150000, "200", 200000); - channel_->SetMaxSendBandwidth(300000); + send_parameters_.max_bandwidth_bps = 300000; + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); EXPECT_EQ(100000, fake_call_->GetConfig().bitrate_config.min_bitrate_bps) << "Setting max bitrate should keep previous min bitrate."; EXPECT_EQ(-1, fake_call_->GetConfig().bitrate_config.start_bitrate_bps) @@ -2009,18 +2007,20 @@ TEST_F(WebRtcVideoChannel2Test, } TEST_F(WebRtcVideoChannel2Test, SetMaxSendBandwidthShouldBeRemovable) { - channel_->SetMaxSendBandwidth(300000); + send_parameters_.max_bandwidth_bps = 300000; + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); EXPECT_EQ(300000, fake_call_->GetConfig().bitrate_config.max_bitrate_bps); // <= 0 means disable (infinite) max bitrate. - channel_->SetMaxSendBandwidth(0); + send_parameters_.max_bandwidth_bps = 0; + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); EXPECT_EQ(-1, fake_call_->GetConfig().bitrate_config.max_bitrate_bps) << "Setting zero max bitrate did not reset start bitrate."; } TEST_F(WebRtcVideoChannel2Test, SetMaxSendBitrateCanIncreaseSenderBitrate) { - std::vector codecs; - codecs.push_back(kVp8Codec720p); - ASSERT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::VideoSendParameters parameters; + parameters.codecs.push_back(kVp8Codec720p); + ASSERT_TRUE(channel_->SetSendParameters(parameters)); channel_->SetSend(true); FakeVideoSendStream* stream = AddSendStream(); @@ -2029,16 +2029,17 @@ TEST_F(WebRtcVideoChannel2Test, SetMaxSendBitrateCanIncreaseSenderBitrate) { int initial_max_bitrate_bps = streams[0].max_bitrate_bps; EXPECT_GT(initial_max_bitrate_bps, 0); - EXPECT_TRUE(channel_->SetMaxSendBandwidth(initial_max_bitrate_bps * 2)); + parameters.max_bandwidth_bps = initial_max_bitrate_bps * 2; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); streams = stream->GetVideoStreams(); EXPECT_EQ(initial_max_bitrate_bps * 2, streams[0].max_bitrate_bps); } TEST_F(WebRtcVideoChannel2Test, SetMaxSendBitrateCanIncreaseSimulcastSenderBitrate) { - std::vector codecs; - codecs.push_back(kVp8Codec720p); - ASSERT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::VideoSendParameters parameters; + parameters.codecs.push_back(kVp8Codec720p); + ASSERT_TRUE(channel_->SetSendParameters(parameters)); channel_->SetSend(true); FakeVideoSendStream* stream = AddSendStream( @@ -2059,7 +2060,8 @@ TEST_F(WebRtcVideoChannel2Test, initial_max_bitrate_bps += video_stream.max_bitrate_bps; EXPECT_GT(initial_max_bitrate_bps, 0); - EXPECT_TRUE(channel_->SetMaxSendBandwidth(initial_max_bitrate_bps * 2)); + parameters.max_bandwidth_bps = initial_max_bitrate_bps * 2; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); streams = stream->GetVideoStreams(); int increased_max_bitrate_bps = 0; for (auto& video_stream : streams) @@ -2071,10 +2073,10 @@ TEST_F(WebRtcVideoChannel2Test, TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithMaxQuantization) { static const char* kMaxQuantization = "21"; - std::vector codecs; - codecs.push_back(kVp8Codec); - codecs[0].params[kCodecParamMaxQuantization] = kMaxQuantization; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::VideoSendParameters parameters; + parameters.codecs.push_back(kVp8Codec); + parameters.codecs[0].params[kCodecParamMaxQuantization] = kMaxQuantization; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_EQ(static_cast(atoi(kMaxQuantization)), AddSendStream()->GetVideoStreams().back().max_qp); @@ -2084,81 +2086,83 @@ TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithMaxQuantization) { } TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectBadDimensions) { - std::vector codecs; - codecs.push_back(kVp8Codec); + cricket::VideoSendParameters parameters; + parameters.codecs.push_back(kVp8Codec); - codecs[0].width = 0; - EXPECT_FALSE(channel_->SetSendCodecs(codecs)) + parameters.codecs[0].width = 0; + EXPECT_FALSE(channel_->SetSendParameters(parameters)) << "Codec set though codec width is zero."; - codecs[0].width = kVp8Codec.width; - codecs[0].height = 0; - EXPECT_FALSE(channel_->SetSendCodecs(codecs)) + parameters.codecs[0].width = kVp8Codec.width; + parameters.codecs[0].height = 0; + EXPECT_FALSE(channel_->SetSendParameters(parameters)) << "Codec set though codec height is zero."; } TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectBadPayloadTypes) { // TODO(pbos): Should we only allow the dynamic range? static const int kIncorrectPayloads[] = {-2, -1, 128, 129}; - std::vector codecs; - codecs.push_back(kVp8Codec); + cricket::VideoSendParameters parameters; + parameters.codecs.push_back(kVp8Codec); for (size_t i = 0; i < arraysize(kIncorrectPayloads); ++i) { - codecs[0].id = kIncorrectPayloads[i]; - EXPECT_FALSE(channel_->SetSendCodecs(codecs)) + parameters.codecs[0].id = kIncorrectPayloads[i]; + EXPECT_FALSE(channel_->SetSendParameters(parameters)) << "Bad payload type '" << kIncorrectPayloads[i] << "' accepted."; } } TEST_F(WebRtcVideoChannel2Test, SetSendCodecsAcceptAllValidPayloadTypes) { - std::vector codecs; - codecs.push_back(kVp8Codec); + cricket::VideoSendParameters parameters; + parameters.codecs.push_back(kVp8Codec); for (int payload_type = 0; payload_type <= 127; ++payload_type) { - codecs[0].id = payload_type; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)) + parameters.codecs[0].id = payload_type; + EXPECT_TRUE(channel_->SetSendParameters(parameters)) << "Payload type '" << payload_type << "' rejected."; } } TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsWithOnlyVp8) { - std::vector codecs; - codecs.push_back(kVp8Codec); - EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); + cricket::VideoRecvParameters parameters; + parameters.codecs.push_back(kVp8Codec); + EXPECT_TRUE(channel_->SetRecvParameters(parameters)); } // Test that we set our inbound RTX codecs properly. TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsWithRtx) { - std::vector codecs; - codecs.push_back(kVp8Codec); + cricket::VideoRecvParameters parameters; + parameters.codecs.push_back(kVp8Codec); cricket::VideoCodec rtx_codec(96, "rtx", 0, 0, 0, 0); - codecs.push_back(rtx_codec); - EXPECT_FALSE(channel_->SetRecvCodecs(codecs)) + parameters.codecs.push_back(rtx_codec); + EXPECT_FALSE(channel_->SetRecvParameters(parameters)) << "RTX codec without associated payload should be rejected."; - codecs[1].SetParam("apt", kVp8Codec.id + 1); - EXPECT_FALSE(channel_->SetRecvCodecs(codecs)) + parameters.codecs[1].SetParam("apt", kVp8Codec.id + 1); + EXPECT_FALSE(channel_->SetRecvParameters(parameters)) << "RTX codec with invalid associated payload type should be rejected."; - codecs[1].SetParam("apt", kVp8Codec.id); - EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); + parameters.codecs[1].SetParam("apt", kVp8Codec.id); + EXPECT_TRUE(channel_->SetRecvParameters(parameters)); cricket::VideoCodec rtx_codec2(97, "rtx", 0, 0, 0, 0); rtx_codec2.SetParam("apt", rtx_codec.id); - codecs.push_back(rtx_codec2); + parameters.codecs.push_back(rtx_codec2); - EXPECT_FALSE(channel_->SetRecvCodecs(codecs)) << "RTX codec with another RTX " - "as associated payload type " - "should be rejected."; + EXPECT_FALSE(channel_->SetRecvParameters(parameters)) << + "RTX codec with another RTX as associated payload type should be " + "rejected."; } TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsDifferentPayloadType) { - std::vector codecs; - codecs.push_back(kVp8Codec); - codecs[0].id = 99; - EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); + cricket::VideoRecvParameters parameters; + parameters.codecs.push_back(kVp8Codec); + parameters.codecs[0].id = 99; + EXPECT_TRUE(channel_->SetRecvParameters(parameters)); } TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsAcceptDefaultCodecs) { - EXPECT_TRUE(channel_->SetRecvCodecs(engine_.codecs())); + cricket::VideoRecvParameters parameters; + parameters.codecs = engine_.codecs(); + EXPECT_TRUE(channel_->SetRecvParameters(parameters)); FakeVideoReceiveStream* stream = AddRecvStream(); webrtc::VideoReceiveStream::Config config = stream->GetConfig(); @@ -2167,43 +2171,44 @@ TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsAcceptDefaultCodecs) { } TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsRejectUnsupportedCodec) { - std::vector codecs; - codecs.push_back(kVp8Codec); - codecs.push_back(VideoCodec(101, "WTF3", 640, 400, 30, 0)); - EXPECT_FALSE(channel_->SetRecvCodecs(codecs)); + cricket::VideoRecvParameters parameters; + parameters.codecs.push_back(kVp8Codec); + parameters.codecs.push_back(VideoCodec(101, "WTF3", 640, 400, 30, 0)); + EXPECT_FALSE(channel_->SetRecvParameters(parameters)); } // TODO(pbos): Enable VP9 through external codec support TEST_F(WebRtcVideoChannel2Test, DISABLED_SetRecvCodecsAcceptsMultipleVideoCodecs) { - std::vector codecs; - codecs.push_back(kVp8Codec); - codecs.push_back(kVp9Codec); - EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); + cricket::VideoRecvParameters parameters; + parameters.codecs.push_back(kVp8Codec); + parameters.codecs.push_back(kVp9Codec); + EXPECT_TRUE(channel_->SetRecvParameters(parameters)); } TEST_F(WebRtcVideoChannel2Test, DISABLED_SetRecvCodecsSetsFecForAllVideoCodecs) { - std::vector codecs; - codecs.push_back(kVp8Codec); - codecs.push_back(kVp9Codec); - EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); + cricket::VideoRecvParameters parameters; + parameters.codecs.push_back(kVp8Codec); + parameters.codecs.push_back(kVp9Codec); + EXPECT_TRUE(channel_->SetRecvParameters(parameters)); FAIL(); // TODO(pbos): Verify that the FEC parameters are set for all codecs. } TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsWithoutFecDisablesFec) { - std::vector codecs; - codecs.push_back(kVp8Codec); - codecs.push_back(kUlpfecCodec); - ASSERT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::VideoSendParameters send_parameters; + send_parameters.codecs.push_back(kVp8Codec); + send_parameters.codecs.push_back(kUlpfecCodec); + ASSERT_TRUE(channel_->SetSendParameters(send_parameters)); FakeVideoReceiveStream* stream = AddRecvStream(); webrtc::VideoReceiveStream::Config config = stream->GetConfig(); EXPECT_EQ(kUlpfecCodec.id, config.rtp.fec.ulpfec_payload_type); - codecs.pop_back(); - ASSERT_TRUE(channel_->SetRecvCodecs(codecs)); + cricket::VideoRecvParameters recv_parameters; + recv_parameters.codecs.push_back(kVp8Codec); + ASSERT_TRUE(channel_->SetRecvParameters(recv_parameters)); stream = fake_call_->GetVideoReceiveStreams()[0]; ASSERT_TRUE(stream != NULL); config = stream->GetConfig(); @@ -2212,47 +2217,47 @@ TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsWithoutFecDisablesFec) { } TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectDuplicateFecPayloads) { - std::vector codecs; - codecs.push_back(kVp8Codec); - codecs.push_back(kRedCodec); - codecs[1].id = codecs[0].id; - EXPECT_FALSE(channel_->SetRecvCodecs(codecs)); + cricket::VideoRecvParameters parameters; + parameters.codecs.push_back(kVp8Codec); + parameters.codecs.push_back(kRedCodec); + parameters.codecs[1].id = parameters.codecs[0].id; + EXPECT_FALSE(channel_->SetRecvParameters(parameters)); } TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsRejectDuplicateCodecPayloads) { - std::vector codecs; - codecs.push_back(kVp8Codec); - codecs.push_back(kVp9Codec); - codecs[1].id = codecs[0].id; - EXPECT_FALSE(channel_->SetRecvCodecs(codecs)); + cricket::VideoRecvParameters parameters; + parameters.codecs.push_back(kVp8Codec); + parameters.codecs.push_back(kVp9Codec); + parameters.codecs[1].id = parameters.codecs[0].id; + EXPECT_FALSE(channel_->SetRecvParameters(parameters)); } TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsAcceptSameCodecOnMultiplePayloadTypes) { - std::vector codecs; - codecs.push_back(kVp8Codec); - codecs.push_back(kVp8Codec); - codecs[1].id += 1; - EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); + cricket::VideoRecvParameters parameters; + parameters.codecs.push_back(kVp8Codec); + parameters.codecs.push_back(kVp8Codec); + parameters.codecs[1].id += 1; + EXPECT_TRUE(channel_->SetRecvParameters(parameters)); } // Test that setting the same codecs but with a different order and preference // doesn't result in the stream being recreated. TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsDifferentOrderAndPreferenceDoesntRecreateStream) { - std::vector codecs1; - codecs1.push_back(kVp8Codec); - codecs1.push_back(kRedCodec); - EXPECT_TRUE(channel_->SetRecvCodecs(codecs1)); + cricket::VideoRecvParameters parameters1; + parameters1.codecs.push_back(kVp8Codec); + parameters1.codecs.push_back(kRedCodec); + EXPECT_TRUE(channel_->SetRecvParameters(parameters1)); AddRecvStream(cricket::StreamParams::CreateLegacy(123)); EXPECT_EQ(1, fake_call_->GetNumCreatedReceiveStreams()); - std::vector codecs2; - codecs2.push_back(kRedCodec); - codecs2.push_back(kVp8Codec); - codecs2[1].preference += 1; - EXPECT_TRUE(channel_->SetRecvCodecs(codecs2)); + cricket::VideoRecvParameters parameters2; + parameters2.codecs.push_back(kRedCodec); + parameters2.codecs.push_back(kVp8Codec); + parameters2.codecs[1].preference += 1; + EXPECT_TRUE(channel_->SetRecvParameters(parameters2)); EXPECT_EQ(1, fake_call_->GetNumCreatedReceiveStreams()); } @@ -2292,18 +2297,18 @@ TEST_F(WebRtcVideoChannel2Test, TestSetDscpOptions) { rtc::scoped_ptr network_interface( new cricket::FakeNetworkInterface); channel_->SetInterface(network_interface.get()); - cricket::VideoOptions options; - EXPECT_TRUE(channel_->SetOptions(options)); + cricket::VideoSendParameters parameters = send_parameters_; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_EQ(rtc::DSCP_NO_CHANGE, network_interface->dscp()); - options.dscp.Set(true); - EXPECT_TRUE(channel_->SetOptions(options)); + parameters.options.dscp.Set(true); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_EQ(rtc::DSCP_AF41, network_interface->dscp()); // Verify previous value is not modified if dscp option is not set. - cricket::VideoOptions options1; - EXPECT_TRUE(channel_->SetOptions(options1)); + cricket::VideoSendParameters parameters1 = send_parameters_; + EXPECT_TRUE(channel_->SetSendParameters(parameters1)); EXPECT_EQ(rtc::DSCP_AF41, network_interface->dscp()); - options.dscp.Set(false); - EXPECT_TRUE(channel_->SetOptions(options)); + parameters1.options.dscp.Set(false); + EXPECT_TRUE(channel_->SetSendParameters(parameters1)); EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface->dscp()); channel_->SetInterface(NULL); } @@ -2319,9 +2324,9 @@ TEST_F(WebRtcVideoChannel2Test, OnReadyToSendSignalsNetworkState) { } TEST_F(WebRtcVideoChannel2Test, GetStatsReportsSentCodecName) { - std::vector codecs; - codecs.push_back(kVp8Codec); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::VideoSendParameters parameters; + parameters.codecs.push_back(kVp8Codec); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); AddSendStream(); @@ -2374,15 +2379,14 @@ TEST_F(WebRtcVideoChannel2Test, GetStatsTracksAdaptationStats) { EXPECT_TRUE(video_capturer_vga.CaptureFrame()); cricket::VideoCodec send_codec(100, "VP8", 640, 480, 30, 0); - std::vector codecs; - codecs.push_back(send_codec); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::VideoSendParameters parameters; + parameters.codecs.push_back(send_codec); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_TRUE(channel_->SetSend(true)); // Verify that the CpuOveruseObserver is registered and trigger downgrade. - cricket::VideoOptions options; - options.cpu_overuse_detection.Set(true); - EXPECT_TRUE(channel_->SetOptions(options)); + parameters.options.cpu_overuse_detection.Set(true); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); // Trigger overuse. ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size()); @@ -2579,7 +2583,7 @@ TEST_F(WebRtcVideoChannel2Test, TranslatesSenderBitrateStatsCorrectly) { } TEST_F(WebRtcVideoChannel2Test, DefaultReceiveStreamReconfiguresToUseRtx) { - EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); const std::vector ssrcs = MAKE_VECTOR(kSsrcs1); const std::vector rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); @@ -2610,7 +2614,7 @@ TEST_F(WebRtcVideoChannel2Test, DefaultReceiveStreamReconfiguresToUseRtx) { } TEST_F(WebRtcVideoChannel2Test, RejectsAddingStreamsWithMissingSsrcsForRtx) { - EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); const std::vector ssrcs = MAKE_VECTOR(kSsrcs1); const std::vector rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); @@ -2624,7 +2628,7 @@ TEST_F(WebRtcVideoChannel2Test, RejectsAddingStreamsWithMissingSsrcsForRtx) { } TEST_F(WebRtcVideoChannel2Test, RejectsAddingStreamsWithOverlappingRtxSsrcs) { - EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); const std::vector ssrcs = MAKE_VECTOR(kSsrcs1); const std::vector rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); @@ -2652,7 +2656,7 @@ TEST_F(WebRtcVideoChannel2Test, RejectsAddingStreamsWithOverlappingSimulcastSsrcs) { static const uint32 kFirstStreamSsrcs[] = {1, 2, 3}; static const uint32 kOverlappingStreamSsrcs[] = {4, 3, 5}; - EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); StreamParams sp = cricket::CreateSimStreamParams("cname", MAKE_VECTOR(kFirstStreamSsrcs)); @@ -2675,7 +2679,7 @@ TEST_F(WebRtcVideoChannel2Test, } TEST_F(WebRtcVideoChannel2Test, ReportsSsrcGroupsInStats) { - EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); static const uint32_t kSenderSsrcs[] = {4, 7, 10}; static const uint32_t kSenderRtxSsrcs[] = {5, 8, 11}; @@ -2729,12 +2733,11 @@ TEST_F(WebRtcVideoChannel2Test, MapsReceivedPayloadTypeToCodecName) { void WebRtcVideoChannel2Test::TestReceiveUnsignalledSsrcPacket( uint8_t payload_type, bool expect_created_receive_stream) { - std::vector codecs(engine_.codecs()); // Add a RED RTX codec. VideoCodec red_rtx_codec = VideoCodec::CreateRtxCodec(kRedRtxPayloadType, kDefaultRedPlType); - codecs.push_back(red_rtx_codec); - EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); + recv_parameters_.codecs.push_back(red_rtx_codec); + EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); ASSERT_EQ(0u, fake_call_->GetVideoReceiveStreams().size()); const size_t kDataLength = 12; @@ -2780,7 +2783,7 @@ TEST_F(WebRtcVideoChannel2Test, RedRtxPacketDoesntCreateUnsignalledStream) { void WebRtcVideoChannel2Test::TestReceiverLocalSsrcConfiguration( bool receiver_first) { - EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); const uint32_t kSenderSsrc = 0xC0FFEE; const uint32_t kReceiverSsrc = 0x4711; @@ -2973,13 +2976,10 @@ class WebRtcVideoChannel2SimulcastTest : public testing::Test { size_t num_configured_streams, size_t expected_num_streams, SimulcastBitrateMode simulcast_bitrate_mode) { - cricket::VideoOptions options; - options.video_highest_bitrate.Set(bitrate_mode); - EXPECT_TRUE(channel_->SetOptions(options)); - - std::vector codecs; - codecs.push_back(codec); - ASSERT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::VideoSendParameters parameters; + parameters.options.video_highest_bitrate.Set(bitrate_mode); + parameters.codecs.push_back(codec); + ASSERT_TRUE(channel_->SetSendParameters(parameters)); std::vector ssrcs = MAKE_VECTOR(kSsrcs3); RTC_DCHECK(num_configured_streams <= ssrcs.size()); diff --git a/talk/media/webrtc/webrtcvoiceengine.cc b/talk/media/webrtc/webrtcvoiceengine.cc index add831d5c7..d0eb4aea24 100644 --- a/talk/media/webrtc/webrtcvoiceengine.cc +++ b/talk/media/webrtc/webrtcvoiceengine.cc @@ -581,14 +581,12 @@ int WebRtcVoiceEngine::GetCapabilities() { VoiceMediaChannel* WebRtcVoiceEngine::CreateChannel(webrtc::Call* call, const AudioOptions& options) { - WebRtcVoiceMediaChannel* ch = new WebRtcVoiceMediaChannel(this, call); + WebRtcVoiceMediaChannel* ch = + new WebRtcVoiceMediaChannel(this, options, call); if (!ch->valid()) { delete ch; return nullptr; } - if (!ch->SetOptions(options)) { - LOG(LS_WARNING) << "Failed to set options while creating channel."; - } return ch; } @@ -1690,6 +1688,7 @@ class WebRtcVoiceMediaChannel::WebRtcVoiceChannelRenderer // WebRtcVoiceMediaChannel WebRtcVoiceMediaChannel::WebRtcVoiceMediaChannel(WebRtcVoiceEngine* engine, + const AudioOptions& options, webrtc::Call* call) : engine_(engine), voe_channel_(engine->CreateMediaVoiceChannel()), @@ -1710,6 +1709,7 @@ WebRtcVoiceMediaChannel::WebRtcVoiceMediaChannel(WebRtcVoiceEngine* engine, << voe_channel(); RTC_DCHECK(nullptr != call); ConfigureSendChannel(voe_channel()); + SetOptions(options); } WebRtcVoiceMediaChannel::~WebRtcVoiceMediaChannel() { diff --git a/talk/media/webrtc/webrtcvoiceengine.h b/talk/media/webrtc/webrtcvoiceengine.h index e8ae157596..aa7d7dafff 100644 --- a/talk/media/webrtc/webrtcvoiceengine.h +++ b/talk/media/webrtc/webrtcvoiceengine.h @@ -282,8 +282,9 @@ class WebRtcVoiceEngine class WebRtcVoiceMediaChannel : public VoiceMediaChannel, public webrtc::Transport { public: - explicit WebRtcVoiceMediaChannel(WebRtcVoiceEngine* engine, - webrtc::Call* call); + WebRtcVoiceMediaChannel(WebRtcVoiceEngine* engine, + const AudioOptions& options, + webrtc::Call* call); ~WebRtcVoiceMediaChannel() override; int voe_channel() const { return voe_channel_; } @@ -292,13 +293,6 @@ class WebRtcVoiceMediaChannel : public VoiceMediaChannel, bool SetSendParameters(const AudioSendParameters& params) override; bool SetRecvParameters(const AudioRecvParameters& params) override; - bool SetOptions(const AudioOptions& options) override; - bool SetRecvCodecs(const std::vector& codecs) override; - bool SetSendCodecs(const std::vector& codecs) override; - bool SetRecvRtpHeaderExtensions( - const std::vector& extensions) override; - bool SetSendRtpHeaderExtensions( - const std::vector& extensions) override; bool SetPlayout(bool playout) override; bool PausePlayout(); bool ResumePlayout(); @@ -332,7 +326,6 @@ class WebRtcVoiceMediaChannel : public VoiceMediaChannel, void OnRtcpReceived(rtc::Buffer* packet, const rtc::PacketTime& packet_time) override; void OnReadyToSend(bool ready) override {} - bool SetMaxSendBandwidth(int bps) override; bool GetStats(VoiceMediaInfo* info) override; // Gets last reported error from WebRtc voice engine. This should be only // called in response a failure. @@ -360,8 +353,17 @@ class WebRtcVoiceMediaChannel : public VoiceMediaChannel, int GetSendChannelNum(uint32 ssrc) const; private: + bool SetSendCodecs(const std::vector& codecs); + bool SetSendRtpHeaderExtensions( + const std::vector& extensions); + bool SetOptions(const AudioOptions& options); + bool SetMaxSendBandwidth(int bps); + bool SetRecvCodecs(const std::vector& codecs); + bool SetRecvRtpHeaderExtensions( + const std::vector& extensions); bool SetLocalRenderer(uint32 ssrc, AudioRenderer* renderer); bool MuteStream(uint32 ssrc, bool mute); + WebRtcVoiceEngine* engine() { return engine_; } int GetLastEngineError() { return engine()->GetLastEngineError(); } int GetOutputLevel(int channel); diff --git a/talk/media/webrtc/webrtcvoiceengine_unittest.cc b/talk/media/webrtc/webrtcvoiceengine_unittest.cc index 5fcdf5b3d5..fc373db916 100644 --- a/talk/media/webrtc/webrtcvoiceengine_unittest.cc +++ b/talk/media/webrtc/webrtcvoiceengine_unittest.cc @@ -128,6 +128,8 @@ class WebRtcVoiceEngineTestFake : public testing::Test { trace_wrapper_(new FakeVoETraceWrapper()), engine_(new FakeVoEWrapper(&voe_), trace_wrapper_), channel_(nullptr) { + send_parameters_.codecs.push_back(kPcmuCodec); + recv_parameters_.codecs.push_back(kPcmuCodec); options_conference_.conference_mode.Set(true); options_adjust_agc_.adjust_agc_delta.Set(-10); } @@ -179,14 +181,12 @@ class WebRtcVoiceEngineTestFake : public testing::Test { int channel_id = voe_.GetLastChannel(); // Test we can only InsertDtmf when the other side supports telephone-event. - std::vector codecs; - codecs.push_back(kPcmuCodec); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); EXPECT_FALSE(channel_->CanInsertDtmf()); EXPECT_FALSE(channel_->InsertDtmf(ssrc, 1, 111, cricket::DF_SEND)); - codecs.push_back(kTelephoneEventCodec); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + send_parameters_.codecs.push_back(kTelephoneEventCodec); + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); EXPECT_TRUE(channel_->CanInsertDtmf()); if (!caller) { @@ -227,18 +227,14 @@ class WebRtcVoiceEngineTestFake : public testing::Test { int max_bitrate, bool expected_result, int expected_bitrate) { + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(codec); + parameters.max_bandwidth_bps = max_bitrate; + EXPECT_EQ(expected_result, channel_->SetSendParameters(parameters)); + int channel_num = voe_.GetLastChannel(); - std::vector codecs; - - codecs.push_back(codec); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); - - bool result = channel_->SetMaxSendBandwidth(max_bitrate); - EXPECT_EQ(expected_result, result); - webrtc::CodecInst temp_codec; EXPECT_FALSE(voe_.GetSendCodec(channel_num, temp_codec)); - EXPECT_EQ(expected_bitrate, temp_codec.rate); } @@ -249,22 +245,21 @@ class WebRtcVoiceEngineTestFake : public testing::Test { // Ensure extensions are off by default. EXPECT_EQ(-1, voe_.GetSendRtpExtensionId(channel_num, ext)); - std::vector extensions; // Ensure unknown extensions won't cause an error. - extensions.push_back(cricket::RtpHeaderExtension( + send_parameters_.extensions.push_back(cricket::RtpHeaderExtension( "urn:ietf:params:unknownextention", 1)); - EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); EXPECT_EQ(-1, voe_.GetSendRtpExtensionId(channel_num, ext)); // Ensure extensions stay off with an empty list of headers. - extensions.clear(); - EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); + send_parameters_.extensions.clear(); + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); EXPECT_EQ(-1, voe_.GetSendRtpExtensionId(channel_num, ext)); // Ensure extension is set properly. const int id = 1; - extensions.push_back(cricket::RtpHeaderExtension(ext, id)); - EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); + send_parameters_.extensions.push_back(cricket::RtpHeaderExtension(ext, id)); + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); EXPECT_EQ(id, voe_.GetSendRtpExtensionId(channel_num, ext)); // Ensure extension is set properly on new channel. @@ -278,8 +273,9 @@ class WebRtcVoiceEngineTestFake : public testing::Test { EXPECT_EQ(id, voe_.GetSendRtpExtensionId(new_channel_num, ext)); // Ensure all extensions go back off with an empty list. - extensions.clear(); - EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); + send_parameters_.codecs.push_back(kPcmuCodec); + send_parameters_.extensions.clear(); + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); EXPECT_EQ(-1, voe_.GetSendRtpExtensionId(channel_num, ext)); EXPECT_EQ(-1, voe_.GetSendRtpExtensionId(new_channel_num, ext)); } @@ -291,22 +287,22 @@ class WebRtcVoiceEngineTestFake : public testing::Test { // Ensure extensions are off by default. EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(channel_num, ext)); - std::vector extensions; + cricket::AudioRecvParameters parameters; // Ensure unknown extensions won't cause an error. - extensions.push_back(cricket::RtpHeaderExtension( + parameters.extensions.push_back(cricket::RtpHeaderExtension( "urn:ietf:params:unknownextention", 1)); - EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions)); + EXPECT_TRUE(channel_->SetRecvParameters(parameters)); EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(channel_num, ext)); // Ensure extensions stay off with an empty list of headers. - extensions.clear(); - EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions)); + parameters.extensions.clear(); + EXPECT_TRUE(channel_->SetRecvParameters(parameters)); EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(channel_num, ext)); // Ensure extension is set properly. const int id = 2; - extensions.push_back(cricket::RtpHeaderExtension(ext, id)); - EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions)); + parameters.extensions.push_back(cricket::RtpHeaderExtension(ext, id)); + EXPECT_TRUE(channel_->SetRecvParameters(parameters)); EXPECT_EQ(id, voe_.GetReceiveRtpExtensionId(channel_num, ext)); // Ensure extension is set properly on new channel. @@ -320,8 +316,8 @@ class WebRtcVoiceEngineTestFake : public testing::Test { EXPECT_EQ(id, voe_.GetReceiveRtpExtensionId(new_channel_num, ext)); // Ensure all extensions go back off with an empty list. - extensions.clear(); - EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions)); + parameters.extensions.clear(); + EXPECT_TRUE(channel_->SetRecvParameters(parameters)); EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(channel_num, ext)); EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(new_channel_num, ext)); } @@ -333,6 +329,8 @@ class WebRtcVoiceEngineTestFake : public testing::Test { cricket::WebRtcVoiceEngine engine_; cricket::VoiceMediaChannel* channel_; + cricket::AudioSendParameters send_parameters_; + cricket::AudioRecvParameters recv_parameters_; cricket::AudioOptions options_conference_; cricket::AudioOptions options_adjust_agc_; }; @@ -417,13 +415,13 @@ TEST_F(WebRtcVoiceEngineTestFake, FindCodec) { TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecs) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kIsacCodec); - codecs.push_back(kPcmuCodec); - codecs.push_back(kTelephoneEventCodec); - codecs[0].id = 106; // collide with existing telephone-event - codecs[2].id = 126; - EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); + cricket::AudioRecvParameters parameters; + parameters.codecs.push_back(kIsacCodec); + parameters.codecs.push_back(kPcmuCodec); + parameters.codecs.push_back(kTelephoneEventCodec); + parameters.codecs[0].id = 106; // collide with existing telephone-event + parameters.codecs[2].id = 126; + EXPECT_TRUE(channel_->SetRecvParameters(parameters)); webrtc::CodecInst gcodec; rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), "ISAC"); gcodec.plfreq = 16000; @@ -442,31 +440,30 @@ TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecs) { // Test that we fail to set an unknown inbound codec. TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsUnsupportedCodec) { EXPECT_TRUE(SetupEngine()); - std::vector codecs; - codecs.push_back(kIsacCodec); - codecs.push_back(cricket::AudioCodec(127, "XYZ", 32000, 0, 1, 0)); - EXPECT_FALSE(channel_->SetRecvCodecs(codecs)); + cricket::AudioRecvParameters parameters; + parameters.codecs.push_back(kIsacCodec); + parameters.codecs.push_back(cricket::AudioCodec(127, "XYZ", 32000, 0, 1, 0)); + EXPECT_FALSE(channel_->SetRecvParameters(parameters)); } // Test that we fail if we have duplicate types in the inbound list. TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsDuplicatePayloadType) { EXPECT_TRUE(SetupEngine()); - std::vector codecs; - codecs.push_back(kIsacCodec); - codecs.push_back(kCn16000Codec); - codecs[1].id = kIsacCodec.id; - EXPECT_FALSE(channel_->SetRecvCodecs(codecs)); + cricket::AudioRecvParameters parameters; + parameters.codecs.push_back(kIsacCodec); + parameters.codecs.push_back(kCn16000Codec); + parameters.codecs[1].id = kIsacCodec.id; + EXPECT_FALSE(channel_->SetRecvParameters(parameters)); } // Test that we can decode OPUS without stereo parameters. TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithOpusNoStereo) { EXPECT_TRUE(SetupEngine()); - EXPECT_TRUE(channel_->SetOptions(options_conference_)); - std::vector codecs; - codecs.push_back(kIsacCodec); - codecs.push_back(kPcmuCodec); - codecs.push_back(kOpusCodec); - EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); + cricket::AudioRecvParameters parameters; + parameters.codecs.push_back(kIsacCodec); + parameters.codecs.push_back(kPcmuCodec); + parameters.codecs.push_back(kOpusCodec); + EXPECT_TRUE(channel_->SetRecvParameters(parameters)); EXPECT_TRUE(channel_->AddRecvStream( cricket::StreamParams::CreateLegacy(kSsrc1))); int channel_num2 = voe_.GetLastChannel(); @@ -484,13 +481,12 @@ TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithOpusNoStereo) { // Test that we can decode OPUS with stereo = 0. TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithOpus0Stereo) { EXPECT_TRUE(SetupEngine()); - EXPECT_TRUE(channel_->SetOptions(options_conference_)); - std::vector codecs; - codecs.push_back(kIsacCodec); - codecs.push_back(kPcmuCodec); - codecs.push_back(kOpusCodec); - codecs[2].params["stereo"] = "0"; - EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); + cricket::AudioRecvParameters parameters; + parameters.codecs.push_back(kIsacCodec); + parameters.codecs.push_back(kPcmuCodec); + parameters.codecs.push_back(kOpusCodec); + parameters.codecs[2].params["stereo"] = "0"; + EXPECT_TRUE(channel_->SetRecvParameters(parameters)); EXPECT_TRUE(channel_->AddRecvStream( cricket::StreamParams::CreateLegacy(kSsrc1))); int channel_num2 = voe_.GetLastChannel(); @@ -508,13 +504,12 @@ TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithOpus0Stereo) { // Test that we can decode OPUS with stereo = 1. TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithOpus1Stereo) { EXPECT_TRUE(SetupEngine()); - EXPECT_TRUE(channel_->SetOptions(options_conference_)); - std::vector codecs; - codecs.push_back(kIsacCodec); - codecs.push_back(kPcmuCodec); - codecs.push_back(kOpusCodec); - codecs[2].params["stereo"] = "1"; - EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); + cricket::AudioRecvParameters parameters; + parameters.codecs.push_back(kIsacCodec); + parameters.codecs.push_back(kPcmuCodec); + parameters.codecs.push_back(kOpusCodec); + parameters.codecs[2].params["stereo"] = "1"; + EXPECT_TRUE(channel_->SetRecvParameters(parameters)); EXPECT_TRUE(channel_->AddRecvStream( cricket::StreamParams::CreateLegacy(kSsrc1))); int channel_num2 = voe_.GetLastChannel(); @@ -531,14 +526,13 @@ TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithOpus1Stereo) { // Test that changes to recv codecs are applied to all streams. TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithMultipleStreams) { EXPECT_TRUE(SetupEngine()); - EXPECT_TRUE(channel_->SetOptions(options_conference_)); - std::vector codecs; - codecs.push_back(kIsacCodec); - codecs.push_back(kPcmuCodec); - codecs.push_back(kTelephoneEventCodec); - codecs[0].id = 106; // collide with existing telephone-event - codecs[2].id = 126; - EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); + cricket::AudioRecvParameters parameters; + parameters.codecs.push_back(kIsacCodec); + parameters.codecs.push_back(kPcmuCodec); + parameters.codecs.push_back(kTelephoneEventCodec); + parameters.codecs[0].id = 106; // collide with existing telephone-event + parameters.codecs[2].id = 126; + EXPECT_TRUE(channel_->SetRecvParameters(parameters)); EXPECT_TRUE(channel_->AddRecvStream( cricket::StreamParams::CreateLegacy(kSsrc1))); int channel_num2 = voe_.GetLastChannel(); @@ -560,14 +554,12 @@ TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithMultipleStreams) { TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsAfterAddingStreams) { EXPECT_TRUE(SetupEngine()); - EXPECT_TRUE(channel_->SetOptions(options_conference_)); - std::vector codecs; - codecs.push_back(kIsacCodec); - codecs[0].id = 106; // collide with existing telephone-event - + cricket::AudioRecvParameters parameters; + parameters.codecs.push_back(kIsacCodec); + parameters.codecs[0].id = 106; // collide with existing telephone-event EXPECT_TRUE(channel_->AddRecvStream( cricket::StreamParams::CreateLegacy(kSsrc1))); - EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); + EXPECT_TRUE(channel_->SetRecvParameters(parameters)); int channel_num2 = voe_.GetLastChannel(); webrtc::CodecInst gcodec; @@ -582,32 +574,32 @@ TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsAfterAddingStreams) { // Test that we can apply the same set of codecs again while playing. TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWhilePlaying) { EXPECT_TRUE(SetupEngine()); - int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kIsacCodec); - codecs.push_back(kCn16000Codec); - EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); + cricket::AudioRecvParameters parameters; + parameters.codecs.push_back(kIsacCodec); + parameters.codecs.push_back(kCn16000Codec); + EXPECT_TRUE(channel_->SetRecvParameters(parameters)); EXPECT_TRUE(channel_->SetPlayout(true)); - EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); + EXPECT_TRUE(channel_->SetRecvParameters(parameters)); // Changing the payload type of a codec should fail. - codecs[0].id = 127; - EXPECT_FALSE(channel_->SetRecvCodecs(codecs)); + parameters.codecs[0].id = 127; + EXPECT_FALSE(channel_->SetRecvParameters(parameters)); + int channel_num = voe_.GetLastChannel(); EXPECT_TRUE(voe_.GetPlayout(channel_num)); } // Test that we can add a codec while playing. TEST_F(WebRtcVoiceEngineTestFake, AddRecvCodecsWhilePlaying) { EXPECT_TRUE(SetupEngine()); - int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kIsacCodec); - codecs.push_back(kCn16000Codec); - EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); + cricket::AudioRecvParameters parameters; + parameters.codecs.push_back(kIsacCodec); + parameters.codecs.push_back(kCn16000Codec); + EXPECT_TRUE(channel_->SetRecvParameters(parameters)); EXPECT_TRUE(channel_->SetPlayout(true)); - codecs.push_back(kOpusCodec); - EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); + parameters.codecs.push_back(kOpusCodec); + EXPECT_TRUE(channel_->SetRecvParameters(parameters)); + int channel_num = voe_.GetLastChannel(); EXPECT_TRUE(voe_.GetPlayout(channel_num)); webrtc::CodecInst gcodec; EXPECT_TRUE(engine_.FindWebRtcCodec(kOpusCodec, &gcodec)); @@ -616,7 +608,6 @@ TEST_F(WebRtcVoiceEngineTestFake, AddRecvCodecsWhilePlaying) { TEST_F(WebRtcVoiceEngineTestFake, SetSendBandwidthAuto) { EXPECT_TRUE(SetupEngine()); - EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); // Test that when autobw is enabled, bitrate is kept as the default // value. autobw is enabled for the following tests because the target @@ -634,7 +625,6 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendBandwidthAuto) { TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthMultiRateAsCaller) { EXPECT_TRUE(SetupEngine()); - EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); // Test that the bitrate of a multi-rate codec is always the maximum. @@ -649,7 +639,6 @@ TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthMultiRateAsCaller) { TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthFixedRateAsCaller) { EXPECT_TRUE(SetupEngine()); - EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); // Test that we can only set a maximum bitrate for a fixed-rate codec // if it's bigger than the fixed rate. @@ -665,13 +654,12 @@ TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthFixedRateAsCaller) { } TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthMultiRateAsCallee) { - EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); - channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions()); - EXPECT_TRUE(channel_ != nullptr); - EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); - - int desired_bitrate = 128000; - EXPECT_TRUE(channel_->SetMaxSendBandwidth(desired_bitrate)); + EXPECT_TRUE(SetupEngineWithoutStream()); + const int kDesiredBitrate = 128000; + cricket::AudioSendParameters parameters; + parameters.codecs = engine_.codecs(); + parameters.max_bandwidth_bps = kDesiredBitrate; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_TRUE(channel_->AddSendStream( cricket::StreamParams::CreateLegacy(kSsrc1))); @@ -679,7 +667,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthMultiRateAsCallee) { int channel_num = voe_.GetLastChannel(); webrtc::CodecInst codec; EXPECT_EQ(0, voe_.GetSendCodec(channel_num, codec)); - EXPECT_EQ(desired_bitrate, codec.rate); + EXPECT_EQ(kDesiredBitrate, codec.rate); } // Test that bitrate cannot be set for CBR codecs. @@ -687,21 +675,21 @@ TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthMultiRateAsCallee) { // Bitrate less then the fixed bitrate is an error. TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthCbr) { EXPECT_TRUE(SetupEngine()); - EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); - - webrtc::CodecInst codec; - int channel_num = voe_.GetLastChannel(); - std::vector codecs; // PCMU, default bitrate == 64000. - codecs.push_back(kPcmuCodec); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); + int channel_num = voe_.GetLastChannel(); + webrtc::CodecInst codec; EXPECT_EQ(0, voe_.GetSendCodec(channel_num, codec)); EXPECT_EQ(64000, codec.rate); - EXPECT_TRUE(channel_->SetMaxSendBandwidth(128000)); + + send_parameters_.max_bandwidth_bps = 128000; + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); EXPECT_EQ(0, voe_.GetSendCodec(channel_num, codec)); EXPECT_EQ(64000, codec.rate); - EXPECT_FALSE(channel_->SetMaxSendBandwidth(128)); + + send_parameters_.max_bandwidth_bps = 128; + EXPECT_FALSE(channel_->SetSendParameters(send_parameters_)); EXPECT_EQ(0, voe_.GetSendCodec(channel_num, codec)); EXPECT_EQ(64000, codec.rate); } @@ -709,15 +697,15 @@ TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthCbr) { // Test that we apply codecs properly. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecs) { EXPECT_TRUE(SetupEngine()); - int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kIsacCodec); - codecs.push_back(kPcmuCodec); - codecs.push_back(kRedCodec); - codecs[0].id = 96; - codecs[0].bitrate = 48000; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kIsacCodec); + parameters.codecs.push_back(kPcmuCodec); + parameters.codecs.push_back(kRedCodec); + parameters.codecs[0].id = 96; + parameters.codecs[0].bitrate = 48000; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_EQ(1, voe_.GetNumSetSendCodecs()); + int channel_num = voe_.GetLastChannel(); webrtc::CodecInst gcodec; EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_EQ(96, gcodec.pltype); @@ -734,17 +722,17 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecs) { // to apply. TEST_F(WebRtcVoiceEngineTestFake, DontResetSetSendCodec) { EXPECT_TRUE(SetupEngine()); - std::vector codecs; - codecs.push_back(kIsacCodec); - codecs.push_back(kPcmuCodec); - codecs.push_back(kRedCodec); - codecs[0].id = 96; - codecs[0].bitrate = 48000; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kIsacCodec); + parameters.codecs.push_back(kPcmuCodec); + parameters.codecs.push_back(kRedCodec); + parameters.codecs[0].id = 96; + parameters.codecs[0].bitrate = 48000; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_EQ(1, voe_.GetNumSetSendCodecs()); // Calling SetSendCodec again with same codec which is already set. // In this case media channel shouldn't send codec to VoE. - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_EQ(1, voe_.GetNumSetSendCodecs()); } @@ -752,9 +740,9 @@ TEST_F(WebRtcVoiceEngineTestFake, DontResetSetSendCodec) { TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecG722) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kG722CodecSdp); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kG722CodecSdp); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); webrtc::CodecInst gcodec; EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_STREQ("G722", gcodec.plname); @@ -765,64 +753,64 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecG722) { // Test that if clockrate is not 48000 for opus, we fail. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBadClockrate) { EXPECT_TRUE(SetupEngine()); - std::vector codecs; - codecs.push_back(kOpusCodec); - codecs[0].bitrate = 0; - codecs[0].clockrate = 50000; - EXPECT_FALSE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kOpusCodec); + parameters.codecs[0].bitrate = 0; + parameters.codecs[0].clockrate = 50000; + EXPECT_FALSE(channel_->SetSendParameters(parameters)); } // Test that if channels=0 for opus, we fail. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad0ChannelsNoStereo) { EXPECT_TRUE(SetupEngine()); - std::vector codecs; - codecs.push_back(kOpusCodec); - codecs[0].bitrate = 0; - codecs[0].channels = 0; - EXPECT_FALSE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kOpusCodec); + parameters.codecs[0].bitrate = 0; + parameters.codecs[0].channels = 0; + EXPECT_FALSE(channel_->SetSendParameters(parameters)); } // Test that if channels=0 for opus, we fail. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad0Channels1Stereo) { EXPECT_TRUE(SetupEngine()); - std::vector codecs; - codecs.push_back(kOpusCodec); - codecs[0].bitrate = 0; - codecs[0].channels = 0; - codecs[0].params["stereo"] = "1"; - EXPECT_FALSE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kOpusCodec); + parameters.codecs[0].bitrate = 0; + parameters.codecs[0].channels = 0; + parameters.codecs[0].params["stereo"] = "1"; + EXPECT_FALSE(channel_->SetSendParameters(parameters)); } // Test that if channel is 1 for opus and there's no stereo, we fail. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpus1ChannelNoStereo) { EXPECT_TRUE(SetupEngine()); - std::vector codecs; - codecs.push_back(kOpusCodec); - codecs[0].bitrate = 0; - codecs[0].channels = 1; - EXPECT_FALSE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kOpusCodec); + parameters.codecs[0].bitrate = 0; + parameters.codecs[0].channels = 1; + EXPECT_FALSE(channel_->SetSendParameters(parameters)); } // Test that if channel is 1 for opus and stereo=0, we fail. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad1Channel0Stereo) { EXPECT_TRUE(SetupEngine()); - std::vector codecs; - codecs.push_back(kOpusCodec); - codecs[0].bitrate = 0; - codecs[0].channels = 1; - codecs[0].params["stereo"] = "0"; - EXPECT_FALSE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kOpusCodec); + parameters.codecs[0].bitrate = 0; + parameters.codecs[0].channels = 1; + parameters.codecs[0].params["stereo"] = "0"; + EXPECT_FALSE(channel_->SetSendParameters(parameters)); } // Test that if channel is 1 for opus and stereo=1, we fail. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad1Channel1Stereo) { EXPECT_TRUE(SetupEngine()); - std::vector codecs; - codecs.push_back(kOpusCodec); - codecs[0].bitrate = 0; - codecs[0].channels = 1; - codecs[0].params["stereo"] = "1"; - EXPECT_FALSE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kOpusCodec); + parameters.codecs[0].bitrate = 0; + parameters.codecs[0].channels = 1; + parameters.codecs[0].params["stereo"] = "1"; + EXPECT_FALSE(channel_->SetSendParameters(parameters)); } // Test that with bitrate=0 and no stereo, @@ -830,10 +818,10 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad1Channel1Stereo) { TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGood0BitrateNoStereo) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kOpusCodec); - codecs[0].bitrate = 0; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kOpusCodec); + parameters.codecs[0].bitrate = 0; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); webrtc::CodecInst gcodec; EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_STREQ("opus", gcodec.plname); @@ -846,11 +834,11 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGood0BitrateNoStereo) { TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGood0Bitrate0Stereo) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kOpusCodec); - codecs[0].bitrate = 0; - codecs[0].params["stereo"] = "0"; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kOpusCodec); + parameters.codecs[0].bitrate = 0; + parameters.codecs[0].params["stereo"] = "0"; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); webrtc::CodecInst gcodec; EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_STREQ("opus", gcodec.plname); @@ -863,21 +851,21 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGood0Bitrate0Stereo) { TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodXBitrate0Stereo) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kOpusCodec); - codecs[0].params["stereo"] = "0"; + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kOpusCodec); + parameters.codecs[0].params["stereo"] = "0"; webrtc::CodecInst gcodec; // bitrate that's out of the range between 6000 and 510000 will be clamped. - codecs[0].bitrate = 5999; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + parameters.codecs[0].bitrate = 5999; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_STREQ("opus", gcodec.plname); EXPECT_EQ(1, gcodec.channels); EXPECT_EQ(6000, gcodec.rate); - codecs[0].bitrate = 510001; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + parameters.codecs[0].bitrate = 510001; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_STREQ("opus", gcodec.plname); EXPECT_EQ(1, gcodec.channels); @@ -889,11 +877,11 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodXBitrate0Stereo) { TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGood0Bitrate1Stereo) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kOpusCodec); - codecs[0].bitrate = 0; - codecs[0].params["stereo"] = "1"; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kOpusCodec); + parameters.codecs[0].bitrate = 0; + parameters.codecs[0].params["stereo"] = "1"; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); webrtc::CodecInst gcodec; EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_STREQ("opus", gcodec.plname); @@ -906,21 +894,21 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGood0Bitrate1Stereo) { TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodXBitrate1Stereo) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kOpusCodec); - codecs[0].params["stereo"] = "1"; + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kOpusCodec); + parameters.codecs[0].params["stereo"] = "1"; webrtc::CodecInst gcodec; // bitrate that's out of the range between 6000 and 510000 will be clamped. - codecs[0].bitrate = 5999; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + parameters.codecs[0].bitrate = 5999; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_STREQ("opus", gcodec.plname); EXPECT_EQ(2, gcodec.channels); EXPECT_EQ(6000, gcodec.rate); - codecs[0].bitrate = 510001; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + parameters.codecs[0].bitrate = 510001; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_STREQ("opus", gcodec.plname); EXPECT_EQ(2, gcodec.channels); @@ -932,10 +920,10 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodXBitrate1Stereo) { TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrateNoStereo) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kOpusCodec); - codecs[0].bitrate = 96000; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kOpusCodec); + parameters.codecs[0].bitrate = 96000; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); webrtc::CodecInst gcodec; EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_EQ(111, gcodec.pltype); @@ -950,11 +938,11 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrateNoStereo) { TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrate0Stereo) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kOpusCodec); - codecs[0].bitrate = 30000; - codecs[0].params["stereo"] = "0"; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kOpusCodec); + parameters.codecs[0].bitrate = 30000; + parameters.codecs[0].params["stereo"] = "0"; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); webrtc::CodecInst gcodec; EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_EQ(1, gcodec.channels); @@ -967,10 +955,10 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrate0Stereo) { TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrateNoParameters) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kOpusCodec); - codecs[0].bitrate = 30000; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kOpusCodec); + parameters.codecs[0].bitrate = 30000; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); webrtc::CodecInst gcodec; EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_EQ(1, gcodec.channels); @@ -983,11 +971,11 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrateNoParameters) { TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrate1Stereo) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kOpusCodec); - codecs[0].bitrate = 30000; - codecs[0].params["stereo"] = "1"; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kOpusCodec); + parameters.codecs[0].bitrate = 30000; + parameters.codecs[0].params["stereo"] = "1"; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); webrtc::CodecInst gcodec; EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_EQ(2, gcodec.channels); @@ -1001,25 +989,25 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrate1Stereo) { TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusMaxAverageBitrate) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kOpusCodec); - codecs[0].bitrate = 30000; + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kOpusCodec); + parameters.codecs[0].bitrate = 30000; webrtc::CodecInst gcodec; // Ignore if less than 6000. - codecs[0].params["maxaveragebitrate"] = "5999"; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + parameters.codecs[0].params["maxaveragebitrate"] = "5999"; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_EQ(6000, gcodec.rate); // Ignore if larger than 510000. - codecs[0].params["maxaveragebitrate"] = "510001"; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + parameters.codecs[0].params["maxaveragebitrate"] = "510001"; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_EQ(510000, gcodec.rate); - codecs[0].params["maxaveragebitrate"] = "200000"; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + parameters.codecs[0].params["maxaveragebitrate"] = "200000"; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_EQ(200000, gcodec.rate); } @@ -1028,28 +1016,27 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusMaxAverageBitrate) { TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackAsCaller) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kOpusCodec); - codecs[0].AddFeedbackParam(cricket::FeedbackParam(cricket::kRtcpFbParamNack, - cricket::kParamValueEmpty)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kOpusCodec); + parameters.codecs[0].AddFeedbackParam( + cricket::FeedbackParam(cricket::kRtcpFbParamNack, + cricket::kParamValueEmpty)); EXPECT_FALSE(voe_.GetNACK(channel_num)); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_TRUE(voe_.GetNACK(channel_num)); } // Test that we can enable NACK with opus as callee. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackAsCallee) { - EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); - channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions()); - EXPECT_TRUE(channel_ != nullptr); - + EXPECT_TRUE(SetupEngineWithoutStream()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kOpusCodec); - codecs[0].AddFeedbackParam(cricket::FeedbackParam(cricket::kRtcpFbParamNack, - cricket::kParamValueEmpty)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kOpusCodec); + parameters.codecs[0].AddFeedbackParam( + cricket::FeedbackParam(cricket::kRtcpFbParamNack, + cricket::kParamValueEmpty)); EXPECT_FALSE(voe_.GetNACK(channel_num)); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_FALSE(voe_.GetNACK(channel_num)); EXPECT_TRUE(channel_->AddSendStream( @@ -1060,17 +1047,17 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackAsCallee) { // Test that we can enable NACK on receive streams. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackRecvStreams) { EXPECT_TRUE(SetupEngine()); - EXPECT_TRUE(channel_->SetOptions(options_conference_)); int channel_num1 = voe_.GetLastChannel(); EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); int channel_num2 = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kOpusCodec); - codecs[0].AddFeedbackParam(cricket::FeedbackParam(cricket::kRtcpFbParamNack, - cricket::kParamValueEmpty)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kOpusCodec); + parameters.codecs[0].AddFeedbackParam( + cricket::FeedbackParam(cricket::kRtcpFbParamNack, + cricket::kParamValueEmpty)); EXPECT_FALSE(voe_.GetNACK(channel_num1)); EXPECT_FALSE(voe_.GetNACK(channel_num2)); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_TRUE(voe_.GetNACK(channel_num1)); EXPECT_TRUE(voe_.GetNACK(channel_num2)); } @@ -1079,37 +1066,38 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackRecvStreams) { TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecDisableNack) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kOpusCodec); - codecs[0].AddFeedbackParam(cricket::FeedbackParam(cricket::kRtcpFbParamNack, - cricket::kParamValueEmpty)); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kOpusCodec); + parameters.codecs[0].AddFeedbackParam( + cricket::FeedbackParam(cricket::kRtcpFbParamNack, + cricket::kParamValueEmpty)); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_TRUE(voe_.GetNACK(channel_num)); - codecs.clear(); - codecs.push_back(kOpusCodec); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + parameters.codecs.clear(); + parameters.codecs.push_back(kOpusCodec); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_FALSE(voe_.GetNACK(channel_num)); } // Test that we can disable NACK on receive streams. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecDisableNackRecvStreams) { EXPECT_TRUE(SetupEngine()); - EXPECT_TRUE(channel_->SetOptions(options_conference_)); int channel_num1 = voe_.GetLastChannel(); EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); int channel_num2 = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kOpusCodec); - codecs[0].AddFeedbackParam(cricket::FeedbackParam(cricket::kRtcpFbParamNack, - cricket::kParamValueEmpty)); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kOpusCodec); + parameters.codecs[0].AddFeedbackParam( + cricket::FeedbackParam(cricket::kRtcpFbParamNack, + cricket::kParamValueEmpty)); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_TRUE(voe_.GetNACK(channel_num1)); EXPECT_TRUE(voe_.GetNACK(channel_num2)); - codecs.clear(); - codecs.push_back(kOpusCodec); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + parameters.codecs.clear(); + parameters.codecs.push_back(kOpusCodec); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_FALSE(voe_.GetNACK(channel_num1)); EXPECT_FALSE(voe_.GetNACK(channel_num2)); } @@ -1117,14 +1105,14 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecDisableNackRecvStreams) { // Test that NACK is enabled on a new receive stream. TEST_F(WebRtcVoiceEngineTestFake, AddRecvStreamEnableNack) { EXPECT_TRUE(SetupEngine()); - EXPECT_TRUE(channel_->SetOptions(options_conference_)); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kIsacCodec); - codecs[0].AddFeedbackParam(cricket::FeedbackParam(cricket::kRtcpFbParamNack, - cricket::kParamValueEmpty)); - codecs.push_back(kCn16000Codec); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kIsacCodec); + parameters.codecs.push_back(kCn16000Codec); + parameters.codecs[0].AddFeedbackParam( + cricket::FeedbackParam(cricket::kRtcpFbParamNack, + cricket::kParamValueEmpty)); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_TRUE(voe_.GetNACK(channel_num)); EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); @@ -1139,9 +1127,9 @@ TEST_F(WebRtcVoiceEngineTestFake, AddRecvStreamEnableNack) { TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecNoOpusFec) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kOpusCodec); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kOpusCodec); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_FALSE(voe_.GetCodecFEC(channel_num)); } @@ -1149,11 +1137,11 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecNoOpusFec) { TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusDisableFec) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kOpusCodec); - codecs[0].bitrate = 0; - codecs[0].params["useinbandfec"] = "0"; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kOpusCodec); + parameters.codecs[0].bitrate = 0; + parameters.codecs[0].params["useinbandfec"] = "0"; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_FALSE(voe_.GetCodecFEC(channel_num)); webrtc::CodecInst gcodec; EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); @@ -1166,11 +1154,11 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusDisableFec) { TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusEnableFec) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kOpusCodec); - codecs[0].bitrate = 0; - codecs[0].params["useinbandfec"] = "1"; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kOpusCodec); + parameters.codecs[0].bitrate = 0; + parameters.codecs[0].params["useinbandfec"] = "1"; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_TRUE(voe_.GetCodecFEC(channel_num)); webrtc::CodecInst gcodec; EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); @@ -1183,12 +1171,12 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusEnableFec) { TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusEnableFecStereo) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kOpusCodec); - codecs[0].bitrate = 0; - codecs[0].params["stereo"] = "1"; - codecs[0].params["useinbandfec"] = "1"; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kOpusCodec); + parameters.codecs[0].bitrate = 0; + parameters.codecs[0].params["stereo"] = "1"; + parameters.codecs[0].params["useinbandfec"] = "1"; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_TRUE(voe_.GetCodecFEC(channel_num)); webrtc::CodecInst gcodec; EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); @@ -1201,9 +1189,9 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusEnableFecStereo) { TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecIsacNoFec) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kIsacCodec); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kIsacCodec); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_FALSE(voe_.GetCodecFEC(channel_num)); } @@ -1211,10 +1199,10 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecIsacNoFec) { TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecIsacWithParamNoFec) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kIsacCodec); - codecs[0].params["useinbandfec"] = "1"; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kIsacCodec); + parameters.codecs[0].params["useinbandfec"] = "1"; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_FALSE(voe_.GetCodecFEC(channel_num)); } @@ -1222,12 +1210,12 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecIsacWithParamNoFec) { TEST_F(WebRtcVoiceEngineTestFake, ChangeOpusFecStatus) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kOpusCodec); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kOpusCodec); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_FALSE(voe_.GetCodecFEC(channel_num)); - codecs[0].params["useinbandfec"] = "1"; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + parameters.codecs[0].params["useinbandfec"] = "1"; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_TRUE(voe_.GetCodecFEC(channel_num)); } @@ -1235,11 +1223,11 @@ TEST_F(WebRtcVoiceEngineTestFake, ChangeOpusFecStatus) { TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateNb) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kOpusCodec); - codecs[0].bitrate = 0; - codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 8000); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kOpusCodec); + parameters.codecs[0].bitrate = 0; + parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 8000); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_EQ(cricket::kOpusBandwidthNb, voe_.GetMaxEncodingBandwidth(channel_num)); webrtc::CodecInst gcodec; @@ -1247,8 +1235,8 @@ TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateNb) { EXPECT_STREQ("opus", gcodec.plname); EXPECT_EQ(12000, gcodec.rate); - codecs[0].SetParam(cricket::kCodecParamStereo, "1"); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + parameters.codecs[0].SetParam(cricket::kCodecParamStereo, "1"); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_EQ(24000, gcodec.rate); } @@ -1257,11 +1245,11 @@ TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateNb) { TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateMb) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kOpusCodec); - codecs[0].bitrate = 0; - codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 8001); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kOpusCodec); + parameters.codecs[0].bitrate = 0; + parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 8001); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_EQ(cricket::kOpusBandwidthMb, voe_.GetMaxEncodingBandwidth(channel_num)); webrtc::CodecInst gcodec; @@ -1269,8 +1257,8 @@ TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateMb) { EXPECT_STREQ("opus", gcodec.plname); EXPECT_EQ(20000, gcodec.rate); - codecs[0].SetParam(cricket::kCodecParamStereo, "1"); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + parameters.codecs[0].SetParam(cricket::kCodecParamStereo, "1"); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_EQ(40000, gcodec.rate); } @@ -1279,11 +1267,11 @@ TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateMb) { TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateWb) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kOpusCodec); - codecs[0].bitrate = 0; - codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 12001); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kOpusCodec); + parameters.codecs[0].bitrate = 0; + parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 12001); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_EQ(cricket::kOpusBandwidthWb, voe_.GetMaxEncodingBandwidth(channel_num)); webrtc::CodecInst gcodec; @@ -1291,8 +1279,8 @@ TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateWb) { EXPECT_STREQ("opus", gcodec.plname); EXPECT_EQ(20000, gcodec.rate); - codecs[0].SetParam(cricket::kCodecParamStereo, "1"); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + parameters.codecs[0].SetParam(cricket::kCodecParamStereo, "1"); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_EQ(40000, gcodec.rate); } @@ -1301,11 +1289,11 @@ TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateWb) { TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateSwb) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kOpusCodec); - codecs[0].bitrate = 0; - codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 16001); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kOpusCodec); + parameters.codecs[0].bitrate = 0; + parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 16001); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_EQ(cricket::kOpusBandwidthSwb, voe_.GetMaxEncodingBandwidth(channel_num)); webrtc::CodecInst gcodec; @@ -1313,8 +1301,8 @@ TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateSwb) { EXPECT_STREQ("opus", gcodec.plname); EXPECT_EQ(32000, gcodec.rate); - codecs[0].SetParam(cricket::kCodecParamStereo, "1"); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + parameters.codecs[0].SetParam(cricket::kCodecParamStereo, "1"); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_EQ(64000, gcodec.rate); } @@ -1323,11 +1311,11 @@ TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateSwb) { TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateFb) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kOpusCodec); - codecs[0].bitrate = 0; - codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 24001); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kOpusCodec); + parameters.codecs[0].bitrate = 0; + parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 24001); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_EQ(cricket::kOpusBandwidthFb, voe_.GetMaxEncodingBandwidth(channel_num)); webrtc::CodecInst gcodec; @@ -1335,8 +1323,8 @@ TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateFb) { EXPECT_STREQ("opus", gcodec.plname); EXPECT_EQ(32000, gcodec.rate); - codecs[0].SetParam(cricket::kCodecParamStereo, "1"); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + parameters.codecs[0].SetParam(cricket::kCodecParamStereo, "1"); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_EQ(64000, gcodec.rate); } @@ -1345,9 +1333,9 @@ TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateFb) { TEST_F(WebRtcVoiceEngineTestFake, DefaultOpusMaxPlaybackRate) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kOpusCodec); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kOpusCodec); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_EQ(cricket::kOpusBandwidthFb, voe_.GetMaxEncodingBandwidth(channel_num)); } @@ -1356,10 +1344,10 @@ TEST_F(WebRtcVoiceEngineTestFake, DefaultOpusMaxPlaybackRate) { TEST_F(WebRtcVoiceEngineTestFake, SetNonOpusMaxPlaybackRate) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kIsacCodec); - codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 32000); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kIsacCodec); + parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 32000); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_EQ(0, voe_.GetMaxEncodingBandwidth(channel_num)); } @@ -1367,16 +1355,16 @@ TEST_F(WebRtcVoiceEngineTestFake, SetNonOpusMaxPlaybackRate) { TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateOnTwoStreams) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kOpusCodec); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kOpusCodec); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); // Default bandwidth is 24000. EXPECT_EQ(cricket::kOpusBandwidthFb, voe_.GetMaxEncodingBandwidth(channel_num)); - codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 8000); + parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 8000); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_EQ(cricket::kOpusBandwidthNb, voe_.GetMaxEncodingBandwidth(channel_num)); @@ -1390,10 +1378,10 @@ TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateOnTwoStreams) { TEST_F(WebRtcVoiceEngineTestFake, DisableOpusDtxOnOpus) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kOpusCodec); - codecs[0].params["usedtx"] = "0"; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kOpusCodec); + parameters.codecs[0].params["usedtx"] = "0"; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_FALSE(voe_.GetOpusDtx(channel_num)); } @@ -1401,10 +1389,10 @@ TEST_F(WebRtcVoiceEngineTestFake, DisableOpusDtxOnOpus) { TEST_F(WebRtcVoiceEngineTestFake, EnableOpusDtxOnOpus) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kOpusCodec); - codecs[0].params["usedtx"] = "1"; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kOpusCodec); + parameters.codecs[0].params["usedtx"] = "1"; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_TRUE(voe_.GetOpusDtx(channel_num)); EXPECT_FALSE(voe_.GetVAD(channel_num)); // Opus DTX should not affect VAD. } @@ -1413,11 +1401,11 @@ TEST_F(WebRtcVoiceEngineTestFake, EnableOpusDtxOnOpus) { TEST_F(WebRtcVoiceEngineTestFake, EnableOpusDtxOnOpusStereo) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kOpusCodec); - codecs[0].params["usedtx"] = "1"; - codecs[0].params["stereo"] = "1"; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kOpusCodec); + parameters.codecs[0].params["usedtx"] = "1"; + parameters.codecs[0].params["stereo"] = "1"; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_TRUE(voe_.GetOpusDtx(channel_num)); EXPECT_FALSE(voe_.GetVAD(channel_num)); // Opus DTX should not affect VAD. } @@ -1426,10 +1414,10 @@ TEST_F(WebRtcVoiceEngineTestFake, EnableOpusDtxOnOpusStereo) { TEST_F(WebRtcVoiceEngineTestFake, CannotEnableOpusDtxOnNonOpus) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kIsacCodec); - codecs[0].params["usedtx"] = "1"; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kIsacCodec); + parameters.codecs[0].params["usedtx"] = "1"; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_FALSE(voe_.GetOpusDtx(channel_num)); } @@ -1437,24 +1425,24 @@ TEST_F(WebRtcVoiceEngineTestFake, CannotEnableOpusDtxOnNonOpus) { TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsIsacOpusSwitching) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector opus_codecs; - opus_codecs.push_back(kOpusCodec); - EXPECT_TRUE(channel_->SetSendCodecs(opus_codecs)); + cricket::AudioSendParameters opus_parameters; + opus_parameters.codecs.push_back(kOpusCodec); + EXPECT_TRUE(channel_->SetSendParameters(opus_parameters)); webrtc::CodecInst gcodec; EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_EQ(111, gcodec.pltype); EXPECT_STREQ("opus", gcodec.plname); - std::vector isac_codecs; - isac_codecs.push_back(kIsacCodec); - isac_codecs.push_back(kCn16000Codec); - isac_codecs.push_back(kOpusCodec); - EXPECT_TRUE(channel_->SetSendCodecs(isac_codecs)); + cricket::AudioSendParameters isac_parameters; + isac_parameters.codecs.push_back(kIsacCodec); + isac_parameters.codecs.push_back(kCn16000Codec); + isac_parameters.codecs.push_back(kOpusCodec); + EXPECT_TRUE(channel_->SetSendParameters(isac_parameters)); EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_EQ(103, gcodec.pltype); EXPECT_STREQ("ISAC", gcodec.plname); - EXPECT_TRUE(channel_->SetSendCodecs(opus_codecs)); + EXPECT_TRUE(channel_->SetSendParameters(opus_parameters)); EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_EQ(111, gcodec.pltype); EXPECT_STREQ("opus", gcodec.plname); @@ -1464,46 +1452,46 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsIsacOpusSwitching) { TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBitrate) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kIsacCodec); // bitrate == 32000 - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kIsacCodec); // bitrate == 32000 + EXPECT_TRUE(channel_->SetSendParameters(parameters)); webrtc::CodecInst gcodec; EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_EQ(103, gcodec.pltype); EXPECT_STREQ("ISAC", gcodec.plname); EXPECT_EQ(32000, gcodec.rate); - codecs[0].bitrate = 0; // bitrate == default - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + parameters.codecs[0].bitrate = 0; // bitrate == default + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_EQ(103, gcodec.pltype); EXPECT_STREQ("ISAC", gcodec.plname); EXPECT_EQ(-1, gcodec.rate); - codecs[0].bitrate = 28000; // bitrate == 28000 - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + parameters.codecs[0].bitrate = 28000; // bitrate == 28000 + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_EQ(103, gcodec.pltype); EXPECT_STREQ("ISAC", gcodec.plname); EXPECT_EQ(28000, gcodec.rate); - codecs[0] = kPcmuCodec; // bitrate == 64000 - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + parameters.codecs[0] = kPcmuCodec; // bitrate == 64000 + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_EQ(0, gcodec.pltype); EXPECT_STREQ("PCMU", gcodec.plname); EXPECT_EQ(64000, gcodec.rate); - codecs[0].bitrate = 0; // bitrate == default - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + parameters.codecs[0].bitrate = 0; // bitrate == default + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_EQ(0, gcodec.pltype); EXPECT_STREQ("PCMU", gcodec.plname); EXPECT_EQ(64000, gcodec.rate); - codecs[0] = kOpusCodec; - codecs[0].bitrate = 0; // bitrate == default - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + parameters.codecs[0] = kOpusCodec; + parameters.codecs[0].bitrate = 0; // bitrate == default + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_EQ(111, gcodec.pltype); EXPECT_STREQ("opus", gcodec.plname); @@ -1514,33 +1502,33 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBitrate) { TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsPTimeAsPacketSize) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kOpusCodec); - codecs[0].SetParam(cricket::kCodecParamPTime, 40); // Value within range. - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kOpusCodec); + parameters.codecs[0].SetParam(cricket::kCodecParamPTime, 40); // Within range. + EXPECT_TRUE(channel_->SetSendParameters(parameters)); webrtc::CodecInst gcodec; EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_EQ(1920, gcodec.pacsize); // Opus gets 40ms. - codecs[0].SetParam(cricket::kCodecParamPTime, 5); // Value below range. - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + parameters.codecs[0].SetParam(cricket::kCodecParamPTime, 5); // Below range. + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_EQ(480, gcodec.pacsize); // Opus gets 10ms. - codecs[0].SetParam(cricket::kCodecParamPTime, 80); // Value beyond range. - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + parameters.codecs[0].SetParam(cricket::kCodecParamPTime, 80); // Beyond range. + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_EQ(2880, gcodec.pacsize); // Opus gets 60ms. - codecs[0] = kIsacCodec; // Also try Isac, and with unsupported size. - codecs[0].SetParam(cricket::kCodecParamPTime, 40); // Value within range. - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + parameters.codecs[0] = kIsacCodec; // Also try Isac, with unsupported size. + parameters.codecs[0].SetParam(cricket::kCodecParamPTime, 40); // Within range. + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_EQ(480, gcodec.pacsize); // Isac gets 30ms as the next smallest value. - codecs[0] = kG722CodecSdp; // Try G722 @8kHz as negotiated in SDP. - codecs[0].SetParam(cricket::kCodecParamPTime, 40); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + parameters.codecs[0] = kG722CodecSdp; // Try G722 @8kHz as negotiated in SDP. + parameters.codecs[0].SetParam(cricket::kCodecParamPTime, 40); + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_EQ(640, gcodec.pacsize); // G722 gets 40ms @16kHz as defined in VoE. } @@ -1548,8 +1536,8 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsPTimeAsPacketSize) { // Test that we fail if no codecs are specified. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsNoCodecs) { EXPECT_TRUE(SetupEngine()); - std::vector codecs; - EXPECT_FALSE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + EXPECT_FALSE(channel_->SetSendParameters(parameters)); } // Test that we can set send codecs even with telephone-event codec as the first @@ -1557,13 +1545,13 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsNoCodecs) { TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsDTMFOnTop) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kTelephoneEventCodec); - codecs.push_back(kIsacCodec); - codecs.push_back(kPcmuCodec); - codecs[0].id = 98; // DTMF - codecs[1].id = 96; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kTelephoneEventCodec); + parameters.codecs.push_back(kIsacCodec); + parameters.codecs.push_back(kPcmuCodec); + parameters.codecs[0].id = 98; // DTMF + parameters.codecs[1].id = 96; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); webrtc::CodecInst gcodec; EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_EQ(96, gcodec.pltype); @@ -1576,13 +1564,13 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsDTMFOnTop) { TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNOnTop) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kCn16000Codec); - codecs.push_back(kIsacCodec); - codecs.push_back(kPcmuCodec); - codecs[0].id = 98; // wideband CN - codecs[1].id = 96; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kCn16000Codec); + parameters.codecs.push_back(kIsacCodec); + parameters.codecs.push_back(kPcmuCodec); + parameters.codecs[0].id = 98; // wideband CN + parameters.codecs[1].id = 96; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); webrtc::CodecInst gcodec; EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_EQ(96, gcodec.pltype); @@ -1594,18 +1582,18 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNOnTop) { TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCaller) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kIsacCodec); - codecs.push_back(kPcmuCodec); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kIsacCodec); + parameters.codecs.push_back(kPcmuCodec); // TODO(juberti): cn 32000 - codecs.push_back(kCn16000Codec); - codecs.push_back(kCn8000Codec); - codecs.push_back(kTelephoneEventCodec); - codecs.push_back(kRedCodec); - codecs[0].id = 96; - codecs[2].id = 97; // wideband CN - codecs[4].id = 98; // DTMF - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + parameters.codecs.push_back(kCn16000Codec); + parameters.codecs.push_back(kCn8000Codec); + parameters.codecs.push_back(kTelephoneEventCodec); + parameters.codecs.push_back(kRedCodec); + parameters.codecs[0].id = 96; + parameters.codecs[2].id = 97; // wideband CN + parameters.codecs[4].id = 98; // DTMF + EXPECT_TRUE(channel_->SetSendParameters(parameters)); webrtc::CodecInst gcodec; EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_EQ(96, gcodec.pltype); @@ -1624,18 +1612,18 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCallee) { EXPECT_TRUE(channel_ != nullptr); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kIsacCodec); - codecs.push_back(kPcmuCodec); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kIsacCodec); + parameters.codecs.push_back(kPcmuCodec); // TODO(juberti): cn 32000 - codecs.push_back(kCn16000Codec); - codecs.push_back(kCn8000Codec); - codecs.push_back(kTelephoneEventCodec); - codecs.push_back(kRedCodec); - codecs[0].id = 96; - codecs[2].id = 97; // wideband CN - codecs[4].id = 98; // DTMF - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + parameters.codecs.push_back(kCn16000Codec); + parameters.codecs.push_back(kCn8000Codec); + parameters.codecs.push_back(kTelephoneEventCodec); + parameters.codecs.push_back(kRedCodec); + parameters.codecs[0].id = 96; + parameters.codecs[2].id = 97; // wideband CN + parameters.codecs[4].id = 98; // DTMF + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_TRUE(channel_->AddSendStream( cricket::StreamParams::CreateLegacy(kSsrc1))); @@ -1655,33 +1643,33 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCallee) { TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNNoMatch) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; + cricket::AudioSendParameters parameters; // Set ISAC(16K) and CN(16K). VAD should be activated. - codecs.push_back(kIsacCodec); - codecs.push_back(kCn16000Codec); - codecs[1].id = 97; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + parameters.codecs.push_back(kIsacCodec); + parameters.codecs.push_back(kCn16000Codec); + parameters.codecs[1].id = 97; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); webrtc::CodecInst gcodec; EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_STREQ("ISAC", gcodec.plname); EXPECT_TRUE(voe_.GetVAD(channel_num)); EXPECT_EQ(97, voe_.GetSendCNPayloadType(channel_num, true)); // Set PCMU(8K) and CN(16K). VAD should not be activated. - codecs[0] = kPcmuCodec; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + parameters.codecs[0] = kPcmuCodec; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_STREQ("PCMU", gcodec.plname); EXPECT_FALSE(voe_.GetVAD(channel_num)); // Set PCMU(8K) and CN(8K). VAD should be activated. - codecs[1] = kCn8000Codec; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + parameters.codecs[1] = kCn8000Codec; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_STREQ("PCMU", gcodec.plname); EXPECT_TRUE(voe_.GetVAD(channel_num)); EXPECT_EQ(13, voe_.GetSendCNPayloadType(channel_num, false)); // Set ISAC(16K) and CN(8K). VAD should not be activated. - codecs[0] = kIsacCodec; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + parameters.codecs[0] = kIsacCodec; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_STREQ("ISAC", gcodec.plname); EXPECT_FALSE(voe_.GetVAD(channel_num)); @@ -1691,18 +1679,18 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNNoMatch) { TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCaseInsensitive) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kIsacCodec); - codecs.push_back(kPcmuCodec); - codecs.push_back(kCn16000Codec); - codecs.push_back(kCn8000Codec); - codecs.push_back(kTelephoneEventCodec); - codecs.push_back(kRedCodec); - codecs[0].name = "iSaC"; - codecs[0].id = 96; - codecs[2].id = 97; // wideband CN - codecs[4].id = 98; // DTMF - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kIsacCodec); + parameters.codecs.push_back(kPcmuCodec); + parameters.codecs.push_back(kCn16000Codec); + parameters.codecs.push_back(kCn8000Codec); + parameters.codecs.push_back(kTelephoneEventCodec); + parameters.codecs.push_back(kRedCodec); + parameters.codecs[0].name = "iSaC"; + parameters.codecs[0].id = 96; + parameters.codecs[2].id = 97; // wideband CN + parameters.codecs[4].id = 98; // DTMF + EXPECT_TRUE(channel_->SetSendParameters(parameters)); webrtc::CodecInst gcodec; EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_EQ(96, gcodec.pltype); @@ -1718,14 +1706,14 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCaseInsensitive) { TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsREDAsCaller) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kRedCodec); - codecs.push_back(kIsacCodec); - codecs.push_back(kPcmuCodec); - codecs[0].id = 127; - codecs[0].params[""] = "96/96"; - codecs[1].id = 96; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kRedCodec); + parameters.codecs.push_back(kIsacCodec); + parameters.codecs.push_back(kPcmuCodec); + parameters.codecs[0].id = 127; + parameters.codecs[0].params[""] = "96/96"; + parameters.codecs[1].id = 96; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); webrtc::CodecInst gcodec; EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_EQ(96, gcodec.pltype); @@ -1741,14 +1729,14 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsREDAsCallee) { EXPECT_TRUE(channel_ != nullptr); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kRedCodec); - codecs.push_back(kIsacCodec); - codecs.push_back(kPcmuCodec); - codecs[0].id = 127; - codecs[0].params[""] = "96/96"; - codecs[1].id = 96; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kRedCodec); + parameters.codecs.push_back(kIsacCodec); + parameters.codecs.push_back(kPcmuCodec); + parameters.codecs[0].id = 127; + parameters.codecs[0].params[""] = "96/96"; + parameters.codecs[1].id = 96; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_TRUE(channel_->AddSendStream( cricket::StreamParams::CreateLegacy(kSsrc1))); webrtc::CodecInst gcodec; @@ -1763,13 +1751,13 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsREDAsCallee) { TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsREDNoParams) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kRedCodec); - codecs.push_back(kIsacCodec); - codecs.push_back(kPcmuCodec); - codecs[0].id = 127; - codecs[1].id = 96; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kRedCodec); + parameters.codecs.push_back(kIsacCodec); + parameters.codecs.push_back(kPcmuCodec); + parameters.codecs[0].id = 127; + parameters.codecs[1].id = 96; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); webrtc::CodecInst gcodec; EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_EQ(96, gcodec.pltype); @@ -1782,14 +1770,14 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsREDNoParams) { TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED1) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kRedCodec); - codecs.push_back(kIsacCodec); - codecs.push_back(kPcmuCodec); - codecs[0].id = 127; - codecs[0].params["ABC"] = "96/96"; - codecs[1].id = 96; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kRedCodec); + parameters.codecs.push_back(kIsacCodec); + parameters.codecs.push_back(kPcmuCodec); + parameters.codecs[0].id = 127; + parameters.codecs[0].params["ABC"] = "96/96"; + parameters.codecs[1].id = 96; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); webrtc::CodecInst gcodec; EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_EQ(96, gcodec.pltype); @@ -1801,14 +1789,14 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED1) { TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED2) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kRedCodec); - codecs.push_back(kIsacCodec); - codecs.push_back(kPcmuCodec); - codecs[0].id = 127; - codecs[0].params[""] = "96/0"; - codecs[1].id = 96; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kRedCodec); + parameters.codecs.push_back(kIsacCodec); + parameters.codecs.push_back(kPcmuCodec); + parameters.codecs[0].id = 127; + parameters.codecs[0].params[""] = "96/0"; + parameters.codecs[1].id = 96; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); webrtc::CodecInst gcodec; EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_EQ(96, gcodec.pltype); @@ -1820,14 +1808,14 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED2) { TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED3) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kRedCodec); - codecs.push_back(kIsacCodec); - codecs.push_back(kPcmuCodec); - codecs[0].id = 127; - codecs[0].params[""] = "96/96/96"; - codecs[1].id = 96; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kRedCodec); + parameters.codecs.push_back(kIsacCodec); + parameters.codecs.push_back(kPcmuCodec); + parameters.codecs[0].id = 127; + parameters.codecs[0].params[""] = "96/96/96"; + parameters.codecs[1].id = 96; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); webrtc::CodecInst gcodec; EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_EQ(96, gcodec.pltype); @@ -1839,14 +1827,14 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED3) { TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED4) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kRedCodec); - codecs.push_back(kIsacCodec); - codecs.push_back(kPcmuCodec); - codecs[0].id = 127; - codecs[0].params[""] = "ABC/ABC"; - codecs[1].id = 96; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kRedCodec); + parameters.codecs.push_back(kIsacCodec); + parameters.codecs.push_back(kPcmuCodec); + parameters.codecs[0].id = 127; + parameters.codecs[0].params[""] = "ABC/ABC"; + parameters.codecs[1].id = 96; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); webrtc::CodecInst gcodec; EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_EQ(96, gcodec.pltype); @@ -1858,14 +1846,14 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED4) { TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED5) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kRedCodec); - codecs.push_back(kIsacCodec); - codecs.push_back(kPcmuCodec); - codecs[0].id = 127; - codecs[0].params[""] = "97/97"; - codecs[1].id = 96; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + cricket::AudioSendParameters parameters; + parameters.codecs.push_back(kRedCodec); + parameters.codecs.push_back(kIsacCodec); + parameters.codecs.push_back(kPcmuCodec); + parameters.codecs[0].id = 127; + parameters.codecs[0].params[""] = "97/97"; + parameters.codecs[1].id = 96; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); webrtc::CodecInst gcodec; EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); EXPECT_EQ(96, gcodec.pltype); @@ -1893,9 +1881,7 @@ TEST_F(WebRtcVoiceEngineTestFake, RecvAbsoluteSendTimeHeaderExtensions) { TEST_F(WebRtcVoiceEngineTestFake, SendAndPlayout) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kPcmuCodec); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); EXPECT_TRUE(voe_.GetSend(channel_num)); EXPECT_TRUE(channel_->SetPlayout(true)); @@ -1952,12 +1938,12 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsWithMultipleSendStreams) { cricket::StreamParams::CreateLegacy(kSsrcs4[i]))); } - std::vector codecs; + cricket::AudioSendParameters parameters; // Set ISAC(16K) and CN(16K). VAD should be activated. - codecs.push_back(kIsacCodec); - codecs.push_back(kCn16000Codec); - codecs[1].id = 97; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + parameters.codecs.push_back(kIsacCodec); + parameters.codecs.push_back(kCn16000Codec); + parameters.codecs[1].id = 97; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); // Verify ISAC and VAD are corrected configured on all send channels. webrtc::CodecInst gcodec; @@ -1970,8 +1956,8 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsWithMultipleSendStreams) { } // Change to PCMU(8K) and CN(16K). VAD should not be activated. - codecs[0] = kPcmuCodec; - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + parameters.codecs[0] = kPcmuCodec; + EXPECT_TRUE(channel_->SetSendParameters(parameters)); for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs4); ++i) { int channel_num = voe_.GetChannelFromLocalSsrc(kSsrcs4[i]); EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); @@ -2025,10 +2011,8 @@ TEST_F(WebRtcVoiceEngineTestFake, GetStatsWithMultipleSendStreams) { EXPECT_TRUE(channel_->AddRecvStream( cricket::StreamParams::CreateLegacy(kSsrc2))); // We need send codec to be set to get all stats. - std::vector codecs; - codecs.push_back(kPcmuCodec); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); - EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); + EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); cricket::VoiceMediaInfo info; EXPECT_EQ(true, channel_->GetStats(&info)); @@ -2079,16 +2063,14 @@ TEST_F(WebRtcVoiceEngineTestFake, PlayoutWithMultipleStreams) { int channel_num1 = voe_.GetLastChannel(); // Start playout on the default channel. - EXPECT_TRUE(channel_->SetOptions(options_conference_)); + send_parameters_.options = options_conference_; + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); EXPECT_TRUE(channel_->SetPlayout(true)); EXPECT_TRUE(voe_.GetPlayout(channel_num1)); // Adding another stream should disable playout on the default channel. EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); int channel_num2 = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kPcmuCodec); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); EXPECT_TRUE(voe_.GetSend(channel_num1)); EXPECT_FALSE(voe_.GetSend(channel_num2)); @@ -2135,9 +2117,7 @@ TEST_F(WebRtcVoiceEngineTestFake, PlayoutWithMultipleStreams) { TEST_F(WebRtcVoiceEngineTestFake, SetDevices) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kPcmuCodec); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); cricket::Device default_dev(cricket::kFakeDefaultDeviceName, cricket::kFakeDefaultDeviceId); @@ -2189,9 +2169,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetDevices) { TEST_F(WebRtcVoiceEngineTestFake, SetDevicesWithInitiallyBadDevices) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - std::vector codecs; - codecs.push_back(kPcmuCodec); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); cricket::Device default_dev(cricket::kFakeDefaultDeviceName, cricket::kFakeDefaultDeviceId); @@ -2229,10 +2207,8 @@ TEST_F(WebRtcVoiceEngineTestFake, SetDevicesWithInitiallyBadDevices) { TEST_F(WebRtcVoiceEngineTestFake, ConferenceSendAndPlayout) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - EXPECT_TRUE(channel_->SetOptions(options_conference_)); - std::vector codecs; - codecs.push_back(kPcmuCodec); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + send_parameters_.options = options_conference_; + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); EXPECT_TRUE(voe_.GetSend(channel_num)); } @@ -2245,10 +2221,8 @@ TEST_F(WebRtcVoiceEngineTestFake, CodianSendAndPlayout) { webrtc::AgcConfig agc_config; EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); EXPECT_EQ(0, agc_config.targetLeveldBOv); - EXPECT_TRUE(channel_->SetOptions(options_adjust_agc_)); - std::vector codecs; - codecs.push_back(kPcmuCodec); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + send_parameters_.options = options_adjust_agc_; + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); EXPECT_TRUE(voe_.GetSend(channel_num)); EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); @@ -2293,12 +2267,11 @@ TEST_F(WebRtcVoiceEngineTestFake, TxAgcConfigViaOptions) { TEST_F(WebRtcVoiceEngineTestFake, RxAgcConfigViaOptions) { EXPECT_TRUE(SetupEngine()); int channel_num = voe_.GetLastChannel(); - cricket::AudioOptions options; - options.rx_agc_target_dbov.Set(6); - options.rx_agc_digital_compression_gain.Set(0); - options.rx_agc_limiter.Set(true); - options.rx_auto_gain_control.Set(true); - EXPECT_TRUE(channel_->SetOptions(options)); + send_parameters_.options.rx_agc_target_dbov.Set(6); + send_parameters_.options.rx_agc_digital_compression_gain.Set(0); + send_parameters_.options.rx_agc_limiter.Set(true); + send_parameters_.options.rx_auto_gain_control.Set(true); + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); webrtc::AgcConfig agc_config; EXPECT_EQ(0, engine_.voe()->processing()->GetRxAgcConfig( @@ -2360,10 +2333,8 @@ TEST_F(WebRtcVoiceEngineTestFake, GetStats) { // use a different SSRC. EXPECT_TRUE(channel_->AddRecvStream( cricket::StreamParams::CreateLegacy(kSsrc2))); - std::vector codecs; - codecs.push_back(kPcmuCodec); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); - EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); + EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); cricket::VoiceMediaInfo info; EXPECT_EQ(true, channel_->GetStats(&info)); @@ -2410,7 +2381,6 @@ TEST_F(WebRtcVoiceEngineTestFake, GetStats) { // SSRC is set in SetupEngine by calling AddSendStream. TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrcWithMultipleStreams) { EXPECT_TRUE(SetupEngine()); - EXPECT_TRUE(channel_->SetOptions(options_conference_)); int channel_num1 = voe_.GetLastChannel(); unsigned int send_ssrc; EXPECT_EQ(0, voe_.GetLocalSSRC(channel_num1, send_ssrc)); @@ -2427,7 +2397,6 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrcWithMultipleStreams) { TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrcAfterCreatingReceiveChannel) { EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions()); - EXPECT_TRUE(channel_->SetOptions(options_conference_)); EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); int receive_channel_num = voe_.GetLastChannel(); @@ -2455,7 +2424,8 @@ TEST_F(WebRtcVoiceEngineTestFake, Recv) { // Test that we can properly receive packets on multiple streams. TEST_F(WebRtcVoiceEngineTestFake, RecvWithMultipleStreams) { EXPECT_TRUE(SetupEngine()); - EXPECT_TRUE(channel_->SetOptions(options_conference_)); + send_parameters_.options = options_conference_; + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); int channel_num1 = voe_.GetLastChannel(); EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); @@ -2499,13 +2469,13 @@ TEST_F(WebRtcVoiceEngineTestFake, RecvWithMultipleStreams) { TEST_F(WebRtcVoiceEngineTestFake, AddStreamFail) { EXPECT_TRUE(SetupEngine()); voe_.set_fail_create_channel(true); - EXPECT_TRUE(channel_->SetOptions(options_conference_)); + send_parameters_.options = options_conference_; + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); EXPECT_FALSE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); // In 1:1 call, we should not try to create a new channel. - cricket::AudioOptions options_no_conference_; - options_no_conference_.conference_mode.Set(false); - EXPECT_TRUE(channel_->SetOptions(options_no_conference_)); + send_parameters_.options.conference_mode.Set(false); + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); } @@ -2521,11 +2491,10 @@ TEST_F(WebRtcVoiceEngineTestFake, AddRecvStream1On1) { // those previously passed into SetRecvCodecs. TEST_F(WebRtcVoiceEngineTestFake, AddRecvStreamUnsupportedCodec) { EXPECT_TRUE(SetupEngine()); - EXPECT_TRUE(channel_->SetOptions(options_conference_)); - std::vector codecs; - codecs.push_back(kIsacCodec); - codecs.push_back(kPcmuCodec); - EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); + cricket::AudioRecvParameters parameters; + parameters.codecs.push_back(kIsacCodec); + parameters.codecs.push_back(kPcmuCodec); + EXPECT_TRUE(channel_->SetRecvParameters(parameters)); EXPECT_TRUE(channel_->AddRecvStream( cricket::StreamParams::CreateLegacy(kSsrc1))); int channel_num2 = voe_.GetLastChannel(); @@ -2540,7 +2509,8 @@ TEST_F(WebRtcVoiceEngineTestFake, AddRecvStreamUnsupportedCodec) { // not explicitly removed. TEST_F(WebRtcVoiceEngineTestFake, StreamCleanup) { EXPECT_TRUE(SetupEngine()); - EXPECT_TRUE(channel_->SetOptions(options_conference_)); + send_parameters_.options = options_conference_; + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); EXPECT_EQ(3, voe_.GetNumChannels()); // default channel + 2 added @@ -2615,7 +2585,6 @@ TEST_F(WebRtcVoiceEngineTestFake, PlayRingback) { // Test that we can play a ringback tone properly in a multi-stream call. TEST_F(WebRtcVoiceEngineTestFake, PlayRingbackWithMultipleStreams) { EXPECT_TRUE(SetupEngine()); - EXPECT_TRUE(channel_->SetOptions(options_conference_)); EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); int channel_num = voe_.GetLastChannel(); @@ -2652,7 +2621,8 @@ TEST_F(WebRtcVoiceEngineTestFake, MediaEngineCallbackOnError) { unsigned int ssrc = 0; EXPECT_TRUE(SetupEngine()); - EXPECT_TRUE(channel_->SetOptions(options_conference_)); + send_parameters_.options = options_conference_; + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); media_channel = static_cast(channel_); @@ -2692,10 +2662,8 @@ TEST_F(WebRtcVoiceEngineTestFake, MediaEngineCallbackOnError) { TEST_F(WebRtcVoiceEngineTestFake, TestSetPlayoutError) { EXPECT_TRUE(SetupEngine()); - EXPECT_TRUE(channel_->SetOptions(options_conference_)); - std::vector codecs; - codecs.push_back(kPcmuCodec); - EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + send_parameters_.options = options_conference_; + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(3))); @@ -2709,7 +2677,6 @@ TEST_F(WebRtcVoiceEngineTestFake, TestSetPlayoutError) { // webrtcvoiceengine works as expected TEST_F(WebRtcVoiceEngineTestFake, RegisterVoiceProcessor) { EXPECT_TRUE(SetupEngine()); - EXPECT_TRUE(channel_->SetOptions(options_conference_)); EXPECT_TRUE(channel_->AddRecvStream( cricket::StreamParams::CreateLegacy(kSsrc2))); cricket::FakeMediaProcessor vp_1; @@ -3011,38 +2978,35 @@ TEST_F(WebRtcVoiceEngineTestFake, SetOptionOverridesViaChannels) { channel2->AddSendStream(stream2); // AEC and AGC and NS - cricket::AudioOptions options_all; - options_all.echo_cancellation.Set(true); - options_all.auto_gain_control.Set(true); - options_all.noise_suppression.Set(true); - - ASSERT_TRUE(channel1->SetOptions(options_all)); - cricket::AudioOptions expected_options = options_all; - EXPECT_EQ(expected_options, channel1->options()); - ASSERT_TRUE(channel2->SetOptions(options_all)); - EXPECT_EQ(expected_options, channel2->options()); + cricket::AudioSendParameters parameters_options_all = send_parameters_; + parameters_options_all.options.echo_cancellation.Set(true); + parameters_options_all.options.auto_gain_control.Set(true); + parameters_options_all.options.noise_suppression.Set(true); + ASSERT_TRUE(channel1->SetSendParameters(parameters_options_all)); + EXPECT_EQ(parameters_options_all.options, channel1->options()); + ASSERT_TRUE(channel2->SetSendParameters(parameters_options_all)); + EXPECT_EQ(parameters_options_all.options, channel2->options()); // unset NS - cricket::AudioOptions options_no_ns; - options_no_ns.noise_suppression.Set(false); - ASSERT_TRUE(channel1->SetOptions(options_no_ns)); - + cricket::AudioSendParameters parameters_options_no_ns = send_parameters_; + parameters_options_no_ns.options.noise_suppression.Set(false); + ASSERT_TRUE(channel1->SetSendParameters(parameters_options_no_ns)); + cricket::AudioOptions expected_options = parameters_options_all.options; expected_options.echo_cancellation.Set(true); expected_options.auto_gain_control.Set(true); expected_options.noise_suppression.Set(false); EXPECT_EQ(expected_options, channel1->options()); // unset AGC - cricket::AudioOptions options_no_agc; - options_no_agc.auto_gain_control.Set(false); - ASSERT_TRUE(channel2->SetOptions(options_no_agc)); - + cricket::AudioSendParameters parameters_options_no_agc = send_parameters_; + parameters_options_no_agc.options.auto_gain_control.Set(false); + ASSERT_TRUE(channel2->SetSendParameters(parameters_options_no_agc)); expected_options.echo_cancellation.Set(true); expected_options.auto_gain_control.Set(false); expected_options.noise_suppression.Set(true); EXPECT_EQ(expected_options, channel2->options()); - ASSERT_TRUE(engine_.SetOptions(options_all)); + ASSERT_TRUE(engine_.SetOptions(parameters_options_all.options)); bool ec_enabled; webrtc::EcModes ec_mode; bool agc_enabled; @@ -3089,13 +3053,13 @@ TEST_F(WebRtcVoiceEngineTestFake, SetOptionOverridesViaChannels) { EXPECT_TRUE(ns_enabled); // Make sure settings take effect while we are sending. - ASSERT_TRUE(engine_.SetOptions(options_all)); - cricket::AudioOptions options_no_agc_nor_ns; - options_no_agc_nor_ns.auto_gain_control.Set(false); - options_no_agc_nor_ns.noise_suppression.Set(false); + ASSERT_TRUE(engine_.SetOptions(parameters_options_all.options)); + cricket::AudioSendParameters parameters_options_no_agc_nor_ns = + send_parameters_; + parameters_options_no_agc_nor_ns.options.auto_gain_control.Set(false); + parameters_options_no_agc_nor_ns.options.noise_suppression.Set(false); channel2->SetSend(cricket::SEND_MICROPHONE); - channel2->SetOptions(options_no_agc_nor_ns); - + channel2->SetSendParameters(parameters_options_no_agc_nor_ns); expected_options.echo_cancellation.Set(true); expected_options.auto_gain_control.Set(false); expected_options.noise_suppression.Set(false); @@ -3116,16 +3080,15 @@ TEST_F(WebRtcVoiceEngineTestFake, TestSetDscpOptions) { rtc::scoped_ptr network_interface( new cricket::FakeNetworkInterface); channel->SetInterface(network_interface.get()); - cricket::AudioOptions options; - options.dscp.Set(true); - EXPECT_TRUE(channel->SetOptions(options)); + cricket::AudioSendParameters parameters = send_parameters_; + parameters.options.dscp.Set(true); + EXPECT_TRUE(channel->SetSendParameters(parameters)); EXPECT_EQ(rtc::DSCP_EF, network_interface->dscp()); // Verify previous value is not modified if dscp option is not set. - cricket::AudioOptions options1; - EXPECT_TRUE(channel->SetOptions(options1)); + EXPECT_TRUE(channel->SetSendParameters(send_parameters_)); EXPECT_EQ(rtc::DSCP_EF, network_interface->dscp()); - options.dscp.Set(false); - EXPECT_TRUE(channel->SetOptions(options)); + parameters.options.dscp.Set(false); + EXPECT_TRUE(channel->SetSendParameters(parameters)); EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface->dscp()); } @@ -3149,7 +3112,8 @@ TEST_F(WebRtcVoiceEngineTestFake, TestGetReceiveChannelNumIn1To1Calls) { // first recv stream in conference calls. TEST_F(WebRtcVoiceEngineTestFake, TestGetChannelNumInConferenceCalls) { EXPECT_TRUE(SetupEngine()); - EXPECT_TRUE(channel_->SetOptions(options_conference_)); + send_parameters_.options = options_conference_; + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); cricket::StreamParams stream; stream.ssrcs.push_back(kSsrc2); EXPECT_TRUE(channel_->AddRecvStream(stream)); @@ -3228,9 +3192,8 @@ TEST_F(WebRtcVoiceEngineTestFake, CanChangeCombinedBweOption) { } // Enable combined BWE option - now it should be set up. - cricket::AudioOptions options; - options.combined_audio_video_bwe.Set(true); - EXPECT_TRUE(media_channel->SetOptions(options)); + send_parameters_.options.combined_audio_video_bwe.Set(true); + EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_)); for (uint32 ssrc : ssrcs) { const auto* s = call_.GetAudioReceiveStream(ssrc); EXPECT_NE(nullptr, s); @@ -3238,8 +3201,8 @@ TEST_F(WebRtcVoiceEngineTestFake, CanChangeCombinedBweOption) { } // Disable combined BWE option - should be disabled again. - options.combined_audio_video_bwe.Set(false); - EXPECT_TRUE(media_channel->SetOptions(options)); + send_parameters_.options.combined_audio_video_bwe.Set(false); + EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_)); for (uint32 ssrc : ssrcs) { const auto* s = call_.GetAudioReceiveStream(ssrc); EXPECT_NE(nullptr, s); @@ -3255,9 +3218,8 @@ TEST_F(WebRtcVoiceEngineTestFake, ConfigureCombinedBweForNewRecvStreams) { EXPECT_TRUE(SetupEngine()); cricket::WebRtcVoiceMediaChannel* media_channel = static_cast(channel_); - cricket::AudioOptions options; - options.combined_audio_video_bwe.Set(true); - EXPECT_TRUE(media_channel->SetOptions(options)); + send_parameters_.options.combined_audio_video_bwe.Set(true); + EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_)); static const uint32 kSsrcs[] = {1, 2, 3, 4}; for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs); ++i) { @@ -3278,9 +3240,8 @@ TEST_F(WebRtcVoiceEngineTestFake, ConfiguresAudioReceiveStreamRtpExtensions) { EXPECT_TRUE(SetupEngine()); cricket::WebRtcVoiceMediaChannel* media_channel = static_cast(channel_); - cricket::AudioOptions options; - options.combined_audio_video_bwe.Set(true); - EXPECT_TRUE(media_channel->SetOptions(options)); + send_parameters_.options.combined_audio_video_bwe.Set(true); + EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_)); for (uint32 ssrc : ssrcs) { EXPECT_TRUE(media_channel->AddRecvStream( cricket::StreamParams::CreateLegacy(ssrc))); @@ -3296,7 +3257,9 @@ TEST_F(WebRtcVoiceEngineTestFake, ConfiguresAudioReceiveStreamRtpExtensions) { // Set up receive extensions. const auto& e_exts = engine_.rtp_header_extensions(); - channel_->SetRecvRtpHeaderExtensions(e_exts); + cricket::AudioRecvParameters recv_parameters; + recv_parameters.extensions = e_exts; + channel_->SetRecvParameters(recv_parameters); EXPECT_EQ(2, call_.GetAudioReceiveStreams().size()); for (uint32 ssrc : ssrcs) { const auto* s = call_.GetAudioReceiveStream(ssrc); @@ -3313,8 +3276,7 @@ TEST_F(WebRtcVoiceEngineTestFake, ConfiguresAudioReceiveStreamRtpExtensions) { } // Disable receive extensions. - std::vector extensions; - channel_->SetRecvRtpHeaderExtensions(extensions); + channel_->SetRecvParameters(cricket::AudioRecvParameters()); for (uint32 ssrc : ssrcs) { const auto* s = call_.GetAudioReceiveStream(ssrc); EXPECT_NE(nullptr, s); @@ -3337,9 +3299,8 @@ TEST_F(WebRtcVoiceEngineTestFake, DeliverAudioPacket_Call) { EXPECT_TRUE(SetupEngine()); cricket::WebRtcVoiceMediaChannel* media_channel = static_cast(channel_); - cricket::AudioOptions options; - options.combined_audio_video_bwe.Set(true); - EXPECT_TRUE(media_channel->SetOptions(options)); + send_parameters_.options.combined_audio_video_bwe.Set(true); + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); EXPECT_TRUE(media_channel->AddRecvStream( cricket::StreamParams::CreateLegacy(kAudioSsrc))); @@ -3387,7 +3348,8 @@ TEST_F(WebRtcVoiceEngineTestFake, AssociateDefaultChannelOnSecondRecvChannel) { // default channel, since they do not send RTCP SR. TEST_F(WebRtcVoiceEngineTestFake, AssociateDefaultChannelOnConference) { EXPECT_TRUE(SetupEngine()); - EXPECT_TRUE(channel_->SetOptions(options_conference_)); + send_parameters_.options = options_conference_; + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); cricket::WebRtcVoiceMediaChannel* media_channel = static_cast(channel_); int default_channel = media_channel->voe_channel(); @@ -3401,7 +3363,8 @@ TEST_F(WebRtcVoiceEngineTestFake, AssociateDefaultChannelOnConference) { TEST_F(WebRtcVoiceEngineTestFake, AssociateChannelResetUponDeleteChannnel) { EXPECT_TRUE(SetupEngine()); - EXPECT_TRUE(channel_->SetOptions(options_conference_)); + send_parameters_.options = options_conference_; + EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); int recv_ch = voe_.GetLastChannel(); @@ -3563,6 +3526,9 @@ TEST(WebRtcVoiceEngineTest, SetRecvCodecs) { EXPECT_TRUE(engine.Init(rtc::Thread::Current())); rtc::scoped_ptr call( webrtc::Call::Create(webrtc::Call::Config())); - cricket::WebRtcVoiceMediaChannel channel(&engine, call.get()); - EXPECT_TRUE(channel.SetRecvCodecs(engine.codecs())); + cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::AudioOptions(), + call.get()); + cricket::AudioRecvParameters parameters; + parameters.codecs = engine.codecs(); + EXPECT_TRUE(channel.SetRecvParameters(parameters)); } diff --git a/talk/session/media/channel_unittest.cc b/talk/session/media/channel_unittest.cc index a7d5c15692..9020cafcec 100644 --- a/talk/session/media/channel_unittest.cc +++ b/talk/session/media/channel_unittest.cc @@ -77,7 +77,8 @@ template + class MediaInfoT, + class OptionsT> class Traits { public: typedef ChannelT Channel; @@ -85,6 +86,7 @@ class Traits { typedef ContentT Content; typedef CodecT Codec; typedef MediaInfoT MediaInfo; + typedef OptionsT Options; }; // Controls how long we wait for a session to send messages that we @@ -95,21 +97,24 @@ class VoiceTraits : public Traits { + cricket::VoiceMediaInfo, + cricket::AudioOptions> { }; class VideoTraits : public Traits { + cricket::VideoMediaInfo, + cricket::VideoOptions> { }; class DataTraits : public Traits { + cricket::DataMediaInfo, + cricket::DataOptions> { }; @@ -140,27 +145,10 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { } void CreateChannels(int flags1, int flags2) { - CreateChannels(new typename T::MediaChannel(NULL), - new typename T::MediaChannel(NULL), + CreateChannels(new typename T::MediaChannel(NULL, typename T::Options()), + new typename T::MediaChannel(NULL, typename T::Options()), flags1, flags2, rtc::Thread::Current()); } - void CreateChannels(int flags) { - CreateChannels(new typename T::MediaChannel(NULL), - new typename T::MediaChannel(NULL), - flags, rtc::Thread::Current()); - } - void CreateChannels(int flags1, int flags2, - rtc::Thread* thread) { - CreateChannels(new typename T::MediaChannel(NULL), - new typename T::MediaChannel(NULL), - flags1, flags2, thread); - } - void CreateChannels(int flags, - rtc::Thread* thread) { - CreateChannels(new typename T::MediaChannel(NULL), - new typename T::MediaChannel(NULL), - flags, thread); - } void CreateChannels( typename T::MediaChannel* ch1, typename T::MediaChannel* ch2, int flags1, int flags2, rtc::Thread* thread) { @@ -216,42 +204,6 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { AddLegacyStreamInContent(kSsrc2, flags2, &remote_media_content2_); } } - - void CreateChannels( - typename T::MediaChannel* ch1, typename T::MediaChannel* ch2, - int flags, rtc::Thread* thread) { - media_channel1_ = ch1; - media_channel2_ = ch2; - - channel1_.reset(CreateChannel(thread, &media_engine_, ch1, &session1_, - (flags & RTCP) != 0)); - channel2_.reset(CreateChannel(thread, &media_engine_, ch2, &session1_, - (flags & RTCP) != 0)); - channel1_->SignalMediaMonitor.connect( - this, &ChannelTest::OnMediaMonitor); - channel2_->SignalMediaMonitor.connect( - this, &ChannelTest::OnMediaMonitor); - channel2_->SignalMediaError.connect( - this, &ChannelTest::OnMediaChannelError); - CreateContent(flags, kPcmuCodec, kH264Codec, - &local_media_content1_); - CreateContent(flags, kPcmuCodec, kH264Codec, - &local_media_content2_); - CopyContent(local_media_content1_, &remote_media_content1_); - CopyContent(local_media_content2_, &remote_media_content2_); - // Add stream information (SSRC) to the local content but not to the remote - // content. This means that we per default know the SSRC of what we send but - // not what we receive. - AddLegacyStreamInContent(kSsrc1, flags, &local_media_content1_); - AddLegacyStreamInContent(kSsrc2, flags, &local_media_content2_); - - // If SSRC_MUX is used we also need to know the SSRC of the incoming stream. - if (flags & SSRC_MUX) { - AddLegacyStreamInContent(kSsrc1, flags, &remote_media_content1_); - AddLegacyStreamInContent(kSsrc2, flags, &remote_media_content2_); - } - } - typename T::Channel* CreateChannel(rtc::Thread* thread, cricket::MediaEngineInterface* engine, typename T::MediaChannel* ch, @@ -967,7 +919,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { void TestCallTeardownRtcpMux() { class LastWordMediaChannel : public T::MediaChannel { public: - LastWordMediaChannel() : T::MediaChannel(NULL) {} + LastWordMediaChannel() : T::MediaChannel(NULL, typename T::Options()) {} ~LastWordMediaChannel() { T::MediaChannel::SendRtp(kPcmuFrame, sizeof(kPcmuFrame)); T::MediaChannel::SendRtcp(kRtcpReport, sizeof(kRtcpReport));