diff --git a/src/modules/interface/module.h b/src/modules/interface/module.h index 37e5027f15..55f849178d 100644 --- a/src/modules/interface/module.h +++ b/src/modules/interface/module.h @@ -19,9 +19,6 @@ namespace webrtc { class Module { public: - // Change the unique identifier of this object. - virtual int32_t ChangeUniqueId(const int32_t id) = 0; - // Returns the number of milliseconds until the module want a worker // thread to call Process. virtual int32_t TimeUntilNextProcess() = 0; diff --git a/src/modules/rtp_rtcp/interface/rtp_rtcp.h b/src/modules/rtp_rtcp/interface/rtp_rtcp.h index eb6c8e325a..c1f9a4a2a6 100644 --- a/src/modules/rtp_rtcp/interface/rtp_rtcp.h +++ b/src/modules/rtp_rtcp/interface/rtp_rtcp.h @@ -13,122 +13,75 @@ #include -#include "module.h" -#include "rtp_rtcp_defines.h" +#include "modules/interface/module.h" +#include "modules/rtp_rtcp/interface/rtp_rtcp_defines.h" namespace webrtc { // forward declaration class Transport; -class RtpRtcp : public Module -{ -public: - /* - * create a RTP/RTCP module object using the system clock - * - * id - unique identifier of this RTP/RTCP module object - * audio - true for a audio version of the RTP/RTCP module object false will create a video version +class RtpRtcp : public Module { + public: + struct Configuration { + Configuration() + : id(-1), + audio(false), + clock(NULL), + default_module(NULL), + incoming_data(NULL), + incoming_messages(NULL), + outgoing_transport(NULL), + rtcp_feedback(NULL), + intra_frame_callback(NULL), + bandwidth_callback(NULL), + audio_messages(NULL), + bitrate_observer(NULL) { + } + /* id - Unique identifier of this RTP/RTCP module object + * audio - True for a audio version of the RTP/RTCP module + * object false will create a video version + * clock - The clock to use to read time. If NULL object + * will be using the system clock. + * incoming_data - Callback object that will receive the incoming + * data + * incoming_messages - Callback object that will receive the incoming + * RTP messages. + * outgoing_transport - Transport object that will be called when packets + * are ready to be sent out on the network + * rtcp_feedback - Callback object that will receive the incoming + * RTP messages. + * intra_frame_callback - Called when the receiver request a intra frame. + * bandwidth_callback - Called when we receive a changed estimate from + * the receiver of out stream. + * audio_messages - Telehone events. + * bitrate_observer - Called when the estimate of the incoming RTP + * stream changes. */ - static RtpRtcp* CreateRtpRtcp(const WebRtc_Word32 id, - const bool audio); + int32_t id; + bool audio; + RtpRtcpClock* clock; + RtpRtcp* default_module; + RtpData* incoming_data; + RtpFeedback* incoming_messages; + Transport* outgoing_transport; + RtcpFeedback* rtcp_feedback; + RtcpIntraFrameObserver* intra_frame_callback; + RtcpBandwidthObserver* bandwidth_callback; + RtpAudioFeedback* audio_messages; + RtpRemoteBitrateObserver* bitrate_observer; + }; + /* + * Create a RTP/RTCP module object using the system clock. + * + * configuration - Configuration of the RTP/RTCP module. + */ + static RtpRtcp* CreateRtpRtcp(const RtpRtcp::Configuration& configuration); - /* - * create a RTP/RTCP module object - * - * id - unique identifier of this RTP/RTCP module object - * audio - true for a audio version of the RTP/RTCP module object - * false will create a video version - * clock - the clock to use to read time; must not be NULL - */ - static RtpRtcp* CreateRtpRtcp(const WebRtc_Word32 id, - const bool audio, - RtpRtcpClock* clock); - - /* - * destroy a RTP/RTCP module object - * - * module - object to destroy - */ - static void DestroyRtpRtcp(RtpRtcp* module); - - /* - * Change the unique identifier of this object - * - * id - new unique identifier of this RTP/RTCP module object - */ - virtual WebRtc_Word32 ChangeUniqueId(const WebRtc_Word32 id) = 0; - - /* - * De-muxing functionality for conferencing - * - * register a module that will act as a default module for this module - * used for feedback messages back to the encoder when one encoded stream - * is sent to multiple destinations - * - * module - default module - */ - virtual WebRtc_Word32 RegisterDefaultModule(RtpRtcp* module) = 0; - - /* - * unregister the default module - * will stop the demuxing feedback - */ - virtual WebRtc_Word32 DeRegisterDefaultModule() = 0; - - /* - * returns true if a default module is registered, false otherwise - */ - virtual bool DefaultModuleRegistered() = 0; - - /* - * returns number of registered child modules - */ - virtual WebRtc_UWord32 NumberChildModules() = 0; - - /* - * Lip-sync between voice-video - * - * module - audio module - * - * Note: only allowed on a video module - */ - virtual WebRtc_Word32 RegisterSyncModule(RtpRtcp* module) = 0; - - /* - * Turn off lip-sync between voice-video - */ - virtual WebRtc_Word32 DeRegisterSyncModule() = 0; - - /************************************************************************** - * - * Receiver functions - * - ***************************************************************************/ - - /* - * Initialize receive side - * - * return -1 on failure else 0 - */ - virtual WebRtc_Word32 InitReceiver() = 0; - - /* - * Used by the module to deliver the incoming data to the codec module - * - * incomingDataCallback - callback object that will receive the incoming data - * - * return -1 on failure else 0 - */ - virtual WebRtc_Word32 RegisterIncomingDataCallback(RtpData* incomingDataCallback) = 0; - - /* - * Used by the module to deliver messages to the codec module/appliation - * - * incomingMessagesCallback - callback object that will receive the incoming messages - * - * return -1 on failure else 0 - */ - virtual WebRtc_Word32 RegisterIncomingRTPCallback(RtpFeedback* incomingMessagesCallback) = 0; + /************************************************************************** + * + * Receiver functions + * + ***************************************************************************/ /* * configure a RTP packet timeout value @@ -138,30 +91,35 @@ public: * * return -1 on failure else 0 */ - virtual WebRtc_Word32 SetPacketTimeout(const WebRtc_UWord32 RTPtimeoutMS, - const WebRtc_UWord32 RTCPtimeoutMS) = 0; + virtual WebRtc_Word32 SetPacketTimeout( + const WebRtc_UWord32 RTPtimeoutMS, + const WebRtc_UWord32 RTCPtimeoutMS) = 0; /* * Set periodic dead or alive notification * * enable - turn periodic dead or alive notification on/off - * sampleTimeSeconds - sample interval in seconds for dead or alive notifications + * sampleTimeSeconds - sample interval in seconds for dead or alive + * notifications * * return -1 on failure else 0 */ - virtual WebRtc_Word32 SetPeriodicDeadOrAliveStatus(const bool enable, - const WebRtc_UWord8 sampleTimeSeconds) = 0; + virtual WebRtc_Word32 SetPeriodicDeadOrAliveStatus( + const bool enable, + const WebRtc_UWord8 sampleTimeSeconds) = 0; /* * Get periodic dead or alive notification status * * enable - periodic dead or alive notification on/off - * sampleTimeSeconds - sample interval in seconds for dead or alive notifications + * sampleTimeSeconds - sample interval in seconds for dead or alive + * notifications * * return -1 on failure else 0 */ - virtual WebRtc_Word32 PeriodicDeadOrAliveStatus(bool &enable, - WebRtc_UWord8 &sampleTimeSeconds) = 0; + virtual WebRtc_Word32 PeriodicDeadOrAliveStatus( + bool& enable, + WebRtc_UWord8& sampleTimeSeconds) = 0; /* * set voice codec name and payload type @@ -231,7 +189,8 @@ public: * * return -1 on failure else 0 */ - virtual WebRtc_Word32 EstimatedRemoteTimeStamp(WebRtc_UWord32& timestamp) const = 0; + virtual WebRtc_Word32 EstimatedRemoteTimeStamp( + WebRtc_UWord32& timestamp) const = 0; /* * Get incoming SSRC @@ -245,7 +204,8 @@ public: * * return -1 on failure else the number of valid entries in the list */ - virtual WebRtc_Word32 RemoteCSRCs( WebRtc_UWord32 arrOfCSRC[kRtpCsrcSize]) const = 0; + virtual WebRtc_Word32 RemoteCSRCs( + WebRtc_UWord32 arrOfCSRC[kRtpCsrcSize]) const = 0; /* * get the currently configured SSRC filter @@ -289,42 +249,12 @@ public: virtual WebRtc_Word32 IncomingPacket(const WebRtc_UWord8* incomingPacket, const WebRtc_UWord16 packetLength) = 0; - - /* - * Option when not using the RegisterSyncModule function - * - * Inform the module about the received audion NTP - * - * return -1 on failure else 0 - */ - virtual WebRtc_Word32 IncomingAudioNTP( - const WebRtc_UWord32 audioReceivedNTPsecs, - const WebRtc_UWord32 audioReceivedNTPfrac, - const WebRtc_UWord32 audioRTCPArrivalTimeSecs, - const WebRtc_UWord32 audioRTCPArrivalTimeFrac) = 0; - /************************************************************************** * * Sender * ***************************************************************************/ - /* - * Initialize send side - * - * return -1 on failure else 0 - */ - virtual WebRtc_Word32 InitSender() = 0; - - /* - * Used by the module to send RTP and RTCP packet to the network module - * - * outgoingTransport - transport object that will be called when packets are ready to be sent out on the network - * - * return -1 on failure else 0 - */ - virtual WebRtc_Word32 RegisterSendTransport(Transport* outgoingTransport) = 0; - /* * set MTU * @@ -340,18 +270,21 @@ public: * * TCP - true for TCP false UDP * IPv6 - true for IP version 6 false for version 4 - * authenticationOverhead - number of bytes to leave for an authentication header + * authenticationOverhead - number of bytes to leave for an + * authentication header * * return -1 on failure else 0 */ - virtual WebRtc_Word32 SetTransportOverhead(const bool TCP, - const bool IPV6, - const WebRtc_UWord8 authenticationOverhead = 0) = 0; + virtual WebRtc_Word32 SetTransportOverhead( + const bool TCP, + const bool IPV6, + const WebRtc_UWord8 authenticationOverhead = 0) = 0; /* * Get max payload length * - * A combination of the configuration MaxTransferUnit and TransportOverhead. + * A combination of the configuration MaxTransferUnit and + * TransportOverhead. * Does not account FEC/ULP/RED overhead if FEC is enabled. * Does not account for RTP headers */ @@ -360,7 +293,8 @@ public: /* * Get max data payload length * - * A combination of the configuration MaxTransferUnit, headers and TransportOverhead. + * A combination of the configuration MaxTransferUnit, headers and + * TransportOverhead. * Takes into account FEC/ULP/RED overhead if FEC is enabled. * Takes into account RTP headers */ @@ -490,7 +424,6 @@ public: const bool setSSRC, const WebRtc_UWord32 SSRC) = 0; - /* * Get status of sending RTX (RFC 4588) on a specific SSRC. */ @@ -540,14 +473,16 @@ public: WebRtc_UWord32* available_bandwidth) const = 0; /* - * Used by the codec module to deliver a video or audio frame for packetization + * Used by the codec module to deliver a video or audio frame for + * packetization. * * frameType - type of frame to send * payloadType - payload type of frame to send * timestamp - timestamp of frame to send * payloadData - payload buffer of frame to send * payloadSize - size of payload buffer to send - * fragmentation - fragmentation offset data for fragmented frames such as layers or RED + * fragmentation - fragmentation offset data for fragmented frames such + * as layers or RED * * return -1 on failure else 0 */ @@ -566,16 +501,6 @@ public: * ***************************************************************************/ - /* - * Register a callback objects that will receive callbacks for video - * related events such as an incoming key frame request and events that - * could indicate bandwidth overuse. - */ - virtual void RegisterRtcpObservers( - RtcpIntraFrameObserver* intraFrameCallback, - RtcpBandwidthObserver* bandwidthCallback, - RtcpFeedback* callback) = 0; - /* * Get RTCP status */ @@ -664,18 +589,21 @@ public: * * return -1 on failure else 0 */ - virtual WebRtc_Word32 SendRTCP(WebRtc_UWord32 rtcpPacketType = kRtcpReport) = 0; + virtual WebRtc_Word32 SendRTCP( + WebRtc_UWord32 rtcpPacketType = kRtcpReport) = 0; /* * Good state of RTP receiver inform sender */ - virtual WebRtc_Word32 SendRTCPReferencePictureSelection(const WebRtc_UWord64 pictureID) = 0; + virtual WebRtc_Word32 SendRTCPReferencePictureSelection( + const WebRtc_UWord64 pictureID) = 0; /* * Send a RTCP Slice Loss Indication (SLI) * 6 least significant bits of pictureID */ - virtual WebRtc_Word32 SendRTCPSliceLossIndication(const WebRtc_UWord8 pictureID) = 0; + virtual WebRtc_Word32 SendRTCPSliceLossIndication( + const WebRtc_UWord8 pictureID) = 0; /* * Reset RTP statistics @@ -689,11 +617,12 @@ public: * * return -1 on failure else 0 */ - virtual WebRtc_Word32 StatisticsRTP(WebRtc_UWord8 *fraction_lost, // scale 0 to 255 - WebRtc_UWord32 *cum_lost, // number of lost packets - WebRtc_UWord32 *ext_max, // highest sequence number received - WebRtc_UWord32 *jitter, - WebRtc_UWord32 *max_jitter = NULL) const = 0; + virtual WebRtc_Word32 StatisticsRTP( + WebRtc_UWord8* fraction_lost, // scale 0 to 255 + WebRtc_UWord32* cum_lost, // number of lost packets + WebRtc_UWord32* ext_max, // highest sequence number received + WebRtc_UWord32* jitter, + WebRtc_UWord32* max_jitter = NULL) const = 0; /* * Reset RTP data counters for the receiving side @@ -714,10 +643,11 @@ public: * * return -1 on failure else 0 */ - virtual WebRtc_Word32 DataCountersRTP(WebRtc_UWord32 *bytesSent, - WebRtc_UWord32 *packetsSent, - WebRtc_UWord32 *bytesReceived, - WebRtc_UWord32 *packetsReceived) const = 0; + virtual WebRtc_Word32 DataCountersRTP( + WebRtc_UWord32* bytesSent, + WebRtc_UWord32* packetsSent, + WebRtc_UWord32* bytesReceived, + WebRtc_UWord32* packetsReceived) const = 0; /* * Get received RTCP sender info * @@ -753,16 +683,18 @@ public: * * return -1 on failure else 0 */ - virtual WebRtc_Word32 SetRTCPApplicationSpecificData(const WebRtc_UWord8 subType, - const WebRtc_UWord32 name, - const WebRtc_UWord8* data, - const WebRtc_UWord16 length) = 0; + virtual WebRtc_Word32 SetRTCPApplicationSpecificData( + const WebRtc_UWord8 subType, + const WebRtc_UWord32 name, + const WebRtc_UWord8* data, + const WebRtc_UWord16 length) = 0; /* * (XR) VOIP metric * * return -1 on failure else 0 */ - virtual WebRtc_Word32 SetRTCPVoIPMetrics(const RTCPVoIPMetric* VoIPMetric) = 0; + virtual WebRtc_Word32 SetRTCPVoIPMetrics( + const RTCPVoIPMetric* VoIPMetric) = 0; /* * (REMB) Receiver Estimated Max Bitrate @@ -775,11 +707,6 @@ public: const WebRtc_UWord8 numberOfSSRC, const WebRtc_UWord32* SSRC) = 0; - // Registers an observer to call when the estimate of the incoming channel - // changes. - virtual bool SetRemoteBitrateObserver( - RtpRemoteBitrateObserver* observer) = 0; - /* * (IJ) Extended jitter report. */ @@ -839,11 +766,14 @@ public: const WebRtc_UWord16 size) = 0; /* - * Store the sent packets, needed to answer to a Negative acknowledgement requests + * Store the sent packets, needed to answer to a Negative acknowledgement + * requests * * return -1 on failure else 0 */ - virtual WebRtc_Word32 SetStorePacketsStatus(const bool enable, const WebRtc_UWord16 numberToStore = 200) = 0; + virtual WebRtc_Word32 SetStorePacketsStatus( + const bool enable, + const WebRtc_UWord16 numberToStore = 200) = 0; /************************************************************************** * @@ -852,27 +782,23 @@ public: ***************************************************************************/ /* - * RegisterAudioCallback + * set audio packet size, used to determine when it's time to send a DTMF + * packet in silence (CNG) * * return -1 on failure else 0 */ - virtual WebRtc_Word32 RegisterAudioCallback(RtpAudioFeedback* messagesCallback) = 0; - - /* - * set audio packet size, used to determine when it's time to send a DTMF packet in silence (CNG) - * - * return -1 on failure else 0 - */ - virtual WebRtc_Word32 SetAudioPacketSize(const WebRtc_UWord16 packetSizeSamples) = 0; + virtual WebRtc_Word32 SetAudioPacketSize( + const WebRtc_UWord16 packetSizeSamples) = 0; /* * Outband TelephoneEvent(DTMF) detection * * return -1 on failure else 0 */ - virtual WebRtc_Word32 SetTelephoneEventStatus(const bool enable, - const bool forwardToDecoder, - const bool detectEndOfTone = false) = 0; + virtual WebRtc_Word32 SetTelephoneEventStatus( + const bool enable, + const bool forwardToDecoder, + const bool detectEndOfTone = false) = 0; /* * Is outband TelephoneEvent(DTMF) turned on/off? @@ -888,55 +814,61 @@ public: /* * SendTelephoneEventActive * - * return true if we currently send a telephone event and 100 ms after an event is sent - * used to prevent teh telephone event tone to be recorded by the microphone and send inband - * just after the tone has ended + * return true if we currently send a telephone event and 100 ms after an + * event is sent used to prevent the telephone event tone to be recorded + * by the microphone and send inband just after the tone has ended. */ - virtual bool SendTelephoneEventActive(WebRtc_Word8& telephoneEvent) const = 0; + virtual bool SendTelephoneEventActive( + WebRtc_Word8& telephoneEvent) const = 0; /* * Send a TelephoneEvent tone using RFC 2833 (4733) * * return -1 on failure else 0 */ - virtual WebRtc_Word32 SendTelephoneEventOutband(const WebRtc_UWord8 key, - const WebRtc_UWord16 time_ms, - const WebRtc_UWord8 level) = 0; + virtual WebRtc_Word32 SendTelephoneEventOutband( + const WebRtc_UWord8 key, + const WebRtc_UWord16 time_ms, + const WebRtc_UWord8 level) = 0; /* * Set payload type for Redundant Audio Data RFC 2198 * * return -1 on failure else 0 */ - virtual WebRtc_Word32 SetSendREDPayloadType(const WebRtc_Word8 payloadType) = 0; + virtual WebRtc_Word32 SetSendREDPayloadType( + const WebRtc_Word8 payloadType) = 0; /* * Get payload type for Redundant Audio Data RFC 2198 * * return -1 on failure else 0 */ - virtual WebRtc_Word32 SendREDPayloadType(WebRtc_Word8& payloadType) const = 0; + virtual WebRtc_Word32 SendREDPayloadType( + WebRtc_Word8& payloadType) const = 0; /* * Set status and ID for header-extension-for-audio-level-indication. - * See https://datatracker.ietf.org/doc/draft-lennox-avt-rtp-audio-level-exthdr/ - * for more details. + * See http://tools.ietf.org/html/rfc6464 for more details. * * return -1 on failure else 0 */ - virtual WebRtc_Word32 SetRTPAudioLevelIndicationStatus(const bool enable, - const WebRtc_UWord8 ID) = 0; + virtual WebRtc_Word32 SetRTPAudioLevelIndicationStatus( + const bool enable, + const WebRtc_UWord8 ID) = 0; /* * Get status and ID for header-extension-for-audio-level-indication. * * return -1 on failure else 0 */ - virtual WebRtc_Word32 GetRTPAudioLevelIndicationStatus(bool& enable, - WebRtc_UWord8& ID) const = 0; + virtual WebRtc_Word32 GetRTPAudioLevelIndicationStatus( + bool& enable, + WebRtc_UWord8& ID) const = 0; /* - * Store the audio level in dBov for header-extension-for-audio-level-indication. + * Store the audio level in dBov for header-extension-for-audio-level- + * indication. * This API shall be called before transmision of an RTP packet to ensure * that the |level| part of the extended RTP header is updated. * @@ -967,9 +899,10 @@ public: * * return -1 on failure else 0 */ - virtual WebRtc_Word32 SetGenericFECStatus(const bool enable, - const WebRtc_UWord8 payloadTypeRED, - const WebRtc_UWord8 payloadTypeFEC) = 0; + virtual WebRtc_Word32 SetGenericFECStatus( + const bool enable, + const WebRtc_UWord8 payloadTypeRED, + const WebRtc_UWord8 payloadTypeFEC) = 0; /* * Get generic FEC setting @@ -977,8 +910,8 @@ public: * return -1 on failure else 0 */ virtual WebRtc_Word32 GenericFECStatus(bool& enable, - WebRtc_UWord8& payloadTypeRED, - WebRtc_UWord8& payloadTypeFEC) = 0; + WebRtc_UWord8& payloadTypeRED, + WebRtc_UWord8& payloadTypeFEC) = 0; virtual WebRtc_Word32 SetFecParameters( @@ -990,7 +923,8 @@ public: * * return -1 on failure else 0 */ - virtual WebRtc_Word32 SetKeyFrameRequestMethod(const KeyFrameRequestMethod method) = 0; + virtual WebRtc_Word32 SetKeyFrameRequestMethod( + const KeyFrameRequestMethod method) = 0; /* * send a request for a keyframe diff --git a/src/modules/rtp_rtcp/interface/rtp_rtcp_defines.h b/src/modules/rtp_rtcp/interface/rtp_rtcp_defines.h index 3b6b4a8ef7..110b08c2b1 100644 --- a/src/modules/rtp_rtcp/interface/rtp_rtcp_defines.h +++ b/src/modules/rtp_rtcp/interface/rtp_rtcp_defines.h @@ -139,10 +139,6 @@ protected: class RtcpFeedback { public: - // if audioVideoOffset > 0 video is behind audio - virtual void OnLipSyncUpdate(const WebRtc_Word32 /*id*/, - const WebRtc_Word32 /*audioVideoOffset*/) {}; - virtual void OnApplicationDataReceived(const WebRtc_Word32 /*id*/, const WebRtc_UWord8 /*subType*/, const WebRtc_UWord32 /*name*/, diff --git a/src/modules/rtp_rtcp/source/Bitrate.h b/src/modules/rtp_rtcp/source/Bitrate.h index ab5637b22b..3859aaa3a8 100644 --- a/src/modules/rtp_rtcp/source/Bitrate.h +++ b/src/modules/rtp_rtcp/source/Bitrate.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -25,9 +25,6 @@ class Bitrate public: Bitrate(RtpRtcpClock* clock); - // initialize members - void Init(); - // calculate rates void Process(); diff --git a/src/modules/rtp_rtcp/source/bitrate.cc b/src/modules/rtp_rtcp/source/bitrate.cc index be0c7dd544..0fbb7ad3b0 100644 --- a/src/modules/rtp_rtcp/source/bitrate.cc +++ b/src/modules/rtp_rtcp/source/bitrate.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -28,21 +28,6 @@ Bitrate::Bitrate(RtpRtcpClock* clock) : memset(_bitrateArray, 0, sizeof(_bitrateArray)); } -void -Bitrate::Init() -{ - _packetRate = 0; - _bitrate = 0; - _timeLastRateUpdate = 0; - _bytesCount = 0; - _packetCount = 0; - _bitrateNextIdx = 0; - - memset(_packetRateArray, 0, sizeof(_packetRateArray)); - memset(_bitrateDiffMS, 0, sizeof(_bitrateDiffMS)); - memset(_bitrateArray, 0, sizeof(_bitrateArray)); -} - void Bitrate::Update(const WebRtc_Word32 bytes) { diff --git a/src/modules/rtp_rtcp/source/rtcp_format_remb_unittest.cc b/src/modules/rtp_rtcp/source/rtcp_format_remb_unittest.cc index 9fdd6ca4c8..d937f3510b 100644 --- a/src/modules/rtp_rtcp/source/rtcp_format_remb_unittest.cc +++ b/src/modules/rtp_rtcp/source/rtcp_format_remb_unittest.cc @@ -70,7 +70,11 @@ class RtcpFormatRembTest : public ::testing::Test { void RtcpFormatRembTest::SetUp() { system_clock_ = ModuleRTPUtility::GetSystemClock(); - dummy_rtp_rtcp_impl_ = new ModuleRtpRtcpImpl(0, false, system_clock_); + RtpRtcp::Configuration configuration; + configuration.id = 0; + configuration.audio = false; + configuration.clock = system_clock_; + dummy_rtp_rtcp_impl_ = new ModuleRtpRtcpImpl(configuration); rtcp_sender_ = new RTCPSender(0, false, system_clock_, dummy_rtp_rtcp_impl_); rtcp_receiver_ = new RTCPReceiver(0, system_clock_, dummy_rtp_rtcp_impl_); test_transport_ = new TestTransport(rtcp_receiver_); diff --git a/src/modules/rtp_rtcp/source/rtcp_receiver.cc b/src/modules/rtp_rtcp/source/rtcp_receiver.cc index 2fc7c8393a..d9365e953f 100644 --- a/src/modules/rtp_rtcp/source/rtcp_receiver.cc +++ b/src/modules/rtp_rtcp/source/rtcp_receiver.cc @@ -165,9 +165,6 @@ WebRtc_Word32 RTCPReceiver::RTT(const WebRtc_UWord32 remoteSSRC, GetReportBlockInformation(remoteSSRC); if (reportBlock == NULL) { - WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id, - "\tfailed to GetReportBlockInformation(%u)", - remoteSSRC); return -1; } if (RTT) { @@ -202,16 +199,6 @@ int RTCPReceiver::SetRTT(WebRtc_UWord16 rtt) { return 0; } -void -RTCPReceiver::UpdateLipSync(const WebRtc_Word32 audioVideoOffset) const -{ - CriticalSectionScoped lock(_criticalSectionFeedbacks); - if(_cbRtcpFeedback) - { - _cbRtcpFeedback->OnLipSyncUpdate(_id,audioVideoOffset); - } -}; - WebRtc_Word32 RTCPReceiver::NTP(WebRtc_UWord32 *ReceivedNTPsecs, WebRtc_UWord32 *ReceivedNTPfrac, @@ -1247,9 +1234,6 @@ void RTCPReceiver::TriggerCallbacksFromRTCPPacket( // Might trigger a OnReceivedBandwidthEstimateUpdate. UpdateTMMBR(); } - if (rtcpPacketInformation.rtcpPacketTypeFlags & kRtcpSr) { - _rtpRtcp.OnReceivedNTP(); - } if (rtcpPacketInformation.rtcpPacketTypeFlags & kRtcpSrReq) { _rtpRtcp.OnRequestSendReport(); } diff --git a/src/modules/rtp_rtcp/source/rtcp_receiver.h b/src/modules/rtp_rtcp/source/rtcp_receiver.h index 294e67df6c..df2d18b4cb 100644 --- a/src/modules/rtp_rtcp/source/rtcp_receiver.h +++ b/src/modules/rtp_rtcp/source/rtcp_receiver.h @@ -76,8 +76,6 @@ public: WebRtc_Word32 ResetRTT(const WebRtc_UWord32 remoteSSRC); - void UpdateLipSync(const WebRtc_Word32 audioVideoOffset) const; - WebRtc_Word32 SenderInfoReceived(RTCPSenderInfo* senderInfo) const; // get statistics diff --git a/src/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc b/src/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc index 5bfdb7344d..9598a43318 100644 --- a/src/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc +++ b/src/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc @@ -151,10 +151,12 @@ class FakeSystemClock : public RtpRtcpClock { class TestTransport : public Transport, public RtpData { public: - explicit TestTransport(RTCPReceiver* rtcp_receiver) : - rtcp_receiver_(rtcp_receiver) { + explicit TestTransport() + : rtcp_receiver_(NULL) { + } + void SetRTCPReceiver(RTCPReceiver* rtcp_receiver) { + rtcp_receiver_ = rtcp_receiver; } - virtual int SendPacket(int /*ch*/, const void* /*data*/, int /*len*/) { ADD_FAILURE(); // FAIL() gives a compile error. return -1; @@ -180,10 +182,15 @@ class RtcpReceiverTest : public ::testing::Test { RtcpReceiverTest() { // system_clock_ = ModuleRTPUtility::GetSystemClock(); system_clock_ = new FakeSystemClock(); - rtp_rtcp_impl_ = new ModuleRtpRtcpImpl(0, false, system_clock_); + test_transport_ = new TestTransport(); + RtpRtcp::Configuration configuration; + configuration.id = 0; + configuration.audio = false; + configuration.clock = system_clock_; + configuration.outgoing_transport = test_transport_; + rtp_rtcp_impl_ = new ModuleRtpRtcpImpl(configuration); rtcp_receiver_ = new RTCPReceiver(0, system_clock_, rtp_rtcp_impl_); - test_transport_ = new TestTransport(rtcp_receiver_); - EXPECT_EQ(0, rtp_rtcp_impl_->RegisterIncomingDataCallback(test_transport_)); + test_transport_->SetRTCPReceiver(rtcp_receiver_); } ~RtcpReceiverTest() { delete rtcp_receiver_; diff --git a/src/modules/rtp_rtcp/source/rtcp_sender_unittest.cc b/src/modules/rtp_rtcp/source/rtcp_sender_unittest.cc index 2d86682ba9..17fbafc72c 100644 --- a/src/modules/rtp_rtcp/source/rtcp_sender_unittest.cc +++ b/src/modules/rtp_rtcp/source/rtcp_sender_unittest.cc @@ -59,10 +59,12 @@ void CreateRtpPacket(const bool marker_bit, const WebRtc_UWord8 payload, class TestTransport : public Transport, public RtpData { public: - TestTransport(RTCPReceiver* rtcp_receiver) : - rtcp_receiver_(rtcp_receiver) { + TestTransport() + : rtcp_receiver_(NULL) { + } + void SetRTCPReceiver(RTCPReceiver* rtcp_receiver) { + rtcp_receiver_ = rtcp_receiver; } - virtual int SendPacket(int /*ch*/, const void* /*data*/, int /*len*/) { return -1; } @@ -83,8 +85,9 @@ class TestTransport : public Transport, virtual int OnReceivedPayloadData(const WebRtc_UWord8* payloadData, const WebRtc_UWord16 payloadSize, - const WebRtcRTPHeader* rtpHeader) - {return 0;} + const WebRtcRTPHeader* rtpHeader) { + return 0; + } RTCPReceiver* rtcp_receiver_; RTCPHelp::RTCPPacketInformation rtcp_packet_info_; }; @@ -93,14 +96,22 @@ class RtcpSenderTest : public ::testing::Test { protected: RtcpSenderTest() { system_clock_ = ModuleRTPUtility::GetSystemClock(); - rtp_rtcp_impl_ = new ModuleRtpRtcpImpl(0, false, system_clock_); + test_transport_ = new TestTransport(); + + RtpRtcp::Configuration configuration; + configuration.id = 0; + configuration.audio = false; + configuration.clock = system_clock_; + configuration.incoming_data = test_transport_; + configuration.outgoing_transport = test_transport_; + + rtp_rtcp_impl_ = new ModuleRtpRtcpImpl(configuration); rtcp_sender_ = new RTCPSender(0, false, system_clock_, rtp_rtcp_impl_); rtcp_receiver_ = new RTCPReceiver(0, system_clock_, rtp_rtcp_impl_); - test_transport_ = new TestTransport(rtcp_receiver_); + test_transport_->SetRTCPReceiver(rtcp_receiver_); // Initialize EXPECT_EQ(0, rtcp_sender_->Init()); EXPECT_EQ(0, rtcp_sender_->RegisterSendTransport(test_transport_)); - EXPECT_EQ(0, rtp_rtcp_impl_->RegisterIncomingDataCallback(test_transport_)); } ~RtcpSenderTest() { delete rtcp_sender_; diff --git a/src/modules/rtp_rtcp/source/rtp_receiver.cc b/src/modules/rtp_rtcp/source/rtp_receiver.cc index ef5e7218a0..40eb6b0aea 100644 --- a/src/modules/rtp_rtcp/source/rtp_receiver.cc +++ b/src/modules/rtp_rtcp/source/rtp_receiver.cc @@ -123,75 +123,6 @@ RTPReceiver::~RTPReceiver() { WEBRTC_TRACE(kTraceMemory, kTraceRtpRtcp, _id, "%s deleted", __FUNCTION__); } -void RTPReceiver::Init() { - CriticalSectionScoped lock(_criticalSectionRTPReceiver); - - _lastReceiveTime = 0; - _lastReceivedPayloadLength = 0; - _packetTimeOutMS = 0; - _lastReceivedPayloadType = -1; - _lastReceivedMediaPayloadType = -1; - _redPayloadType = -1; - - memset(&_lastReceivedAudioSpecific, 0, sizeof(_lastReceivedAudioSpecific)); - _lastReceivedAudioSpecific.channels = 1; - - _lastReceivedVideoSpecific.videoCodecType = kRtpNoVideo; - _lastReceivedVideoSpecific.maxRate = 0; - _SSRC = 0; - _numCSRCs = 0; - _numEnergy = 0; - _jitterQ4 = 0; - _jitterMaxQ4 = 0; - _cumulativeLoss = 0; - _jitterQ4TransmissionTimeOffset = 0; - _useSSRCFilter = false; - _SSRCFilter = 0; - - _localTimeLastReceivedTimestamp = 0; - _lastReceivedTimestamp = 0; - _lastReceivedSequenceNumber = 0; - _lastReceivedTransmissionTimeOffset = 0; - - _receivedSeqFirst = 0; - _receivedSeqMax = 0; - _receivedSeqWraps = 0; - - _receivedPacketOH = 12; // RTP header - _receivedByteCount = 0; - _receivedOldPacketCount = 0; - _receivedInorderPacketCount = 0; - - _lastReportInorderPackets = 0; - _lastReportOldPackets = 0; - _lastReportSeqMax = 0; - _lastReportFractionLost = 0; - _lastReportCumulativeLost = 0; - _lastReportExtendedHighSeqNum = 0; - _lastReportJitter = 0; - _lastReportJitterTransmissionTimeOffset = 0; - - _rtpHeaderExtensionMap.Erase(); - - while (!_payloadTypeMap.empty()) { - std::map::iterator it = _payloadTypeMap.begin(); - delete it->second; - _payloadTypeMap.erase(it); - } - - Bitrate::Init(); - RTPReceiverAudio::Init(); - RTPReceiverVideo::Init(); -} - -void -RTPReceiver::ChangeUniqueId(const WebRtc_Word32 id) -{ - _id = id; - RTPReceiverAudio::ChangeUniqueId(id); - RTPReceiverVideo::ChangeUniqueId(id); -} - RtpVideoCodecTypes RTPReceiver::VideoCodecType() const { diff --git a/src/modules/rtp_rtcp/source/rtp_receiver.h b/src/modules/rtp_rtcp/source/rtp_receiver.h index f283676989..d6ecfaaafa 100644 --- a/src/modules/rtp_rtcp/source/rtp_receiver.h +++ b/src/modules/rtp_rtcp/source/rtp_receiver.h @@ -39,10 +39,6 @@ public: virtual ~RTPReceiver(); - virtual void ChangeUniqueId(const WebRtc_Word32 id); - - void Init(); - RtpVideoCodecTypes VideoCodecType() const; WebRtc_UWord32 MaxConfiguredBitrate() const; diff --git a/src/modules/rtp_rtcp/source/rtp_receiver_audio.cc b/src/modules/rtp_rtcp/source/rtp_receiver_audio.cc index 1b870e27c2..a57da755fd 100644 --- a/src/modules/rtp_rtcp/source/rtp_receiver_audio.cc +++ b/src/modules/rtp_rtcp/source/rtp_receiver_audio.cc @@ -40,30 +40,6 @@ RTPReceiverAudio::~RTPReceiverAudio() delete _criticalSectionFeedback; } -WebRtc_Word32 RTPReceiverAudio::Init() { - _lastReceivedFrequency = 8000; - _telephoneEvent = false; - _telephoneEventForwardToDecoder = false; - _telephoneEventDetectEndOfTone = false; - _telephoneEventPayloadType = -1; - - _telephoneEventReported.clear(); - - _cngNBPayloadType = -1; - _cngWBPayloadType = -1; - _cngSWBPayloadType = -1; - _cngPayloadType = -1; - _G722PayloadType = -1; - _lastReceivedG722 = false; - return 0; -} - -void -RTPReceiverAudio::ChangeUniqueId(const WebRtc_Word32 id) -{ - _id = id; -} - WebRtc_Word32 RTPReceiverAudio::RegisterIncomingAudioCallback(RtpAudioFeedback* incomingMessagesCallback) { diff --git a/src/modules/rtp_rtcp/source/rtp_receiver_audio.h b/src/modules/rtp_rtcp/source/rtp_receiver_audio.h index 89cd062e91..0b0ba3015a 100644 --- a/src/modules/rtp_rtcp/source/rtp_receiver_audio.h +++ b/src/modules/rtp_rtcp/source/rtp_receiver_audio.h @@ -27,10 +27,6 @@ public: RTPReceiverAudio(const WebRtc_Word32 id); virtual ~RTPReceiverAudio(); - virtual void ChangeUniqueId(const WebRtc_Word32 id); - - WebRtc_Word32 Init(); - WebRtc_Word32 RegisterIncomingAudioCallback(RtpAudioFeedback* incomingMessagesCallback); ModuleRTPUtility::Payload* RegisterReceiveAudioPayload( diff --git a/src/modules/rtp_rtcp/source/rtp_receiver_video.cc b/src/modules/rtp_rtcp/source/rtp_receiver_video.cc index c5f99bd9ed..94d49e0588 100644 --- a/src/modules/rtp_rtcp/source/rtp_receiver_video.cc +++ b/src/modules/rtp_rtcp/source/rtp_receiver_video.cc @@ -58,16 +58,6 @@ RTPReceiverVideo::~RTPReceiverVideo() { delete _receiveFEC; } -void RTPReceiverVideo::Init() { - _currentFecFrameDecoded = false; - _packetOverHead = 28; - ResetOverUseDetector(); -} - -void RTPReceiverVideo::ChangeUniqueId(const WebRtc_Word32 id) { - _id = id; -} - ModuleRTPUtility::Payload* RTPReceiverVideo::RegisterReceiveVideoPayload( const char payloadName[RTP_PAYLOAD_NAME_SIZE], const WebRtc_Word8 payloadType, diff --git a/src/modules/rtp_rtcp/source/rtp_receiver_video.h b/src/modules/rtp_rtcp/source/rtp_receiver_video.h index f2e223e3f2..ce3229374e 100644 --- a/src/modules/rtp_rtcp/source/rtp_receiver_video.h +++ b/src/modules/rtp_rtcp/source/rtp_receiver_video.h @@ -32,10 +32,6 @@ class RTPReceiverVideo { virtual ~RTPReceiverVideo(); - virtual void ChangeUniqueId(const WebRtc_Word32 id); - - void Init(); - ModuleRTPUtility::Payload* RegisterReceiveVideoPayload( const char payloadName[RTP_PAYLOAD_NAME_SIZE], const WebRtc_Word8 payloadType, diff --git a/src/modules/rtp_rtcp/source/rtp_rtcp_impl.cc b/src/modules/rtp_rtcp/source/rtp_rtcp_impl.cc index 8906e208d8..e2ab811ca5 100644 --- a/src/modules/rtp_rtcp/source/rtp_rtcp_impl.cc +++ b/src/modules/rtp_rtcp/source/rtp_rtcp_impl.cc @@ -36,222 +36,103 @@ namespace webrtc { const WebRtc_UWord16 kDefaultRtt = 200; -RtpRtcp* RtpRtcp::CreateRtpRtcp(const WebRtc_Word32 id, - bool audio) { - if(audio) { - WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id, "CreateRtpRtcp(audio)"); +RtpRtcp* RtpRtcp::CreateRtpRtcp(const RtpRtcp::Configuration& configuration) { + if (configuration.clock) { + return new ModuleRtpRtcpImpl(configuration); } else { - WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id, "CreateRtpRtcp(video)"); - } - // ModuleRTPUtility::GetSystemClock() creates a new instance of a system - // clock implementation. The OwnsClock() function informs the module that - // it is responsible for deleting the instance. - ModuleRtpRtcpImpl* rtp_rtcp_instance = new ModuleRtpRtcpImpl(id, - audio, ModuleRTPUtility::GetSystemClock()); - rtp_rtcp_instance->OwnsClock(); - return rtp_rtcp_instance; -} - -RtpRtcp* RtpRtcp::CreateRtpRtcp(const WebRtc_Word32 id, - const bool audio, - RtpRtcpClock* clock) { - if (audio) { - WEBRTC_TRACE(kTraceModuleCall, - kTraceRtpRtcp, - id, - "CreateRtpRtcp(audio)"); - } else { - WEBRTC_TRACE(kTraceModuleCall, - kTraceRtpRtcp, - id, - "CreateRtpRtcp(video)"); - } - return new ModuleRtpRtcpImpl(id, audio, clock); -} - -void RtpRtcp::DestroyRtpRtcp(RtpRtcp* module) { - if (module) { - WEBRTC_TRACE(kTraceModuleCall, - kTraceRtpRtcp, - static_cast(module)->Id(), - "DestroyRtpRtcp()"); - delete static_cast(module); + RtpRtcp::Configuration configuration_copy; + memcpy(&configuration_copy, &configuration, + sizeof(RtpRtcp::Configuration)); + configuration_copy.clock = ModuleRTPUtility::GetSystemClock(); + ModuleRtpRtcpImpl* rtp_rtcp_instance = + new ModuleRtpRtcpImpl(configuration_copy); + rtp_rtcp_instance->OwnsClock(); + return rtp_rtcp_instance; } } -ModuleRtpRtcpImpl::ModuleRtpRtcpImpl(const WebRtc_Word32 id, - const bool audio, - RtpRtcpClock* clock): - _rtpSender(id, audio, clock), - _rtpReceiver(id, audio, clock, this), - _rtcpSender(id, audio, clock, this), - _rtcpReceiver(id, clock, this), - _owns_clock(false), - _clock(*clock), - _id(id), - _audio(audio), - _collisionDetected(false), - _lastProcessTime(clock->GetTimeInMS()), - _lastBitrateProcessTime(clock->GetTimeInMS()), - _lastPacketTimeoutProcessTime(clock->GetTimeInMS()), - _packetOverHead(28), // IPV4 UDP - _criticalSectionModulePtrs(CriticalSectionWrapper::CreateCriticalSection()), - _criticalSectionModulePtrsFeedback( - CriticalSectionWrapper::CreateCriticalSection()), - _defaultModule(NULL), - _audioModule(NULL), - _videoModule(NULL), - _deadOrAliveActive(false), - _deadOrAliveTimeoutMS(0), - _deadOrAliveLastTimer(0), - _receivedNTPsecsAudio(0), - _receivedNTPfracAudio(0), - _RTCPArrivalTimeSecsAudio(0), - _RTCPArrivalTimeFracAudio(0), - _nackMethod(kNackOff), - _nackLastTimeSent(0), - _nackLastSeqNumberSent(0), - _simulcast(false), - _keyFrameReqMethod(kKeyFrameReqFirRtp) +ModuleRtpRtcpImpl::ModuleRtpRtcpImpl(const Configuration& configuration) + : _rtpSender(configuration.id, configuration.audio, configuration.clock), + _rtpReceiver(configuration.id, configuration.audio, configuration.clock, + this), + _rtcpSender(configuration.id, configuration.audio, configuration.clock, + this), + _rtcpReceiver(configuration.id, configuration.clock, this), + _owns_clock(false), + _clock(*configuration.clock), + _id(configuration.id), + _audio(configuration.audio), + _collisionDetected(false), + _lastProcessTime(configuration.clock->GetTimeInMS()), + _lastBitrateProcessTime(configuration.clock->GetTimeInMS()), + _lastPacketTimeoutProcessTime(configuration.clock->GetTimeInMS()), + _packetOverHead(28), // IPV4 UDP + _criticalSectionModulePtrs( + CriticalSectionWrapper::CreateCriticalSection()), + _criticalSectionModulePtrsFeedback( + CriticalSectionWrapper::CreateCriticalSection()), + _defaultModule( + static_cast(configuration.default_module)), + _deadOrAliveActive(false), + _deadOrAliveTimeoutMS(0), + _deadOrAliveLastTimer(0), + _nackMethod(kNackOff), + _nackLastTimeSent(0), + _nackLastSeqNumberSent(0), + _simulcast(false), + _keyFrameReqMethod(kKeyFrameReqFirRtp) #ifdef MATLAB - , _plot1(NULL) + , _plot1(NULL) #endif { _sendVideoCodec.codecType = kVideoCodecUnknown; + + if (_defaultModule) { + _defaultModule->RegisterChildModule(this); + } + // TODO(pwestin) move to constructors of each rtp/rtcp sender/receiver object. + _rtpReceiver.RegisterIncomingDataCallback(configuration.incoming_data); + _rtpReceiver.RegisterIncomingRTPCallback(configuration.incoming_messages); + _rtcpReceiver.RegisterRtcpObservers(configuration.intra_frame_callback, + configuration.bandwidth_callback, + configuration.rtcp_feedback); + _rtpSender.RegisterAudioCallback(configuration.audio_messages); + _rtpReceiver.RegisterIncomingAudioCallback(configuration.audio_messages); + + _rtpSender.RegisterSendTransport(configuration.outgoing_transport); + _rtcpSender.RegisterSendTransport(configuration.outgoing_transport); + + _rtcpSender.SetRemoteBitrateObserver(configuration.bitrate_observer); + // make sure that RTCP objects are aware of our SSRC WebRtc_UWord32 SSRC = _rtpSender.SSRC(); _rtcpSender.SetSSRC(SSRC); - WEBRTC_TRACE(kTraceMemory, kTraceRtpRtcp, id, "%s created", __FUNCTION__); + WEBRTC_TRACE(kTraceMemory, kTraceRtpRtcp, _id, "%s created", __FUNCTION__); } ModuleRtpRtcpImpl::~ModuleRtpRtcpImpl() { WEBRTC_TRACE(kTraceMemory, kTraceRtpRtcp, _id, "%s deleted", __FUNCTION__); - // make sure to unregister this module from other modules + // All child modules MUST be deleted before deleting the default. + assert(_childModules.empty()); - const bool defaultInstance(_childModules.empty() ? false : true); - - if (defaultInstance) { - // deregister for the default module - // will go in to the child modules and remove it self - std::list::iterator it = _childModules.begin(); - while (it != _childModules.end()) { - RtpRtcp* module = *it; - _childModules.erase(it); - if (module) { - module->DeRegisterDefaultModule(); - } - it = _childModules.begin(); - } - } else { - // deregister for the child modules - // will go in to the default and remove it self - DeRegisterDefaultModule(); + // Deregister for the child modules + // will go in to the default and remove it self + if (_defaultModule) { + _defaultModule->DeRegisterChildModule(this); } - - if (_audio) { - DeRegisterVideoModule(); - } else { - DeRegisterSyncModule(); - } - #ifdef MATLAB if (_plot1) { eng.DeletePlot(_plot1); _plot1 = NULL; } #endif - - delete _criticalSectionModulePtrs; - delete _criticalSectionModulePtrsFeedback; if (_owns_clock) { delete &_clock; } } -WebRtc_Word32 ModuleRtpRtcpImpl::ChangeUniqueId(const WebRtc_Word32 id) { - WEBRTC_TRACE(kTraceModuleCall, - kTraceRtpRtcp, - _id, - "ChangeUniqueId(new id:%d)", id); - - _id = id; - - _rtpReceiver.ChangeUniqueId(id); - _rtcpReceiver.ChangeUniqueId(id); - _rtpSender.ChangeUniqueId(id); - _rtcpSender.ChangeUniqueId(id); - return 0; -} - -// default encoder that we need to multiplex out -WebRtc_Word32 ModuleRtpRtcpImpl::RegisterDefaultModule(RtpRtcp* module) { - WEBRTC_TRACE(kTraceModuleCall, - kTraceRtpRtcp, - _id, - "RegisterDefaultModule(module:0x%x)", module); - - if (module == NULL) { - return -1; - } - if (module == this) { - WEBRTC_TRACE(kTraceError, - kTraceRtpRtcp, - _id, - "RegisterDefaultModule can't register self as default"); - return -1; - } - CriticalSectionScoped lock(_criticalSectionModulePtrs); - - if (_defaultModule) { - _defaultModule->DeRegisterChildModule(this); - } - _defaultModule = (ModuleRtpRtcpImpl*)module; - _defaultModule->RegisterChildModule(this); - return 0; -} - -WebRtc_Word32 ModuleRtpRtcpImpl::DeRegisterDefaultModule() { - WEBRTC_TRACE(kTraceModuleCall, - kTraceRtpRtcp, - _id, - "DeRegisterDefaultModule()"); - - CriticalSectionScoped lock(_criticalSectionModulePtrs); - if (_defaultModule) { - _defaultModule->DeRegisterChildModule(this); - _defaultModule = NULL; - } - return 0; -} - -bool ModuleRtpRtcpImpl::DefaultModuleRegistered() { - WEBRTC_TRACE(kTraceModuleCall, - kTraceRtpRtcp, - _id, - "DefaultModuleRegistered()"); - - CriticalSectionScoped lock(_criticalSectionModulePtrs); - if (_defaultModule) { - return true; - } - return false; -} - -WebRtc_UWord32 ModuleRtpRtcpImpl::NumberChildModules() { - WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, _id, "NumberChildModules"); - - CriticalSectionScoped lock(_criticalSectionModulePtrs); - CriticalSectionScoped doubleLock(_criticalSectionModulePtrsFeedback); - // we use two locks for protecting _childModules one - // (_criticalSectionModulePtrsFeedback) for incoming messages - // (BitrateSent and UpdateTMMBR) and _criticalSectionModulePtrs for - // all outgoing messages sending packets etc - - return _childModules.size(); -} - void ModuleRtpRtcpImpl::RegisterChildModule(RtpRtcp* module) { WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, @@ -259,9 +140,9 @@ void ModuleRtpRtcpImpl::RegisterChildModule(RtpRtcp* module) { "RegisterChildModule(module:0x%x)", module); - CriticalSectionScoped lock(_criticalSectionModulePtrs); + CriticalSectionScoped lock(_criticalSectionModulePtrs.get()); - CriticalSectionScoped doubleLock(_criticalSectionModulePtrsFeedback); + CriticalSectionScoped doubleLock(_criticalSectionModulePtrsFeedback.get()); // we use two locks for protecting _childModules one // (_criticalSectionModulePtrsFeedback) for incoming // messages (BitrateSent) and _criticalSectionModulePtrs @@ -275,9 +156,9 @@ void ModuleRtpRtcpImpl::DeRegisterChildModule(RtpRtcp* removeModule) { _id, "DeRegisterChildModule(module:0x%x)", removeModule); - CriticalSectionScoped lock(_criticalSectionModulePtrs); + CriticalSectionScoped lock(_criticalSectionModulePtrs.get()); - CriticalSectionScoped doubleLock(_criticalSectionModulePtrsFeedback); + CriticalSectionScoped doubleLock(_criticalSectionModulePtrsFeedback.get()); std::list::iterator it = _childModules.begin(); while (it != _childModules.end()) { @@ -290,76 +171,6 @@ void ModuleRtpRtcpImpl::DeRegisterChildModule(RtpRtcp* removeModule) { } } -// Lip-sync between voice-video engine, -WebRtc_Word32 ModuleRtpRtcpImpl::RegisterSyncModule(RtpRtcp* audioModule) { - WEBRTC_TRACE(kTraceModuleCall, - kTraceRtpRtcp, - _id, - "RegisterSyncModule(module:0x%x)", - audioModule); - - if (audioModule == NULL) { - return -1; - } - if (_audio) { - return -1; - } - CriticalSectionScoped lock(_criticalSectionModulePtrs); - _audioModule = (ModuleRtpRtcpImpl*)audioModule; - return _audioModule->RegisterVideoModule(this); -} - -WebRtc_Word32 ModuleRtpRtcpImpl::DeRegisterSyncModule() { - WEBRTC_TRACE(kTraceModuleCall, - kTraceRtpRtcp, - _id, - "DeRegisterSyncModule()"); - - CriticalSectionScoped lock(_criticalSectionModulePtrs); - if (_audioModule) { - ModuleRtpRtcpImpl* audioModule = _audioModule; - _audioModule = NULL; - _receivedNTPsecsAudio = 0; - _receivedNTPfracAudio = 0; - _RTCPArrivalTimeSecsAudio = 0; - _RTCPArrivalTimeFracAudio = 0; - audioModule->DeRegisterVideoModule(); - } - return 0; -} - -WebRtc_Word32 ModuleRtpRtcpImpl::RegisterVideoModule(RtpRtcp* videoModule) { - WEBRTC_TRACE(kTraceModuleCall, - kTraceRtpRtcp, - _id, - "RegisterVideoModule(module:0x%x)", - videoModule); - - if (videoModule == NULL) { - return -1; - } - if (!_audio) { - return -1; - } - CriticalSectionScoped lock(_criticalSectionModulePtrs); - _videoModule = (ModuleRtpRtcpImpl*)videoModule; - return 0; -} - -void ModuleRtpRtcpImpl::DeRegisterVideoModule() { - WEBRTC_TRACE(kTraceModuleCall, - kTraceRtpRtcp, - _id, - "DeRegisterVideoModule()"); - - CriticalSectionScoped lock(_criticalSectionModulePtrs); - if (_videoModule) { - ModuleRtpRtcpImpl* videoModule = _videoModule; - _videoModule = NULL; - videoModule->DeRegisterSyncModule(); - } -} - // returns the number of milliseconds until the module want a worker thread // to call Process WebRtc_Word32 ModuleRtpRtcpImpl::TimeUntilNextProcess() { @@ -436,20 +247,6 @@ WebRtc_Word32 ModuleRtpRtcpImpl::Process() { * Receiver */ -WebRtc_Word32 ModuleRtpRtcpImpl::InitReceiver() { - WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, _id, "InitReceiver()"); - - _packetOverHead = 28; // default is IPV4 UDP - _receivedNTPsecsAudio = 0; - _receivedNTPfracAudio = 0; - _RTCPArrivalTimeSecsAudio = 0; - _RTCPArrivalTimeFracAudio = 0; - - _rtpReceiver.Init(); - _rtpReceiver.SetPacketOverHead(_packetOverHead); - return 0; -} - void ModuleRtpRtcpImpl::ProcessDeadOrAliveTimer() { if (_deadOrAliveActive) { const WebRtc_UWord32 now = _clock.GetTimeInMS(); @@ -687,7 +484,6 @@ WebRtc_Word32 ModuleRtpRtcpImpl::IncomingPacket( _id, "IncomingPacket(packetLength:%u)", incomingPacketLength); - // minimum RTP is 12 bytes // minimum RTCP is 8 bytes (RTCP BYE) if (incomingPacketLength < 8 || incomingPacket == NULL) { @@ -754,85 +550,10 @@ WebRtc_Word32 ModuleRtpRtcpImpl::IncomingPacket( } } -WebRtc_Word32 ModuleRtpRtcpImpl::IncomingAudioNTP( - const WebRtc_UWord32 audioReceivedNTPsecs, - const WebRtc_UWord32 audioReceivedNTPfrac, - const WebRtc_UWord32 audioRTCPArrivalTimeSecs, - const WebRtc_UWord32 audioRTCPArrivalTimeFrac) { - _receivedNTPsecsAudio = audioReceivedNTPsecs; - _receivedNTPfracAudio = audioReceivedNTPfrac; - _RTCPArrivalTimeSecsAudio = audioRTCPArrivalTimeSecs; - _RTCPArrivalTimeFracAudio = audioRTCPArrivalTimeFrac; - return 0; -} - -WebRtc_Word32 ModuleRtpRtcpImpl::RegisterIncomingDataCallback( - RtpData* incomingDataCallback) { - WEBRTC_TRACE(kTraceModuleCall, - kTraceRtpRtcp, - _id, - "RegisterIncomingDataCallback(incomingDataCallback:0x%x)", - incomingDataCallback); - - return _rtpReceiver.RegisterIncomingDataCallback(incomingDataCallback); -} - -WebRtc_Word32 ModuleRtpRtcpImpl::RegisterIncomingRTPCallback( - RtpFeedback* incomingMessagesCallback) { - WEBRTC_TRACE(kTraceModuleCall, - kTraceRtpRtcp, - _id, - "RegisterIncomingRTPCallback(incomingMessagesCallback:0x%x)", - incomingMessagesCallback); - - return _rtpReceiver.RegisterIncomingRTPCallback(incomingMessagesCallback); -} - -void ModuleRtpRtcpImpl::RegisterRtcpObservers( - RtcpIntraFrameObserver* intra_frame_callback, - RtcpBandwidthObserver* bandwidth_callback, - RtcpFeedback* feedback_callback) { - _rtcpReceiver.RegisterRtcpObservers(intra_frame_callback, bandwidth_callback, - feedback_callback); -} - -WebRtc_Word32 ModuleRtpRtcpImpl::RegisterAudioCallback( - RtpAudioFeedback* messagesCallback) { - WEBRTC_TRACE(kTraceModuleCall, - kTraceRtpRtcp, - _id, - "RegisterAudioCallback(messagesCallback:0x%x)", - messagesCallback); - - if (_rtpSender.RegisterAudioCallback(messagesCallback) == 0) { - return _rtpReceiver.RegisterIncomingAudioCallback(messagesCallback); - } - return -1; -} - /** * Sender */ -WebRtc_Word32 ModuleRtpRtcpImpl::InitSender() { - WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, _id, "InitSender()"); - - _collisionDetected = false; - - // if we are already receiving inform our sender to avoid collision - if (_rtpSender.Init(_rtpReceiver.SSRC()) != 0) { - return -1; - } - WebRtc_Word32 retVal = _rtcpSender.Init(); - - // make sure that RTCP objects are aware of our SSRC - // (it could have changed due to collision) - WebRtc_UWord32 SSRC = _rtpSender.SSRC(); - _rtcpReceiver.SetSSRC(SSRC); - _rtcpSender.SetSSRC(SSRC); - return retVal; -} - WebRtc_Word32 ModuleRtpRtcpImpl::RegisterSendPayload( const CodecInst& voiceCodec) { WEBRTC_TRACE(kTraceModuleCall, @@ -962,7 +683,7 @@ WebRtc_Word32 ModuleRtpRtcpImpl::SetCSRCs( if (defaultInstance) { // for default we need to update all child modules too - CriticalSectionScoped lock(_criticalSectionModulePtrs); + CriticalSectionScoped lock(_criticalSectionModulePtrs.get()); std::list::iterator it = _childModules.begin(); while (it != _childModules.end()) { @@ -1060,7 +781,7 @@ bool ModuleRtpRtcpImpl::SendingMedia() const { return _rtpSender.SendingMedia(); } - CriticalSectionScoped lock(_criticalSectionModulePtrs); + CriticalSectionScoped lock(_criticalSectionModulePtrs.get()); std::list::const_iterator it = _childModules.begin(); while (it != _childModules.end()) { RTPSender& rtpSender = (*it)->_rtpSender; @@ -1072,19 +793,6 @@ bool ModuleRtpRtcpImpl::SendingMedia() const { return false; } -WebRtc_Word32 ModuleRtpRtcpImpl::RegisterSendTransport( - Transport* outgoingTransport) { - WEBRTC_TRACE(kTraceModuleCall, - kTraceRtpRtcp, - _id, - "RegisterSendTransport(0x%x)", outgoingTransport); - - if (_rtpSender.RegisterSendTransport(outgoingTransport) == 0) { - return _rtcpSender.RegisterSendTransport(outgoingTransport); - } - return -1; -} - WebRtc_Word32 ModuleRtpRtcpImpl::SendOutgoingData( FrameType frameType, WebRtc_Word8 payloadType, @@ -1121,7 +829,7 @@ WebRtc_Word32 ModuleRtpRtcpImpl::SendOutgoingData( return -1; } int idx = 0; - CriticalSectionScoped lock(_criticalSectionModulePtrs); + CriticalSectionScoped lock(_criticalSectionModulePtrs.get()); std::list::iterator it = _childModules.begin(); for (; idx < rtpVideoHdr->simulcastIdx; idx++) { it++; @@ -1144,7 +852,7 @@ WebRtc_Word32 ModuleRtpRtcpImpl::SendOutgoingData( NULL, &(rtpVideoHdr->codecHeader)); } else { - CriticalSectionScoped lock(_criticalSectionModulePtrs); + CriticalSectionScoped lock(_criticalSectionModulePtrs.get()); // TODO(pwestin) remove codecInfo from SendOutgoingData VideoCodecInformation* codecInfo = NULL; @@ -1198,7 +906,7 @@ WebRtc_UWord16 ModuleRtpRtcpImpl::MaxDataPayloadLength() const { const bool defaultInstance(_childModules.empty() ? false : true); if (defaultInstance) { // for default we need to update all child modules too - CriticalSectionScoped lock(_criticalSectionModulePtrs); + CriticalSectionScoped lock(_criticalSectionModulePtrs.get()); std::list::const_iterator it = _childModules.begin(); while (it != _childModules.end()) { @@ -1563,11 +1271,6 @@ WebRtc_Word32 ModuleRtpRtcpImpl::SetREMBData(const WebRtc_UWord32 bitrate, return _rtcpSender.SetREMBData(bitrate, numberOfSSRC, SSRC); } -bool ModuleRtpRtcpImpl::SetRemoteBitrateObserver( - RtpRemoteBitrateObserver* observer) { - return _rtcpSender.SetRemoteBitrateObserver(observer); -} - /* * (IJ) Extended jitter report. */ @@ -1655,7 +1358,7 @@ NACKMethod ModuleRtpRtcpImpl::NACK() const { const bool defaultInstance(_childModules.empty() ? false : true); if (defaultInstance) { // for default we need to check all child modules too - CriticalSectionScoped lock(_criticalSectionModulePtrs); + CriticalSectionScoped lock(_criticalSectionModulePtrs.get()); std::list::const_iterator it = _childModules.begin(); while (it != _childModules.end()) { @@ -1918,7 +1621,7 @@ void ModuleRtpRtcpImpl::SetTargetSendBitrate(const uint32_t bitrate) { const bool haveChildModules(_childModules.empty() ? false : true); if (haveChildModules) { - CriticalSectionScoped lock(_criticalSectionModulePtrs); + CriticalSectionScoped lock(_criticalSectionModulePtrs.get()); if (_simulcast) { uint32_t bitrate_remainder = bitrate; std::list::iterator it = _childModules.begin(); @@ -1994,7 +1697,7 @@ WebRtc_Word32 ModuleRtpRtcpImpl::SetCameraDelay(const WebRtc_Word32 delayMS) { const bool defaultInstance(_childModules.empty() ? false : true); if (defaultInstance) { - CriticalSectionScoped lock(_criticalSectionModulePtrs); + CriticalSectionScoped lock(_criticalSectionModulePtrs.get()); std::list::iterator it = _childModules.begin(); while (it != _childModules.end()) { @@ -2041,7 +1744,7 @@ WebRtc_Word32 ModuleRtpRtcpImpl::GenericFECStatus( const bool defaultInstance(_childModules.empty() ? false : true); if (defaultInstance) { // for default we need to check all child modules too - CriticalSectionScoped lock(_criticalSectionModulePtrs); + CriticalSectionScoped lock(_criticalSectionModulePtrs.get()); std::list::iterator it = _childModules.begin(); while (it != _childModules.end()) { RtpRtcp* module = *it; @@ -2075,7 +1778,7 @@ WebRtc_Word32 ModuleRtpRtcpImpl::SetFecParameters( const bool defaultInstance(_childModules.empty() ? false : true); if (defaultInstance) { // for default we need to update all child modules too - CriticalSectionScoped lock(_criticalSectionModulePtrs); + CriticalSectionScoped lock(_criticalSectionModulePtrs.get()); std::list::iterator it = _childModules.begin(); while (it != _childModules.end()) { @@ -2128,7 +1831,7 @@ void ModuleRtpRtcpImpl::BitrateSent(WebRtc_UWord32* totalRate, if (defaultInstance) { // for default we need to update the send bitrate - CriticalSectionScoped lock(_criticalSectionModulePtrsFeedback); + CriticalSectionScoped lock(_criticalSectionModulePtrsFeedback.get()); if (totalRate != NULL) *totalRate = 0; @@ -2183,66 +1886,6 @@ int ModuleRtpRtcpImpl::EstimatedReceiveBandwidth( return 0; } -// for lip sync -void ModuleRtpRtcpImpl::OnReceivedNTP() { - // don't do anything if we are the audio module - // video module is responsible for sync - if (!_audio) { - WebRtc_Word32 diff = 0; - WebRtc_UWord32 receivedNTPsecs = 0; - WebRtc_UWord32 receivedNTPfrac = 0; - WebRtc_UWord32 RTCPArrivalTimeSecs = 0; - WebRtc_UWord32 RTCPArrivalTimeFrac = 0; - - if (0 == _rtcpReceiver.NTP(&receivedNTPsecs, - &receivedNTPfrac, - &RTCPArrivalTimeSecs, - &RTCPArrivalTimeFrac)) { - CriticalSectionScoped lock(_criticalSectionModulePtrs); - - if (_audioModule) { - if (0 != _audioModule->RemoteNTP(&_receivedNTPsecsAudio, - &_receivedNTPfracAudio, - &_RTCPArrivalTimeSecsAudio, - &_RTCPArrivalTimeFracAudio)) { - // failed ot get audio NTP - return; - } - } - if (_receivedNTPfracAudio != 0) { - // ReceivedNTPxxx is NTP at sender side when sent. - // RTCPArrivalTimexxx is NTP at receiver side when received. - // can't use ConvertNTPTimeToMS since calculation can be - // negative - - WebRtc_Word32 NTPdiff = (WebRtc_Word32) - ((_receivedNTPsecsAudio - receivedNTPsecs) * - 1000); // ms - NTPdiff += (WebRtc_Word32) - (_receivedNTPfracAudio / FracMS - receivedNTPfrac / FracMS); - - WebRtc_Word32 RTCPdiff = - static_cast ((_RTCPArrivalTimeSecsAudio - - RTCPArrivalTimeSecs) * 1000); - RTCPdiff += (WebRtc_Word32) - (_RTCPArrivalTimeFracAudio / FracMS - - RTCPArrivalTimeFrac / FracMS); - - diff = NTPdiff - RTCPdiff; - // if diff is + video is behind - if (diff < -1000 || diff > 1000) { - // unresonable ignore value. - diff = 0; - return; - } - } - } - // export via callback - // after release of critsect - _rtcpReceiver.UpdateLipSync(diff); - } -} - RateControlRegion ModuleRtpRtcpImpl::OnOverUseStateUpdate( const RateControlInput& rateControlInput) { diff --git a/src/modules/rtp_rtcp/source/rtp_rtcp_impl.h b/src/modules/rtp_rtcp/source/rtp_rtcp_impl.h index f71c9d234f..8724d78b3f 100644 --- a/src/modules/rtp_rtcp/source/rtp_rtcp_impl.h +++ b/src/modules/rtp_rtcp/source/rtp_rtcp_impl.h @@ -13,11 +13,12 @@ #include -#include "rtcp_receiver.h" -#include "rtcp_sender.h" -#include "rtp_receiver.h" -#include "rtp_rtcp.h" -#include "rtp_sender.h" +#include "modules/rtp_rtcp/interface/rtp_rtcp.h" +#include "modules/rtp_rtcp/source/rtcp_receiver.h" +#include "modules/rtp_rtcp/source/rtcp_sender.h" +#include "modules/rtp_rtcp/source/rtp_receiver.h" +#include "modules/rtp_rtcp/source/rtp_sender.h" +#include "system_wrappers/interface/scoped_ptr.h" #ifdef MATLAB class MatlabPlot; @@ -25,34 +26,12 @@ class MatlabPlot; namespace webrtc { -class ModuleRtpRtcpImpl : public RtpRtcp -{ -public: - ModuleRtpRtcpImpl(const WebRtc_Word32 id, - const bool audio, - RtpRtcpClock* clock); +class ModuleRtpRtcpImpl : public RtpRtcp { + public: + explicit ModuleRtpRtcpImpl(const RtpRtcp::Configuration& configuration); virtual ~ModuleRtpRtcpImpl(); - // get Module ID - WebRtc_Word32 Id() {return _id;} - - virtual WebRtc_Word32 ChangeUniqueId(const WebRtc_Word32 id); - - // De-muxing functionality for - virtual WebRtc_Word32 RegisterDefaultModule(RtpRtcp* module); - virtual WebRtc_Word32 DeRegisterDefaultModule(); - virtual bool DefaultModuleRegistered(); - - virtual WebRtc_UWord32 NumberChildModules(); - - // Lip-sync between voice-video - virtual WebRtc_Word32 RegisterSyncModule(RtpRtcp* module); - virtual WebRtc_Word32 DeRegisterSyncModule(); - - virtual WebRtc_Word32 RegisterVideoModule(RtpRtcp* videoModule); - virtual void DeRegisterVideoModule(); - // returns the number of milliseconds until the module want a worker thread to call Process virtual WebRtc_Word32 TimeUntilNextProcess(); @@ -62,8 +41,6 @@ public: /** * Receiver */ - virtual WebRtc_Word32 InitReceiver(); - // configure a timeout value virtual WebRtc_Word32 SetPacketTimeout(const WebRtc_UWord32 RTPtimeoutMS, const WebRtc_UWord32 RTCPtimeoutMS); @@ -125,31 +102,9 @@ public: virtual WebRtc_Word32 IncomingPacket( const WebRtc_UWord8* incomingPacket, const WebRtc_UWord16 packetLength); - virtual WebRtc_Word32 IncomingAudioNTP(const WebRtc_UWord32 audioReceivedNTPsecs, - const WebRtc_UWord32 audioReceivedNTPfrac, - const WebRtc_UWord32 audioRTCPArrivalTimeSecs, - const WebRtc_UWord32 audioRTCPArrivalTimeFrac); - - // Used by the module to deliver the incoming data to the codec module - virtual WebRtc_Word32 RegisterIncomingDataCallback( - RtpData* incomingDataCallback); - - // Used by the module to deliver messages to the codec module/appliation - virtual WebRtc_Word32 RegisterIncomingRTPCallback( - RtpFeedback* incomingMessagesCallback); - - virtual void RegisterRtcpObservers( - RtcpIntraFrameObserver* intraFrameCallback, - RtcpBandwidthObserver* bandwidthCallback, - RtcpFeedback* callback); - - virtual WebRtc_Word32 RegisterAudioCallback(RtpAudioFeedback* messagesCallback); - /** * Sender */ - virtual WebRtc_Word32 InitSender(); - virtual WebRtc_Word32 RegisterSendPayload(const CodecInst& voiceCodec); virtual WebRtc_Word32 RegisterSendPayload(const VideoCodec& videoCodec); @@ -216,9 +171,6 @@ public: virtual bool SendingMedia() const; - // Used by the module to send RTP and RTCP packet to the network module - virtual WebRtc_Word32 RegisterSendTransport(Transport* outgoingTransport); - // Used by the codec module to deliver a video or audio frame for packetization virtual WebRtc_Word32 SendOutgoingData( const FrameType frameType, @@ -325,7 +277,6 @@ public: const WebRtc_UWord8 numberOfSSRC, const WebRtc_UWord32* SSRC); - virtual bool SetRemoteBitrateObserver(RtpRemoteBitrateObserver* observer); /* * (IJ) Extended jitter report. */ @@ -482,8 +433,6 @@ public: // good state of RTP receiver inform sender virtual WebRtc_Word32 SendRTCPReferencePictureSelection(const WebRtc_UWord64 pictureID); - void OnReceivedNTP() ; - void OnReceivedTMMBR(); // bad state of RTP receiver request a keyframe @@ -539,23 +488,15 @@ private: WebRtc_UWord32 _lastPacketTimeoutProcessTime; WebRtc_UWord16 _packetOverHead; - CriticalSectionWrapper* _criticalSectionModulePtrs; - CriticalSectionWrapper* _criticalSectionModulePtrsFeedback; + scoped_ptr _criticalSectionModulePtrs; + scoped_ptr _criticalSectionModulePtrsFeedback; ModuleRtpRtcpImpl* _defaultModule; - ModuleRtpRtcpImpl* _audioModule; - ModuleRtpRtcpImpl* _videoModule; std::list _childModules; // Dead or alive bool _deadOrAliveActive; WebRtc_UWord32 _deadOrAliveTimeoutMS; WebRtc_UWord32 _deadOrAliveLastTimer; - - WebRtc_UWord32 _receivedNTPsecsAudio; - WebRtc_UWord32 _receivedNTPfracAudio; - WebRtc_UWord32 _RTCPArrivalTimeSecsAudio; - WebRtc_UWord32 _RTCPArrivalTimeFracAudio; - // send side NACKMethod _nackMethod; WebRtc_UWord32 _nackLastTimeSent; diff --git a/src/modules/rtp_rtcp/source/rtp_sender.cc b/src/modules/rtp_rtcp/source/rtp_sender.cc index e877692bac..945171c212 100644 --- a/src/modules/rtp_rtcp/source/rtp_sender.cc +++ b/src/modules/rtp_rtcp/source/rtp_sender.cc @@ -117,7 +117,7 @@ RTPSender::~RTPSender() { WEBRTC_TRACE(kTraceMemory, kTraceRtpRtcp, _id, "%s deleted", __FUNCTION__); } - +/* WebRtc_Word32 RTPSender::Init(const WebRtc_UWord32 remoteSSRC) { @@ -173,19 +173,7 @@ RTPSender::Init(const WebRtc_UWord32 remoteSSRC) } return(0); } - -void -RTPSender::ChangeUniqueId(const WebRtc_Word32 id) -{ - _id = id; - if(_audioConfigured) - { - _audio->ChangeUniqueId(id); - } else - { - _video->ChangeUniqueId(id); - } -} +*/ void RTPSender::SetTargetSendBitrate(const WebRtc_UWord32 bits) { _targetSendBitrate = static_cast(bits / 1000); diff --git a/src/modules/rtp_rtcp/source/rtp_sender.h b/src/modules/rtp_rtcp/source/rtp_sender.h index 3906e8cee1..37eec482c4 100644 --- a/src/modules/rtp_rtcp/source/rtp_sender.h +++ b/src/modules/rtp_rtcp/source/rtp_sender.h @@ -68,9 +68,6 @@ public: RTPSender(const WebRtc_Word32 id, const bool audio, RtpRtcpClock* clock); virtual ~RTPSender(); - WebRtc_Word32 Init(const WebRtc_UWord32 remoteSSRC); - void ChangeUniqueId(const WebRtc_Word32 id); - void ProcessBitrate(); void ProcessSendToNetwork(); diff --git a/src/modules/rtp_rtcp/source/rtp_sender_audio.cc b/src/modules/rtp_rtcp/source/rtp_sender_audio.cc index ee3c41401a..361aea591e 100644 --- a/src/modules/rtp_rtcp/source/rtp_sender_audio.cc +++ b/src/modules/rtp_rtcp/source/rtp_sender_audio.cc @@ -50,30 +50,6 @@ RTPSenderAudio::~RTPSenderAudio() delete _audioFeedbackCritsect; } -WebRtc_Word32 -RTPSenderAudio::Init() -{ - CriticalSectionScoped cs(_sendAudioCritsect); - - _dtmfPayloadType = -1; - _inbandVADactive = false; - _cngNBPayloadType = -1; - _cngWBPayloadType = -1; - _cngSWBPayloadType = -1; - _lastPayloadType = -1; - _REDPayloadType = -1; - _dtmfTimeLastSent = 0; - _dtmfTimestampLastSent = 0; - ResetDTMF(); - return 0; -} - -void -RTPSenderAudio::ChangeUniqueId(const WebRtc_Word32 id) -{ - _id = id; -} - WebRtc_Word32 RTPSenderAudio::RegisterAudioCallback(RtpAudioFeedback* messagesCallback) { diff --git a/src/modules/rtp_rtcp/source/rtp_sender_audio.h b/src/modules/rtp_rtcp/source/rtp_sender_audio.h index 5fda2ef1f6..1ea2fab7ca 100644 --- a/src/modules/rtp_rtcp/source/rtp_sender_audio.h +++ b/src/modules/rtp_rtcp/source/rtp_sender_audio.h @@ -28,10 +28,6 @@ public: RTPSenderInterface* rtpSender); virtual ~RTPSenderAudio(); - void ChangeUniqueId(const WebRtc_Word32 id); - - WebRtc_Word32 Init(); - WebRtc_Word32 RegisterAudioPayload( const char payloadName[RTP_PAYLOAD_NAME_SIZE], const WebRtc_Word8 payloadType, diff --git a/src/modules/rtp_rtcp/source/rtp_sender_video.cc b/src/modules/rtp_rtcp/source/rtp_sender_video.cc index 8f44973ec1..f1e3c746b2 100644 --- a/src/modules/rtp_rtcp/source/rtp_sender_video.cc +++ b/src/modules/rtp_rtcp/source/rtp_sender_video.cc @@ -67,29 +67,6 @@ RTPSenderVideo::~RTPSenderVideo() delete _sendVideoCritsect; } -WebRtc_Word32 -RTPSenderVideo::Init() -{ - CriticalSectionScoped cs(_sendVideoCritsect); - - _retransmissionSettings = kRetransmitBaseLayer; - _fecEnabled = false; - _payloadTypeRED = -1; - _payloadTypeFEC = -1; - _numberFirstPartition = 0; - memset(&delta_fec_params_, 0, sizeof(delta_fec_params_)); - memset(&key_fec_params_, 0, sizeof(key_fec_params_)); - delta_fec_params_.max_fec_frames = key_fec_params_.max_fec_frames = 1; - _fecOverheadRate.Init(); - return 0; -} - -void -RTPSenderVideo::ChangeUniqueId(const WebRtc_Word32 id) -{ - _id = id; -} - void RTPSenderVideo::SetVideoCodecType(RtpVideoCodecTypes videoType) { diff --git a/src/modules/rtp_rtcp/source/rtp_sender_video.h b/src/modules/rtp_rtcp/source/rtp_sender_video.h index 18f39ca9b4..5c3f70ce0d 100644 --- a/src/modules/rtp_rtcp/source/rtp_sender_video.h +++ b/src/modules/rtp_rtcp/source/rtp_sender_video.h @@ -37,10 +37,6 @@ public: RTPSenderInterface* rtpSender); virtual ~RTPSenderVideo(); - WebRtc_Word32 Init(); - - virtual void ChangeUniqueId(const WebRtc_Word32 id); - virtual RtpVideoCodecTypes VideoCodecType() const; WebRtc_UWord16 FECPacketOverhead() const; diff --git a/src/modules/rtp_rtcp/test/testAPI/test_api.cc b/src/modules/rtp_rtcp/test/testAPI/test_api.cc index 7c1a309dbd..dd12c45fe9 100644 --- a/src/modules/rtp_rtcp/test/testAPI/test_api.cc +++ b/src/modules/rtp_rtcp/test/testAPI/test_api.cc @@ -33,13 +33,15 @@ class RtpRtcpAPITest : public ::testing::Test { ~RtpRtcpAPITest() {} virtual void SetUp() { - module = RtpRtcp::CreateRtpRtcp(test_id, true, &fake_clock); - EXPECT_EQ(0, module->InitReceiver()); - EXPECT_EQ(0, module->InitSender()); + RtpRtcp::Configuration configuration; + configuration.id = test_id; + configuration.audio = true; + configuration.clock = &fake_clock; + module = RtpRtcp::CreateRtpRtcp(configuration); } virtual void TearDown() { - RtpRtcp::DestroyRtpRtcp(module); + delete module; } int test_id; diff --git a/src/modules/rtp_rtcp/test/testAPI/test_api.h b/src/modules/rtp_rtcp/test/testAPI/test_api.h index c4ff91620a..ed9d75a05e 100644 --- a/src/modules/rtp_rtcp/test/testAPI/test_api.h +++ b/src/modules/rtp_rtcp/test/testAPI/test_api.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -40,10 +40,13 @@ class FakeRtpRtcpClock : public RtpRtcpClock { // with optional packet loss. class LoopBackTransport : public webrtc::Transport { public: - LoopBackTransport(RtpRtcp* rtpRtcpModule) + LoopBackTransport() : _count(0), _packetLoss(0), - _rtpRtcpModule(rtpRtcpModule) { + _rtpRtcpModule(NULL) { + } + void SetSendModule(RtpRtcp* rtpRtcpModule) { + _rtpRtcpModule = rtpRtcpModule; } void DropEveryNthPacket(int n) { _packetLoss = n; diff --git a/src/modules/rtp_rtcp/test/testAPI/test_api_audio.cc b/src/modules/rtp_rtcp/test/testAPI/test_api_audio.cc index e92f8b65cb..25b91a0670 100644 --- a/src/modules/rtp_rtcp/test/testAPI/test_api_audio.cc +++ b/src/modules/rtp_rtcp/test/testAPI/test_api_audio.cc @@ -24,8 +24,6 @@ using namespace webrtc; class VerifyingAudioReceiver : public RtpData { public: - VerifyingAudioReceiver(RtpRtcp* rtpRtcpModule) {} - virtual WebRtc_Word32 OnReceivedPayloadData( const WebRtc_UWord8* payloadData, const WebRtc_UWord16 payloadSize, @@ -132,30 +130,41 @@ class RtpRtcpAudioTest : public ::testing::Test { ~RtpRtcpAudioTest() {} virtual void SetUp() { - module1 = RtpRtcp::CreateRtpRtcp(test_id, true, &fake_clock); - module2 = RtpRtcp::CreateRtpRtcp(test_id+1, true, &fake_clock); - - EXPECT_EQ(0, module1->InitReceiver()); - EXPECT_EQ(0, module1->InitSender()); - EXPECT_EQ(0, module2->InitReceiver()); - EXPECT_EQ(0, module2->InitSender()); - data_receiver1 = new VerifyingAudioReceiver(module1); - EXPECT_EQ(0, module1->RegisterIncomingDataCallback(data_receiver1)); - data_receiver2 = new VerifyingAudioReceiver(module2); - EXPECT_EQ(0, module2->RegisterIncomingDataCallback(data_receiver2)); - transport1 = new LoopBackTransport(module2); - EXPECT_EQ(0, module1->RegisterSendTransport(transport1)); - transport2 = new LoopBackTransport(module1); - EXPECT_EQ(0, module2->RegisterSendTransport(transport2)); + audioFeedback = new AudioFeedback(); + data_receiver1 = new VerifyingAudioReceiver(); + data_receiver2 = new VerifyingAudioReceiver(); rtp_callback = new RTPCallback(); - EXPECT_EQ(0, module2->RegisterIncomingRTPCallback(rtp_callback)); + transport1 = new LoopBackTransport(); + transport2 = new LoopBackTransport(); + + RtpRtcp::Configuration configuration; + configuration.id = test_id; + configuration.audio = true; + configuration.clock = &fake_clock; + configuration.incoming_data = data_receiver1; + configuration.outgoing_transport = transport1; + configuration.audio_messages = audioFeedback; + + module1 = RtpRtcp::CreateRtpRtcp(configuration); + + configuration.id = test_id + 1; + configuration.incoming_data = data_receiver2; + configuration.incoming_messages = rtp_callback; + configuration.outgoing_transport = transport2; + configuration.audio_messages = audioFeedback; + + module2 = RtpRtcp::CreateRtpRtcp(configuration); + + transport1->SetSendModule(module2); + transport2->SetSendModule(module1); } virtual void TearDown() { - RtpRtcp::DestroyRtpRtcp(module1); - RtpRtcp::DestroyRtpRtcp(module2); + delete module1; + delete module2; delete transport1; delete transport2; + delete audioFeedback; delete data_receiver1; delete data_receiver2; delete rtp_callback; @@ -168,6 +177,7 @@ class RtpRtcpAudioTest : public ::testing::Test { VerifyingAudioReceiver* data_receiver2; LoopBackTransport* transport1; LoopBackTransport* transport2; + AudioFeedback* audioFeedback; RTPCallback* rtp_callback; WebRtc_UWord32 test_ssrc; WebRtc_UWord32 test_timestamp; @@ -283,9 +293,6 @@ TEST_F(RtpRtcpAudioTest, DTMF) { EXPECT_EQ(0, module1->SetStartTimestamp(test_timestamp)); EXPECT_EQ(0, module1->SetSendingStatus(true)); - AudioFeedback* audioFeedback = new AudioFeedback(); - EXPECT_EQ(0, module2->RegisterAudioCallback(audioFeedback)); - // Prepare for DTMF. voiceCodec.pltype = 97; voiceCodec.plfreq = 8000; diff --git a/src/modules/rtp_rtcp/test/testAPI/test_api_nack.cc b/src/modules/rtp_rtcp/test/testAPI/test_api_nack.cc index ec4d2bb2c4..ad4dd6af56 100644 --- a/src/modules/rtp_rtcp/test/testAPI/test_api_nack.cc +++ b/src/modules/rtp_rtcp/test/testAPI/test_api_nack.cc @@ -50,12 +50,15 @@ class VerifyingNackReceiver : public RtpData class NackLoopBackTransport : public webrtc::Transport { public: - NackLoopBackTransport(RtpRtcp* rtp_rtcp_module, uint32_t rtx_ssrc) + NackLoopBackTransport(uint32_t rtx_ssrc) : count_(0), packet_loss_(0), rtx_ssrc_(rtx_ssrc), count_rtx_ssrc_(0), - module_(rtp_rtcp_module) { + module_(NULL) { + } + void SetSendModule(RtpRtcp* rtpRtcpModule) { + module_ = rtpRtcpModule; } void DropEveryNthPacket(int n) { packet_loss_ = n; @@ -95,9 +98,17 @@ class RtpRtcpNackTest : public ::testing::Test { ~RtpRtcpNackTest() {} virtual void SetUp() { - video_module_ = RtpRtcp::CreateRtpRtcp(kTestId, false, &fake_clock); - EXPECT_EQ(0, video_module_->InitReceiver()); - EXPECT_EQ(0, video_module_->InitSender()); + transport_ = new NackLoopBackTransport(kTestSsrc + 1); + nack_receiver_ = new VerifyingNackReceiver(); + + RtpRtcp::Configuration configuration; + configuration.id = kTestId; + configuration.audio = false; + configuration.clock = &fake_clock; + configuration.incoming_data = nack_receiver_; + configuration.outgoing_transport = transport_; + video_module_ = RtpRtcp::CreateRtpRtcp(configuration); + EXPECT_EQ(0, video_module_->SetRTCPStatus(kRtcpCompound)); EXPECT_EQ(0, video_module_->SetSSRC(kTestSsrc)); EXPECT_EQ(0, video_module_->SetNACKStatus(kNackRtcp)); @@ -106,11 +117,7 @@ class RtpRtcpNackTest : public ::testing::Test { EXPECT_EQ(0, video_module_->SetSequenceNumber(kTestSequenceNumber)); EXPECT_EQ(0, video_module_->SetStartTimestamp(111111)); - transport_ = new NackLoopBackTransport(video_module_, kTestSsrc + 1); - EXPECT_EQ(0, video_module_->RegisterSendTransport(transport_)); - - nack_receiver_ = new VerifyingNackReceiver(); - EXPECT_EQ(0, video_module_->RegisterIncomingDataCallback(nack_receiver_)); + transport_->SetSendModule(video_module_); VideoCodec video_codec; memset(&video_codec, 0, sizeof(video_codec)); @@ -128,7 +135,7 @@ class RtpRtcpNackTest : public ::testing::Test { } virtual void TearDown() { - RtpRtcp::DestroyRtpRtcp(video_module_); + delete video_module_; delete transport_; delete nack_receiver_; } diff --git a/src/modules/rtp_rtcp/test/testAPI/test_api_rtcp.cc b/src/modules/rtp_rtcp/test/testAPI/test_api_rtcp.cc index 97736200d2..bdf3c6b6e8 100644 --- a/src/modules/rtp_rtcp/test/testAPI/test_api_rtcp.cc +++ b/src/modules/rtp_rtcp/test/testAPI/test_api_rtcp.cc @@ -24,7 +24,7 @@ const uint64_t kTestPictureId = 12345678; class RtcpCallback : public RtcpFeedback, public RtcpIntraFrameObserver { public: - RtcpCallback(RtpRtcp* module) { + void SetModule(RtpRtcp* module) { _rtpRtcpModule = module; }; virtual void OnRTCPPacketTimeout(const WebRtc_Word32 id) { @@ -85,32 +85,32 @@ class RtpRtcpRtcpTest : public ::testing::Test { ~RtpRtcpRtcpTest() {} virtual void SetUp() { - module1 = RtpRtcp::CreateRtpRtcp(test_id, true, &fake_clock); - module2 = RtpRtcp::CreateRtpRtcp(test_id+1, true, &fake_clock); - - EXPECT_EQ(0, module1->InitReceiver()); - EXPECT_EQ(0, module1->InitSender()); - EXPECT_EQ(0, module2->InitReceiver()); - EXPECT_EQ(0, module2->InitSender()); receiver = new RtpReceiver(); - EXPECT_EQ(0, module2->RegisterIncomingDataCallback(receiver)); - transport1 = new LoopBackTransport(module2); - EXPECT_EQ(0, module1->RegisterSendTransport(transport1)); - transport2 = new LoopBackTransport(module1); - EXPECT_EQ(0, module2->RegisterSendTransport(transport2)); - } + transport1 = new LoopBackTransport(); + transport2 = new LoopBackTransport(); + myRTCPFeedback1 = new RtcpCallback(); + myRTCPFeedback2 = new RtcpCallback(); - virtual void TearDown() { - RtpRtcp::DestroyRtpRtcp(module1); - RtpRtcp::DestroyRtpRtcp(module2); - delete transport1; - delete transport2; - delete receiver; - } + RtpRtcp::Configuration configuration; + configuration.id = test_id; + configuration.audio = false; + configuration.clock = &fake_clock; + configuration.outgoing_transport = transport1; + configuration.rtcp_feedback = myRTCPFeedback1; + configuration.intra_frame_callback = myRTCPFeedback1; - void SetUpCallFromModule1(RtcpCallback* feedback1, RtcpCallback* feedback2 ) { - module1->RegisterRtcpObservers(feedback1, NULL, feedback1); - module2->RegisterRtcpObservers(feedback2, NULL, feedback2); + module1 = RtpRtcp::CreateRtpRtcp(configuration); + + configuration.id = test_id + 1; + configuration.outgoing_transport = transport2; + configuration.rtcp_feedback = myRTCPFeedback2; + configuration.intra_frame_callback = myRTCPFeedback2; + module2 = RtpRtcp::CreateRtpRtcp(configuration); + + transport1->SetSendModule(module2); + transport2->SetSendModule(module1); + myRTCPFeedback1->SetModule(module1); + myRTCPFeedback2->SetModule(module2); EXPECT_EQ(0, module1->SetRTCPStatus(kRtcpCompound)); EXPECT_EQ(0, module2->SetRTCPStatus(kRtcpCompound)); @@ -143,12 +143,23 @@ class RtpRtcpRtcpTest : public ::testing::Test { 0, test, 8)); } + virtual void TearDown() { + delete module1; + delete module2; + delete transport1; + delete transport2; + delete receiver; + } + int test_id; RtpRtcp* module1; RtpRtcp* module2; RtpReceiver* receiver; LoopBackTransport* transport1; LoopBackTransport* transport2; + RtcpCallback* myRTCPFeedback1; + RtcpCallback* myRTCPFeedback2; + WebRtc_UWord32 test_ssrc; WebRtc_UWord32 test_timestamp; WebRtc_UWord16 test_sequence_number; @@ -157,20 +168,11 @@ class RtpRtcpRtcpTest : public ::testing::Test { }; TEST_F(RtpRtcpRtcpTest, RTCP_PLI_RPSI) { - RtcpCallback* myRTCPFeedback1 = new RtcpCallback(module1); - RtcpCallback* myRTCPFeedback2 = new RtcpCallback(module2); - - SetUpCallFromModule1(myRTCPFeedback1, myRTCPFeedback2); - EXPECT_EQ(0, module1->SendRTCPReferencePictureSelection(kTestPictureId)); EXPECT_EQ(0, module1->SendRTCPSliceLossIndication(156)); } TEST_F(RtpRtcpRtcpTest, RTCP_CNAME) { - RtcpCallback* myRTCPFeedback1 = new RtcpCallback(module1); - RtcpCallback* myRTCPFeedback2 = new RtcpCallback(module2); - - SetUpCallFromModule1(myRTCPFeedback1, myRTCPFeedback2); WebRtc_UWord32 testOfCSRC[webrtc::kRtpCsrcSize]; EXPECT_EQ(2, module2->RemoteCSRCs(testOfCSRC)); EXPECT_EQ(test_CSRC[0], testOfCSRC[0]); @@ -210,10 +212,6 @@ TEST_F(RtpRtcpRtcpTest, RTCP_CNAME) { } TEST_F(RtpRtcpRtcpTest, RTCP) { - RtcpCallback* myRTCPFeedback1 = new RtcpCallback(module1); - RtcpCallback* myRTCPFeedback2 = new RtcpCallback(module2); - - SetUpCallFromModule1(myRTCPFeedback1, myRTCPFeedback2); RTCPReportBlock reportBlock; reportBlock.cumulativeLost = 1; reportBlock.delaySinceLastSR = 2; @@ -316,10 +314,6 @@ TEST_F(RtpRtcpRtcpTest, RTCP) { TEST_F(RtpRtcpRtcpTest, RemoteRTCPStatRemote) { std::vector report_blocks; - RtcpCallback feedback1(module1); - RtcpCallback feedback2(module2); - - SetUpCallFromModule1(&feedback1, &feedback2); EXPECT_EQ(0, module1->RemoteRTCPStat(&report_blocks)); EXPECT_EQ(0u, report_blocks.size()); diff --git a/src/modules/rtp_rtcp/test/testAPI/test_api_video.cc b/src/modules/rtp_rtcp/test/testAPI/test_api_video.cc index 7a06ef79a3..c5b134a345 100644 --- a/src/modules/rtp_rtcp/test/testAPI/test_api_video.cc +++ b/src/modules/rtp_rtcp/test/testAPI/test_api_video.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -31,20 +31,24 @@ class RtpRtcpVideoTest : public ::testing::Test { ~RtpRtcpVideoTest() {} virtual void SetUp() { - video_module = RtpRtcp::CreateRtpRtcp(test_id, false, &fake_clock); - EXPECT_EQ(0, video_module->InitReceiver()); - EXPECT_EQ(0, video_module->InitSender()); + transport = new LoopBackTransport(); + receiver = new RtpReceiver(); + RtpRtcp::Configuration configuration; + configuration.id = test_id; + configuration.audio = false; + configuration.clock = &fake_clock; + configuration.incoming_data = receiver; + configuration.outgoing_transport = transport; + + video_module = RtpRtcp::CreateRtpRtcp(configuration); + EXPECT_EQ(0, video_module->SetRTCPStatus(kRtcpCompound)); EXPECT_EQ(0, video_module->SetSSRC(test_ssrc)); EXPECT_EQ(0, video_module->SetNACKStatus(kNackRtcp)); EXPECT_EQ(0, video_module->SetStorePacketsStatus(true)); EXPECT_EQ(0, video_module->SetSendingStatus(true)); - transport = new LoopBackTransport(video_module); - EXPECT_EQ(0, video_module->RegisterSendTransport(transport)); - - receiver = new RtpReceiver(); - EXPECT_EQ(0, video_module->RegisterIncomingDataCallback(receiver)); + transport->SetSendModule(video_module); VideoCodec video_codec; memset(&video_codec, 0, sizeof(video_codec)); @@ -62,7 +66,7 @@ class RtpRtcpVideoTest : public ::testing::Test { } virtual void TearDown() { - RtpRtcp::DestroyRtpRtcp(video_module); + delete video_module; delete transport; delete receiver; } diff --git a/src/modules/video_coding/main/test/generic_codec_test.cc b/src/modules/video_coding/main/test/generic_codec_test.cc index 56b3c86b01..8d1232545a 100644 --- a/src/modules/video_coding/main/test/generic_codec_test.cc +++ b/src/modules/video_coding/main/test/generic_codec_test.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -398,10 +398,14 @@ GenericCodecTest::Perform(CmdArgs& args) /********************************/ /* Encoder Packet Size Test */ /********************************/ - RtpRtcp& rtpModule = *RtpRtcp::CreateRtpRtcp(1, false); - TEST(rtpModule.InitSender() == 0); RTPSendCallback_SizeTest sendCallback; - rtpModule.RegisterSendTransport(&sendCallback); + + RtpRtcp::Configuration configuration; + configuration.id = 1; + configuration.audio = false; + configuration.outgoing_transport = &sendCallback; + + RtpRtcp& rtpModule = *RtpRtcp::CreateRtpRtcp(configuration); VCMRTPEncodeCompleteCallback encCompleteCallback(&rtpModule); _vcm->InitializeSender(); @@ -485,7 +489,7 @@ GenericCodecTest::Perform(CmdArgs& args) IncrementDebugClock(_frameRate); } // first frame encoded - RtpRtcp::DestroyRtpRtcp(&rtpModule); + delete &rtpModule; Print(); delete tmpBuffer; delete _decodeCallback; diff --git a/src/modules/video_coding/main/test/media_opt_test.cc b/src/modules/video_coding/main/test/media_opt_test.cc index f7679197b5..b20fce8b23 100644 --- a/src/modules/video_coding/main/test/media_opt_test.cc +++ b/src/modules/video_coding/main/test/media_opt_test.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -19,8 +19,6 @@ #include #include "../source/event.h" -#include "receiver_tests.h" // receive side callbacks -#include "test_callbacks.h" #include "test_macros.h" #include "test_util.h" // send side callback #include "testsupport/metrics/video_metrics.h" @@ -67,35 +65,34 @@ int MediaOptTest::RunTest(int testNum, CmdArgs& args) } -MediaOptTest::MediaOptTest(VideoCodingModule* vcm, TickTimeBase* clock): -_vcm(vcm), -_clock(clock), -_width(0), -_height(0), -_lengthSourceFrame(0), -_timeStamp(0), -_frameRate(30.0f), -_nackEnabled(false), -_fecEnabled(false), -_rttMS(0), -_bitRate(300.0f), -_lossRate(0.0f), -_renderDelayMs(0), -_frameCnt(0), -_sumEncBytes(0), -_numFramesDropped(0), -_numberOfCores(4) -{ - _rtp = RtpRtcp::CreateRtpRtcp(1, false); +MediaOptTest::MediaOptTest(VideoCodingModule* vcm, TickTimeBase* clock) + : _vcm(vcm), + _rtp(NULL), + _outgoingTransport(NULL), + _dataCallback(NULL), + _clock(clock), + _width(0), + _height(0), + _lengthSourceFrame(0), + _timeStamp(0), + _frameRate(30.0f), + _nackEnabled(false), + _fecEnabled(false), + _rttMS(0), + _bitRate(300.0f), + _lossRate(0.0f), + _renderDelayMs(0), + _frameCnt(0), + _sumEncBytes(0), + _numFramesDropped(0), + _numberOfCores(4) { } -MediaOptTest::~MediaOptTest() -{ - RtpRtcp::DestroyRtpRtcp(_rtp); +MediaOptTest::~MediaOptTest() { + delete _rtp; } -void -MediaOptTest::Setup(int testType, CmdArgs& args) -{ + +void MediaOptTest::Setup(int testType, CmdArgs& args) { /*TEST USER SETTINGS*/ // test parameters _inname = args.inputFile; @@ -168,7 +165,6 @@ MediaOptTest::Setup(int testType, CmdArgs& args) _lengthSourceFrame = 3*_width*_height/2; _log.open((test::OutputPath() + "VCM_MediaOptLog.txt").c_str(), std::fstream::out | std::fstream::app); - return; } void @@ -193,15 +189,6 @@ MediaOptTest::GeneralSetup() printf("Cannot read file %s.\n", _actualSourcename.c_str()); exit(1); } - - if (_rtp->InitReceiver() < 0) - { - exit(1); - } - if (_rtp->InitSender() < 0) - { - exit(1); - } if (_vcm->InitializeReceiver() < 0) { exit(1); @@ -210,6 +197,17 @@ MediaOptTest::GeneralSetup() { exit(1); } + _outgoingTransport = new RTPSendCompleteCallback(_clock); + _dataCallback = new RtpDataCallback(_vcm); + + RtpRtcp::Configuration configuration; + configuration.id = 1; + configuration.audio = false; + configuration.incoming_data = _dataCallback; + configuration.outgoing_transport = _outgoingTransport; + _rtp = RtpRtcp::CreateRtpRtcp(configuration); + + _outgoingTransport->SetRtpModule(_rtp); // Registering codecs for the RTP module @@ -262,8 +260,6 @@ MediaOptTest::GeneralSetup() _vcm->SetRenderDelay(_renderDelayMs); _vcm->SetMinimumPlayoutDelay(minPlayoutDelayMs); - - return; } // The following test shall be conducted under release tests @@ -272,33 +268,23 @@ MediaOptTest::GeneralSetup() WebRtc_Word32 MediaOptTest::Perform() { - //Setup(); - EventWrapper* waitEvent = EventWrapper::Create(); + VCMDecodeCompleteCallback receiveCallback(_decodedFile); - // callback settings VCMRTPEncodeCompleteCallback* encodeCompleteCallback = new VCMRTPEncodeCompleteCallback(_rtp); _vcm->RegisterTransportCallback(encodeCompleteCallback); encodeCompleteCallback->SetCodecType(ConvertCodecType(_codecName.c_str())); encodeCompleteCallback->SetFrameDimensions(_width, _height); - // frame ready to be sent to network - RTPSendCompleteCallback* outgoingTransport = - new RTPSendCompleteCallback(_rtp, _clock); - _rtp->RegisterSendTransport(outgoingTransport); - //FrameReceiveCallback - VCMDecodeCompleteCallback receiveCallback(_decodedFile); - RtpDataCallback dataCallback(_vcm); - _rtp->RegisterIncomingDataCallback(&dataCallback); + // callback settings VideoProtectionCallback protectionCallback; protectionCallback.RegisterRtpModule(_rtp); _vcm->RegisterProtectionCallback(&protectionCallback); // set error resilience / test parameters: - outgoingTransport->SetLossPct(_lossRate); - if (_nackFecEnabled == 1) + _outgoingTransport->SetLossPct(_lossRate); + if (_nackFecEnabled == 1) { _vcm->SetVideoProtection(kProtectionNackFEC, _nackFecEnabled); - else - { + } else { _vcm->SetVideoProtection(kProtectionNack, _nackEnabled); _vcm->SetVideoProtection(kProtectionFEC, _fecEnabled); } @@ -349,13 +335,10 @@ MediaOptTest::Perform() } _sumEncBytes += encBytes; - //waitEvent->Wait(33); } //END TEST - delete waitEvent; delete encodeCompleteCallback; - delete outgoingTransport; delete tmpBuffer; return 0; @@ -441,17 +424,10 @@ MediaOptTest::RTTest() printf("**FOR RUN: **%d %d %d %d \n",_nackEnabled,_fecEnabled,int(lossPctVec[j]),int(_bitRate)); */ - if (_rtp != NULL) - { - RtpRtcp::DestroyRtpRtcp(_rtp); - } - _rtp = RtpRtcp::CreateRtpRtcp(1, false); GeneralSetup(); Perform(); Print(1); TearDown(); - RtpRtcp::DestroyRtpRtcp(_rtp); - _rtp = NULL; printf("\n"); //printf("**DONE WITH RUN: **%d %d %f %d \n",_nackEnabled,_fecEnabled,lossPctVec[j],int(_bitRate)); @@ -549,12 +525,15 @@ MediaOptTest::Print(int mode) TEST(psnr.average > 10); // low becuase of possible frame dropping (need to verify that OK for all packet loss values/ rates) } -void -MediaOptTest::TearDown() -{ - _log.close(); - fclose(_sourceFile); - fclose(_decodedFile); - fclose(_actualSourceFile); - return; +void MediaOptTest::TearDown() { + delete _rtp; + _rtp = NULL; + delete _outgoingTransport; + _outgoingTransport = NULL; + delete _dataCallback; + _dataCallback = NULL; + _log.close(); + fclose(_sourceFile); + fclose(_decodedFile); + fclose(_actualSourceFile); } diff --git a/src/modules/video_coding/main/test/media_opt_test.h b/src/modules/video_coding/main/test/media_opt_test.h index 7d4e22617c..5f210e6bcf 100644 --- a/src/modules/video_coding/main/test/media_opt_test.h +++ b/src/modules/video_coding/main/test/media_opt_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -15,7 +15,9 @@ #include +#include "receiver_tests.h" // receive side callbacks #include "rtp_rtcp.h" +#include "test_callbacks.h" #include "test_util.h" #include "video_coding.h" #include "video_source.h" @@ -52,6 +54,9 @@ private: webrtc::VideoCodingModule* _vcm; webrtc::RtpRtcp* _rtp; + webrtc::RTPSendCompleteCallback* _outgoingTransport; + RtpDataCallback* _dataCallback; + webrtc::TickTimeBase* _clock; std::string _inname; std::string _outname; diff --git a/src/modules/video_coding/main/test/mt_rx_tx_test.cc b/src/modules/video_coding/main/test/mt_rx_tx_test.cc index dc20b32108..3eac939122 100644 --- a/src/modules/video_coding/main/test/mt_rx_tx_test.cc +++ b/src/modules/video_coding/main/test/mt_rx_tx_test.cc @@ -138,17 +138,20 @@ int MTRxTxTest(CmdArgs& args) printf("Cannot read file %s.\n", outname.c_str()); return -1; } + TickTimeBase clock; + VideoCodingModule* vcm = VideoCodingModule::Create(1, &clock); + RtpDataCallback dataCallback(vcm); + + RTPSendCompleteCallback* outgoingTransport = + new RTPSendCompleteCallback(&clock, "dump.rtp"); + + RtpRtcp::Configuration configuration; + configuration.id = 1; + configuration.audio = false; + configuration.incoming_data = &dataCallback; + configuration.outgoing_transport = outgoingTransport; + RtpRtcp* rtp = RtpRtcp::CreateRtpRtcp(configuration); - //RTP - RtpRtcp* rtp = RtpRtcp::CreateRtpRtcp(1, false); - if (rtp->InitReceiver() < 0) - { - return -1; - } - if (rtp->InitSender() < 0) - { - return -1; - } // registering codecs for the RTP module VideoCodec videoCodec; strncpy(videoCodec.plName, "ULPFEC", 32); @@ -170,8 +173,6 @@ int MTRxTxTest(CmdArgs& args) TEST(rtp->SetGenericFECStatus(fecEnabled, VCM_RED_PAYLOAD_TYPE, VCM_ULPFEC_PAYLOAD_TYPE) == 0); //VCM - TickTimeBase clock; - VideoCodingModule* vcm = VideoCodingModule::Create(1, &clock); if (vcm->InitializeReceiver() < 0) { return -1; @@ -216,13 +217,8 @@ int MTRxTxTest(CmdArgs& args) encodeCompleteCallback->SetCodecType(ConvertCodecType(args.codecName.c_str())); encodeCompleteCallback->SetFrameDimensions(width, height); // frame ready to be sent to network - RTPSendCompleteCallback* outgoingTransport = - new RTPSendCompleteCallback(rtp, &clock, "dump.rtp"); - rtp->RegisterSendTransport(outgoingTransport); - // FrameReceiveCallback + VCMDecodeCompleteCallback receiveCallback(decodedFile); - RtpDataCallback dataCallback(vcm); - rtp->RegisterIncomingDataCallback(&dataCallback); vcm->RegisterReceiveCallback(&receiveCallback); VideoProtectionCallback protectionCallback; @@ -351,7 +347,7 @@ int MTRxTxTest(CmdArgs& args) delete encodeCompleteCallback; delete outgoingTransport; VideoCodingModule::Destroy(vcm); - RtpRtcp::DestroyRtpRtcp(rtp); + delete rtp; rtp = NULL; vcm = NULL; Trace::ReturnTrace(); diff --git a/src/modules/video_coding/main/test/mt_test_common.cc b/src/modules/video_coding/main/test/mt_test_common.cc index e3ebd97312..ece0d9cd82 100644 --- a/src/modules/video_coding/main/test/mt_test_common.cc +++ b/src/modules/video_coding/main/test/mt_test_common.cc @@ -17,12 +17,8 @@ namespace webrtc { -TransportCallback::TransportCallback(webrtc::RtpRtcp* rtp, - TickTimeBase* clock, - const char* filename): -RTPSendCompleteCallback(rtp, clock, filename) -{ - // +TransportCallback::TransportCallback(TickTimeBase* clock, const char* filename) + : RTPSendCompleteCallback(clock, filename) { } TransportCallback::~TransportCallback() diff --git a/src/modules/video_coding/main/test/mt_test_common.h b/src/modules/video_coding/main/test/mt_test_common.h index 438f0be998..c17d269470 100644 --- a/src/modules/video_coding/main/test/mt_test_common.h +++ b/src/modules/video_coding/main/test/mt_test_common.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -47,8 +47,7 @@ class TransportCallback:public RTPSendCompleteCallback { public: // constructor input: (receive side) rtp module to send encoded data to - TransportCallback(webrtc::RtpRtcp* rtp, TickTimeBase* clock, - const char* filename = NULL); + TransportCallback(TickTimeBase* clock, const char* filename = NULL); virtual ~TransportCallback(); // Add packets to list // Incorporate network conditions - delay and packet loss diff --git a/src/modules/video_coding/main/test/receiver_tests.h b/src/modules/video_coding/main/test/receiver_tests.h index 33d9f5f68b..cb45ca1478 100644 --- a/src/modules/video_coding/main/test/receiver_tests.h +++ b/src/modules/video_coding/main/test/receiver_tests.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source diff --git a/src/modules/video_coding/main/test/rtp_player.cc b/src/modules/video_coding/main/test/rtp_player.cc index 5361e3133d..9eacf343d7 100644 --- a/src/modules/video_coding/main/test/rtp_player.cc +++ b/src/modules/video_coding/main/test/rtp_player.cc @@ -140,7 +140,7 @@ RTPPlayer::RTPPlayer(const char* filename, TickTimeBase* clock) : _clock(clock), -_rtpModule(*RtpRtcp::CreateRtpRtcp(1, false)), +_rtpModule(NULL), _nextRtpTime(0), _dataCallback(callback), _firstPacket(true), @@ -165,7 +165,7 @@ _randVecPos(0) RTPPlayer::~RTPPlayer() { - RtpRtcp::DestroyRtpRtcp(&_rtpModule); + delete _rtpModule; if (_rtpFile != NULL) { fclose(_rtpFile); @@ -179,28 +179,26 @@ RTPPlayer::~RTPPlayer() WebRtc_Word32 RTPPlayer::Initialize(const PayloadTypeList* payloadList) { + RtpRtcp::Configuration configuration; + configuration.id = 1; + configuration.audio = false; + configuration.incoming_data = _dataCallback; + _rtpModule = RtpRtcp::CreateRtpRtcp(configuration); + std::srand(321); for (int i=0; i < RAND_VEC_LENGTH; i++) { _randVec[i] = rand(); } _randVecPos = 0; - WebRtc_Word32 ret = _rtpModule.SetNACKStatus(kNackOff); - if (ret < 0) - { - return -1; - } - ret = _rtpModule.InitReceiver(); + WebRtc_Word32 ret = _rtpModule->SetNACKStatus(kNackOff); if (ret < 0) { return -1; } + _rtpModule->SetRTCPStatus(kRtcpNonCompound); + _rtpModule->SetTMMBRStatus(true); - _rtpModule.InitSender(); - _rtpModule.SetRTCPStatus(kRtcpNonCompound); - _rtpModule.SetTMMBRStatus(true); - - ret = _rtpModule.RegisterIncomingDataCallback(_dataCallback); if (ret < 0) { return -1; @@ -214,7 +212,7 @@ WebRtc_Word32 RTPPlayer::Initialize(const PayloadTypeList* payloadList) VideoCodec videoCodec; strncpy(videoCodec.plName, payloadType->name.c_str(), 32); videoCodec.plType = payloadType->payloadType; - if (_rtpModule.RegisterReceivePayload(videoCodec) < 0) + if (_rtpModule->RegisterReceivePayload(videoCodec) < 0) { return -1; } @@ -305,7 +303,7 @@ WebRtc_Word32 RTPPlayer::NextPacket(const WebRtc_Word64 timeNow) // Send any packets from rtp file if (!_endOfFile && (TimeUntilNextPacket() == 0 || _firstPacket)) { - _rtpModule.Process(); + _rtpModule->Process(); if (_firstPacket) { _firstPacketRtpTime = static_cast(_nextRtpTime); @@ -362,7 +360,7 @@ WebRtc_Word32 RTPPlayer::SendPacket(WebRtc_UWord8* rtpData, WebRtc_UWord16 rtpLe } else if (rtpLen > 0) { - WebRtc_Word32 ret = _rtpModule.IncomingPacket(rtpData, rtpLen); + WebRtc_Word32 ret = _rtpModule->IncomingPacket(rtpData, rtpLen); if (ret < 0) { return -1; diff --git a/src/modules/video_coding/main/test/rtp_player.h b/src/modules/video_coding/main/test/rtp_player.h index eac6ba8fa5..9920d0c576 100644 --- a/src/modules/video_coding/main/test/rtp_player.h +++ b/src/modules/video_coding/main/test/rtp_player.h @@ -95,7 +95,7 @@ private: WebRtc_Word32 ReadHeader(); webrtc::TickTimeBase* _clock; FILE* _rtpFile; - webrtc::RtpRtcp& _rtpModule; + webrtc::RtpRtcp* _rtpModule; WebRtc_UWord32 _nextRtpTime; webrtc::RtpData* _dataCallback; bool _firstPacket; diff --git a/src/modules/video_coding/main/test/test_callbacks.cc b/src/modules/video_coding/main/test/test_callbacks.cc index da28073cfb..348cbcc1d4 100644 --- a/src/modules/video_coding/main/test/test_callbacks.cc +++ b/src/modules/video_coding/main/test/test_callbacks.cc @@ -195,12 +195,11 @@ VCMDecodeCompleteCallback::DecodedBytes() return _decodedBytes; } -RTPSendCompleteCallback::RTPSendCompleteCallback(RtpRtcp* rtp, - TickTimeBase* clock, +RTPSendCompleteCallback::RTPSendCompleteCallback(TickTimeBase* clock, const char* filename): _clock(clock), _sendCount(0), - _rtp(rtp), + _rtp(NULL), _lossPct(0), _burstLength(0), _networkDelayMs(0), @@ -282,6 +281,7 @@ RTPSendCompleteCallback::SendPacket(int channel, const void *data, int len) } _rtpPackets.pop_front(); + assert(_rtp); // We must have a configured RTP module for this test. // Send to receive side if (_rtp->IncomingPacket((const WebRtc_UWord8*)packet->data, packet->length) < 0) diff --git a/src/modules/video_coding/main/test/test_callbacks.h b/src/modules/video_coding/main/test/test_callbacks.h index 2c25931629..9f179e264a 100644 --- a/src/modules/video_coding/main/test/test_callbacks.h +++ b/src/modules/video_coding/main/test/test_callbacks.h @@ -155,9 +155,11 @@ class RTPSendCompleteCallback: public Transport { public: // Constructor input: (receive side) rtp module to send encoded data to - RTPSendCompleteCallback(RtpRtcp* rtp, TickTimeBase* clock, + RTPSendCompleteCallback(TickTimeBase* clock, const char* filename = NULL); virtual ~RTPSendCompleteCallback(); + + void SetRtpModule(RtpRtcp* rtp_module) { _rtp = rtp_module; } // Send Packet to receive side RTP module virtual int SendPacket(int channel, const void *data, int len); // Send RTCP Packet to receive side RTP module diff --git a/src/video_engine/vie_channel.cc b/src/video_engine/vie_channel.cc index 6e242fbc94..fcd1e30d64 100644 --- a/src/video_engine/vie_channel.cc +++ b/src/video_engine/vie_channel.cc @@ -27,9 +27,6 @@ #include "video_engine/include/vie_image_process.h" #include "video_engine/include/vie_rtp_rtcp.h" #include "video_engine/vie_defines.h" -#include "video_engine/vie_receiver.h" -#include "video_engine/vie_sender.h" -#include "video_engine/vie_sync_module.h" namespace webrtc { @@ -40,25 +37,25 @@ ViEChannel::ViEChannel(WebRtc_Word32 channel_id, WebRtc_UWord32 number_of_cores, ProcessThread& module_process_thread, RtcpIntraFrameObserver* intra_frame_observer, - RtcpBandwidthObserver* bandwidth_observer) + RtcpBandwidthObserver* bandwidth_observer, + RtpRemoteBitrateObserver* bitrate_observer, + RtpRtcp* default_rtp_rtcp) : ViEFrameProviderBase(channel_id, engine_id), channel_id_(channel_id), engine_id_(engine_id), number_of_cores_(number_of_cores), num_socket_threads_(kViESocketThreads), callback_cs_(CriticalSectionWrapper::CreateCriticalSection()), - rtp_rtcp_(*RtpRtcp::CreateRtpRtcp(ViEModuleId(engine_id, channel_id), - false)), - default_rtp_rtcp_(NULL), + default_rtp_rtcp_(default_rtp_rtcp), + rtp_rtcp_(NULL), #ifndef WEBRTC_EXTERNAL_TRANSPORT socket_transport_(*UdpTransport::Create( ViEModuleId(engine_id, channel_id), num_socket_threads_)), #endif vcm_(*VideoCodingModule::Create(ViEModuleId(engine_id, channel_id))), - vie_receiver_(*(new ViEReceiver(engine_id, channel_id, rtp_rtcp_, vcm_))), - vie_sender_(*(new ViESender(engine_id, channel_id))), - vie_sync_(*(new ViESyncModule(ViEId(engine_id, channel_id), vcm_, - rtp_rtcp_))), + vie_receiver_(channel_id, &vcm_), + vie_sender_(channel_id), + vie_sync_(channel_id, &vcm_), module_process_thread_(module_process_thread), codec_observer_(NULL), do_key_frame_callbackRequest_(false), @@ -82,62 +79,47 @@ ViEChannel::ViEChannel(WebRtc_Word32 channel_id, WEBRTC_TRACE(kTraceMemory, kTraceVideo, ViEId(engine_id, channel_id), "ViEChannel::ViEChannel(channel_id: %d, engine_id: %d)", channel_id, engine_id); + + RtpRtcp::Configuration configuration; + configuration.id = ViEModuleId(engine_id, channel_id); + configuration.audio = false; + configuration.default_module = default_rtp_rtcp; + configuration.incoming_data = &vie_receiver_; + configuration.incoming_messages = this; + configuration.outgoing_transport = &vie_sender_; + configuration.rtcp_feedback = this; + configuration.intra_frame_callback = intra_frame_observer; + configuration.bandwidth_callback = bandwidth_observer; + configuration.bitrate_observer = bitrate_observer; + + rtp_rtcp_.reset(RtpRtcp::CreateRtpRtcp(configuration)); + vie_receiver_.SetRtpRtcpModule(rtp_rtcp_.get()); } WebRtc_Word32 ViEChannel::Init() { WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(engine_id_, channel_id_), "%s: channel_id: %d, engine_id: %d)", __FUNCTION__, channel_id_, engine_id_); + // RTP/RTCP initialization. - if (rtp_rtcp_.InitSender() != 0) { - WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(engine_id_, channel_id_), - "%s: RTP::InitSender failure", __FUNCTION__); - return -1; - } - if (rtp_rtcp_.SetSendingMediaStatus(false) != 0) { + if (rtp_rtcp_->SetSendingMediaStatus(false) != 0) { WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(engine_id_, channel_id_), "%s: RTP::SetSendingMediaStatus failure", __FUNCTION__); return -1; } - if (rtp_rtcp_.InitReceiver() != 0) { - WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(engine_id_, channel_id_), - "%s: RTP::InitReceiver failure", __FUNCTION__); - return -1; - } - if (rtp_rtcp_.RegisterIncomingDataCallback( - static_cast(&vie_receiver_)) != 0) { - WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(engine_id_, channel_id_), - "%s: RTP::RegisterIncomingDataCallback failure", __FUNCTION__); - return -1; - } - if (rtp_rtcp_.RegisterSendTransport( - static_cast(&vie_sender_)) != 0) { - WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(engine_id_, channel_id_), - "%s: RTP::RegisterSendTransport failure", __FUNCTION__); - return -1; - } - rtp_rtcp_.RegisterRtcpObservers(intra_frame_observer_, - bandwidth_observer_.get(), - this); - - if (module_process_thread_.RegisterModule(&rtp_rtcp_) != 0) { + if (module_process_thread_.RegisterModule(rtp_rtcp_.get()) != 0) { WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(engine_id_, channel_id_), "%s: RTP::RegisterModule failure", __FUNCTION__); return -1; } - if (rtp_rtcp_.SetKeyFrameRequestMethod(kKeyFrameReqFirRtp) != 0) { + if (rtp_rtcp_->SetKeyFrameRequestMethod(kKeyFrameReqFirRtp) != 0) { WEBRTC_TRACE(kTraceWarning, kTraceVideo, ViEId(engine_id_, channel_id_), "%s: RTP::SetKeyFrameRequestMethod failure", __FUNCTION__); } - if (rtp_rtcp_.SetRTCPStatus(kRtcpCompound) != 0) { + if (rtp_rtcp_->SetRTCPStatus(kRtcpCompound) != 0) { WEBRTC_TRACE(kTraceWarning, kTraceVideo, ViEId(engine_id_, channel_id_), "%s: RTP::SetRTCPStatus failure", __FUNCTION__); } - if (rtp_rtcp_.RegisterIncomingRTPCallback(this) != 0) { - WEBRTC_TRACE(kTraceWarning, kTraceVideo, ViEId(engine_id_, channel_id_), - "%s: RTP::RegisterIncomingRTPCallback failure", __FUNCTION__); - return -1; - } // VCM initialization if (vcm_.InitializeReceiver() != 0) { WEBRTC_TRACE(kTraceError, kTraceVideo, @@ -171,11 +153,11 @@ WebRtc_Word32 ViEChannel::Init() { #ifdef VIDEOCODEC_VP8 VideoCodec video_codec; if (vcm_.Codec(kVideoCodecVP8, &video_codec) == VCM_OK) { - rtp_rtcp_.RegisterSendPayload(video_codec); - rtp_rtcp_.RegisterReceivePayload(video_codec); + rtp_rtcp_->RegisterSendPayload(video_codec); + rtp_rtcp_->RegisterReceivePayload(video_codec); vcm_.RegisterReceiveCodec(&video_codec, number_of_cores_); vcm_.RegisterSendCodec(&video_codec, number_of_cores_, - rtp_rtcp_.MaxDataPayloadLength()); + rtp_rtcp_->MaxDataPayloadLength()); } else { assert(false); } @@ -190,32 +172,23 @@ ViEChannel::~ViEChannel() { channel_id_, engine_id_); // Make sure we don't get more callbacks from the RTP module. - rtp_rtcp_.RegisterIncomingRTPCallback(NULL); - rtp_rtcp_.RegisterSendTransport(NULL); #ifndef WEBRTC_EXTERNAL_TRANSPORT socket_transport_.StopReceiving(); #endif - module_process_thread_.DeRegisterModule(&rtp_rtcp_); + module_process_thread_.DeRegisterModule(rtp_rtcp_.get()); module_process_thread_.DeRegisterModule(&vcm_); module_process_thread_.DeRegisterModule(&vie_sync_); while (simulcast_rtp_rtcp_.size() > 0) { std::list::iterator it = simulcast_rtp_rtcp_.begin(); RtpRtcp* rtp_rtcp = *it; - rtp_rtcp->RegisterSendTransport(NULL); module_process_thread_.DeRegisterModule(rtp_rtcp); - RtpRtcp::DestroyRtpRtcp(rtp_rtcp); + delete rtp_rtcp; simulcast_rtp_rtcp_.erase(it); } if (decode_thread_) { StopDecodeThread(); } - - delete &vie_receiver_; - delete &vie_sender_; - delete &vie_sync_; - // Release modules. - RtpRtcp::DestroyRtpRtcp(&rtp_rtcp_); #ifndef WEBRTC_EXTERNAL_TRANSPORT UdpTransport::Destroy(&socket_transport_); #endif @@ -243,9 +216,9 @@ WebRtc_Word32 ViEChannel::SetSendCodec(const VideoCodec& video_codec, // Stop and Start the RTP module -> trigger new SSRC, if an SSRC hasn't been // set explicitly. bool restart_rtp = false; - if (rtp_rtcp_.Sending() && new_stream) { + if (rtp_rtcp_->Sending() && new_stream) { restart_rtp = true; - rtp_rtcp_.SetSendingStatus(false); + rtp_rtcp_->SetSendingStatus(false); } if (video_codec.numberOfSimulcastStreams > 0) { // Set correct bitrate to base layer. @@ -253,36 +226,19 @@ WebRtc_Word32 ViEChannel::SetSendCodec(const VideoCodec& video_codec, for (int i = simulcast_rtp_rtcp_.size(); i < video_codec.numberOfSimulcastStreams - 1; i++) { - RtpRtcp* rtp_rtcp = RtpRtcp::CreateRtpRtcp( - ViEModuleId(engine_id_, channel_id_), false); - if (rtp_rtcp->RegisterDefaultModule(default_rtp_rtcp_)) { - WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(engine_id_, channel_id_), - "%s: could not register default module", __FUNCTION__); - return -1; - } - if (rtp_rtcp->InitSender() != 0) { - WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(engine_id_, channel_id_), - "%s: RTP::InitSender failure", __FUNCTION__); - return -1; - } - if (rtp_rtcp->InitReceiver() != 0) { - WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(engine_id_, channel_id_), - "%s: RTP::InitReceiver failure", __FUNCTION__); - return -1; - } - rtp_rtcp->RegisterRtcpObservers(intra_frame_observer_, - bandwidth_observer_.get(), - this); + RtpRtcp::Configuration configuration; + configuration.id = ViEModuleId(engine_id_, channel_id_); + configuration.audio = false; // Video. + configuration.default_module = default_rtp_rtcp_; + configuration.outgoing_transport = &vie_sender_; + configuration.intra_frame_callback = intra_frame_observer_; + configuration.bandwidth_callback = bandwidth_observer_.get(); + + RtpRtcp* rtp_rtcp = RtpRtcp::CreateRtpRtcp(configuration); - if (rtp_rtcp->RegisterSendTransport( - static_cast(&vie_sender_)) != 0) { - WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(engine_id_, channel_id_), - "%s: RTP::RegisterSendTransport failure", __FUNCTION__); - return -1; - } // Silently ignore error. module_process_thread_.RegisterModule(rtp_rtcp); - if (rtp_rtcp->SetRTCPStatus(rtp_rtcp_.RTCP()) != 0) { + if (rtp_rtcp->SetRTCPStatus(rtp_rtcp_->RTCP()) != 0) { WEBRTC_TRACE(kTraceWarning, kTraceVideo, ViEId(engine_id_, channel_id_), "%s: RTP::SetRTCPStatus failure", __FUNCTION__); } @@ -293,9 +249,8 @@ WebRtc_Word32 ViEChannel::SetSendCodec(const VideoCodec& video_codec, j > (video_codec.numberOfSimulcastStreams - 1); j--) { RtpRtcp* rtp_rtcp = simulcast_rtp_rtcp_.back(); - rtp_rtcp->RegisterSendTransport(NULL); module_process_thread_.DeRegisterModule(rtp_rtcp); - RtpRtcp::DestroyRtpRtcp(rtp_rtcp); + delete rtp_rtcp; simulcast_rtp_rtcp_.pop_back(); } WebRtc_UWord8 idx = 0; @@ -324,9 +279,8 @@ WebRtc_Word32 ViEChannel::SetSendCodec(const VideoCodec& video_codec, // Delete all simulcast rtp modules. while (!simulcast_rtp_rtcp_.empty()) { RtpRtcp* rtp_rtcp = simulcast_rtp_rtcp_.back(); - rtp_rtcp->RegisterSendTransport(NULL); module_process_thread_.DeRegisterModule(rtp_rtcp); - RtpRtcp::DestroyRtpRtcp(rtp_rtcp); + delete rtp_rtcp; simulcast_rtp_rtcp_.pop_back(); } } @@ -337,25 +291,25 @@ WebRtc_Word32 ViEChannel::SetSendCodec(const VideoCodec& video_codec, // This sets the wanted packetization mode. // if (video_codec.plType == kVideoCodecH264) { // if (video_codec.codecSpecific.H264.packetization == kH264SingleMode) { - // rtp_rtcp_.SetH264PacketizationMode(H264_SINGLE_NAL_MODE); + // rtp_rtcp_->SetH264PacketizationMode(H264_SINGLE_NAL_MODE); // } else { - // rtp_rtcp_.SetH264PacketizationMode(H264_NON_INTERLEAVED_MODE); + // rtp_rtcp_->SetH264PacketizationMode(H264_NON_INTERLEAVED_MODE); // } // if (video_codec.codecSpecific.H264.configParametersSize > 0) { - // rtp_rtcp_.SetH264SendModeNALU_PPS_SPS(true); + // rtp_rtcp_->SetH264SendModeNALU_PPS_SPS(true); // } // } // Don't log this error, no way to check in advance if this pl_type is // registered or not... - rtp_rtcp_.DeRegisterSendPayload(video_codec.plType); - if (rtp_rtcp_.RegisterSendPayload(video_codec) != 0) { + rtp_rtcp_->DeRegisterSendPayload(video_codec.plType); + if (rtp_rtcp_->RegisterSendPayload(video_codec) != 0) { WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(engine_id_, channel_id_), "%s: could not register payload type", __FUNCTION__); return -1; } if (restart_rtp) { - rtp_rtcp_.SetSendingStatus(true); + rtp_rtcp_->SetSendingStatus(true); } return 0; } @@ -366,11 +320,11 @@ WebRtc_Word32 ViEChannel::SetReceiveCodec(const VideoCodec& video_codec) { "%s", __FUNCTION__); WebRtc_Word8 old_pltype = -1; - if (rtp_rtcp_.ReceivePayloadType(video_codec, &old_pltype) != -1) { - rtp_rtcp_.DeRegisterReceivePayload(old_pltype); + if (rtp_rtcp_->ReceivePayloadType(video_codec, &old_pltype) != -1) { + rtp_rtcp_->DeRegisterReceivePayload(old_pltype); } - if (rtp_rtcp_.RegisterReceivePayload(video_codec) != 0) { + if (rtp_rtcp_->RegisterReceivePayload(video_codec) != 0) { WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(engine_id_, channel_id_), "%s: Could not register receive payload type", __FUNCTION__); return -1; @@ -527,13 +481,13 @@ WebRtc_Word32 ViEChannel::SetRTCPMode(const RTCPMethod rtcp_mode) { RtpRtcp* rtp_rtcp = *it; rtp_rtcp->SetRTCPStatus(rtcp_mode); } - return rtp_rtcp_.SetRTCPStatus(rtcp_mode); + return rtp_rtcp_->SetRTCPStatus(rtcp_mode); } WebRtc_Word32 ViEChannel::GetRTCPMode(RTCPMethod& rtcp_mode) { WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(engine_id_, channel_id_), "%s", __FUNCTION__); - rtcp_mode = rtp_rtcp_.RTCP(); + rtcp_mode = rtp_rtcp_->RTCP(); return 0; } @@ -569,12 +523,12 @@ WebRtc_Word32 ViEChannel::ProcessNACKRequest(const bool enable) { if (enable) { // Turn on NACK. NACKMethod nackMethod = kNackRtcp; - if (rtp_rtcp_.RTCP() == kRtcpOff) { + if (rtp_rtcp_->RTCP() == kRtcpOff) { WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(engine_id_, channel_id_), "%s: Could not enable NACK, RTPC not on ", __FUNCTION__); return -1; } - if (rtp_rtcp_.SetNACKStatus(nackMethod) != 0) { + if (rtp_rtcp_->SetNACKStatus(nackMethod) != 0) { WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(engine_id_, channel_id_), "%s: Could not set NACK method %d", __FUNCTION__, nackMethod); @@ -582,7 +536,7 @@ WebRtc_Word32 ViEChannel::ProcessNACKRequest(const bool enable) { } WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(engine_id_, channel_id_), "%s: Using NACK method %d", __FUNCTION__, nackMethod); - rtp_rtcp_.SetStorePacketsStatus(true, kNackHistorySize); + rtp_rtcp_->SetStorePacketsStatus(true, kNackHistorySize); vcm_.RegisterPacketRequestCallback(this); @@ -599,9 +553,9 @@ WebRtc_Word32 ViEChannel::ProcessNACKRequest(const bool enable) { RtpRtcp* rtp_rtcp = *it; rtp_rtcp->SetStorePacketsStatus(false); } - rtp_rtcp_.SetStorePacketsStatus(false); + rtp_rtcp_->SetStorePacketsStatus(false); vcm_.RegisterPacketRequestCallback(NULL); - if (rtp_rtcp_.SetNACKStatus(kNackOff) != 0) { + if (rtp_rtcp_->SetNACKStatus(kNackOff) != 0) { WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(engine_id_, channel_id_), "%s: Could not turn off NACK", __FUNCTION__); return -1; @@ -629,7 +583,7 @@ WebRtc_Word32 ViEChannel::ProcessFECRequest( "%s(enable: %d, payload_typeRED: %u, payload_typeFEC: %u)", __FUNCTION__, enable, payload_typeRED, payload_typeFEC); - if (rtp_rtcp_.SetGenericFECStatus(enable, payload_typeRED, + if (rtp_rtcp_->SetGenericFECStatus(enable, payload_typeRED, payload_typeFEC) != 0) { WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(engine_id_, channel_id_), "%s: Could not change FEC status to %d", __FUNCTION__, @@ -669,13 +623,13 @@ WebRtc_Word32 ViEChannel::SetKeyFrameRequestMethod( const KeyFrameRequestMethod method) { WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(engine_id_, channel_id_), "%s: %d", __FUNCTION__, method); - return rtp_rtcp_.SetKeyFrameRequestMethod(method); + return rtp_rtcp_->SetKeyFrameRequestMethod(method); } bool ViEChannel::EnableRemb(bool enable) { WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(engine_id_, channel_id_), "ViEChannel::EnableRemb: %d", enable); - if (rtp_rtcp_.SetREMBStatus(enable) != 0) + if (rtp_rtcp_->SetREMBStatus(enable) != 0) return false; return true; } @@ -683,7 +637,7 @@ bool ViEChannel::EnableRemb(bool enable) { WebRtc_Word32 ViEChannel::EnableTMMBR(const bool enable) { WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(engine_id_, channel_id_), "%s: %d", __FUNCTION__, enable); - return rtp_rtcp_.SetTMMBRStatus(enable); + return rtp_rtcp_->SetTMMBRStatus(enable); } WebRtc_Word32 ViEChannel::EnableKeyFrameRequestCallback(const bool enable) { @@ -709,7 +663,7 @@ WebRtc_Word32 ViEChannel::SetSSRC(const WebRtc_UWord32 SSRC, "%s(usage:%d, SSRC: 0x%x, idx:%u)", __FUNCTION__, usage, SSRC, simulcast_idx); if (simulcast_idx == 0) { - return rtp_rtcp_.SetSSRC(SSRC); + return rtp_rtcp_->SetSSRC(SSRC); } if (simulcast_idx > simulcast_rtp_rtcp_.size()) { return -1; @@ -735,13 +689,13 @@ WebRtc_Word32 ViEChannel::SetRemoteSSRCType(const StreamType usage, "%s(usage:%d, SSRC: 0x%x)", __FUNCTION__, usage, SSRC); - return rtp_rtcp_.SetRTXReceiveStatus(true, SSRC); + return rtp_rtcp_->SetRTXReceiveStatus(true, SSRC); } WebRtc_Word32 ViEChannel::GetLocalSSRC(WebRtc_UWord32& SSRC) { WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(engine_id_, channel_id_), "%s", __FUNCTION__); - SSRC = rtp_rtcp_.SSRC(); + SSRC = rtp_rtcp_->SSRC(); return 0; } @@ -749,7 +703,7 @@ WebRtc_Word32 ViEChannel::GetRemoteSSRC(WebRtc_UWord32& SSRC) { WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(engine_id_, channel_id_), "%s", __FUNCTION__); - SSRC = rtp_rtcp_.RemoteSSRC(); + SSRC = rtp_rtcp_->RemoteSSRC(); return 0; } @@ -760,7 +714,7 @@ WebRtc_Word32 ViEChannel::GetRemoteCSRC(unsigned int CSRCs[kRtpCsrcSize]) { WebRtc_UWord32 arrayCSRC[kRtpCsrcSize]; memset(arrayCSRC, 0, sizeof(arrayCSRC)); - WebRtc_Word32 num_csrcs = rtp_rtcp_.RemoteCSRCs(arrayCSRC); + WebRtc_Word32 num_csrcs = rtp_rtcp_->RemoteCSRCs(arrayCSRC); if (num_csrcs > 0) { memcpy(CSRCs, arrayCSRC, num_csrcs * sizeof(WebRtc_UWord32)); for (int idx = 0; idx < num_csrcs; idx++) { @@ -779,37 +733,37 @@ WebRtc_Word32 ViEChannel::SetStartSequenceNumber( WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(engine_id_, channel_id_), "%s", __FUNCTION__); - if (rtp_rtcp_.Sending()) { + if (rtp_rtcp_->Sending()) { WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(engine_id_, channel_id_), "%s: already sending", __FUNCTION__); return -1; } - return rtp_rtcp_.SetSequenceNumber(sequence_number); + return rtp_rtcp_->SetSequenceNumber(sequence_number); } WebRtc_Word32 ViEChannel::SetRTCPCName(const char rtcp_cname[]) { WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(engine_id_, channel_id_), "%s", __FUNCTION__); - if (rtp_rtcp_.Sending()) { + if (rtp_rtcp_->Sending()) { WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(engine_id_, channel_id_), "%s: already sending", __FUNCTION__); return -1; } - return rtp_rtcp_.SetCNAME(rtcp_cname); + return rtp_rtcp_->SetCNAME(rtcp_cname); } WebRtc_Word32 ViEChannel::GetRTCPCName(char rtcp_cname[]) { WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(engine_id_, channel_id_), "%s", __FUNCTION__); - return rtp_rtcp_.CNAME(rtcp_cname); + return rtp_rtcp_->CNAME(rtcp_cname); } WebRtc_Word32 ViEChannel::GetRemoteRTCPCName(char rtcp_cname[]) { WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(engine_id_, channel_id_), "%s", __FUNCTION__); - WebRtc_UWord32 remoteSSRC = rtp_rtcp_.RemoteSSRC(); - return rtp_rtcp_.RemoteCNAME(remoteSSRC, rtcp_cname); + WebRtc_UWord32 remoteSSRC = rtp_rtcp_->RemoteSSRC(); + return rtp_rtcp_->RemoteCNAME(remoteSSRC, rtcp_cname); } WebRtc_Word32 ViEChannel::RegisterRtpObserver(ViERTPObserver* observer) { @@ -867,7 +821,7 @@ WebRtc_Word32 ViEChannel::SendApplicationDefinedRTCPPacket( WebRtc_UWord16 data_length_in_bytes) { WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(engine_id_, channel_id_), "%s", __FUNCTION__); - if (!rtp_rtcp_.Sending()) { + if (!rtp_rtcp_->Sending()) { WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(engine_id_, channel_id_), "%s: not sending", __FUNCTION__); return -1; @@ -882,14 +836,14 @@ WebRtc_Word32 ViEChannel::SendApplicationDefinedRTCPPacket( "%s: input length error", __FUNCTION__); return -1; } - RTCPMethod rtcp_method = rtp_rtcp_.RTCP(); + RTCPMethod rtcp_method = rtp_rtcp_->RTCP(); if (rtcp_method == kRtcpOff) { WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(engine_id_, channel_id_), "%s: RTCP not enabled", __FUNCTION__); return -1; } // Create and send packet. - if (rtp_rtcp_.SetRTCPApplicationSpecificData(sub_type, name, data, + if (rtp_rtcp_->SetRTCPApplicationSpecificData(sub_type, name, data, data_length_in_bytes) != 0) { WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(engine_id_, channel_id_), "%s: Could not send RTCP application data", __FUNCTION__); @@ -913,14 +867,14 @@ WebRtc_Word32 ViEChannel::GetSendRtcpStatistics(WebRtc_UWord16& fraction_lost, // it++) { // RtpRtcp* rtp_rtcp = *it; // } - WebRtc_UWord32 remoteSSRC = rtp_rtcp_.RemoteSSRC(); + WebRtc_UWord32 remoteSSRC = rtp_rtcp_->RemoteSSRC(); // Get all RTCP receiver report blocks that have been received on this // channel. If we receive RTP packets from a remote source we know the // remote SSRC and use the report block from him. // Otherwise use the first report block. std::vector remote_stats; - if (rtp_rtcp_.RemoteRTCPStat(&remote_stats) != 0 || remote_stats.empty()) { + if (rtp_rtcp_->RemoteRTCPStat(&remote_stats) != 0 || remote_stats.empty()) { WEBRTC_TRACE(kTraceWarning, kTraceVideo, ViEId(engine_id_, channel_id_), "%s: Could not get remote stats", __FUNCTION__); return -1; @@ -947,7 +901,7 @@ WebRtc_Word32 ViEChannel::GetSendRtcpStatistics(WebRtc_UWord16& fraction_lost, WebRtc_UWord16 dummy; WebRtc_UWord16 rtt = 0; - if (rtp_rtcp_.RTT(remoteSSRC, &rtt, &dummy, &dummy, &dummy) != 0) { + if (rtp_rtcp_->RTT(remoteSSRC, &rtt, &dummy, &dummy, &dummy) != 0) { WEBRTC_TRACE(kTraceWarning, kTraceVideo, ViEId(engine_id_, channel_id_), "%s: Could not get RTT", __FUNCTION__); return -1; @@ -966,7 +920,7 @@ WebRtc_Word32 ViEChannel::GetReceivedRtcpStatistics( "%s", __FUNCTION__); WebRtc_UWord8 frac_lost = 0; - if (rtp_rtcp_.StatisticsRTP(&frac_lost, &cumulative_lost, &extended_max, + if (rtp_rtcp_->StatisticsRTP(&frac_lost, &cumulative_lost, &extended_max, &jitter_samples) != 0) { WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(engine_id_, channel_id_), "%s: Could not get received RTP statistics", __FUNCTION__); @@ -974,10 +928,10 @@ WebRtc_Word32 ViEChannel::GetReceivedRtcpStatistics( } fraction_lost = frac_lost; - WebRtc_UWord32 remoteSSRC = rtp_rtcp_.RemoteSSRC(); + WebRtc_UWord32 remoteSSRC = rtp_rtcp_->RemoteSSRC(); WebRtc_UWord16 dummy = 0; WebRtc_UWord16 rtt = 0; - if (rtp_rtcp_.RTT(remoteSSRC, &rtt, &dummy, &dummy, &dummy) != 0) { + if (rtp_rtcp_->RTT(remoteSSRC, &rtt, &dummy, &dummy, &dummy) != 0) { WEBRTC_TRACE(kTraceStateInfo, kTraceVideo, ViEId(engine_id_, channel_id_), "%s: Could not get RTT", __FUNCTION__); } @@ -993,7 +947,7 @@ WebRtc_Word32 ViEChannel::GetRtpStatistics( WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(engine_id_, channel_id_), "%s", __FUNCTION__); - if (rtp_rtcp_.DataCountersRTP(&bytes_sent, + if (rtp_rtcp_->DataCountersRTP(&bytes_sent, &packets_sent, &bytes_received, &packets_received) != 0) { @@ -1021,7 +975,7 @@ void ViEChannel::GetBandwidthUsage(WebRtc_UWord32& total_bitrate_sent, WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(engine_id_, channel_id_), "%s", __FUNCTION__); - rtp_rtcp_.BitrateSent(&total_bitrate_sent, + rtp_rtcp_->BitrateSent(&total_bitrate_sent, &video_bitrate_sent, &fec_bitrate_sent, &nackBitrateSent); @@ -1041,7 +995,7 @@ void ViEChannel::GetBandwidthUsage(WebRtc_UWord32& total_bitrate_sent, int ViEChannel::GetEstimatedReceiveBandwidth( WebRtc_UWord32* estimated_bandwidth) const { - return rtp_rtcp_.EstimatedReceiveBandwidth(estimated_bandwidth); + return rtp_rtcp_->EstimatedReceiveBandwidth(estimated_bandwidth); } WebRtc_Word32 ViEChannel::StartRTPDump(const char file_nameUTF8[1024], @@ -1230,7 +1184,7 @@ WebRtc_Word32 ViEChannel::SetSendDestination( if ((UdpTransport::LocalHostAddress(local_host_address) == 0 && local_host_address == current_ip_address) || strncmp("127.0.0.1", ip_address, 9) == 0) { - rtp_rtcp_.SetSSRC(0xFFFFFFFF); + rtp_rtcp_->SetSSRC(0xFFFFFFFF); WEBRTC_TRACE(kTraceStateInfo, kTraceVideo, ViEId(engine_id_, channel_id_), "Running in loopback. Forcing fixed SSRC"); } @@ -1263,7 +1217,7 @@ WebRtc_Word32 ViEChannel::SetSendDestination( } } if (local_host) { - rtp_rtcp_.SetSSRC(0xFFFFFFFF); + rtp_rtcp_->SetSSRC(0xFFFFFFFF); WEBRTC_TRACE(kTraceStateInfo, kTraceVideo, ViEId(engine_id_, channel_id_), "Running in loopback. Forcing fixed SSRC"); @@ -1338,15 +1292,15 @@ WebRtc_Word32 ViEChannel::StartSend() { } } #endif - rtp_rtcp_.SetSendingMediaStatus(true); + rtp_rtcp_->SetSendingMediaStatus(true); - if (rtp_rtcp_.Sending()) { + if (rtp_rtcp_->Sending()) { // Already sending. WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(engine_id_, channel_id_), "%s: Already sending", __FUNCTION__); return kViEBaseAlreadySending; } - if (rtp_rtcp_.SetSendingStatus(true) != 0) { + if (rtp_rtcp_->SetSendingStatus(true) != 0) { WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(engine_id_, channel_id_), "%s: Could not start sending RTP", __FUNCTION__); return -1; @@ -1365,22 +1319,22 @@ WebRtc_Word32 ViEChannel::StopSend() { WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(engine_id_, channel_id_), "%s", __FUNCTION__); - rtp_rtcp_.SetSendingMediaStatus(false); + rtp_rtcp_->SetSendingMediaStatus(false); for (std::list::iterator it = simulcast_rtp_rtcp_.begin(); it != simulcast_rtp_rtcp_.end(); it++) { RtpRtcp* rtp_rtcp = *it; rtp_rtcp->SetSendingMediaStatus(false); } - if (!rtp_rtcp_.Sending()) { + if (!rtp_rtcp_->Sending()) { WEBRTC_TRACE(kTraceWarning, kTraceVideo, ViEId(engine_id_, channel_id_), "%s: Not sending", __FUNCTION__); return kViEBaseNotSending; } // Reset. - rtp_rtcp_.ResetSendDataCountersRTP(); - if (rtp_rtcp_.SetSendingStatus(false) != 0) { + rtp_rtcp_->ResetSendDataCountersRTP(); + if (rtp_rtcp_->SetSendingStatus(false) != 0) { WEBRTC_TRACE(kTraceWarning, kTraceVideo, ViEId(engine_id_, channel_id_), "%s: could not stop RTP sending", __FUNCTION__); return -1; @@ -1396,7 +1350,7 @@ WebRtc_Word32 ViEChannel::StopSend() { } bool ViEChannel::Sending() { - return rtp_rtcp_.Sending(); + return rtp_rtcp_->Sending(); } WebRtc_Word32 ViEChannel::StartReceive() { @@ -1535,7 +1489,7 @@ WebRtc_Word32 ViEChannel::RegisterSendTransport(Transport& transport) { return -1; } #endif - if (rtp_rtcp_.Sending()) { + if (rtp_rtcp_->Sending()) { WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(engine_id_, channel_id_), "%s: Sending", __FUNCTION__); return -1; @@ -1566,7 +1520,7 @@ WebRtc_Word32 ViEChannel::DeregisterSendTransport() { "%s: no transport registered", __FUNCTION__); return -1; } - if (rtp_rtcp_.Sending()) { + if (rtp_rtcp_->Sending()) { WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(engine_id_, channel_id_), "%s: Sending", __FUNCTION__); return -1; @@ -1833,7 +1787,7 @@ WebRtc_Word32 ViEChannel::GetSendGQoS(bool& enabled, WebRtc_Word32 ViEChannel::SetMTU(WebRtc_UWord16 mtu) { WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(engine_id_, channel_id_), "%s", __FUNCTION__); - if (rtp_rtcp_.SetMaxTransferUnit(mtu) != 0) { + if (rtp_rtcp_->SetMaxTransferUnit(mtu) != 0) { // Logging done. return -1; } @@ -1850,7 +1804,7 @@ WebRtc_Word32 ViEChannel::SetMTU(WebRtc_UWord16 mtu) { WebRtc_UWord16 ViEChannel::MaxDataPayloadLength() const { WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(engine_id_, channel_id_), "%s", __FUNCTION__); - return rtp_rtcp_.MaxDataPayloadLength(); + return rtp_rtcp_->MaxDataPayloadLength(); } WebRtc_Word32 ViEChannel::SetPacketTimeoutNotification( @@ -1859,13 +1813,13 @@ WebRtc_Word32 ViEChannel::SetPacketTimeoutNotification( __FUNCTION__); if (enable) { WebRtc_UWord32 timeout_ms = 1000 * timeout_seconds; - if (rtp_rtcp_.SetPacketTimeout(timeout_ms, 0) != 0) { + if (rtp_rtcp_->SetPacketTimeout(timeout_ms, 0) != 0) { WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(engine_id_, channel_id_), "%s", __FUNCTION__); return -1; } } else { - if (rtp_rtcp_.SetPacketTimeout(0, 0) != 0) { + if (rtp_rtcp_->SetPacketTimeout(0, 0) != 0) { WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(engine_id_, channel_id_), "%s", __FUNCTION__); return -1; @@ -1920,9 +1874,9 @@ WebRtc_Word32 ViEChannel::SetPeriodicDeadOrAliveStatus( WebRtc_UWord8 current_sampletime_seconds = 0; // Get old settings. - rtp_rtcp_.PeriodicDeadOrAliveStatus(enabled, current_sampletime_seconds); + rtp_rtcp_->PeriodicDeadOrAliveStatus(enabled, current_sampletime_seconds); // Set new settings. - if (rtp_rtcp_.SetPeriodicDeadOrAliveStatus( + if (rtp_rtcp_->SetPeriodicDeadOrAliveStatus( enable, static_cast(sample_time_seconds)) != 0) { WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(engine_id_, channel_id_), "%s: Could not set periodic dead-or-alive status", @@ -1934,7 +1888,7 @@ WebRtc_Word32 ViEChannel::SetPeriodicDeadOrAliveStatus( // Without this trick, the sample time would always be reset to default // (2 sec), each time dead-or-alive was disabled without sample-time // parameter. - rtp_rtcp_.SetPeriodicDeadOrAliveStatus(enable, current_sampletime_seconds); + rtp_rtcp_->SetPeriodicDeadOrAliveStatus(enable, current_sampletime_seconds); } return 0; } @@ -1977,39 +1931,10 @@ WebRtc_Word32 ViEChannel::EnableColorEnhancement(bool enable) { return 0; } -WebRtc_Word32 ViEChannel::RegisterSendRtpRtcpModule( - RtpRtcp& send_rtp_rtcp_module) { - WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(engine_id_, channel_id_), "%s", - __FUNCTION__); - - WebRtc_Word32 ret_val = rtp_rtcp_.RegisterDefaultModule( - &send_rtp_rtcp_module); - if (ret_val == 0) { - // We need to store this for the SetSendCodec call. - default_rtp_rtcp_ = &send_rtp_rtcp_module; - } - return ret_val; -} - -WebRtc_Word32 ViEChannel::DeregisterSendRtpRtcpModule() { - WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(engine_id_, channel_id_), "%s", - __FUNCTION__); - default_rtp_rtcp_ = NULL; - - for (std::list::const_iterator it = simulcast_rtp_rtcp_.begin(); - it != simulcast_rtp_rtcp_.end(); - it++) { - RtpRtcp* rtp_rtcp = *it; - rtp_rtcp->DeRegisterDefaultModule(); - } - return rtp_rtcp_.DeRegisterDefaultModule(); -} - RtpRtcp* ViEChannel::rtp_rtcp() { - return &rtp_rtcp_; + return rtp_rtcp_.get(); } - WebRtc_Word32 ViEChannel::FrameToRender(VideoFrame& video_frame) { CriticalSectionScoped cs(callback_cs_.get()); @@ -2046,9 +1971,9 @@ WebRtc_Word32 ViEChannel::FrameToRender(VideoFrame& video_frame) { file_recorder_.RecordVideoFrame(video_frame); WebRtc_UWord32 arr_ofCSRC[kRtpCsrcSize]; - WebRtc_Word32 no_of_csrcs = rtp_rtcp_.RemoteCSRCs(arr_ofCSRC); + WebRtc_Word32 no_of_csrcs = rtp_rtcp_->RemoteCSRCs(arr_ofCSRC); if (no_of_csrcs <= 0) { - arr_ofCSRC[0] = rtp_rtcp_.RemoteSSRC(); + arr_ofCSRC[0] = rtp_rtcp_->RemoteSSRC(); no_of_csrcs = 1; } WEBRTC_TRACE(kTraceStream, kTraceVideo, ViEId(engine_id_, channel_id_), @@ -2059,7 +1984,7 @@ WebRtc_Word32 ViEChannel::FrameToRender(VideoFrame& video_frame) { WebRtc_Word32 ViEChannel::ReceivedDecodedReferenceFrame( const WebRtc_UWord64 picture_id) { - return rtp_rtcp_.SendRTCPReferencePictureSelection(picture_id); + return rtp_rtcp_->SendRTCPReferencePictureSelection(picture_id); } WebRtc_Word32 ViEChannel::StoreReceivedFrame( @@ -2088,19 +2013,19 @@ WebRtc_Word32 ViEChannel::RequestKeyFrame() { codec_observer_->RequestNewKeyFrame(channel_id_); } } - return rtp_rtcp_.RequestKeyFrame(); + return rtp_rtcp_->RequestKeyFrame(); } WebRtc_Word32 ViEChannel::SliceLossIndicationRequest( const WebRtc_UWord64 picture_id) { - return rtp_rtcp_.SendRTCPSliceLossIndication((WebRtc_UWord8) picture_id); + return rtp_rtcp_->SendRTCPSliceLossIndication((WebRtc_UWord8) picture_id); } WebRtc_Word32 ViEChannel::ResendPackets(const WebRtc_UWord16* sequence_numbers, WebRtc_UWord16 length) { WEBRTC_TRACE(kTraceStream, kTraceVideo, ViEId(engine_id_, channel_id_), "%s(length: %d)", __FUNCTION__, length); - return rtp_rtcp_.SendNACK(sequence_numbers, length); + return rtp_rtcp_->SendNACK(sequence_numbers, length); } bool ViEChannel::ChannelDecodeThreadFunction(void* obj) { @@ -2117,11 +2042,11 @@ bool ViEChannel::ChannelDecodeProcess() { WebRtc_UWord16 minRTT; WebRtc_UWord16 maxRTT; - if (rtp_rtcp_.RTT(rtp_rtcp_.RemoteSSRC(), &RTT, &avgRTT, &minRTT, &maxRTT) + if (rtp_rtcp_->RTT(rtp_rtcp_->RemoteSSRC(), &RTT, &avgRTT, &minRTT, &maxRTT) == 0) { vcm_.SetReceiveChannelParameters(RTT); vcm_rttreported_ = TickTime::Now(); - } else if (!rtp_rtcp_.Sending() && + } else if (!rtp_rtcp_->Sending() && (TickTime::Now() - vcm_rttreported_).Milliseconds() > 5000) { // Wait at least 5 seconds before faking a 200 ms RTT. This is to // make sure we have a chance to start sending before we decide to fake. @@ -2239,7 +2164,8 @@ WebRtc_Word32 ViEChannel::SetVoiceChannel(WebRtc_Word32 ve_channel_id, } else { module_process_thread_.DeRegisterModule(&vie_sync_); } - return vie_sync_.SetVoiceChannel(ve_channel_id, ve_sync_interface); + return vie_sync_.ConfigureSync(ve_channel_id, ve_sync_interface, + rtp_rtcp_.get()); } WebRtc_Word32 ViEChannel::VoiceChannel() { @@ -2284,16 +2210,6 @@ void ViEChannel::ReleaseIncomingFileRecorder() { vcm_.RegisterFrameStorageCallback(NULL); } -void ViEChannel::OnLipSyncUpdate(const WebRtc_Word32 id, - const WebRtc_Word32 audio_video_offset) { - if (channel_id_ != ChannelId(id)) { - WEBRTC_TRACE(kTraceStream, kTraceVideo, ViEId(engine_id_, channel_id_), - "%s, incorrect id", __FUNCTION__, id); - return; - } - vie_sync_.SetNetworkDelay(audio_video_offset); -} - void ViEChannel::OnApplicationDataReceived(const WebRtc_Word32 id, const WebRtc_UWord8 sub_type, const WebRtc_UWord32 name, diff --git a/src/video_engine/vie_channel.h b/src/video_engine/vie_channel.h index d347d615d3..fe4c73e554 100644 --- a/src/video_engine/vie_channel.h +++ b/src/video_engine/vie_channel.h @@ -26,6 +26,9 @@ #include "video_engine/vie_defines.h" #include "video_engine/vie_file_recorder.h" #include "video_engine/vie_frame_provider_base.h" +#include "video_engine/vie_receiver.h" +#include "video_engine/vie_sender.h" +#include "video_engine/vie_sync_module.h" namespace webrtc { @@ -40,11 +43,8 @@ class VideoRenderCallback; class ViEDecoderObserver; class ViEEffectFilter; class ViENetworkObserver; -class ViEReceiver; class ViERTCPObserver; class ViERTPObserver; -class ViESender; -class ViESyncModule; class VoEVideoSync; class ViEChannel @@ -62,7 +62,9 @@ class ViEChannel WebRtc_UWord32 number_of_cores, ProcessThread& module_process_thread, RtcpIntraFrameObserver* intra_frame_observer, - RtcpBandwidthObserver* bandwidth_observer); + RtcpBandwidthObserver* bandwidth_observer, + RtpRemoteBitrateObserver* bitrate_observer, + RtpRtcp* default_rtp_rtcp); ~ViEChannel(); WebRtc_Word32 Init(); @@ -171,8 +173,7 @@ class ViEChannel WebRtc_Word32 StopRTPDump(RTPDirections direction); // Implements RtcpFeedback. - virtual void OnLipSyncUpdate(const WebRtc_Word32 id, - const WebRtc_Word32 audio_video_offset); + // TODO(pwestin) Depricate this functionality. virtual void OnApplicationDataReceived(const WebRtc_Word32 id, const WebRtc_UWord8 sub_type, const WebRtc_UWord32 name, @@ -282,14 +283,6 @@ class ViEChannel WebRtc_Word32 EnableColorEnhancement(bool enable); - // Register send RTP RTCP module, which will deliver encoded frames to the - // to the channel RTP module. - WebRtc_Word32 RegisterSendRtpRtcpModule(RtpRtcp& send_rtp_rtcp_module); - - // Deregisters the send RTP RTCP module, which will stop the encoder input to - // the channel. - WebRtc_Word32 DeregisterSendRtpRtcpModule(); - // Gets the modules used by the channel. RtpRtcp* rtp_rtcp(); @@ -356,17 +349,18 @@ class ViEChannel // Used for all registered callbacks except rendering. scoped_ptr callback_cs_; - // Owned modules/classes. - RtpRtcp& rtp_rtcp_; RtpRtcp* default_rtp_rtcp_; + + // Owned modules/classes. + scoped_ptr rtp_rtcp_; std::list simulcast_rtp_rtcp_; #ifndef WEBRTC_EXTERNAL_TRANSPORT UdpTransport& socket_transport_; #endif VideoCodingModule& vcm_; - ViEReceiver& vie_receiver_; - ViESender& vie_sender_; - ViESyncModule& vie_sync_; + ViEReceiver vie_receiver_; + ViESender vie_sender_; + ViESyncModule vie_sync_; // Not owned. ProcessThread& module_process_thread_; diff --git a/src/video_engine/vie_channel_group.cc b/src/video_engine/vie_channel_group.cc index f542d6b146..2555286b8c 100644 --- a/src/video_engine/vie_channel_group.cc +++ b/src/video_engine/vie_channel_group.cc @@ -43,6 +43,14 @@ bool ChannelGroup::Empty() { return channels_.empty(); } +RtpRemoteBitrateObserver* ChannelGroup::GetRtpRemoteBitrateObserver() { + return remb_.get(); +} + +BitrateController* ChannelGroup::GetBitrateController() { + return bitrate_controller_.get(); +} + bool ChannelGroup::SetChannelRembStatus(int channel_id, bool sender, bool receiver, @@ -68,11 +76,6 @@ bool ChannelGroup::SetChannelRembStatus(int channel_id, } else { remb_->RemoveReceiveChannel(rtp_module); } - if (sender || receiver) { - rtp_module->SetRemoteBitrateObserver(remb_.get()); - } else { - rtp_module->SetRemoteBitrateObserver(NULL); - } return true; } diff --git a/src/video_engine/vie_channel_group.h b/src/video_engine/vie_channel_group.h index 00c77a8c97..279a5560ee 100644 --- a/src/video_engine/vie_channel_group.h +++ b/src/video_engine/vie_channel_group.h @@ -19,6 +19,7 @@ namespace webrtc { class BitrateController; class ProcessThread; +class RtpRemoteBitrateObserver; class ViEChannel; class ViEEncoder; class VieRemb; @@ -41,7 +42,9 @@ class ChannelGroup { ViEChannel* channel, ViEEncoder* encoder); - BitrateController* GetBitrateController() { return bitrate_controller_.get();} + BitrateController* GetBitrateController(); + + RtpRemoteBitrateObserver* GetRtpRemoteBitrateObserver(); private: typedef std::set ChannelSet; diff --git a/src/video_engine/vie_channel_manager.cc b/src/video_engine/vie_channel_manager.cc index e9f6c5dad9..777bcccc29 100644 --- a/src/video_engine/vie_channel_manager.cc +++ b/src/video_engine/vie_channel_manager.cc @@ -98,8 +98,12 @@ int ViEChannelManager::CreateChannel(int& channel_id) { RtcpBandwidthObserver* bandwidth_observer = bitrate_controller->CreateRtcpBandwidthObserver(); + RtpRemoteBitrateObserver* bitrate_observer = + group->GetRtpRemoteBitrateObserver(); + if (!(vie_encoder->Init() && - CreateChannelObject(new_channel_id, vie_encoder, bandwidth_observer))) { + CreateChannelObject(new_channel_id, vie_encoder, bandwidth_observer, + bitrate_observer))) { delete vie_encoder; vie_encoder = NULL; ReturnChannelId(new_channel_id); @@ -129,8 +133,13 @@ int ViEChannelManager::CreateChannel(int& channel_id, } BitrateController* bitrate_controller = channel_group->GetBitrateController(); + RtcpBandwidthObserver* bandwidth_observer = bitrate_controller->CreateRtcpBandwidthObserver(); + + RtpRemoteBitrateObserver* bitrate_observer = + channel_group->GetRtpRemoteBitrateObserver(); + ViEEncoder* vie_encoder = NULL; if (sender) { // We need to create a new ViEEncoder. @@ -139,14 +148,15 @@ int ViEChannelManager::CreateChannel(int& channel_id, bitrate_controller); if (!(vie_encoder->Init() && CreateChannelObject(new_channel_id, vie_encoder, - bandwidth_observer))) { + bandwidth_observer, bitrate_observer))) { delete vie_encoder; vie_encoder = NULL; } } else { vie_encoder = ViEEncoderPtr(original_channel); assert(vie_encoder); - if (!CreateChannelObject(new_channel_id, vie_encoder, bandwidth_observer)) { + if (!CreateChannelObject(new_channel_id, vie_encoder, bandwidth_observer, + bitrate_observer)) { vie_encoder = NULL; } } @@ -182,8 +192,6 @@ int ViEChannelManager::DeleteChannel(int channel_id) { vie_channel = c_it->second; channel_map_.erase(c_it); - // Deregister the channel from the ViEEncoder to stop the media flow. - vie_channel->DeregisterSendRtpRtcpModule(); ReturnChannelId(channel_id); // Find the encoder object. @@ -198,10 +206,6 @@ int ViEChannelManager::DeleteChannel(int channel_id) { // Check if other channels are using the same encoder. if (ChannelUsingViEEncoder(channel_id)) { - // Don't delete the ViEEncoder, at least one other channel is using it. - WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(engine_id_), - "%s ViEEncoder removed from map for channel %d, not deleted", - __FUNCTION__, channel_id); vie_encoder = NULL; } else { // Delete later when we've released the critsect. @@ -217,6 +221,7 @@ int ViEChannelManager::DeleteChannel(int channel_id) { group = NULL; // Prevent group from being deleted. } } + delete vie_channel; // Leave the write critsect before deleting the objects. // Deleting a channel can cause other objects, such as renderers, to be // deleted, which might take time. @@ -236,7 +241,6 @@ int ViEChannelManager::DeleteChannel(int channel_id) { channel_id); delete group; } - delete vie_channel; WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(engine_id_), "%s Channel %d deleted", __FUNCTION__, channel_id); return 0; @@ -321,39 +325,32 @@ bool ViEChannelManager::SetRembStatus(int channel_id, bool sender, bool ViEChannelManager::CreateChannelObject( int channel_id, ViEEncoder* vie_encoder, - RtcpBandwidthObserver* bandwidth_observer) { + RtcpBandwidthObserver* bandwidth_observer, + RtpRemoteBitrateObserver* bitrate_observer) { + // Register the channel at the encoder. + RtpRtcp* send_rtp_rtcp_module = vie_encoder->SendRtpRtcpModule(); + ViEChannel* vie_channel = new ViEChannel(channel_id, engine_id_, number_of_cores_, *module_process_thread_, vie_encoder, - bandwidth_observer); + bandwidth_observer, + bitrate_observer, + send_rtp_rtcp_module); if (vie_channel->Init() != 0) { WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(engine_id_), "%s could not init channel", __FUNCTION__, channel_id); delete vie_channel; return false; } - // Register the channel at the encoder. - // Need to call RegisterSendRtpRtcpModule before SetSendCodec since - // the SetSendCodec call use the default rtp/rtcp module. - RtpRtcp* send_rtp_rtcp_module = vie_encoder->SendRtpRtcpModule(); - if (vie_channel->RegisterSendRtpRtcpModule(*send_rtp_rtcp_module) != 0) { - delete vie_channel; - WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(engine_id_, channel_id), - "%s: Could not register RTP module", __FUNCTION__); - return false; - } - VideoCodec encoder; if (vie_encoder->GetEncoder(encoder) != 0 || vie_channel->SetSendCodec(encoder) != 0) { WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(engine_id_, channel_id), "%s: Could not GetEncoder or SetSendCodec.", __FUNCTION__); - vie_channel->DeregisterSendRtpRtcpModule(); delete vie_channel; return false; } - // Store the channel, add it to the channel group and save the vie_encoder. channel_map_[channel_id] = vie_channel; vie_encoder_map_[channel_id] = vie_encoder; diff --git a/src/video_engine/vie_channel_manager.h b/src/video_engine/vie_channel_manager.h index fac38d7d26..a0c9382a59 100644 --- a/src/video_engine/vie_channel_manager.h +++ b/src/video_engine/vie_channel_manager.h @@ -77,7 +77,8 @@ class ViEChannelManager: private ViEManagerBase { // Creates a channel object connected to |vie_encoder|. Assumed to be called // protected. bool CreateChannelObject(int channel_id, ViEEncoder* vie_encoder, - RtcpBandwidthObserver* bandwidth_observer); + RtcpBandwidthObserver* bandwidth_observer, + RtpRemoteBitrateObserver* bitrate_observer); // Used by ViEChannelScoped, forcing a manager user to use scoped. // Returns a pointer to the channel with id 'channelId'. diff --git a/src/video_engine/vie_encoder.cc b/src/video_engine/vie_encoder.cc index 229d74d519..af5f34e08a 100644 --- a/src/video_engine/vie_encoder.cc +++ b/src/video_engine/vie_encoder.cc @@ -67,8 +67,7 @@ ViEEncoder::ViEEncoder(WebRtc_Word32 engine_id, channel_id))), vpm_(*webrtc::VideoProcessingModule::Create(ViEModuleId(engine_id, channel_id))), - default_rtp_rtcp_(*RtpRtcp::CreateRtpRtcp( - ViEModuleId(engine_id, channel_id), false)), + default_rtp_rtcp_(NULL), callback_cs_(CriticalSectionWrapper::CreateCriticalSection()), data_cs_(CriticalSectionWrapper::CreateCriticalSection()), bitrate_controller_(bitrate_controller), @@ -92,6 +91,11 @@ ViEEncoder::ViEEncoder(WebRtc_Word32 engine_id, "%s(engine_id: %d) 0x%p - Constructor", __FUNCTION__, engine_id, this); + RtpRtcp::Configuration configuration; + configuration.id = ViEModuleId(engine_id_, channel_id_); + configuration.audio = false; // Video. + + default_rtp_rtcp_.reset(RtpRtcp::CreateRtpRtcp(configuration)); bitrate_observer_.reset(new ViEBitrateObserver(this)); } @@ -113,13 +117,7 @@ bool ViEEncoder::Init() { "%s RegisterModule failure", __FUNCTION__); return false; } - if (default_rtp_rtcp_.InitSender() != 0) { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, - ViEId(engine_id_, channel_id_), - "%s InitSender failure", __FUNCTION__); - return false; - } - if (module_process_thread_.RegisterModule(&default_rtp_rtcp_) != 0) { + if (module_process_thread_.RegisterModule(default_rtp_rtcp_.get()) != 0) { WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(engine_id_, channel_id_), "%s RegisterModule failure", __FUNCTION__); @@ -140,13 +138,13 @@ bool ViEEncoder::Init() { return false; } if (vcm_.RegisterSendCodec(&video_codec, number_of_cores_, - default_rtp_rtcp_.MaxDataPayloadLength()) != 0) { + default_rtp_rtcp_->MaxDataPayloadLength()) != 0) { WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(engine_id_, channel_id_), "%s RegisterSendCodec failure", __FUNCTION__); return false; } - if (default_rtp_rtcp_.RegisterSendPayload(video_codec) != 0) { + if (default_rtp_rtcp_->RegisterSendPayload(video_codec) != 0) { WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(engine_id_, channel_id_), "%s RegisterSendPayload failure", __FUNCTION__); @@ -156,8 +154,8 @@ bool ViEEncoder::Init() { VideoCodec video_codec; if (vcm_.Codec(webrtc::kVideoCodecI420, &video_codec) == VCM_OK) { vcm_.RegisterSendCodec(&video_codec, number_of_cores_, - default_rtp_rtcp_.MaxDataPayloadLength()); - default_rtp_rtcp_.RegisterSendPayload(video_codec); + default_rtp_rtcp_->MaxDataPayloadLength()); + default_rtp_rtcp_->RegisterSendPayload(video_codec); } else { return false; } @@ -188,21 +186,11 @@ ViEEncoder::~ViEEncoder() { WEBRTC_TRACE(webrtc::kTraceMemory, webrtc::kTraceVideo, ViEId(engine_id_, channel_id_), "ViEEncoder Destructor 0x%p, engine_id: %d", this, engine_id_); - - if (default_rtp_rtcp_.NumberChildModules() > 0) { - assert(false); - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, - ViEId(engine_id_, channel_id_), - "Channels still attached %d, leaking memory", - default_rtp_rtcp_.NumberChildModules()); - return; - } module_process_thread_.DeRegisterModule(&vcm_); module_process_thread_.DeRegisterModule(&vpm_); - module_process_thread_.DeRegisterModule(&default_rtp_rtcp_); + module_process_thread_.DeRegisterModule(default_rtp_rtcp_.get()); delete &vcm_; delete &vpm_; - delete &default_rtp_rtcp_; delete qm_callback_; } @@ -305,7 +293,7 @@ WebRtc_Word32 ViEEncoder::DeRegisterExternalEncoder(WebRtc_UWord8 pl_type) { // encoder. if (current_send_codec.plType == pl_type) { WebRtc_UWord16 max_data_payload_length = - default_rtp_rtcp_.MaxDataPayloadLength(); + default_rtp_rtcp_->MaxDataPayloadLength(); if (vcm_.RegisterSendCodec(¤t_send_codec, number_of_cores_, max_data_payload_length) != VCM_OK) { WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, @@ -332,17 +320,17 @@ WebRtc_Word32 ViEEncoder::SetEncoder(const webrtc::VideoCodec& video_codec) { return -1; } - if (default_rtp_rtcp_.RegisterSendPayload(video_codec) != 0) { + if (default_rtp_rtcp_->RegisterSendPayload(video_codec) != 0) { WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(engine_id_, channel_id_), "Could register RTP module video payload"); return -1; } // Convert from kbps to bps. - default_rtp_rtcp_.SetTargetSendBitrate(video_codec.startBitrate * 1000); + default_rtp_rtcp_->SetTargetSendBitrate(video_codec.startBitrate * 1000); WebRtc_UWord16 max_data_payload_length = - default_rtp_rtcp_.MaxDataPayloadLength(); + default_rtp_rtcp_->MaxDataPayloadLength(); if (vcm_.RegisterSendCodec(&video_codec, number_of_cores_, max_data_payload_length) != VCM_OK) { @@ -354,8 +342,8 @@ WebRtc_Word32 ViEEncoder::SetEncoder(const webrtc::VideoCodec& video_codec) { // Set this module as sending right away, let the slave module in the channel // start and stop sending. - if (default_rtp_rtcp_.Sending() == false) { - if (default_rtp_rtcp_.SetSendingStatus(true) != 0) { + if (default_rtp_rtcp_->Sending() == false) { + if (default_rtp_rtcp_->SetSendingStatus(true) != 0) { WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(engine_id_, channel_id_), "Could start RTP module sending"); @@ -424,7 +412,7 @@ RtpRtcp* ViEEncoder::SendRtpRtcpModule() { WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideo, ViEId(engine_id_, channel_id_), "%s", __FUNCTION__); - return &default_rtp_rtcp_; + return default_rtp_rtcp_.get(); } void ViEEncoder::DeliverFrame(int id, webrtc::VideoFrame& video_frame, @@ -436,7 +424,7 @@ void ViEEncoder::DeliverFrame(int id, webrtc::VideoFrame& video_frame, { CriticalSectionScoped cs(data_cs_.get()); - if (paused_ || default_rtp_rtcp_.SendingMedia() == false) { + if (paused_ || default_rtp_rtcp_->SendingMedia() == false) { // We've paused or we have no channels attached, don't encode. return; } @@ -471,12 +459,12 @@ void ViEEncoder::DeliverFrame(int id, webrtc::VideoFrame& video_frame, WebRtc_UWord32 tempCSRC[kRtpCsrcSize]; for (int i = 0; i < num_csrcs; i++) { if (CSRC[i] == 1) { - tempCSRC[i] = default_rtp_rtcp_.SSRC(); + tempCSRC[i] = default_rtp_rtcp_->SSRC(); } else { tempCSRC[i] = CSRC[i]; } } - default_rtp_rtcp_.SetCSRCs(tempCSRC, (WebRtc_UWord8) num_csrcs); + default_rtp_rtcp_->SetCSRCs(tempCSRC, (WebRtc_UWord8) num_csrcs); } #ifdef VIDEOCODEC_VP8 @@ -559,7 +547,7 @@ void ViEEncoder::DelayChanged(int id, int frame_delay) { ViEId(engine_id_, channel_id_), "%s: %u", __FUNCTION__, frame_delay); - default_rtp_rtcp_.SetCameraDelay(frame_delay); + default_rtp_rtcp_->SetCameraDelay(frame_delay); file_recorder_.SetFrameDelay(frame_delay); } @@ -633,14 +621,14 @@ WebRtc_Word32 ViEEncoder::UpdateProtectionMethod() { // Updated protection method to VCM to get correct packetization sizes. // FEC has larger overhead than NACK -> set FEC if used. - WebRtc_Word32 error = default_rtp_rtcp_.GenericFECStatus(fec_enabled, + WebRtc_Word32 error = default_rtp_rtcp_->GenericFECStatus(fec_enabled, dummy_ptype_red, dummy_ptypeFEC); if (error) { return -1; } - bool nack_enabled = (default_rtp_rtcp_.NACK() == kNackOff) ? false : true; + bool nack_enabled = (default_rtp_rtcp_->NACK() == kNackOff) ? false : true; if (fec_enabled_ == fec_enabled && nack_enabled_ == nack_enabled) { // No change needed, we're already in correct state. return 0; @@ -665,7 +653,7 @@ WebRtc_Word32 ViEEncoder::UpdateProtectionMethod() { // The send codec must be registered to set correct MTU. webrtc::VideoCodec codec; if (vcm_.SendCodec(&codec) == 0) { - WebRtc_UWord16 max_pay_load = default_rtp_rtcp_.MaxDataPayloadLength(); + WebRtc_UWord16 max_pay_load = default_rtp_rtcp_->MaxDataPayloadLength(); if (vcm_.Bitrate(&codec.startBitrate) != 0) { WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceVideo, ViEId(engine_id_, channel_id_), @@ -711,10 +699,11 @@ WebRtc_Word32 ViEEncoder::SendData( } // New encoded data, hand over to the rtp module. - return default_rtp_rtcp_.SendOutgoingData(frame_type, payload_type, - time_stamp, payload_data, - payload_size, &fragmentation_header, - rtp_video_hdr); + return default_rtp_rtcp_->SendOutgoingData(frame_type, payload_type, + time_stamp, payload_data, + payload_size, + &fragmentation_header, + rtp_video_hdr); } WebRtc_Word32 ViEEncoder::ProtectionRequest( @@ -733,13 +722,13 @@ WebRtc_Word32 ViEEncoder::ProtectionRequest( delta_fec_params->use_uep_protection, key_fec_params->use_uep_protection); - if (default_rtp_rtcp_.SetFecParameters(delta_fec_params, + if (default_rtp_rtcp_->SetFecParameters(delta_fec_params, key_fec_params) != 0) { WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(engine_id_, channel_id_), "%s: Could not update FEC parameters", __FUNCTION__); } - default_rtp_rtcp_.BitrateSent(NULL, + default_rtp_rtcp_->BitrateSent(NULL, sent_video_rate_bps, sent_fec_rate_bps, sent_nack_rate_bps); @@ -826,7 +815,7 @@ void ViEEncoder::OnNetworkChanged(const uint32_t bitrate_bps, vcm_.SetChannelParameters(bitrate_bps / 1000, fraction_lost, round_trip_time_ms); - default_rtp_rtcp_.SetTargetSendBitrate(bitrate_bps); + default_rtp_rtcp_->SetTargetSendBitrate(bitrate_bps); } WebRtc_Word32 ViEEncoder::RegisterEffectFilter(ViEEffectFilter* effect_filter) { diff --git a/src/video_engine/vie_encoder.h b/src/video_engine/vie_encoder.h index 3640216e7e..1284d7a558 100644 --- a/src/video_engine/vie_encoder.h +++ b/src/video_engine/vie_encoder.h @@ -157,7 +157,7 @@ class ViEEncoder VideoCodingModule& vcm_; VideoProcessingModule& vpm_; - RtpRtcp& default_rtp_rtcp_; + scoped_ptr default_rtp_rtcp_; scoped_ptr callback_cs_; scoped_ptr data_cs_; scoped_ptr bitrate_observer_; diff --git a/src/video_engine/vie_receiver.cc b/src/video_engine/vie_receiver.cc index 053efde243..3dba7991d6 100644 --- a/src/video_engine/vie_receiver.cc +++ b/src/video_engine/vie_receiver.cc @@ -18,13 +18,11 @@ namespace webrtc { -ViEReceiver::ViEReceiver(int engine_id, int channel_id, - RtpRtcp& rtp_rtcp, - VideoCodingModule& module_vcm) +ViEReceiver::ViEReceiver(const int32_t channel_id, + VideoCodingModule* module_vcm) : receive_cs_(CriticalSectionWrapper::CreateCriticalSection()), - engine_id_(engine_id), channel_id_(channel_id), - rtp_rtcp_(rtp_rtcp), + rtp_rtcp_(NULL), vcm_(module_vcm), external_decryption_(NULL), decryption_buffer_(NULL), @@ -66,6 +64,10 @@ int ViEReceiver::DeregisterExternalDecryption() { return 0; } +void ViEReceiver::SetRtpRtcpModule(RtpRtcp* module) { + rtp_rtcp_ = module; +} + void ViEReceiver::RegisterSimulcastRtpRtcpModules( const std::list& rtp_modules) { CriticalSectionScoped cs(receive_cs_.get()); @@ -116,7 +118,7 @@ WebRtc_Word32 ViEReceiver::OnReceivedPayloadData( return 0; } - if (vcm_.IncomingPacket(payload_data, payload_size, *rtp_header) != 0) { + if (vcm_->IncomingPacket(payload_data, payload_size, *rtp_header) != 0) { // Check this... return -1; } @@ -139,12 +141,11 @@ int ViEReceiver::InsertRTPPacket(const WebRtc_Word8* rtp_packet, decryption_buffer_, received_packet_length, &decrypted_length); if (decrypted_length <= 0) { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, - ViEId(engine_id_, channel_id_), "RTP decryption failed"); + WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, channel_id_, + "RTP decryption failed"); return -1; } else if (decrypted_length > kViEMaxMtu) { - WEBRTC_TRACE(webrtc::kTraceCritical, webrtc::kTraceVideo, - ViEId(engine_id_, channel_id_), + WEBRTC_TRACE(webrtc::kTraceCritical, webrtc::kTraceVideo, channel_id_, "InsertRTPPacket: %d bytes is allocated as RTP decrytption" " output, external decryption used %d bytes. => memory is " " now corrupted", kViEMaxMtu, decrypted_length); @@ -159,14 +160,15 @@ int ViEReceiver::InsertRTPPacket(const WebRtc_Word8* rtp_packet, static_cast(received_packet_length)); } } - return rtp_rtcp_.IncomingPacket(received_packet, received_packet_length); + assert(rtp_rtcp_); // Should be set by owner at construction time. + return rtp_rtcp_->IncomingPacket(received_packet, received_packet_length); } int ViEReceiver::InsertRTCPPacket(const WebRtc_Word8* rtcp_packet, int rtcp_packet_length) { // TODO(mflodman) Change decrypt to get rid of this cast. - WebRtc_Word8* tmp_ptr = const_cast(rtcp_packet); - unsigned char* received_packet = reinterpret_cast(tmp_ptr); + WebRtc_Word8* tmp_ptr = const_cast(rtcp_packet); + unsigned char* received_packet = reinterpret_cast(tmp_ptr); int received_packet_length = rtcp_packet_length; { CriticalSectionScoped cs(receive_cs_.get()); @@ -178,12 +180,11 @@ int ViEReceiver::InsertRTCPPacket(const WebRtc_Word8* rtcp_packet, received_packet_length, &decrypted_length); if (decrypted_length <= 0) { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, - ViEId(engine_id_, channel_id_), "RTP decryption failed"); + WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, channel_id_, + "RTP decryption failed"); return -1; } else if (decrypted_length > kViEMaxMtu) { - WEBRTC_TRACE(webrtc::kTraceCritical, webrtc::kTraceVideo, - ViEId(engine_id_, channel_id_), + WEBRTC_TRACE(webrtc::kTraceCritical, webrtc::kTraceVideo, channel_id_, "InsertRTCPPacket: %d bytes is allocated as RTP " " decrytption output, external decryption used %d bytes. " " => memory is now corrupted", @@ -207,7 +208,8 @@ int ViEReceiver::InsertRTCPPacket(const WebRtc_Word8* rtcp_packet, rtp_rtcp->IncomingPacket(received_packet, received_packet_length); } } - return rtp_rtcp_.IncomingPacket(received_packet, received_packet_length); + assert(rtp_rtcp_); // Should be set by owner at construction time. + return rtp_rtcp_->IncomingPacket(received_packet, received_packet_length); } void ViEReceiver::StartReceive() { @@ -226,8 +228,7 @@ int ViEReceiver::StartRTPDump(const char file_nameUTF8[1024]) { } else { rtp_dump_ = RtpDump::CreateRtpDump(); if (rtp_dump_ == NULL) { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, - ViEId(engine_id_, channel_id_), + WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, channel_id_, "StartRTPDump: Failed to create RTP dump"); return -1; } @@ -235,8 +236,7 @@ int ViEReceiver::StartRTPDump(const char file_nameUTF8[1024]) { if (rtp_dump_->Start(file_nameUTF8) != 0) { RtpDump::DestroyRtpDump(rtp_dump_); rtp_dump_ = NULL; - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, - ViEId(engine_id_, channel_id_), + WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, channel_id_, "StartRTPDump: Failed to start RTP dump"); return -1; } @@ -249,15 +249,13 @@ int ViEReceiver::StopRTPDump() { if (rtp_dump_->IsActive()) { rtp_dump_->Stop(); } else { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, - ViEId(engine_id_, channel_id_), + WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, channel_id_, "StopRTPDump: Dump not active"); } RtpDump::DestroyRtpDump(rtp_dump_); rtp_dump_ = NULL; } else { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, - ViEId(engine_id_, channel_id_), + WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, channel_id_, "StopRTPDump: RTP dump not started"); return -1; } diff --git a/src/video_engine/vie_receiver.h b/src/video_engine/vie_receiver.h index b6633ca610..a36a6d0bf9 100644 --- a/src/video_engine/vie_receiver.h +++ b/src/video_engine/vie_receiver.h @@ -30,13 +30,14 @@ class VideoCodingModule; class ViEReceiver : public UdpTransportData, public RtpData { public: - ViEReceiver(int engine_id, int channel_id, RtpRtcp& rtp_rtcp, - VideoCodingModule& module_vcm); + ViEReceiver(const int32_t channel_id, VideoCodingModule* module_vcm); ~ViEReceiver(); int RegisterExternalDecryption(Encryption* decryption); int DeregisterExternalDecryption(); + void SetRtpRtcpModule(RtpRtcp* module); + void RegisterSimulcastRtpRtcpModules(const std::list& rtp_modules); void StartReceive(); @@ -70,11 +71,10 @@ class ViEReceiver : public UdpTransportData, public RtpData { int InsertRTCPPacket(const WebRtc_Word8* rtcp_packet, int rtcp_packet_length); scoped_ptr receive_cs_; - int engine_id_; - int channel_id_; - RtpRtcp& rtp_rtcp_; + const int32_t channel_id_; + RtpRtcp* rtp_rtcp_; std::list rtp_rtcp_simulcast_; - VideoCodingModule& vcm_; + VideoCodingModule* vcm_; Encryption* external_decryption_; WebRtc_UWord8* decryption_buffer_; diff --git a/src/video_engine/vie_sender.cc b/src/video_engine/vie_sender.cc index cee4086519..ca88db971f 100644 --- a/src/video_engine/vie_sender.cc +++ b/src/video_engine/vie_sender.cc @@ -17,9 +17,8 @@ namespace webrtc { -ViESender::ViESender(int engine_id, int channel_id) - : engine_id_(engine_id), - channel_id_(channel_id), +ViESender::ViESender(int channel_id) + : channel_id_(channel_id), critsect_(CriticalSectionWrapper::CreateCriticalSection()), external_encryption_(NULL), encryption_buffer_(NULL), @@ -92,8 +91,7 @@ int ViESender::StartRTPDump(const char file_nameUTF8[1024]) { } else { rtp_dump_ = RtpDump::CreateRtpDump(); if (rtp_dump_ == NULL) { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, - ViEId(engine_id_, channel_id_), + WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, channel_id_, "StartSRTPDump: Failed to create RTP dump"); return -1; } @@ -101,8 +99,7 @@ int ViESender::StartRTPDump(const char file_nameUTF8[1024]) { if (rtp_dump_->Start(file_nameUTF8) != 0) { RtpDump::DestroyRtpDump(rtp_dump_); rtp_dump_ = NULL; - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, - ViEId(engine_id_, channel_id_), + WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, channel_id_, "StartRTPDump: Failed to start RTP dump"); return -1; } @@ -115,15 +112,13 @@ int ViESender::StopRTPDump() { if (rtp_dump_->IsActive()) { rtp_dump_->Stop(); } else { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, - ViEId(engine_id_, channel_id_), + WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, channel_id_, "StopRTPDump: Dump not active"); } RtpDump::DestroyRtpDump(rtp_dump_); rtp_dump_ = NULL; } else { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, - ViEId(engine_id_, channel_id_), + WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, channel_id_, "StopRTPDump: RTP dump not started"); return -1; } @@ -136,7 +131,6 @@ int ViESender::SendPacket(int vie_id, const void* data, int len) { // No transport return -1; } - assert(ChannelId(vie_id) == channel_id_); // TODO(mflodman) Change decrypt to get rid of this cast. @@ -154,12 +148,10 @@ int ViESender::SendPacket(int vie_id, const void* data, int len) { static_cast(&send_packet_length)); send_packet = encryption_buffer_; } - const int bytes_sent = transport_->SendPacket(channel_id_, send_packet, send_packet_length); if (bytes_sent != send_packet_length) { - WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceVideo, - ViEId(engine_id_, channel_id_), + WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceVideo, channel_id_, "ViESender::SendPacket - Transport failed to send RTP packet"); } return bytes_sent; @@ -195,8 +187,7 @@ int ViESender::SendRTCPPacket(int vie_id, const void* data, int len) { send_packet_length); if (bytes_sent != send_packet_length) { WEBRTC_TRACE( - webrtc::kTraceWarning, webrtc::kTraceVideo, - ViEId(engine_id_, channel_id_), + webrtc::kTraceWarning, webrtc::kTraceVideo, channel_id_, "ViESender::SendRTCPPacket - Transport failed to send RTCP packet"); } return bytes_sent; diff --git a/src/video_engine/vie_sender.h b/src/video_engine/vie_sender.h index a60446dbdc..6c3a110603 100644 --- a/src/video_engine/vie_sender.h +++ b/src/video_engine/vie_sender.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -29,7 +29,7 @@ class VideoCodingModule; class ViESender: public Transport { public: - ViESender(int engine_id, int channel_id); + explicit ViESender(const int32_t channel_id); ~ViESender(); // Registers an encryption class to use before sending packets. @@ -49,8 +49,7 @@ class ViESender: public Transport { virtual int SendRTCPPacket(int vie_id, const void* data, int len); private: - int engine_id_; - int channel_id_; + const int32_t channel_id_; scoped_ptr critsect_; diff --git a/src/video_engine/vie_sync_module.cc b/src/video_engine/vie_sync_module.cc index ea1c558396..5e4f719819 100644 --- a/src/video_engine/vie_sync_module.cc +++ b/src/video_engine/vie_sync_module.cc @@ -23,12 +23,13 @@ enum { kMaxVideoDiffMs = 80 }; enum { kMaxAudioDiffMs = 80 }; enum { kMaxDelay = 1500 }; -ViESyncModule::ViESyncModule(int id, VideoCodingModule& vcm, - RtpRtcp& rtcp_module) +const float FracMS = 4.294967296E6f; + +ViESyncModule::ViESyncModule(const int32_t channel_id, VideoCodingModule* vcm) : data_cs_(CriticalSectionWrapper::CreateCriticalSection()), - id_(id), + channel_id_(channel_id), vcm_(vcm), - rtcp_module_(rtcp_module), + video_rtcp_module_(NULL), voe_channel_id_(-1), voe_sync_interface_(NULL), last_sync_time_(TickTime::Now()) { @@ -37,12 +38,13 @@ ViESyncModule::ViESyncModule(int id, VideoCodingModule& vcm, ViESyncModule::~ViESyncModule() { } -int ViESyncModule::SetVoiceChannel(int voe_channel_id, - VoEVideoSync* voe_sync_interface) { +int ViESyncModule::ConfigureSync(int voe_channel_id, + VoEVideoSync* voe_sync_interface, + RtpRtcp* video_rtcp_module) { CriticalSectionScoped cs(data_cs_.get()); voe_channel_id_ = voe_channel_id; voe_sync_interface_ = voe_sync_interface; - rtcp_module_.DeRegisterSyncModule(); + video_rtcp_module_ = video_rtcp_module; if (!voe_sync_interface) { voe_channel_id_ = -1; @@ -52,44 +54,13 @@ int ViESyncModule::SetVoiceChannel(int voe_channel_id, } return 0; } - RtpRtcp* voe_rtp_rtcp = NULL; - voe_sync_interface->GetRtpRtcp(voe_channel_id_, voe_rtp_rtcp); - return rtcp_module_.RegisterSyncModule(voe_rtp_rtcp); + return 0; } int ViESyncModule::VoiceChannel() { return voe_channel_id_; } -void ViESyncModule::SetNetworkDelay(int network_delay) { - channel_delay_.network_delay = network_delay; -} - -WebRtc_Word32 ViESyncModule::Version(char* version, - WebRtc_UWord32& remaining_buffer_in_bytes, - WebRtc_UWord32& position) const { - if (version == NULL) { - WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceVideo, -1, - "Invalid in argument to ViESyncModule Version()"); - return -1; - } - char our_version[] = "ViESyncModule 1.1.0"; - WebRtc_UWord32 our_length = (WebRtc_UWord32) strlen(our_version); - if (remaining_buffer_in_bytes < our_length + 1) { - return -1; - } - memcpy(version, our_version, our_length); - version[our_length] = '\0'; - remaining_buffer_in_bytes -= (our_length + 1); - position += (our_length + 1); - return 0; -} - -WebRtc_Word32 ViESyncModule::ChangeUniqueId(const WebRtc_Word32 id) { - id_ = id; - return 0; -} - WebRtc_Word32 ViESyncModule::TimeUntilNextProcess() { return (WebRtc_Word32)(kSyncInterval - (TickTime::Now() - last_sync_time_).Milliseconds()); @@ -99,20 +70,21 @@ WebRtc_Word32 ViESyncModule::Process() { CriticalSectionScoped cs(data_cs_.get()); last_sync_time_ = TickTime::Now(); - int total_video_delay_target_ms = vcm_.Delay(); - WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideo, id_, + int total_video_delay_target_ms = vcm_->Delay(); + WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideo, channel_id_, "Video delay (JB + decoder) is %d ms", total_video_delay_target_ms); if (voe_channel_id_ == -1) { return 0; } + assert(video_rtcp_module_ && voe_sync_interface_); int current_audio_delay_ms = 0; if (voe_sync_interface_->GetDelayEstimate(voe_channel_id_, current_audio_delay_ms) != 0) { // Could not get VoE delay value, probably not a valid channel Id. - WEBRTC_TRACE(webrtc::kTraceStream, webrtc::kTraceVideo, id_, + WEBRTC_TRACE(webrtc::kTraceStream, webrtc::kTraceVideo, channel_id_, "%s: VE_GetDelayEstimate error for voice_channel %d", __FUNCTION__, total_video_delay_target_ms, voe_channel_id_); return 0; @@ -124,22 +96,75 @@ WebRtc_Word32 ViESyncModule::Process() { // VoiceEngine report delay estimates even when not started, ignore if the // reported value is lower than 40 ms. if (current_audio_delay_ms < 40) { - WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideo, id_, + WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideo, channel_id_, "A/V Sync: Audio delay < 40, skipping."); return 0; } - WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideo, id_, + RtpRtcp* voice_rtcp_module = NULL; + if (0 != voe_sync_interface_->GetRtpRtcp(voe_channel_id_, + voice_rtcp_module)) { + return 0; + } + assert(voice_rtcp_module); + + uint32_t video_received_ntp_secs = 0; + uint32_t video_received_ntp_frac = 0; + uint32_t video_rtcp_arrivaltime_secs = 0; + uint32_t video_rtcp_arrivaltime_frac = 0; + + if (0 != video_rtcp_module_->RemoteNTP(&video_received_ntp_secs, + &video_received_ntp_frac, + &video_rtcp_arrivaltime_secs, + &video_rtcp_arrivaltime_frac)) { + // Failed to get video NTP. + return 0; + } + uint32_t audio_received_ntp_secs = 0; + uint32_t audio_received_ntp_frac = 0; + uint32_t audio_rtcp_arrivaltime_secs = 0; + uint32_t audio_rtcp_arrivaltime_frac = 0; + + if (0 != voice_rtcp_module->RemoteNTP(&audio_received_ntp_secs, + &audio_received_ntp_frac, + &audio_rtcp_arrivaltime_secs, + &audio_rtcp_arrivaltime_frac)) { + // Failed to get audio NTP. + return 0; + } + // ReceivedNTPxxx is NTP at sender side when sent. + // RTCPArrivalTimexxx is NTP at receiver side when received. + // can't use ConvertNTPTimeToMS since calculation can be + // negative + int NTPdiff = (audio_received_ntp_secs - video_received_ntp_secs) + * 1000; // ms + NTPdiff += static_cast(audio_received_ntp_secs / FracMS - + video_received_ntp_frac / FracMS); + + int RTCPdiff = (audio_rtcp_arrivaltime_secs - video_rtcp_arrivaltime_secs) + * 1000; // ms + RTCPdiff += static_cast(audio_rtcp_arrivaltime_frac / FracMS - + video_rtcp_arrivaltime_frac / FracMS); + + int diff = NTPdiff - RTCPdiff; + // if diff is + video is behind + if (diff < -1000 || diff > 1000) { + // unresonable ignore value. + return 0; + } + channel_delay_.network_delay = diff; + + WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideo, channel_id_, "Audio delay is: %d for voice channel: %d", current_audio_delay_ms, voe_channel_id_); - WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideo, id_, + WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideo, channel_id_, "Network delay diff is: %d for voice channel: %d", channel_delay_.network_delay, voe_channel_id_); // Calculate the difference between the lowest possible video delay and // the current audio delay. current_diff_ms = total_video_delay_target_ms - current_audio_delay_ms + channel_delay_.network_delay; - WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideo, id_, + WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideo, channel_id_, "Current diff is: %d for audio channel: %d", current_diff_ms, voe_channel_id_); @@ -270,7 +295,7 @@ WebRtc_Word32 ViESyncModule::Process() { } } - WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideo, id_, + WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideo, channel_id_, "Sync video delay %d ms for video channel and audio delay %d for audio " "channel %d", video_delay_ms, channel_delay_.extra_audio_delay_ms, voe_channel_id_); @@ -278,7 +303,7 @@ WebRtc_Word32 ViESyncModule::Process() { // Set the extra audio delay.synchronization if (voe_sync_interface_->SetMinimumPlayoutDelay( voe_channel_id_, channel_delay_.extra_audio_delay_ms) == -1) { - WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideo, id_, + WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideo, channel_id_, "Error setting voice delay"); } @@ -288,8 +313,8 @@ WebRtc_Word32 ViESyncModule::Process() { total_video_delay_target_ms = (total_video_delay_target_ms > video_delay_ms) ? total_video_delay_target_ms : video_delay_ms; - vcm_.SetMinimumPlayoutDelay(total_video_delay_target_ms); - WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideo, id_, + vcm_->SetMinimumPlayoutDelay(total_video_delay_target_ms); + WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideo, channel_id_, "New Video delay target is: %d", total_video_delay_target_ms); return 0; } diff --git a/src/video_engine/vie_sync_module.h b/src/video_engine/vie_sync_module.h index 8dd4f86027..052f7e3888 100644 --- a/src/video_engine/vie_sync_module.h +++ b/src/video_engine/vie_sync_module.h @@ -27,29 +27,24 @@ class VoEVideoSync; class ViESyncModule : public Module { public: - ViESyncModule(int id, VideoCodingModule& vcm, RtpRtcp& rtcp_module); + ViESyncModule(const int32_t channel_id, VideoCodingModule* vcm); ~ViESyncModule(); - int SetVoiceChannel(int voe_channel_id, VoEVideoSync* voe_sync_interface); + int ConfigureSync(int voe_channel_id, + VoEVideoSync* voe_sync_interface, + RtpRtcp* video_rtcp_module); + int VoiceChannel(); - // Set how long time, in ms, voice is ahead of video when received on the - // network. Positive value means audio is ahead of video. - void SetNetworkDelay(int network_delay); - // Implements Module. - virtual WebRtc_Word32 Version(char* version, - WebRtc_UWord32& remaining_buffer_in_bytes, - WebRtc_UWord32& position) const; - virtual WebRtc_Word32 ChangeUniqueId(const WebRtc_Word32 id); virtual WebRtc_Word32 TimeUntilNextProcess(); virtual WebRtc_Word32 Process(); private: scoped_ptr data_cs_; - int id_; - VideoCodingModule& vcm_; - RtpRtcp& rtcp_module_; + const int32_t channel_id_; + VideoCodingModule* vcm_; + RtpRtcp* video_rtcp_module_; int voe_channel_id_; VoEVideoSync* voe_sync_interface_; TickTime last_sync_time_; diff --git a/src/voice_engine/main/source/channel.cc b/src/voice_engine/main/source/channel.cc index 8159899720..125c3e7261 100644 --- a/src/voice_engine/main/source/channel.cc +++ b/src/voice_engine/main/source/channel.cc @@ -54,13 +54,13 @@ Channel::SendData(FrameType frameType, // Store current audio level in the RTP/RTCP module. // The level will be used in combination with voice-activity state // (frameType) to add an RTP header extension - _rtpRtcpModule.SetAudioLevel(_rtpAudioProc->level_estimator()->RMS()); + _rtpRtcpModule->SetAudioLevel(_rtpAudioProc->level_estimator()->RMS()); } // Push data from ACM to RTP/RTCP-module to deliver audio frame for // packetization. // This call will trigger Transport::SendPacket() from the RTP/RTCP module. - if (_rtpRtcpModule.SendOutgoingData((FrameType&)frameType, + if (_rtpRtcpModule->SendOutgoingData((FrameType&)frameType, payloadType, timeStamp, payloadData, @@ -415,7 +415,7 @@ Channel::IncomingRTPPacket(const WebRtc_Word8* incomingRtpPacket, // Deliver RTP packet to RTP/RTCP module for parsing // The packet will be pushed back to the channel thru the // OnReceivedPayloadData callback so we don't push it to the ACM here - if (_rtpRtcpModule.IncomingPacket((const WebRtc_UWord8*)rtpBufferPtr, + if (_rtpRtcpModule->IncomingPacket((const WebRtc_UWord8*)rtpBufferPtr, (WebRtc_UWord16)rtpBufferLength) == -1) { _engineStatisticsPtr->SetLastError( @@ -493,7 +493,7 @@ Channel::IncomingRTCPPacket(const WebRtc_Word8* incomingRtcpPacket, } // Deliver RTCP packet to RTP/RTCP module for parsing - if (_rtpRtcpModule.IncomingPacket((const WebRtc_UWord8*)rtcpBufferPtr, + if (_rtpRtcpModule->IncomingPacket((const WebRtc_UWord8*)rtcpBufferPtr, (WebRtc_UWord16)rtcpBufferLength) == -1) { _engineStatisticsPtr->SetLastError( @@ -562,8 +562,8 @@ Channel::OnIncomingSSRCChanged(const WebRtc_Word32 id, assert(channel == _channelId); // Reset RTP-module counters since a new incoming RTP stream is detected - _rtpRtcpModule.ResetReceiveDataCountersRTP(); - _rtpRtcpModule.ResetStatisticsRTP(); + _rtpRtcpModule->ResetReceiveDataCountersRTP(); + _rtpRtcpModule->ResetStatisticsRTP(); if (_rtpObserver) { @@ -1062,8 +1062,6 @@ Channel::Channel(const WebRtc_Word32 channelId, _callbackCritSect(*CriticalSectionWrapper::CreateCriticalSection()), _instanceId(instanceId), _channelId(channelId), - _rtpRtcpModule(*RtpRtcp::CreateRtpRtcp(VoEModuleId( - instanceId, channelId), true)), _audioCodingModule(*AudioCodingModule::Create( VoEModuleId(instanceId, channelId))), #ifndef WEBRTC_EXTERNAL_TRANSPORT @@ -1172,6 +1170,17 @@ Channel::Channel(const WebRtc_Word32 channelId, _inbandDtmfGenerator.Init(); _outputAudioLevel.Clear(); + RtpRtcp::Configuration configuration; + configuration.id = VoEModuleId(instanceId, channelId); + configuration.audio = true; + configuration.incoming_data = this; + configuration.incoming_messages = this; + configuration.outgoing_transport = this; + configuration.rtcp_feedback = this; + configuration.audio_messages = this; + + _rtpRtcpModule.reset(RtpRtcp::CreateRtpRtcp(configuration)); + // Create far end AudioProcessing Module _rxAudioProcessingModulePtr = AudioProcessing::Create( VoEModuleId(instanceId, channelId)); @@ -1234,38 +1243,6 @@ Channel::~Channel() // 1. De-register callbacks in modules // 2. De-register modules in process thread // 3. Destroy modules - - // De-register all RTP module callbacks to ensure geting no callbacks - // (Receive socket callback was de-registered above) - if (_rtpRtcpModule.RegisterIncomingDataCallback(NULL) == -1) - { - WEBRTC_TRACE(kTraceWarning, kTraceVoice, - VoEId(_instanceId,_channelId), - "~Channel() failed to de-register incoming data callback" - " (RTP module)"); - } - if (_rtpRtcpModule.RegisterSendTransport(NULL) == -1) - { - WEBRTC_TRACE(kTraceWarning, kTraceVoice, - VoEId(_instanceId,_channelId), - "~Channel() failed to de-register send transport " - "(RTP module)"); - } - if (_rtpRtcpModule.RegisterIncomingRTPCallback(NULL) == -1) - { - WEBRTC_TRACE(kTraceWarning, kTraceVoice, - VoEId(_instanceId,_channelId), - "~Channel() failed to de-register incoming RTP" - " callback (RTP module)"); - } - _rtpRtcpModule.RegisterRtcpObservers(NULL, NULL, NULL); - if (_rtpRtcpModule.RegisterAudioCallback(NULL) == -1) - { - WEBRTC_TRACE(kTraceWarning, kTraceVoice, - VoEId(_instanceId,_channelId), - "~Channel() failed to de-register audio callback " - "(RTP module)"); - } if (_audioCodingModule.RegisterTransportCallback(NULL) == -1) { WEBRTC_TRACE(kTraceWarning, kTraceVoice, @@ -1299,7 +1276,7 @@ Channel::~Channel() "~Channel() failed to deregister socket module"); } #endif - if (_moduleProcessThreadPtr->DeRegisterModule(&_rtpRtcpModule) == -1) + if (_moduleProcessThreadPtr->DeRegisterModule(_rtpRtcpModule.get()) == -1) { WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId), @@ -1311,7 +1288,6 @@ Channel::~Channel() UdpTransport::Destroy( &_socketTransportModule); #endif - RtpRtcp::DestroyRtpRtcp(&_rtpRtcpModule); AudioCodingModule::Destroy(&_audioCodingModule); #ifdef WEBRTC_SRTP SrtpModule::DestroySrtpModule(&_srtpModule); @@ -1355,7 +1331,7 @@ Channel::Init() // --- Add modules to process thread (for periodic schedulation) const bool processThreadFail = - ((_moduleProcessThreadPtr->RegisterModule(&_rtpRtcpModule) != 0) || + ((_moduleProcessThreadPtr->RegisterModule(_rtpRtcpModule.get()) != 0) || #ifndef WEBRTC_EXTERNAL_TRANSPORT (_moduleProcessThreadPtr->RegisterModule( &_socketTransportModule) != 0)); @@ -1393,11 +1369,9 @@ Channel::Init() // be transmitted since the Transport object will then be invalid. const bool rtpRtcpFail = - ((_rtpRtcpModule.InitReceiver() == -1) || - (_rtpRtcpModule.InitSender() == -1) || - (_rtpRtcpModule.SetTelephoneEventStatus(false, true, true) == -1) || + ((_rtpRtcpModule->SetTelephoneEventStatus(false, true, true) == -1) || // RTCP is enabled by default - (_rtpRtcpModule.SetRTCPStatus(kRtcpCompound) == -1)); + (_rtpRtcpModule->SetRTCPStatus(kRtcpCompound) == -1)); if (rtpRtcpFail) { _engineStatisticsPtr->SetLastError( @@ -1407,13 +1381,7 @@ Channel::Init() } // --- Register all permanent callbacks - _rtpRtcpModule.RegisterRtcpObservers(NULL, NULL, this); - const bool fail = - (_rtpRtcpModule.RegisterIncomingDataCallback(this) == -1) || - (_rtpRtcpModule.RegisterIncomingRTPCallback(this) == -1) || - (_rtpRtcpModule.RegisterSendTransport(this) == -1) || - (_rtpRtcpModule.RegisterAudioCallback(this) == -1) || (_audioCodingModule.RegisterTransportCallback(this) == -1) || (_audioCodingModule.RegisterVADCallback(this) == -1); @@ -1435,7 +1403,7 @@ Channel::Init() { // Open up the RTP/RTCP receiver for all supported codecs if ((_audioCodingModule.Codec(idx, codec) == -1) || - (_rtpRtcpModule.RegisterReceivePayload(codec) == -1)) + (_rtpRtcpModule->RegisterReceivePayload(codec) == -1)) { WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId,_channelId), @@ -1463,7 +1431,7 @@ Channel::Init() // Register default PT for outband 'telephone-event' if (!STR_CASE_CMP(codec.plname, "telephone-event")) { - if ((_rtpRtcpModule.RegisterSendPayload(codec) == -1) || + if ((_rtpRtcpModule->RegisterSendPayload(codec) == -1) || (_audioCodingModule.RegisterReceiveCodec(codec) == -1)) { WEBRTC_TRACE(kTraceWarning, kTraceVoice, @@ -1478,7 +1446,7 @@ Channel::Init() { if ((_audioCodingModule.RegisterSendCodec(codec) == -1) || (_audioCodingModule.RegisterReceiveCodec(codec) == -1) || - (_rtpRtcpModule.RegisterSendPayload(codec) == -1)) + (_rtpRtcpModule->RegisterSendPayload(codec) == -1)) { WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId,_channelId), @@ -1677,7 +1645,7 @@ Channel::StartSend() _sending = true; } - if (_rtpRtcpModule.SetSendingStatus(true) != 0) + if (_rtpRtcpModule->SetSendingStatus(true) != 0) { _engineStatisticsPtr->SetLastError( VE_RTP_RTCP_MODULE_ERROR, kTraceError, @@ -1709,8 +1677,8 @@ Channel::StopSend() // Reset sending SSRC and sequence number and triggers direct transmission // of RTCP BYE - if (_rtpRtcpModule.SetSendingStatus(false) == -1 || - _rtpRtcpModule.ResetSendDataCountersRTP() == -1) + if (_rtpRtcpModule->SetSendingStatus(false) == -1 || + _rtpRtcpModule->ResetSendDataCountersRTP() == -1) { _engineStatisticsPtr->SetLastError( VE_RTP_RTCP_MODULE_ERROR, kTraceWarning, @@ -1779,16 +1747,10 @@ Channel::StopReceiving() } } #endif - bool dtmfDetection = _rtpRtcpModule.TelephoneEvent(); - WebRtc_Word32 ret = _rtpRtcpModule.InitReceiver(); - if (ret != 0) { - _engineStatisticsPtr->SetLastError( - VE_RTP_RTCP_MODULE_ERROR, kTraceError, - "StopReceiving() failed to reinitialize the RTP receiver."); - return -1; - } + bool dtmfDetection = _rtpRtcpModule->TelephoneEvent(); // Recover DTMF detection status. - ret = _rtpRtcpModule.SetTelephoneEventStatus(dtmfDetection, true, true); + WebRtc_Word32 ret = _rtpRtcpModule->SetTelephoneEventStatus(dtmfDetection, + true, true); if (ret != 0) { _engineStatisticsPtr->SetLastError( VE_INVALID_OPERATION, kTraceWarning, @@ -2309,10 +2271,10 @@ Channel::SetSendCodec(const CodecInst& codec) return -1; } - if (_rtpRtcpModule.RegisterSendPayload(codec) != 0) + if (_rtpRtcpModule->RegisterSendPayload(codec) != 0) { - _rtpRtcpModule.DeRegisterSendPayload(codec.pltype); - if (_rtpRtcpModule.RegisterSendPayload(codec) != 0) + _rtpRtcpModule->DeRegisterSendPayload(codec.pltype); + if (_rtpRtcpModule->RegisterSendPayload(codec) != 0) { WEBRTC_TRACE( kTraceError, kTraceVoice, VoEId(_instanceId,_channelId), @@ -2322,7 +2284,7 @@ Channel::SetSendCodec(const CodecInst& codec) } } - if (_rtpRtcpModule.SetAudioPacketSize(codec.pacsize) != 0) + if (_rtpRtcpModule->SetAudioPacketSize(codec.pacsize) != 0) { WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,_channelId), "SetSendCodec() failed to set audio packet size"); @@ -2394,10 +2356,10 @@ Channel::SetRecPayloadType(const CodecInst& codec) CodecInst rxCodec = codec; // Get payload type for the given codec - _rtpRtcpModule.ReceivePayloadType(rxCodec, &pltype); + _rtpRtcpModule->ReceivePayloadType(rxCodec, &pltype); rxCodec.pltype = pltype; - if (_rtpRtcpModule.DeRegisterReceivePayload(pltype) != 0) + if (_rtpRtcpModule->DeRegisterReceivePayload(pltype) != 0) { _engineStatisticsPtr->SetLastError( VE_RTP_RTCP_MODULE_ERROR, @@ -2416,11 +2378,11 @@ Channel::SetRecPayloadType(const CodecInst& codec) return 0; } - if (_rtpRtcpModule.RegisterReceivePayload(codec) != 0) + if (_rtpRtcpModule->RegisterReceivePayload(codec) != 0) { // First attempt to register failed => de-register and try again - _rtpRtcpModule.DeRegisterReceivePayload(codec.pltype); - if (_rtpRtcpModule.RegisterReceivePayload(codec) != 0) + _rtpRtcpModule->DeRegisterReceivePayload(codec.pltype); + if (_rtpRtcpModule->RegisterReceivePayload(codec) != 0) { _engineStatisticsPtr->SetLastError( VE_RTP_RTCP_MODULE_ERROR, kTraceError, @@ -2448,7 +2410,7 @@ Channel::GetRecPayloadType(CodecInst& codec) WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId), "Channel::GetRecPayloadType()"); WebRtc_Word8 payloadType(-1); - if (_rtpRtcpModule.ReceivePayloadType(codec, &payloadType) != 0) + if (_rtpRtcpModule->ReceivePayloadType(codec, &payloadType) != 0) { _engineStatisticsPtr->SetLastError( VE_RTP_RTCP_MODULE_ERROR, kTraceError, @@ -2535,10 +2497,10 @@ Channel::SetSendCNPayloadType(int type, PayloadFrequencies frequency) return -1; } - if (_rtpRtcpModule.RegisterSendPayload(codec) != 0) + if (_rtpRtcpModule->RegisterSendPayload(codec) != 0) { - _rtpRtcpModule.DeRegisterSendPayload(codec.pltype); - if (_rtpRtcpModule.RegisterSendPayload(codec) != 0) + _rtpRtcpModule->DeRegisterSendPayload(codec.pltype); + if (_rtpRtcpModule->RegisterSendPayload(codec) != 0) { _engineStatisticsPtr->SetLastError( VE_RTP_RTCP_MODULE_ERROR, kTraceError, @@ -3196,13 +3158,13 @@ Channel::SetPacketTimeoutNotification(bool enable, int timeoutSeconds) { const WebRtc_UWord32 RTPtimeoutMS = 1000*timeoutSeconds; const WebRtc_UWord32 RTCPtimeoutMS = 0; - _rtpRtcpModule.SetPacketTimeout(RTPtimeoutMS, RTCPtimeoutMS); + _rtpRtcpModule->SetPacketTimeout(RTPtimeoutMS, RTCPtimeoutMS); _rtpPacketTimeOutIsEnabled = true; _rtpTimeOutSeconds = timeoutSeconds; } else { - _rtpRtcpModule.SetPacketTimeout(0, 0); + _rtpRtcpModule->SetPacketTimeout(0, 0); _rtpPacketTimeOutIsEnabled = false; _rtpTimeOutSeconds = 0; } @@ -3285,9 +3247,9 @@ Channel::SetPeriodicDeadOrAliveStatus(bool enable, int sampleTimeSeconds) bool enabled(false); WebRtc_UWord8 currentSampleTimeSec(0); // Store last state (will be used later if dead-or-alive is disabled). - _rtpRtcpModule.PeriodicDeadOrAliveStatus(enabled, currentSampleTimeSec); + _rtpRtcpModule->PeriodicDeadOrAliveStatus(enabled, currentSampleTimeSec); // Update the dead-or-alive state. - if (_rtpRtcpModule.SetPeriodicDeadOrAliveStatus( + if (_rtpRtcpModule->SetPeriodicDeadOrAliveStatus( enable, (WebRtc_UWord8)sampleTimeSeconds) != 0) { _engineStatisticsPtr->SetLastError( @@ -3303,7 +3265,7 @@ Channel::SetPeriodicDeadOrAliveStatus(bool enable, int sampleTimeSeconds) // Without this, the sample time would always be reset to default // (2 sec), each time dead-or-alived was disabled without sample-time // parameter. - _rtpRtcpModule.SetPeriodicDeadOrAliveStatus(enable, + _rtpRtcpModule->SetPeriodicDeadOrAliveStatus(enable, currentSampleTimeSec); } return 0; @@ -3312,7 +3274,7 @@ Channel::SetPeriodicDeadOrAliveStatus(bool enable, int sampleTimeSeconds) WebRtc_Word32 Channel::GetPeriodicDeadOrAliveStatus(bool& enabled, int& sampleTimeSeconds) { - _rtpRtcpModule.PeriodicDeadOrAliveStatus( + _rtpRtcpModule->PeriodicDeadOrAliveStatus( enabled, (WebRtc_UWord8&)sampleTimeSeconds); WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId,-1), @@ -3337,7 +3299,7 @@ Channel::SendUDPPacket(const void* data, "SendUDPPacket() external transport is enabled"); return -1; } - if (useRtcpSocket && !_rtpRtcpModule.RTCP()) + if (useRtcpSocket && !_rtpRtcpModule->RTCP()) { _engineStatisticsPtr->SetLastError( VE_RTCP_ERROR, kTraceError, @@ -4423,7 +4385,7 @@ int Channel::SendTelephoneEventOutband(unsigned char eventCode, _playOutbandDtmfEvent = playDtmfEvent; - if (_rtpRtcpModule.SendTelephoneEventOutband(eventCode, lengthMs, + if (_rtpRtcpModule->SendTelephoneEventOutband(eventCode, lengthMs, attenuationDb) != 0) { _engineStatisticsPtr->SetLastError( @@ -4487,7 +4449,7 @@ Channel::SetSendTelephoneEventPayloadType(unsigned char type) codec.plfreq = 8000; codec.pltype = type; memcpy(codec.plname, "telephone-event", 16); - if (_rtpRtcpModule.RegisterSendPayload(codec) != 0) + if (_rtpRtcpModule->RegisterSendPayload(codec) != 0) { _engineStatisticsPtr->SetLastError( VE_RTP_RTCP_MODULE_ERROR, kTraceError, @@ -4569,9 +4531,9 @@ Channel::RegisterTelephoneEventDetection( // When enabled, RtpAudioFeedback::OnReceivedTelephoneEvent() will be // called two times by the RTP/RTCP module (start & end). const bool forwardToDecoder = - _rtpRtcpModule.TelephoneEventForwardToDecoder(); + _rtpRtcpModule->TelephoneEventForwardToDecoder(); const bool detectEndOfTone = true; - _rtpRtcpModule.SetTelephoneEventStatus(_outOfBandTelephoneEventDetecion, + _rtpRtcpModule->SetTelephoneEventStatus(_outOfBandTelephoneEventDetecion, forwardToDecoder, detectEndOfTone); @@ -4597,8 +4559,8 @@ Channel::DeRegisterTelephoneEventDetection() // Disable out-of-band event detection const bool forwardToDecoder = - _rtpRtcpModule.TelephoneEventForwardToDecoder(); - _rtpRtcpModule.SetTelephoneEventStatus(false, forwardToDecoder); + _rtpRtcpModule->TelephoneEventForwardToDecoder(); + _rtpRtcpModule->SetTelephoneEventStatus(false, forwardToDecoder); // Disable in-band Dtmf detection _audioCodingModule.RegisterIncomingMessagesCallback(NULL); @@ -5057,7 +5019,7 @@ Channel::SetLocalSSRC(unsigned int ssrc) "SetLocalSSRC() already sending"); return -1; } - if (_rtpRtcpModule.SetSSRC(ssrc) != 0) + if (_rtpRtcpModule->SetSSRC(ssrc) != 0) { _engineStatisticsPtr->SetLastError( VE_RTP_RTCP_MODULE_ERROR, kTraceError, @@ -5070,7 +5032,7 @@ Channel::SetLocalSSRC(unsigned int ssrc) int Channel::GetLocalSSRC(unsigned int& ssrc) { - ssrc = _rtpRtcpModule.SSRC(); + ssrc = _rtpRtcpModule->SSRC(); WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId,_channelId), "GetLocalSSRC() => ssrc=%lu", ssrc); @@ -5080,7 +5042,7 @@ Channel::GetLocalSSRC(unsigned int& ssrc) int Channel::GetRemoteSSRC(unsigned int& ssrc) { - ssrc = _rtpRtcpModule.RemoteSSRC(); + ssrc = _rtpRtcpModule->RemoteSSRC(); WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId,_channelId), "GetRemoteSSRC() => ssrc=%lu", ssrc); @@ -5099,7 +5061,7 @@ Channel::GetRemoteCSRCs(unsigned int arrCSRC[15]) } WebRtc_UWord32 arrOfCSRC[kRtpCsrcSize]; WebRtc_Word32 CSRCs(0); - CSRCs = _rtpRtcpModule.CSRCs(arrOfCSRC); + CSRCs = _rtpRtcpModule->CSRCs(arrOfCSRC); if (CSRCs > 0) { memcpy(arrCSRC, arrOfCSRC, CSRCs * sizeof(WebRtc_UWord32)); @@ -5141,7 +5103,7 @@ Channel::SetRTPAudioLevelIndicationStatus(bool enable, unsigned char ID) } _includeAudioLevelIndication = enable; - return _rtpRtcpModule.SetRTPAudioLevelIndicationStatus(enable, ID); + return _rtpRtcpModule->SetRTPAudioLevelIndicationStatus(enable, ID); } int Channel::GetRTPAudioLevelIndicationStatus(bool& enabled, unsigned char& ID) @@ -5150,7 +5112,7 @@ Channel::GetRTPAudioLevelIndicationStatus(bool& enabled, unsigned char& ID) VoEId(_instanceId,_channelId), "GetRTPAudioLevelIndicationStatus() => enabled=%d, ID=%u", enabled, ID); - return _rtpRtcpModule.GetRTPAudioLevelIndicationStatus(enabled, ID); + return _rtpRtcpModule->GetRTPAudioLevelIndicationStatus(enabled, ID); } int @@ -5158,7 +5120,7 @@ Channel::SetRTCPStatus(bool enable) { WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId), "Channel::SetRTCPStatus()"); - if (_rtpRtcpModule.SetRTCPStatus(enable ? + if (_rtpRtcpModule->SetRTCPStatus(enable ? kRtcpCompound : kRtcpOff) != 0) { _engineStatisticsPtr->SetLastError( @@ -5172,7 +5134,7 @@ Channel::SetRTCPStatus(bool enable) int Channel::GetRTCPStatus(bool& enabled) { - RTCPMethod method = _rtpRtcpModule.RTCP(); + RTCPMethod method = _rtpRtcpModule->RTCP(); enabled = (method != kRtcpOff); WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId,_channelId), @@ -5185,7 +5147,7 @@ Channel::SetRTCP_CNAME(const char cName[256]) { WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), "Channel::SetRTCP_CNAME()"); - if (_rtpRtcpModule.SetCNAME(cName) != 0) + if (_rtpRtcpModule->SetCNAME(cName) != 0) { _engineStatisticsPtr->SetLastError( VE_RTP_RTCP_MODULE_ERROR, kTraceError, @@ -5198,7 +5160,7 @@ Channel::SetRTCP_CNAME(const char cName[256]) int Channel::GetRTCP_CNAME(char cName[256]) { - if (_rtpRtcpModule.CNAME(cName) != 0) + if (_rtpRtcpModule->CNAME(cName) != 0) { _engineStatisticsPtr->SetLastError( VE_RTP_RTCP_MODULE_ERROR, kTraceError, @@ -5222,8 +5184,8 @@ Channel::GetRemoteRTCP_CNAME(char cName[256]) return -1; } char cname[RTCP_CNAME_SIZE]; - const WebRtc_UWord32 remoteSSRC = _rtpRtcpModule.RemoteSSRC(); - if (_rtpRtcpModule.RemoteCNAME(remoteSSRC, cname) != 0) + const WebRtc_UWord32 remoteSSRC = _rtpRtcpModule->RemoteSSRC(); + if (_rtpRtcpModule->RemoteCNAME(remoteSSRC, cname) != 0) { _engineStatisticsPtr->SetLastError( VE_CANNOT_RETRIEVE_CNAME, kTraceError, @@ -5249,7 +5211,7 @@ Channel::GetRemoteRTCPData( // --- Information from sender info in received Sender Reports RTCPSenderInfo senderInfo; - if (_rtpRtcpModule.RemoteRTCPStat(&senderInfo) != 0) + if (_rtpRtcpModule->RemoteRTCPStat(&senderInfo) != 0) { _engineStatisticsPtr->SetLastError( VE_RTP_RTCP_MODULE_ERROR, kTraceError, @@ -5288,7 +5250,7 @@ Channel::GetRemoteRTCPData( // remote SSRC and use the report block from him. // Otherwise use the first report block. std::vector remote_stats; - if (_rtpRtcpModule.RemoteRTCPStat(&remote_stats) != 0 || + if (_rtpRtcpModule->RemoteRTCPStat(&remote_stats) != 0 || remote_stats.empty()) { WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), @@ -5297,7 +5259,7 @@ Channel::GetRemoteRTCPData( return -1; } - WebRtc_UWord32 remoteSSRC = _rtpRtcpModule.RemoteSSRC(); + WebRtc_UWord32 remoteSSRC = _rtpRtcpModule->RemoteSSRC(); std::vector::const_iterator it = remote_stats.begin(); for (; it != remote_stats.end(); ++it) { if (it->remoteSSRC == remoteSSRC) @@ -5359,7 +5321,7 @@ Channel::SendApplicationDefinedRTCPPacket(const unsigned char subType, "SendApplicationDefinedRTCPPacket() invalid length value"); return -1; } - RTCPMethod status = _rtpRtcpModule.RTCP(); + RTCPMethod status = _rtpRtcpModule->RTCP(); if (status == kRtcpOff) { _engineStatisticsPtr->SetLastError( @@ -5369,7 +5331,7 @@ Channel::SendApplicationDefinedRTCPPacket(const unsigned char subType, } // Create and schedule the RTCP APP packet for transmission - if (_rtpRtcpModule.SetRTCPApplicationSpecificData( + if (_rtpRtcpModule->SetRTCPApplicationSpecificData( subType, name, (const unsigned char*) data, @@ -5397,7 +5359,7 @@ Channel::GetRTPStatistics( // The jitter statistics is updated for each received RTP packet and is // based on received packets. - if (_rtpRtcpModule.StatisticsRTP(&fraction_lost, + if (_rtpRtcpModule->StatisticsRTP(&fraction_lost, &cum_lost, &ext_max, &jitter, @@ -5441,7 +5403,7 @@ Channel::GetRTPStatistics(CallStatistics& stats) // The jitter statistics is updated for each received RTP packet and is // based on received packets. - if (_rtpRtcpModule.StatisticsRTP(&fraction_lost, + if (_rtpRtcpModule->StatisticsRTP(&fraction_lost, &cum_lost, &ext_max, &jitter, @@ -5468,7 +5430,7 @@ Channel::GetRTPStatistics(CallStatistics& stats) // --- Part two of the final structure (one value) WebRtc_UWord16 RTT(0); - RTCPMethod method = _rtpRtcpModule.RTCP(); + RTCPMethod method = _rtpRtcpModule->RTCP(); if (method == kRtcpOff) { WEBRTC_TRACE(kTraceWarning, kTraceVoice, @@ -5478,14 +5440,14 @@ Channel::GetRTPStatistics(CallStatistics& stats) } else { // The remote SSRC will be zero if no RTP packet has been received. - WebRtc_UWord32 remoteSSRC = _rtpRtcpModule.RemoteSSRC(); + WebRtc_UWord32 remoteSSRC = _rtpRtcpModule->RemoteSSRC(); if (remoteSSRC > 0) { WebRtc_UWord16 avgRTT(0); WebRtc_UWord16 maxRTT(0); WebRtc_UWord16 minRTT(0); - if (_rtpRtcpModule.RTT(remoteSSRC, &RTT, &avgRTT, &minRTT, &maxRTT) + if (_rtpRtcpModule->RTT(remoteSSRC, &RTT, &avgRTT, &minRTT, &maxRTT) != 0) { WEBRTC_TRACE(kTraceWarning, kTraceVoice, @@ -5515,7 +5477,7 @@ Channel::GetRTPStatistics(CallStatistics& stats) WebRtc_UWord32 bytesReceived(0); WebRtc_UWord32 packetsReceived(0); - if (_rtpRtcpModule.DataCountersRTP(&bytesSent, + if (_rtpRtcpModule->DataCountersRTP(&bytesSent, &packetsSent, &bytesReceived, &packetsReceived) != 0) @@ -5580,7 +5542,7 @@ Channel::SetFECStatus(bool enable, int redPayloadtype) "SetFECStatus() RED registration in ACM module failed"); return -1; } - if (_rtpRtcpModule.SetSendREDPayloadType(codec.pltype) != 0) + if (_rtpRtcpModule->SetSendREDPayloadType(codec.pltype) != 0) { _engineStatisticsPtr->SetLastError( VE_RTP_RTCP_MODULE_ERROR, kTraceError, @@ -5604,7 +5566,7 @@ Channel::GetFECStatus(bool& enabled, int& redPayloadtype) if (enabled) { WebRtc_Word8 payloadType(0); - if (_rtpRtcpModule.SendREDPayloadType(payloadType) != 0) + if (_rtpRtcpModule->SendREDPayloadType(payloadType) != 0) { _engineStatisticsPtr->SetLastError( VE_RTP_RTCP_MODULE_ERROR, kTraceError, @@ -5722,7 +5684,7 @@ Channel::InsertExtraRTPPacket(unsigned char payloadType, "InsertExtraRTPPacket() invalid payload data"); return -1; } - if (payloadSize > _rtpRtcpModule.MaxDataPayloadLength()) + if (payloadSize > _rtpRtcpModule->MaxDataPayloadLength()) { _engineStatisticsPtr->SetLastError( VE_INVALID_ARGUMENT, kTraceError, @@ -5753,7 +5715,7 @@ Channel::InsertExtraRTPPacket(unsigned char payloadType, _extraMarkerBit = markerBit; _insertExtraRTPPacket = true; - if (_rtpRtcpModule.SendOutgoingData(kAudioFrameSpeech, + if (_rtpRtcpModule->SendOutgoingData(kAudioFrameSpeech, _lastPayloadType, _lastLocalTimeStamp, (const WebRtc_UWord8*) payloadData, @@ -5973,8 +5935,8 @@ Channel::ResetRTCPStatistics() WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId), "Channel::ResetRTCPStatistics()"); WebRtc_UWord32 remoteSSRC(0); - remoteSSRC = _rtpRtcpModule.RemoteSSRC(); - return _rtpRtcpModule.ResetRTT(remoteSSRC); + remoteSSRC = _rtpRtcpModule->RemoteSSRC(); + return _rtpRtcpModule->ResetRTT(remoteSSRC); } int @@ -5985,7 +5947,7 @@ Channel::GetRoundTripTimeSummary(StatVal& delaysMs) const // Override default module outputs for the case when RTCP is disabled. // This is done to ensure that we are backward compatible with the // VoiceEngine where we did not use RTP/RTCP module. - if (!_rtpRtcpModule.RTCP()) + if (!_rtpRtcpModule->RTCP()) { delaysMs.min = -1; delaysMs.max = -1; @@ -6002,7 +5964,7 @@ Channel::GetRoundTripTimeSummary(StatVal& delaysMs) const WebRtc_UWord16 maxRTT; WebRtc_UWord16 minRTT; // The remote SSRC will be zero if no RTP packet has been received. - remoteSSRC = _rtpRtcpModule.RemoteSSRC(); + remoteSSRC = _rtpRtcpModule->RemoteSSRC(); if (remoteSSRC == 0) { WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId,_channelId), @@ -6013,7 +5975,7 @@ Channel::GetRoundTripTimeSummary(StatVal& delaysMs) const // Retrieve RTT statistics from the RTP/RTCP module for the specified // channel and SSRC. The SSRC is required to parse out the correct source // in conference scenarios. - if (_rtpRtcpModule.RTT(remoteSSRC, &RTT, &avgRTT, &minRTT,&maxRTT) != 0) + if (_rtpRtcpModule->RTT(remoteSSRC, &RTT, &avgRTT, &minRTT,&maxRTT) != 0) { WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId,_channelId), "GetRoundTripTimeSummary unable to retrieve RTT values" @@ -6101,7 +6063,7 @@ Channel::SetInitTimestamp(unsigned int timestamp) VE_SENDING, kTraceError, "SetInitTimestamp() already sending"); return -1; } - if (_rtpRtcpModule.SetStartTimestamp(timestamp) != 0) + if (_rtpRtcpModule->SetStartTimestamp(timestamp) != 0) { _engineStatisticsPtr->SetLastError( VE_RTP_RTCP_MODULE_ERROR, kTraceError, @@ -6123,7 +6085,7 @@ Channel::SetInitSequenceNumber(short sequenceNumber) "SetInitSequenceNumber() already sending"); return -1; } - if (_rtpRtcpModule.SetSequenceNumber(sequenceNumber) != 0) + if (_rtpRtcpModule->SetSequenceNumber(sequenceNumber) != 0) { _engineStatisticsPtr->SetLastError( VE_RTP_RTCP_MODULE_ERROR, kTraceError, @@ -6138,7 +6100,7 @@ Channel::GetRtpRtcp(RtpRtcp* &rtpRtcpModule) const { WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId), "Channel::GetRtpRtcp()"); - rtpRtcpModule = &_rtpRtcpModule; + rtpRtcpModule = _rtpRtcpModule.get(); return 0; } @@ -6402,7 +6364,7 @@ Channel::GetDeadOrAliveCounters(int& countDead, int& countAlive) const bool enabled; WebRtc_UWord8 timeSec; - _rtpRtcpModule.PeriodicDeadOrAliveStatus(enabled, timeSec); + _rtpRtcpModule->PeriodicDeadOrAliveStatus(enabled, timeSec); if (!enabled) return (-1); @@ -6540,7 +6502,7 @@ Channel::RegisterReceiveCodecsToRTPModule() { // Open up the RTP/RTCP receiver for all supported codecs if ((_audioCodingModule.Codec(idx, codec) == -1) || - (_rtpRtcpModule.RegisterReceivePayload(codec) == -1)) + (_rtpRtcpModule->RegisterReceivePayload(codec) == -1)) { WEBRTC_TRACE( kTraceWarning, diff --git a/src/voice_engine/main/source/channel.h b/src/voice_engine/main/source/channel.h index 3551054956..b6578ca4c0 100644 --- a/src/voice_engine/main/source/channel.h +++ b/src/voice_engine/main/source/channel.h @@ -493,7 +493,7 @@ public: } RtpRtcp* RtpRtcpModulePtr() const { - return &_rtpRtcpModule; + return _rtpRtcpModule.get(); } WebRtc_Word8 OutputEnergyLevel() const { @@ -534,7 +534,7 @@ private: WebRtc_Word32 _channelId; private: - RtpRtcp& _rtpRtcpModule; + scoped_ptr _rtpRtcpModule; AudioCodingModule& _audioCodingModule; #ifndef WEBRTC_EXTERNAL_TRANSPORT WebRtc_UWord8 _numSocketThreads;