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}
This commit is contained in:
Fredrik Solenberg 2015-09-17 16:42:56 +02:00
parent ae856f2c9f
commit b071a19019
16 changed files with 1194 additions and 1351 deletions

View File

@ -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*));
};

View File

@ -103,16 +103,6 @@ template <class Base> class RtpHelper : public Base {
}
bool CheckNoRtp() { return rtp_packets_.empty(); }
bool CheckNoRtcp() { return rtcp_packets_.empty(); }
virtual bool SetRecvRtpHeaderExtensions(
const std::vector<RtpHeaderExtension>& extensions) {
recv_extensions_ = extensions;
return true;
}
virtual bool SetSendRtpHeaderExtensions(
const std::vector<RtpHeaderExtension>& 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 Base> 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 Base> class RtpHelper : public Base {
return true;
}
void set_playout(bool playout) { playout_ = playout; }
bool SetRecvRtpHeaderExtensions(
const std::vector<RtpHeaderExtension>& extensions) {
recv_extensions_ = extensions;
return true;
}
bool SetSendRtpHeaderExtensions(
const std::vector<RtpHeaderExtension>& 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<char>(), packet->size()));
@ -235,7 +237,8 @@ class FakeVoiceMediaChannel : public RtpHelper<VoiceMediaChannel> {
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<VoiceMediaChannel> {
ringback_tone_loop_(false),
time_since_last_typing_(-1) {
output_scalings_[0] = OutputScaling(); // For default channel.
SetOptions(options);
}
~FakeVoiceMediaChannel();
const std::vector<AudioCodec>& recv_codecs() const { return recv_codecs_; }
@ -257,21 +261,16 @@ class FakeVoiceMediaChannel : public RtpHelper<VoiceMediaChannel> {
bool ringback_tone_play() const { return ringback_tone_play_; }
bool ringback_tone_loop() const { return ringback_tone_loop_; }
virtual bool SetRecvCodecs(const std::vector<AudioCodec>& 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<AudioCodec>& 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<VoiceMediaChannel> {
}
return true;
}
virtual bool SetMaxSendBandwidth(int bps) { return true; }
virtual bool AddRecvStream(const StreamParams& sp) {
if (!RtpHelper<VoiceMediaChannel>::AddRecvStream(sp))
return false;
@ -399,12 +397,6 @@ class FakeVoiceMediaChannel : public RtpHelper<VoiceMediaChannel> {
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<VoiceMediaChannel> {
AudioRenderer* renderer_;
};
bool SetRecvCodecs(const std::vector<AudioCodec>& codecs) {
if (fail_set_recv_codecs()) {
// Fake the failure in SetRecvCodecs.
return false;
}
recv_codecs_ = codecs;
return true;
}
bool SetSendCodecs(const std::vector<AudioCodec>& 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<VideoMediaChannel> {
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<VideoMediaChannel> {
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<VideoMediaChannel>::AddSendStream(sp)) {
return false;
@ -523,27 +550,6 @@ class FakeVideoMediaChannel : public RtpHelper<VideoMediaChannel> {
return RtpHelper<VideoMediaChannel>::RemoveSendStream(ssrc);
}
virtual bool SetRecvCodecs(const std::vector<VideoCodec>& codecs) {
if (fail_set_recv_codecs()) {
// Fake the failure in SetRecvCodecs.
return false;
}
recv_codecs_ = codecs;
return true;
}
virtual bool SetSendCodecs(const std::vector<VideoCodec>& codecs) {
if (fail_set_send_codecs()) {
// Fake the failure in SetSendCodecs.
return false;
}
send_codecs_ = codecs;
for (std::vector<StreamParams>::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<VideoMediaChannel> {
}
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<VideoMediaChannel> {
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<VideoMediaChannel>::AddRecvStream(sp))
return false;
@ -610,10 +611,6 @@ class FakeVideoMediaChannel : public RtpHelper<VideoMediaChannel> {
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<VideoMediaChannel> {
bool requested_intra_frame() const { return requested_intra_frame_; }
private:
bool SetRecvCodecs(const std::vector<VideoCodec>& codecs) {
if (fail_set_recv_codecs()) {
// Fake the failure in SetRecvCodecs.
return false;
}
recv_codecs_ = codecs;
return true;
}
bool SetSendCodecs(const std::vector<VideoCodec>& codecs) {
if (fail_set_send_codecs()) {
// Fake the failure in SetSendCodecs.
return false;
}
send_codecs_ = codecs;
for (std::vector<StreamParams>::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<VideoMediaChannel> {
class FakeDataMediaChannel : public RtpHelper<DataMediaChannel> {
public:
explicit FakeDataMediaChannel(void* unused)
explicit FakeDataMediaChannel(void* unused, const DataOptions& options)
: send_blocked_(false), max_bps_(-1) {}
~FakeDataMediaChannel() {}
const std::vector<DataCodec>& recv_codecs() const { return recv_codecs_; }
@ -653,31 +680,18 @@ class FakeDataMediaChannel : public RtpHelper<DataMediaChannel> {
const std::vector<DataCodec>& codecs() const { return send_codecs(); }
int max_bps() const { return max_bps_; }
virtual bool SetRecvCodecs(const std::vector<DataCodec>& 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<DataCodec>& 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<DataMediaChannel>::AddRecvStream(sp))
return false;
@ -708,6 +722,27 @@ class FakeDataMediaChannel : public RtpHelper<DataMediaChannel> {
void set_send_blocked(bool blocked) { send_blocked_ = blocked; }
private:
bool SetRecvCodecs(const std::vector<DataCodec>& codecs) {
if (fail_set_recv_codecs()) {
// Fake the failure in SetRecvCodecs.
return false;
}
recv_codecs_ = codecs;
return true;
}
bool SetSendCodecs(const std::vector<DataCodec>& 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<DataCodec> recv_codecs_;
std::vector<DataCodec> 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;
}

View File

@ -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<RtpHeaderExtension>& extensions) = 0;
virtual bool SetSendRtpHeaderExtensions(
const std::vector<RtpHeaderExtension>& 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<AudioCodec>& codecs) = 0;
// Sets the codecs/payload types to be used for outgoing media.
virtual bool SetSendCodecs(const std::vector<AudioCodec>& 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<VideoCodec>& codecs) = 0;
// Sets the codecs/payload types to be used for outgoing media.
virtual bool SetSendCodecs(const std::vector<VideoCodec>& 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<DataCodec>& codecs) = 0;
virtual bool SetRecvCodecs(const std::vector<DataCodec>& 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; }

View File

@ -155,6 +155,15 @@ bool RtpDataMediaChannel::SetSendCodecs(const std::vector<DataCodec>& 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;

View File

@ -96,13 +96,8 @@ class RtpDataMediaChannel : public DataMediaChannel {
timing_ = timing;
}
virtual bool SetMaxSendBandwidth(int bps);
virtual bool SetRecvRtpHeaderExtensions(
const std::vector<RtpHeaderExtension>& extensions) { return true; }
virtual bool SetSendRtpHeaderExtensions(
const std::vector<RtpHeaderExtension>& extensions) { return true; }
virtual bool SetSendCodecs(const std::vector<DataCodec>& codecs);
virtual bool SetRecvCodecs(const std::vector<DataCodec>& 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<DataCodec>& codecs);
bool SetRecvCodecs(const std::vector<DataCodec>& codecs);
bool sending_;
bool receiving_;

View File

@ -176,22 +176,29 @@ TEST_F(RtpDataMediaChannelTest, SetUnknownCodecs) {
unknown_codec.id = 104;
unknown_codec.name = "unknown-data";
std::vector<cricket::DataCodec> 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<cricket::DataCodec> 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<cricket::DataCodec> 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<cricket::DataCodec> 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<cricket::DataCodec> 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<cricket::DataCodec> 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<cricket::DataCodec> 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());

View File

@ -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<cricket::VideoCodec> 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.

View File

@ -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);
}

View File

@ -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<RtpHeaderExtension>& extensions) { return true; }
virtual bool SetSendRtpHeaderExtensions(
const std::vector<RtpHeaderExtension>& extensions) { return true; }
virtual bool SetSendCodecs(const std::vector<DataCodec>& codecs);
virtual bool SetRecvCodecs(const std::vector<DataCodec>& 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<DataCodec>& codecs);
bool SetRecvCodecs(const std::vector<DataCodec>& codecs);
// Creates the socket and connects. Sets sending_ to true.
bool Connect();
// Closes the socket. Sets sending_ to false.

View File

@ -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<VideoCodec>& WebRtcVideoEngine2::codecs() const {
@ -764,6 +762,7 @@ std::vector<VideoCodec> WebRtcVideoEngine2::GetSupportedCodecs() const {
WebRtcVideoChannel2::WebRtcVideoChannel2(
webrtc::Call* call,
const VideoOptions& options,
const std::vector<VideoCodec>& 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;
}

View File

@ -161,6 +161,7 @@ class WebRtcVideoChannel2 : public rtc::MessageHandler,
public:
WebRtcVideoChannel2(webrtc::Call* call,
const VideoOptions& options,
const std::vector<VideoCodec>& 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<VideoCodec>& codecs) override;
bool SetSendCodecs(const std::vector<VideoCodec>& 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<RtpHeaderExtension>& extensions) override;
bool SetSendRtpHeaderExtensions(
const std::vector<RtpHeaderExtension>& 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<VideoCodec>& codecs);
bool SetSendRtpHeaderExtensions(
const std::vector<RtpHeaderExtension>& extensions);
bool SetMaxSendBandwidth(int bps);
bool SetOptions(const VideoOptions& options);
bool SetRecvCodecs(const std::vector<VideoCodec>& codecs);
bool SetRecvRtpHeaderExtensions(
const std::vector<RtpHeaderExtension>& extensions);
void ConfigureReceiverRtp(webrtc::VideoReceiveStream::Config* config,
const StreamParams& sp) const;
bool CodecIsExternallySupported(const std::string& name) const;

File diff suppressed because it is too large Load Diff

View File

@ -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() {

View File

@ -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<AudioCodec>& codecs) override;
bool SetSendCodecs(const std::vector<AudioCodec>& codecs) override;
bool SetRecvRtpHeaderExtensions(
const std::vector<RtpHeaderExtension>& extensions) override;
bool SetSendRtpHeaderExtensions(
const std::vector<RtpHeaderExtension>& 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<AudioCodec>& codecs);
bool SetSendRtpHeaderExtensions(
const std::vector<RtpHeaderExtension>& extensions);
bool SetOptions(const AudioOptions& options);
bool SetMaxSendBandwidth(int bps);
bool SetRecvCodecs(const std::vector<AudioCodec>& codecs);
bool SetRecvRtpHeaderExtensions(
const std::vector<RtpHeaderExtension>& 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);

File diff suppressed because it is too large Load Diff

View File

@ -77,7 +77,8 @@ template<class ChannelT,
class MediaChannelT,
class ContentT,
class CodecT,
class MediaInfoT>
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::VoiceChannel,
cricket::FakeVoiceMediaChannel,
cricket::AudioContentDescription,
cricket::AudioCodec,
cricket::VoiceMediaInfo> {
cricket::VoiceMediaInfo,
cricket::AudioOptions> {
};
class VideoTraits : public Traits<cricket::VideoChannel,
cricket::FakeVideoMediaChannel,
cricket::VideoContentDescription,
cricket::VideoCodec,
cricket::VideoMediaInfo> {
cricket::VideoMediaInfo,
cricket::VideoOptions> {
};
class DataTraits : public Traits<cricket::DataChannel,
cricket::FakeDataMediaChannel,
cricket::DataContentDescription,
cricket::DataCodec,
cricket::DataMediaInfo> {
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<T>::OnMediaMonitor);
channel2_->SignalMediaMonitor.connect(
this, &ChannelTest<T>::OnMediaMonitor);
channel2_->SignalMediaError.connect(
this, &ChannelTest<T>::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));