Remove unused SignalMediaError and infrastructure.

BUG=webrtc:4690

Review URL: https://codereview.webrtc.org/1362913004

Cr-Commit-Position: refs/heads/master@{#10133}
This commit is contained in:
solenberg 2015-10-01 04:10:31 -07:00 committed by Commit bot
parent 49f9cdba02
commit 5b14b42e93
9 changed files with 30 additions and 296 deletions

View File

@ -240,7 +240,6 @@ class FakeVoiceMediaChannel : public RtpHelper<VoiceMediaChannel> {
explicit FakeVoiceMediaChannel(FakeVoiceEngine* engine,
const AudioOptions& options)
: engine_(engine),
fail_set_send_(false),
time_since_last_typing_(-1) {
output_scalings_[0] = OutputScaling(); // For default channel.
SetOptions(options);
@ -270,9 +269,6 @@ class FakeVoiceMediaChannel : public RtpHelper<VoiceMediaChannel> {
return true;
}
virtual bool SetSend(SendFlags flag) {
if (fail_set_send_) {
return false;
}
return set_sending(flag != SEND_NOTHING);
}
virtual bool SetAudioSend(uint32 ssrc, bool enable,
@ -370,17 +366,6 @@ class FakeVoiceMediaChannel : public RtpHelper<VoiceMediaChannel> {
}
virtual bool GetStats(VoiceMediaInfo* info) { return false; }
virtual void GetLastMediaError(uint32* ssrc,
VoiceMediaChannel::Error* error) {
*ssrc = 0;
*error = fail_set_send_ ? VoiceMediaChannel::ERROR_REC_DEVICE_OPEN_FAILED
: VoiceMediaChannel::ERROR_NONE;
}
void set_fail_set_send(bool fail) { fail_set_send_ = fail; }
void TriggerError(uint32 ssrc, VoiceMediaChannel::Error error) {
VoiceMediaChannel::SignalMediaError(ssrc, error);
}
private:
struct OutputScaling {
@ -458,7 +443,6 @@ class FakeVoiceMediaChannel : public RtpHelper<VoiceMediaChannel> {
std::vector<AudioCodec> send_codecs_;
std::map<uint32, OutputScaling> output_scalings_;
std::vector<DtmfInfo> dtmf_info_queue_;
bool fail_set_send_;
int time_since_last_typing_;
AudioOptions options_;
std::map<uint32, VoiceChannelAudioSink*> local_renderers_;

View File

@ -1097,16 +1097,6 @@ class VoiceMediaChannel : public MediaChannel {
virtual bool InsertDtmf(uint32 ssrc, int event, int duration, int flags) = 0;
// Gets quality stats for the channel.
virtual bool GetStats(VoiceMediaInfo* info) = 0;
// Gets last reported error for this media channel.
virtual void GetLastMediaError(uint32* ssrc,
VoiceMediaChannel::Error* error) {
ASSERT(error != NULL);
*error = ERROR_NONE;
}
// Signal errors from MediaChannel. Arguments are:
// ssrc(uint32), and error(VoiceMediaChannel::Error).
sigslot::signal2<uint32, VoiceMediaChannel::Error> SignalMediaError;
};
struct VideoSendParameters : RtpSendParameters<VideoCodec, VideoOptions> {
@ -1160,10 +1150,6 @@ class VideoMediaChannel : public MediaChannel {
virtual bool RequestIntraFrame() = 0;
virtual void UpdateAspectRatio(int ratio_w, int ratio_h) = 0;
// Signal errors from MediaChannel. Arguments are:
// ssrc(uint32), and error(VideoMediaChannel::Error).
sigslot::signal2<uint32, Error> SignalMediaError;
protected:
VideoRenderer *renderer_;
};
@ -1286,9 +1272,6 @@ class DataMediaChannel : public MediaChannel {
sigslot::signal3<const ReceiveDataParams&,
const char*,
size_t> SignalDataReceived;
// Signal errors from MediaChannel. Arguments are:
// ssrc(uint32), and error(DataMediaChannel::Error).
sigslot::signal2<uint32, DataMediaChannel::Error> SignalMediaError;
// Signal when the media channel is ready to send the stream. Arguments are:
// writable(bool)
sigslot::signal1<bool> SignalReadyToSend;

View File

@ -465,7 +465,6 @@ class VideoMediaChannelTest : public testing::Test,
channel_.reset(
engine_.CreateChannel(call_.get(), cricket::VideoOptions()));
EXPECT_TRUE(channel_.get() != NULL);
ConnectVideoChannelError();
network_interface_.SetDestination(channel_.get());
channel_->SetInterface(&network_interface_);
media_error_ = cricket::VideoMediaChannel::ERROR_NONE;
@ -520,10 +519,6 @@ class VideoMediaChannelTest : public testing::Test,
virtual void TearDown() {
channel_.reset();
}
void ConnectVideoChannelError() {
channel_->SignalMediaError.connect(this,
&VideoMediaChannelTest<E, C>::OnVideoChannelError);
}
bool SetDefaultCodec() {
return SetOneCodec(DefaultCodec());
}

View File

@ -2970,14 +2970,6 @@ bool WebRtcVoiceMediaChannel::GetStats(VoiceMediaInfo* info) {
return true;
}
void WebRtcVoiceMediaChannel::GetLastMediaError(
uint32* ssrc, VoiceMediaChannel::Error* error) {
RTC_DCHECK(ssrc != NULL);
RTC_DCHECK(error != NULL);
FindSsrc(voe_channel(), ssrc);
*error = WebRtcErrorToChannelError(GetLastEngineError());
}
bool WebRtcVoiceMediaChannel::FindSsrc(int channel_num, uint32* ssrc) {
rtc::CritScope lock(&receive_channels_cs_);
RTC_DCHECK(ssrc != NULL);
@ -3019,7 +3011,6 @@ void WebRtcVoiceMediaChannel::OnError(uint32 ssrc, int error) {
} else if (error == VE_TYPING_NOISE_OFF_WARNING) {
typing_noise_detected_ = false;
}
SignalMediaError(ssrc, WebRtcErrorToChannelError(error));
}
int WebRtcVoiceMediaChannel::GetOutputLevel(int channel) {

View File

@ -221,10 +221,6 @@ class WebRtcVoiceMediaChannel : public VoiceMediaChannel,
const rtc::PacketTime& packet_time) override;
void OnReadyToSend(bool ready) override {}
bool GetStats(VoiceMediaInfo* info) override;
// Gets last reported error from WebRtc voice engine. This should be only
// called in response a failure.
void GetLastMediaError(uint32* ssrc,
VoiceMediaChannel::Error* error) override;
// implements Transport interface
bool SendRtp(const uint8_t* data, size_t len) override {

View File

@ -89,35 +89,6 @@ class FakeVoETraceWrapper : public cricket::VoETraceWrapper {
class WebRtcVoiceEngineTestFake : public testing::Test {
public:
class ChannelErrorListener : public sigslot::has_slots<> {
public:
explicit ChannelErrorListener(cricket::VoiceMediaChannel* channel)
: ssrc_(0), error_(cricket::VoiceMediaChannel::ERROR_NONE) {
RTC_DCHECK(channel != NULL);
channel->SignalMediaError.connect(
this, &ChannelErrorListener::OnVoiceChannelError);
}
void OnVoiceChannelError(uint32 ssrc,
cricket::VoiceMediaChannel::Error error) {
ssrc_ = ssrc;
error_ = error;
}
void Reset() {
ssrc_ = 0;
error_ = cricket::VoiceMediaChannel::ERROR_NONE;
}
uint32 ssrc() const {
return ssrc_;
}
cricket::VoiceMediaChannel::Error error() const {
return error_;
}
private:
uint32 ssrc_;
cricket::VoiceMediaChannel::Error error_;
};
WebRtcVoiceEngineTestFake()
: call_(webrtc::Call::Config()),
voe_(kAudioCodecs, ARRAY_SIZE(kAudioCodecs)),
@ -2543,51 +2514,6 @@ TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnSendStreamAsCallee) {
TestInsertDtmf(kSsrc1, false);
}
TEST_F(WebRtcVoiceEngineTestFake, MediaEngineCallbackOnError) {
rtc::scoped_ptr<ChannelErrorListener> listener;
cricket::WebRtcVoiceMediaChannel* media_channel;
unsigned int ssrc = 0;
EXPECT_TRUE(SetupEngine());
send_parameters_.options = options_conference_;
EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE));
media_channel = static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_);
listener.reset(new ChannelErrorListener(channel_));
// Test on WebRtc VoE channel.
voe_.TriggerCallbackOnError(media_channel->voe_channel(),
VE_SATURATION_WARNING);
EXPECT_EQ(cricket::VoiceMediaChannel::ERROR_REC_DEVICE_SATURATION,
listener->error());
EXPECT_NE(-1, voe_.GetLocalSSRC(voe_.GetLastChannel(), ssrc));
EXPECT_EQ(ssrc, listener->ssrc());
listener->Reset();
voe_.TriggerCallbackOnError(-1, VE_TYPING_NOISE_WARNING);
EXPECT_EQ(cricket::VoiceMediaChannel::ERROR_REC_TYPING_NOISE_DETECTED,
listener->error());
EXPECT_EQ(0U, listener->ssrc());
// Add another stream and test on that.
++ssrc;
EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(
ssrc)));
listener->Reset();
voe_.TriggerCallbackOnError(voe_.GetLastChannel(),
VE_SATURATION_WARNING);
EXPECT_EQ(cricket::VoiceMediaChannel::ERROR_REC_DEVICE_SATURATION,
listener->error());
EXPECT_EQ(ssrc, listener->ssrc());
// Testing a non-existing channel.
listener->Reset();
voe_.TriggerCallbackOnError(voe_.GetLastChannel() + 2,
VE_SATURATION_WARNING);
EXPECT_EQ(0, listener->error());
}
TEST_F(WebRtcVoiceEngineTestFake, TestSetPlayoutError) {
EXPECT_TRUE(SetupEngine());
send_parameters_.options = options_conference_;

View File

@ -1301,10 +1301,6 @@ bool VoiceChannel::Init() {
if (!BaseChannel::Init()) {
return false;
}
media_channel()->SignalMediaError.connect(
this, &VoiceChannel::OnVoiceChannelError);
srtp_filter()->SignalSrtpError.connect(
this, &VoiceChannel::OnSrtpError);
return true;
}
@ -1430,9 +1426,7 @@ void VoiceChannel::ChangeState() {
// Render incoming data if we're the active call, and we have the local
// content. We receive data on the default channel and multiplexed streams.
bool recv = IsReadyToReceive();
if (!media_channel()->SetPlayout(recv)) {
SendLastMediaError();
}
media_channel()->SetPlayout(recv);
// Send outgoing data if we're the active call, we have the remote content,
// and we have had some form of connectivity.
@ -1440,7 +1434,6 @@ void VoiceChannel::ChangeState() {
SendFlags send_flag = send ? SEND_MICROPHONE : SEND_NOTHING;
if (!media_channel()->SetSend(send_flag)) {
LOG(LS_ERROR) << "Failed to SetSend " << send_flag << " on voice channel";
SendLastMediaError();
}
LOG(LS_INFO) << "Changing voice state, recv=" << recv << " send=" << send;
@ -1571,7 +1564,6 @@ void VoiceChannel::OnMessage(rtc::Message *pmsg) {
case MSG_CHANNEL_ERROR: {
VoiceChannelErrorMessageData* data =
static_cast<VoiceChannelErrorMessageData*>(pmsg->pdata);
SignalMediaError(this, data->ssrc, data->error);
delete data;
break;
}
@ -1597,36 +1589,6 @@ void VoiceChannel::OnAudioMonitorUpdate(AudioMonitor* monitor,
SignalAudioMonitor(this, info);
}
void VoiceChannel::OnVoiceChannelError(
uint32 ssrc, VoiceMediaChannel::Error err) {
VoiceChannelErrorMessageData* data = new VoiceChannelErrorMessageData(
ssrc, err);
signaling_thread()->Post(this, MSG_CHANNEL_ERROR, data);
}
void VoiceChannel::OnSrtpError(uint32 ssrc, SrtpFilter::Mode mode,
SrtpFilter::Error error) {
switch (error) {
case SrtpFilter::ERROR_FAIL:
OnVoiceChannelError(ssrc, (mode == SrtpFilter::PROTECT) ?
VoiceMediaChannel::ERROR_REC_SRTP_ERROR :
VoiceMediaChannel::ERROR_PLAY_SRTP_ERROR);
break;
case SrtpFilter::ERROR_AUTH:
OnVoiceChannelError(ssrc, (mode == SrtpFilter::PROTECT) ?
VoiceMediaChannel::ERROR_REC_SRTP_AUTH_FAILED :
VoiceMediaChannel::ERROR_PLAY_SRTP_AUTH_FAILED);
break;
case SrtpFilter::ERROR_REPLAY:
// Only receving channel should have this error.
ASSERT(mode == SrtpFilter::UNPROTECT);
OnVoiceChannelError(ssrc, VoiceMediaChannel::ERROR_PLAY_SRTP_REPLAY);
break;
default:
break;
}
}
void VoiceChannel::GetSrtpCryptoSuiteNames(
std::vector<std::string>* ciphers) const {
GetSupportedAudioCryptoSuites(ciphers);
@ -1649,20 +1611,9 @@ bool VideoChannel::Init() {
if (!BaseChannel::Init()) {
return false;
}
media_channel()->SignalMediaError.connect(
this, &VideoChannel::OnVideoChannelError);
srtp_filter()->SignalSrtpError.connect(
this, &VideoChannel::OnSrtpError);
return true;
}
void VoiceChannel::SendLastMediaError() {
uint32 ssrc;
VoiceMediaChannel::Error error;
media_channel()->GetLastMediaError(&ssrc, &error);
SignalMediaError(this, ssrc, error);
}
VideoChannel::~VideoChannel() {
std::vector<uint32> screencast_ssrcs;
ScreencastMap::iterator iter;
@ -1964,7 +1915,6 @@ void VideoChannel::OnMessage(rtc::Message *pmsg) {
case MSG_CHANNEL_ERROR: {
const VideoChannelErrorMessageData* data =
static_cast<VideoChannelErrorMessageData*>(pmsg->pdata);
SignalMediaError(this, data->ssrc, data->error);
delete data;
break;
}
@ -2029,38 +1979,6 @@ bool VideoChannel::GetLocalSsrc(const VideoCapturer* capturer, uint32* ssrc) {
return false;
}
void VideoChannel::OnVideoChannelError(uint32 ssrc,
VideoMediaChannel::Error error) {
VideoChannelErrorMessageData* data = new VideoChannelErrorMessageData(
ssrc, error);
signaling_thread()->Post(this, MSG_CHANNEL_ERROR, data);
}
void VideoChannel::OnSrtpError(uint32 ssrc, SrtpFilter::Mode mode,
SrtpFilter::Error error) {
switch (error) {
case SrtpFilter::ERROR_FAIL:
OnVideoChannelError(ssrc, (mode == SrtpFilter::PROTECT) ?
VideoMediaChannel::ERROR_REC_SRTP_ERROR :
VideoMediaChannel::ERROR_PLAY_SRTP_ERROR);
break;
case SrtpFilter::ERROR_AUTH:
OnVideoChannelError(ssrc, (mode == SrtpFilter::PROTECT) ?
VideoMediaChannel::ERROR_REC_SRTP_AUTH_FAILED :
VideoMediaChannel::ERROR_PLAY_SRTP_AUTH_FAILED);
break;
case SrtpFilter::ERROR_REPLAY:
// Only receving channel should have this error.
ASSERT(mode == SrtpFilter::UNPROTECT);
// TODO(gangji): Turn on the signaling of replay error once we have
// switched to the new mechanism for doing video retransmissions.
// OnVideoChannelError(ssrc, VideoMediaChannel::ERROR_PLAY_SRTP_REPLAY);
break;
default:
break;
}
}
void VideoChannel::GetSrtpCryptoSuiteNames(
std::vector<std::string>* ciphers) const {
GetSupportedVideoCryptoSuites(ciphers);
@ -2093,14 +2011,10 @@ bool DataChannel::Init() {
}
media_channel()->SignalDataReceived.connect(
this, &DataChannel::OnDataReceived);
media_channel()->SignalMediaError.connect(
this, &DataChannel::OnDataChannelError);
media_channel()->SignalReadyToSend.connect(
this, &DataChannel::OnDataChannelReadyToSend);
media_channel()->SignalStreamClosedRemotely.connect(
this, &DataChannel::OnStreamClosedRemotely);
srtp_filter()->SignalSrtpError.connect(
this, &DataChannel::OnSrtpError);
return true;
}
@ -2308,7 +2222,6 @@ void DataChannel::OnMessage(rtc::Message *pmsg) {
case MSG_CHANNEL_ERROR: {
const DataChannelErrorMessageData* data =
static_cast<DataChannelErrorMessageData*>(pmsg->pdata);
SignalMediaError(this, data->ssrc, data->error);
delete data;
break;
}
@ -2374,29 +2287,6 @@ void DataChannel::OnDataChannelReadyToSend(bool writable) {
new DataChannelReadyToSendMessageData(writable));
}
void DataChannel::OnSrtpError(uint32 ssrc, SrtpFilter::Mode mode,
SrtpFilter::Error error) {
switch (error) {
case SrtpFilter::ERROR_FAIL:
OnDataChannelError(ssrc, (mode == SrtpFilter::PROTECT) ?
DataMediaChannel::ERROR_SEND_SRTP_ERROR :
DataMediaChannel::ERROR_RECV_SRTP_ERROR);
break;
case SrtpFilter::ERROR_AUTH:
OnDataChannelError(ssrc, (mode == SrtpFilter::PROTECT) ?
DataMediaChannel::ERROR_SEND_SRTP_AUTH_FAILED :
DataMediaChannel::ERROR_RECV_SRTP_AUTH_FAILED);
break;
case SrtpFilter::ERROR_REPLAY:
// Only receving channel should have this error.
ASSERT(mode == SrtpFilter::UNPROTECT);
OnDataChannelError(ssrc, DataMediaChannel::ERROR_RECV_SRTP_REPLAY);
break;
default:
break;
}
}
void DataChannel::GetSrtpCryptoSuiteNames(
std::vector<std::string>* ciphers) const {
GetSupportedDataCryptoSuites(ciphers);

View File

@ -144,10 +144,6 @@ class BaseChannel
// For ConnectionStatsGetter, used by ConnectionMonitor
bool GetConnectionStats(ConnectionInfos* infos) override;
void set_srtp_signal_silent_time(uint32 silent_time) {
srtp_filter_.set_signal_silent_time(silent_time);
}
BundleFilter* bundle_filter() { return &bundle_filter_; }
const std::vector<StreamParams>& local_streams() const {
@ -170,6 +166,8 @@ class BaseChannel
// Only public for unit tests. Otherwise, consider protected.
virtual int SetOption(SocketType type, rtc::Socket::Option o, int val);
SrtpFilter* srtp_filter() { return &srtp_filter_; }
protected:
virtual MediaChannel* media_channel() const { return media_channel_; }
// Sets the |transport_channel_| (and |rtcp_transport_channel_|, if |rtcp_| is
@ -192,7 +190,6 @@ class BaseChannel
rtc::Thread* signaling_thread() {
return transport_controller_->signaling_thread();
}
SrtpFilter* srtp_filter() { return &srtp_filter_; }
bool rtcp_transport_enabled() const { return rtcp_transport_enabled_; }
void ConnectToTransportChannel(TransportChannel* tc);
@ -389,11 +386,6 @@ class VoiceChannel : public BaseChannel {
int GetOutputLevel_w();
void GetActiveStreams_w(AudioInfo::StreamList* actives);
// Signal errors from VoiceMediaChannel. Arguments are:
// ssrc(uint32), and error(VoiceMediaChannel::Error).
sigslot::signal3<VoiceChannel*, uint32, VoiceMediaChannel::Error>
SignalMediaError;
private:
// overrides from BaseChannel
virtual void OnChannelRead(TransportChannel* channel,
@ -420,9 +412,6 @@ class VoiceChannel : public BaseChannel {
virtual void OnMediaMonitorUpdate(
VoiceMediaChannel* media_channel, const VoiceMediaInfo& info);
void OnAudioMonitorUpdate(AudioMonitor* monitor, const AudioInfo& info);
void OnVoiceChannelError(uint32 ssrc, VoiceMediaChannel::Error error);
void SendLastMediaError();
void OnSrtpError(uint32 ssrc, SrtpFilter::Mode mode, SrtpFilter::Error error);
static const int kEarlyMediaTimeout = 1000;
MediaEngineInterface* media_engine_;
@ -481,8 +470,6 @@ class VideoChannel : public BaseChannel {
bool SendIntraFrame();
bool RequestIntraFrame();
sigslot::signal3<VideoChannel*, uint32, VideoMediaChannel::Error>
SignalMediaError;
// Configure sending media on the stream with SSRC |ssrc|
// If there is only one sending stream SSRC 0 can be used.
@ -521,9 +508,6 @@ class VideoChannel : public BaseChannel {
virtual void OnStateChange(VideoCapturer* capturer, CaptureState ev);
bool GetLocalSsrc(const VideoCapturer* capturer, uint32* ssrc);
void OnVideoChannelError(uint32 ssrc, VideoMediaChannel::Error error);
void OnSrtpError(uint32 ssrc, SrtpFilter::Mode mode, SrtpFilter::Error error);
VideoRenderer* renderer_;
ScreencastMap screencast_capturers_;
rtc::scoped_ptr<VideoMediaMonitor> media_monitor_;
@ -564,8 +548,6 @@ class DataChannel : public BaseChannel {
sigslot::signal2<DataChannel*, const DataMediaInfo&> SignalMediaMonitor;
sigslot::signal2<DataChannel*, const std::vector<ConnectionInfo>&>
SignalConnectionMonitor;
sigslot::signal3<DataChannel*, uint32, DataMediaChannel::Error>
SignalMediaError;
sigslot::signal3<DataChannel*,
const ReceiveDataParams&,
const rtc::Buffer&>
@ -646,7 +628,6 @@ class DataChannel : public BaseChannel {
const ReceiveDataParams& params, const char* data, size_t len);
void OnDataChannelError(uint32 ssrc, DataMediaChannel::Error error);
void OnDataChannelReadyToSend(bool writable);
void OnSrtpError(uint32 ssrc, SrtpFilter::Mode mode, SrtpFilter::Error error);
void OnStreamClosedRemotely(uint32 sid);
rtc::scoped_ptr<DataMediaMonitor> media_monitor_;

View File

@ -139,9 +139,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
rtp_packet_(reinterpret_cast<const char*>(rtp_data), rtp_len),
rtcp_packet_(reinterpret_cast<const char*>(rtcp_data), rtcp_len),
media_info_callbacks1_(),
media_info_callbacks2_(),
ssrc_(0),
error_(T::MediaChannel::ERROR_NONE) {}
media_info_callbacks2_() {}
void CreateChannels(int flags1, int flags2) {
CreateChannels(new typename T::MediaChannel(NULL, typename T::Options()),
@ -163,10 +161,6 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
this, &ChannelTest<T>::OnMediaMonitor);
channel2_->SignalMediaMonitor.connect(
this, &ChannelTest<T>::OnMediaMonitor);
channel1_->SignalMediaError.connect(
this, &ChannelTest<T>::OnMediaChannelError);
channel2_->SignalMediaError.connect(
this, &ChannelTest<T>::OnMediaChannelError);
if ((flags1 & DTLS) && (flags2 & DTLS)) {
flags1 = (flags1 & ~SECURE);
flags2 = (flags2 & ~SECURE);
@ -472,13 +466,6 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
}
}
void OnMediaChannelError(typename T::Channel* channel,
uint32 ssrc,
typename T::MediaChannel::Error error) {
ssrc_ = ssrc;
error_ = error;
}
void AddLegacyStreamInContent(uint32 ssrc, int flags,
typename T::Content* content) {
// Base implementation.
@ -1677,16 +1664,20 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
EXPECT_TRUE(CheckRtcp2());
}
void TestChangeStateError() {
CreateChannels(RTCP, RTCP);
EXPECT_TRUE(SendInitiate());
media_channel2_->set_fail_set_send(true);
EXPECT_TRUE(channel2_->Enable(true));
EXPECT_EQ(cricket::VoiceMediaChannel::ERROR_REC_DEVICE_OPEN_FAILED,
error_);
}
void TestSrtpError(int pl_type) {
struct SrtpErrorHandler : public sigslot::has_slots<> {
SrtpErrorHandler() :
mode_(cricket::SrtpFilter::UNPROTECT),
error_(cricket::SrtpFilter::ERROR_NONE) {}
void OnSrtpError(uint32 ssrc, cricket::SrtpFilter::Mode mode,
cricket::SrtpFilter::Error error) {
mode_ = mode;
error_ = error;
}
cricket::SrtpFilter::Mode mode_;
cricket::SrtpFilter::Error error_;
} error_handler;
// For Audio, only pl_type 0 is added to the bundle filter.
// For Video, only pl_type 97 is added to the bundle filter.
// So we need to pass in pl_type so that the packet can pass through
@ -1711,30 +1702,36 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
EXPECT_TRUE(SendAccept());
EXPECT_TRUE(channel1_->secure());
EXPECT_TRUE(channel2_->secure());
channel2_->set_srtp_signal_silent_time(200);
channel2_->srtp_filter()->SignalSrtpError.connect(
&error_handler, &SrtpErrorHandler::OnSrtpError);
// Testing failures in sending packets.
EXPECT_FALSE(media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket)));
// The first failure will trigger an error.
EXPECT_EQ_WAIT(T::MediaChannel::ERROR_REC_SRTP_ERROR, error_, 500);
error_ = T::MediaChannel::ERROR_NONE;
EXPECT_EQ_WAIT(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_, 500);
EXPECT_EQ(cricket::SrtpFilter::PROTECT, error_handler.mode_);
error_handler.error_ = cricket::SrtpFilter::ERROR_NONE;
// The next 1 sec failures will not trigger an error.
EXPECT_FALSE(media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket)));
// Wait for a while to ensure no message comes in.
rtc::Thread::Current()->ProcessMessages(210);
EXPECT_EQ(T::MediaChannel::ERROR_NONE, error_);
EXPECT_EQ(cricket::SrtpFilter::ERROR_NONE, error_handler.error_);
// The error will be triggered again.
EXPECT_FALSE(media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket)));
EXPECT_EQ_WAIT(T::MediaChannel::ERROR_REC_SRTP_ERROR, error_, 500);
EXPECT_EQ_WAIT(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_, 500);
EXPECT_EQ(cricket::SrtpFilter::PROTECT, error_handler.mode_);
// Testing failures in receiving packets.
error_ = T::MediaChannel::ERROR_NONE;
error_handler.error_ = cricket::SrtpFilter::ERROR_NONE;
cricket::TransportChannel* transport_channel =
channel2_->transport_channel();
transport_channel->SignalReadPacket(
transport_channel, reinterpret_cast<const char*>(kBadPacket),
sizeof(kBadPacket), rtc::PacketTime(), 0);
EXPECT_EQ_WAIT(T::MediaChannel::ERROR_PLAY_SRTP_ERROR, error_, 500);
EXPECT_EQ_WAIT(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_, 500);
EXPECT_EQ(cricket::SrtpFilter::UNPROTECT, error_handler.mode_);
}
void TestOnReadyToSend() {
@ -1802,9 +1799,6 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
std::string rtcp_packet_;
int media_info_callbacks1_;
int media_info_callbacks2_;
uint32 ssrc_;
typename T::MediaChannel::Error error_;
};
template<>
@ -2168,10 +2162,6 @@ TEST_F(VoiceChannelTest, TestFlushRtcp) {
Base::TestFlushRtcp();
}
TEST_F(VoiceChannelTest, TestChangeStateError) {
Base::TestChangeStateError();
}
TEST_F(VoiceChannelTest, TestSrtpError) {
Base::TestSrtpError(kAudioPts[0]);
}
@ -2524,8 +2514,6 @@ TEST_F(VideoChannelTest, SendBundleToBundleWithRtcpMuxSecure) {
kVideoPts, ARRAY_SIZE(kVideoPts), true, true);
}
// TODO(gangji): Add VideoChannelTest.TestChangeStateError.
TEST_F(VideoChannelTest, TestSrtpError) {
Base::TestSrtpError(kVideoPts[0]);
}