From 5a7507f26af65222bfee8eb0d386ba68d48534e3 Mon Sep 17 00:00:00 2001 From: "mflodman@webrtc.org" Date: Wed, 12 Sep 2012 13:47:06 +0000 Subject: [PATCH] Add API for transmission smotthening. BUG=818 TEST=Only API tests added now. Review URL: https://webrtc-codereview.appspot.com/787009 git-svn-id: http://webrtc.googlecode.com/svn/trunk@2756 4adac7df-926f-26a2-2b94-8c16560cd09d --- src/video_engine/include/vie_rtp_rtcp.h | 8 ++++++++ .../auto_test/source/vie_autotest_rtp_rtcp.cc | 13 ++++++++++++- src/video_engine/vie_channel.cc | 12 ++++++++++++ src/video_engine/vie_channel.h | 1 + src/video_engine/vie_rtp_rtcp_impl.cc | 19 +++++++++++++++++++ src/video_engine/vie_rtp_rtcp_impl.h | 1 + 6 files changed, 53 insertions(+), 1 deletion(-) diff --git a/src/video_engine/include/vie_rtp_rtcp.h b/src/video_engine/include/vie_rtp_rtcp.h index 15eef355cf..f19171d683 100644 --- a/src/video_engine/include/vie_rtp_rtcp.h +++ b/src/video_engine/include/vie_rtp_rtcp.h @@ -219,6 +219,14 @@ class WEBRTC_DLLEXPORT ViERTP_RTCP { bool enable, int id) = 0; + // Enables transmission smoothening, i.e. packets belonging to the same frame + // will be sent over a longer period of time instead of sending them + // back-to-back. + // NOTE: This is still experimental functionality. + // TODO(mflodman) Remove this note when BUG=818 is closed. + virtual int SetTransmissionSmoothingStatus(int video_channel, + bool enable) = 0; + // This function returns our locally created statistics of the received RTP // stream. virtual int GetReceivedRTCPStatistics( diff --git a/src/video_engine/test/auto_test/source/vie_autotest_rtp_rtcp.cc b/src/video_engine/test/auto_test/source/vie_autotest_rtp_rtcp.cc index 98e95079e4..0054830111 100644 --- a/src/video_engine/test/auto_test/source/vie_autotest_rtp_rtcp.cc +++ b/src/video_engine/test/auto_test/source/vie_autotest_rtp_rtcp.cc @@ -648,7 +648,18 @@ void ViEAutoTest::ViERtpRtcpAPITest() EXPECT_EQ(0, ViE.rtp_rtcp->SetReceiveTimestampOffsetStatus( tbChannel.videoChannel, false, 3)); - + // Transmission smoothening. + const int invalid_channel_id = 17; + EXPECT_EQ(-1, ViE.rtp_rtcp->SetTransmissionSmoothingStatus( + invalid_channel_id, true)); + EXPECT_EQ(0, ViE.rtp_rtcp->SetTransmissionSmoothingStatus( + tbChannel.videoChannel, true)); + EXPECT_EQ(0, ViE.rtp_rtcp->SetTransmissionSmoothingStatus( + tbChannel.videoChannel, true)); + EXPECT_EQ(0, ViE.rtp_rtcp->SetTransmissionSmoothingStatus( + tbChannel.videoChannel, false)); + EXPECT_EQ(0, ViE.rtp_rtcp->SetTransmissionSmoothingStatus( + tbChannel.videoChannel, false)); //*************************************************************** // Testing finished. Tear down Video Engine diff --git a/src/video_engine/vie_channel.cc b/src/video_engine/vie_channel.cc index 98ac6b17a6..1a259e4730 100644 --- a/src/video_engine/vie_channel.cc +++ b/src/video_engine/vie_channel.cc @@ -230,6 +230,7 @@ WebRtc_Word32 ViEChannel::SetSendCodec(const VideoCodec& video_codec, rtp_rtcp_->SetSendingStatus(false); } NACKMethod nack_method = rtp_rtcp_->NACK(); + bool transmission_smoothening = rtp_rtcp_->TransmissionSmoothingStatus(); CriticalSectionScoped cs(rtp_rtcp_cs_.get()); @@ -290,6 +291,7 @@ WebRtc_Word32 ViEChannel::SetSendCodec(const VideoCodec& video_codec, if (mtu_ != 0) { rtp_rtcp->SetMaxTransferUnit(mtu_); } + rtp_rtcp->SetTransmissionSmoothingStatus(transmission_smoothening); if (restart_rtp) { rtp_rtcp->SetSendingStatus(true); } @@ -685,6 +687,7 @@ bool ViEChannel::EnableRemb(bool enable) { } int ViEChannel::SetSendTimestampOffsetStatus(bool enable, int id) { + CriticalSectionScoped cs(rtp_rtcp_cs_.get()); int error = 0; if (enable) { // Enable the extension, but disable possible old id to avoid errors. @@ -724,6 +727,15 @@ int ViEChannel::SetReceiveTimestampOffsetStatus(bool enable, int id) { } } +void ViEChannel::SetTransmissionSmoothingStatus(bool enable) { + CriticalSectionScoped cs(rtp_rtcp_cs_.get()); + rtp_rtcp_->SetTransmissionSmoothingStatus(enable); + for (std::list::iterator it = simulcast_rtp_rtcp_.begin(); + it != simulcast_rtp_rtcp_.end(); ++it) { + (*it)->SetTransmissionSmoothingStatus(enable); + } +} + WebRtc_Word32 ViEChannel::EnableTMMBR(const bool enable) { WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(engine_id_, channel_id_), "%s: %d", __FUNCTION__, enable); diff --git a/src/video_engine/vie_channel.h b/src/video_engine/vie_channel.h index f9c7b8d7fa..bdf03fd566 100644 --- a/src/video_engine/vie_channel.h +++ b/src/video_engine/vie_channel.h @@ -109,6 +109,7 @@ class ViEChannel bool EnableRemb(bool enable); int SetSendTimestampOffsetStatus(bool enable, int id); int SetReceiveTimestampOffsetStatus(bool enable, int id); + void SetTransmissionSmoothingStatus(bool enable); WebRtc_Word32 EnableTMMBR(const bool enable); WebRtc_Word32 EnableKeyFrameRequestCallback(const bool enable); diff --git a/src/video_engine/vie_rtp_rtcp_impl.cc b/src/video_engine/vie_rtp_rtcp_impl.cc index b4b4746948..8a444df113 100644 --- a/src/video_engine/vie_rtp_rtcp_impl.cc +++ b/src/video_engine/vie_rtp_rtcp_impl.cc @@ -660,6 +660,25 @@ int ViERTP_RTCPImpl::SetReceiveTimestampOffsetStatus(int video_channel, return 0; } +int ViERTP_RTCPImpl::SetTransmissionSmoothingStatus(int video_channel, + bool enable) { + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, + ViEId(shared_data_->instance_id(), video_channel), + "%s(channel: %d, enble: %d)", __FUNCTION__, video_channel, + enable); + ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); + ViEChannel* vie_channel = cs.Channel(video_channel); + if (!vie_channel) { + WEBRTC_TRACE(kTraceError, kTraceVideo, + ViEId(shared_data_->instance_id(), video_channel), + "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); + shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); + return -1; + } + vie_channel->SetTransmissionSmoothingStatus(enable); + return 0; +} + int ViERTP_RTCPImpl::GetReceivedRTCPStatistics(const int video_channel, uint16_t& fraction_lost, unsigned int& cumulative_lost, diff --git a/src/video_engine/vie_rtp_rtcp_impl.h b/src/video_engine/vie_rtp_rtcp_impl.h index 7c1614b9d6..35db129325 100644 --- a/src/video_engine/vie_rtp_rtcp_impl.h +++ b/src/video_engine/vie_rtp_rtcp_impl.h @@ -74,6 +74,7 @@ class ViERTP_RTCPImpl virtual int SetReceiveTimestampOffsetStatus(int video_channel, bool enable, int id); + virtual int SetTransmissionSmoothingStatus(int video_channel, bool enable); virtual int GetReceivedRTCPStatistics(const int video_channel, uint16_t& fraction_lost, unsigned int& cumulative_lost,