diff --git a/talk/media/base/videocommon.h b/talk/media/base/videocommon.h index 20e01c0bc..c83a3d8d1 100644 --- a/talk/media/base/videocommon.h +++ b/talk/media/base/videocommon.h @@ -212,6 +212,9 @@ struct VideoFormat : VideoFormatPod { } static int IntervalToFps(int64 interval) { + if (!interval) { + return 0; + } return static_cast(talk_base::kNumNanosecsPerSec / interval); } diff --git a/talk/media/base/videocommon_unittest.cc b/talk/media/base/videocommon_unittest.cc index 20bd43d43..90bcd0aec 100644 --- a/talk/media/base/videocommon_unittest.cc +++ b/talk/media/base/videocommon_unittest.cc @@ -57,6 +57,7 @@ TEST(VideoCommonTest, TestVideoFormatFps) { EXPECT_EQ(VideoFormat::kMinimumInterval, VideoFormat::FpsToInterval(0)); EXPECT_EQ(talk_base::kNumNanosecsPerSec / 20, VideoFormat::FpsToInterval(20)); EXPECT_EQ(20, VideoFormat::IntervalToFps(talk_base::kNumNanosecsPerSec / 20)); + EXPECT_EQ(0, VideoFormat::IntervalToFps(0)); } // Test IsSize0x0 diff --git a/talk/media/base/videoengine_unittest.h b/talk/media/base/videoengine_unittest.h index 5586d7600..d3f01ccab 100644 --- a/talk/media/base/videoengine_unittest.h +++ b/talk/media/base/videoengine_unittest.h @@ -1713,7 +1713,7 @@ class VideoMediaChannelTest : public testing::Test, // instead of packets. EXPECT_EQ(0, renderer2_.num_rendered_frames()); // Give a chance for the decoder to process before adding the receiver. - talk_base::Thread::Current()->ProcessMessages(10); + talk_base::Thread::Current()->ProcessMessages(100); // Test sending and receiving on second stream. EXPECT_TRUE(channel_->AddRecvStream( cricket::StreamParams::CreateLegacy(kSsrc + 2))); @@ -1731,6 +1731,7 @@ class VideoMediaChannelTest : public testing::Test, // 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(); @@ -1738,6 +1739,7 @@ class VideoMediaChannelTest : public testing::Test, EXPECT_TRUE(channel_->SetRender(true)); Send(codec); EXPECT_EQ_WAIT(2, NumRtpPackets(), kTimeout); + talk_base::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. @@ -1768,10 +1770,11 @@ class VideoMediaChannelTest : public testing::Test, EXPECT_TRUE(channel_->SetRender(true)); Send(codec); EXPECT_EQ_WAIT(2, NumRtpPackets(), kTimeout); - EXPECT_EQ_WAIT(1, renderer_.num_rendered_frames(), kTimeout); - EXPECT_EQ_WAIT(0, renderer2_.num_rendered_frames(), 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. - talk_base::Thread::Current()->ProcessMessages(10); + talk_base::Thread::Current()->ProcessMessages(100); // Test sending and receiving on second stream. EXPECT_TRUE(channel_->AddRecvStream( cricket::StreamParams::CreateLegacy(kSsrc + 2))); @@ -1780,8 +1783,7 @@ class VideoMediaChannelTest : public testing::Test, 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. + // delivered to default channel. EXPECT_EQ(0, renderer2_.num_rendered_frames()); } diff --git a/talk/media/webrtc/webrtcvideoengine.cc b/talk/media/webrtc/webrtcvideoengine.cc index f1cffa31d..f538f80d0 100644 --- a/talk/media/webrtc/webrtcvideoengine.cc +++ b/talk/media/webrtc/webrtcvideoengine.cc @@ -2597,10 +2597,13 @@ void WebRtcVideoMediaChannel::OnPacketReceived( int processing_channel = GetRecvChannelNum(ssrc); if (processing_channel == -1) { // Allocate an unsignalled recv channel for processing in conference mode. - if (!InConferenceMode() || - !CreateUnsignalledRecvChannel(ssrc, &processing_channel)) { + if (!InConferenceMode()) { // If we cant find or allocate one, use the default. processing_channel = video_channel(); + } else if (!CreateUnsignalledRecvChannel(ssrc, &processing_channel)) { + // If we cant create an unsignalled recv channel, drop the packet in + // conference mode. + return; } } @@ -3149,11 +3152,9 @@ bool WebRtcVideoMediaChannel::CreateChannel(uint32 ssrc_key, bool WebRtcVideoMediaChannel::CreateUnsignalledRecvChannel( uint32 ssrc_key, int* out_channel_id) { - int unsignalled_recv_channel_limit = 0; - // TODO(tvsriram): Enable this once we fix handling packets - // in default channel with unsignalled recv. - // options_.unsignalled_recv_stream_limit.GetWithDefaultIfUnset( - // kNumDefaultUnsignalledVideoRecvStreams); + int unsignalled_recv_channel_limit = + options_.unsignalled_recv_stream_limit.GetWithDefaultIfUnset( + kNumDefaultUnsignalledVideoRecvStreams); if (num_unsignalled_recv_channels_ >= unsignalled_recv_channel_limit) { return false; } diff --git a/talk/media/webrtc/webrtcvideoengine_unittest.cc b/talk/media/webrtc/webrtcvideoengine_unittest.cc index d00fb2de3..9860a8403 100644 --- a/talk/media/webrtc/webrtcvideoengine_unittest.cc +++ b/talk/media/webrtc/webrtcvideoengine_unittest.cc @@ -2095,30 +2095,26 @@ TEST_F(WebRtcVideoMediaChannelTest, TwoStreamsReUseFirstStream) { 0)); } -// TODO(tvsriram): Fix these tests with unsignalled recv before adding again. -TEST_F(WebRtcVideoMediaChannelTest, DISABLED_TwoStreamsSendAndUnsignalledRecv) { +TEST_F(WebRtcVideoMediaChannelTest, TwoStreamsSendAndUnsignalledRecv) { Base::TwoStreamsSendAndUnsignalledRecv(cricket::VideoCodec(100, "VP8", 640, 400, 30, 0)); } -// TODO(tvsriram): Fix these tests with unsignalled recv before adding again. TEST_F(WebRtcVideoMediaChannelTest, - DISABLED_TwoStreamsSendAndFailUnsignalledRecv) { + TwoStreamsSendAndFailUnsignalledRecv) { webrtc::Trace::set_level_filter(webrtc::kTraceAll); Base::TwoStreamsSendAndFailUnsignalledRecv( cricket::VideoCodec(100, "VP8", 640, 400, 30, 0)); } -// TODO(tvsriram): Fix these tests with unsignalled recv before adding again. TEST_F(WebRtcVideoMediaChannelTest, - DISABLED_TwoStreamsSendAndFailUnsignalledRecvInOneToOne) { + TwoStreamsSendAndFailUnsignalledRecvInOneToOne) { Base::TwoStreamsSendAndFailUnsignalledRecvInOneToOne( cricket::VideoCodec(100, "VP8", 640, 400, 30, 0)); } -// TODO(tvsriram): Fix these tests with unsignalled recv before adding again. TEST_F(WebRtcVideoMediaChannelTest, - DISABLED_TwoStreamsAddAndRemoveUnsignalledRecv) { + TwoStreamsAddAndRemoveUnsignalledRecv) { Base::TwoStreamsAddAndRemoveUnsignalledRecv(cricket::VideoCodec(100, "VP8", 640, 400, 30, 0));