LCOV - code coverage report
Current view: top level - media/webrtc/trunk/webrtc/modules/rtp_rtcp/source - rtp_rtcp_impl.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 1 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 2 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
       3             :  *
       4             :  *  Use of this source code is governed by a BSD-style license
       5             :  *  that can be found in the LICENSE file in the root of the source
       6             :  *  tree. An additional intellectual property rights grant can be found
       7             :  *  in the file PATENTS.  All contributing project authors may
       8             :  *  be found in the AUTHORS file in the root of the source tree.
       9             :  */
      10             : 
      11             : #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_RTCP_IMPL_H_
      12             : #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_RTCP_IMPL_H_
      13             : 
      14             : #include <set>
      15             : #include <utility>
      16             : #include <vector>
      17             : 
      18             : #include "webrtc/base/criticalsection.h"
      19             : #include "webrtc/base/gtest_prod_util.h"
      20             : #include "webrtc/base/optional.h"
      21             : #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
      22             : #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
      23             : #include "webrtc/modules/rtp_rtcp/source/packet_loss_stats.h"
      24             : #include "webrtc/modules/rtp_rtcp/source/rtcp_receiver.h"
      25             : #include "webrtc/modules/rtp_rtcp/source/rtcp_sender.h"
      26             : #include "webrtc/modules/rtp_rtcp/source/rtp_sender.h"
      27             : 
      28             : namespace webrtc {
      29             : 
      30           0 : class ModuleRtpRtcpImpl : public RtpRtcp, public RTCPReceiver::ModuleRtpRtcp {
      31             :  public:
      32             :   explicit ModuleRtpRtcpImpl(const RtpRtcp::Configuration& configuration);
      33             : 
      34             :   // Returns the number of milliseconds until the module want a worker thread to
      35             :   // call Process.
      36             :   int64_t TimeUntilNextProcess() override;
      37             : 
      38             :   // Process any pending tasks such as timeouts.
      39             :   void Process() override;
      40             : 
      41             :   // Receiver part.
      42             : 
      43             :   // Called when we receive an RTCP packet.
      44             :   int32_t IncomingRtcpPacket(const uint8_t* incoming_packet,
      45             :                              size_t incoming_packet_length) override;
      46             : 
      47             :   void SetRemoteSSRC(uint32_t ssrc) override;
      48             : 
      49             :   // Sender part.
      50             : 
      51             :   int32_t RegisterSendPayload(const CodecInst& voice_codec) override;
      52             : 
      53             :   int32_t RegisterSendPayload(const VideoCodec& video_codec) override;
      54             : 
      55             :   void RegisterVideoSendPayload(int payload_type,
      56             :                                 const char* payload_name) override;
      57             : 
      58             :   int32_t DeRegisterSendPayload(int8_t payload_type) override;
      59             : 
      60             :   int8_t SendPayloadType() const;
      61             : 
      62             :   // Register RTP header extension.
      63             :   int32_t RegisterSendRtpHeaderExtension(RTPExtensionType type,
      64             :                                          uint8_t id) override;
      65             : 
      66             :   int32_t DeregisterSendRtpHeaderExtension(RTPExtensionType type) override;
      67             : 
      68             :   // Get start timestamp.
      69             :   uint32_t StartTimestamp() const override;
      70             : 
      71             :   // Configure start timestamp, default is a random number.
      72             :   void SetStartTimestamp(uint32_t timestamp) override;
      73             : 
      74             :   uint16_t SequenceNumber() const override;
      75             : 
      76             :   // Set SequenceNumber, default is a random number.
      77             :   void SetSequenceNumber(uint16_t seq) override;
      78             : 
      79             :   void SetRtpState(const RtpState& rtp_state) override;
      80             :   void SetRtxState(const RtpState& rtp_state) override;
      81             :   RtpState GetRtpState() const override;
      82             :   RtpState GetRtxState() const override;
      83             : 
      84             :   uint32_t SSRC() const override;
      85             : 
      86             :   // Configure SSRC, default is a random number.
      87             :   void SetSSRC(uint32_t ssrc) override;
      88             : 
      89             :   void SetCsrcs(const std::vector<uint32_t>& csrcs) override;
      90             : 
      91             :   int32_t SetRID(const char *rid) override;
      92             : 
      93             :   RTCPSender::FeedbackState GetFeedbackState();
      94             : 
      95             :   void SetRtxSendStatus(int mode) override;
      96             :   int RtxSendStatus() const override;
      97             : 
      98             :   void SetRtxSsrc(uint32_t ssrc) override;
      99             : 
     100             :   void SetRtxSendPayloadType(int payload_type,
     101             :                              int associated_payload_type) override;
     102             : 
     103             :   rtc::Optional<uint32_t> FlexfecSsrc() const override;
     104             : 
     105             :   // Sends kRtcpByeCode when going from true to false.
     106             :   int32_t SetSendingStatus(bool sending) override;
     107             : 
     108             :   bool Sending() const override;
     109             : 
     110             :   // Drops or relays media packets.
     111             :   void SetSendingMediaStatus(bool sending) override;
     112             : 
     113             :   bool SendingMedia() const override;
     114             : 
     115             :   // Used by the codec module to deliver a video or audio frame for
     116             :   // packetization.
     117             :   bool SendOutgoingData(FrameType frame_type,
     118             :                         int8_t payload_type,
     119             :                         uint32_t time_stamp,
     120             :                         int64_t capture_time_ms,
     121             :                         const uint8_t* payload_data,
     122             :                         size_t payload_size,
     123             :                         const RTPFragmentationHeader* fragmentation,
     124             :                         const RTPVideoHeader* rtp_video_header,
     125             :                         uint32_t* transport_frame_id_out) override;
     126             : 
     127             :   bool TimeToSendPacket(uint32_t ssrc,
     128             :                         uint16_t sequence_number,
     129             :                         int64_t capture_time_ms,
     130             :                         bool retransmission,
     131             :                         int probe_cluster_id) override;
     132             : 
     133             :   // Returns the number of padding bytes actually sent, which can be more or
     134             :   // less than |bytes|.
     135             :   size_t TimeToSendPadding(size_t bytes, int probe_cluster_id) override;
     136             : 
     137             :   // RTCP part.
     138             : 
     139             :   // Get RTCP status.
     140             :   RtcpMode RTCP() const override;
     141             : 
     142             :   // Configure RTCP status i.e on/off.
     143             :   void SetRTCPStatus(RtcpMode method) override;
     144             : 
     145             :   // Set RTCP CName.
     146             :   int32_t SetCNAME(const char* c_name) override;
     147             : 
     148             :   // Get remote CName.
     149             :   int32_t RemoteCNAME(uint32_t remote_ssrc,
     150             :                       char c_name[RTCP_CNAME_SIZE]) const override;
     151             : 
     152             :   // Get remote NTP.
     153             :   int32_t RemoteNTP(uint32_t* received_ntp_secs,
     154             :                     uint32_t* received_ntp_frac,
     155             :                     uint32_t* rtcp_arrival_time_secs,
     156             :                     uint32_t* rtcp_arrival_time_frac,
     157             :                     uint32_t* rtcp_timestamp) const override;
     158             : 
     159             :   int32_t AddMixedCNAME(uint32_t ssrc, const char* c_name) override;
     160             : 
     161             :   int32_t RemoveMixedCNAME(uint32_t ssrc) override;
     162             : 
     163             :   // Get RoundTripTime.
     164             :   int32_t RTT(uint32_t remote_ssrc,
     165             :               int64_t* rtt,
     166             :               int64_t* avg_rtt,
     167             :               int64_t* min_rtt,
     168             :               int64_t* max_rtt) const override;
     169             : 
     170             :   // Force a send of an RTCP packet.
     171             :   // Normal SR and RR are triggered via the process function.
     172             :   int32_t SendRTCP(RTCPPacketType rtcpPacketType) override;
     173             : 
     174             :   int32_t SendCompoundRTCP(
     175             :       const std::set<RTCPPacketType>& rtcpPacketTypes) override;
     176             : 
     177             :   // Statistics of the amount of data sent and received.
     178             :   int32_t DataCountersRTP(size_t* bytes_sent,
     179             :                           uint32_t* packets_sent) const override;
     180             : 
     181             :   void GetSendStreamDataCounters(
     182             :       StreamDataCounters* rtp_counters,
     183             :       StreamDataCounters* rtx_counters) const override;
     184             : 
     185             :   void GetRtpPacketLossStats(
     186             :       bool outgoing,
     187             :       uint32_t ssrc,
     188             :       struct RtpPacketLossStats* loss_stats) const override;
     189             :  
     190             :   // Get received RTCP report, sender info.
     191             :   int32_t RemoteRTCPStat(RTCPSenderInfo* sender_info) override;
     192             : 
     193             :   // Get received RTCP report, report block.
     194             :   int32_t RemoteRTCPStat(
     195             :       std::vector<RTCPReportBlock>* receive_blocks) const override;
     196             : 
     197             :   // (REMB) Receiver Estimated Max Bitrate.
     198             :   bool REMB() const override;
     199             : 
     200             :   void SetREMBStatus(bool enable) override;
     201             : 
     202             :   void SetREMBData(uint32_t bitrate,
     203             :                    const std::vector<uint32_t>& ssrcs) override;
     204             : 
     205             :   // (TMMBR) Temporary Max Media Bit Rate.
     206             :   bool TMMBR() const override;
     207             : 
     208             :   void SetTMMBRStatus(bool enable) override;
     209             : 
     210             :   void SetTmmbn(std::vector<rtcp::TmmbItem> bounding_set) override;
     211             : 
     212             :   size_t MaxPayloadSize() const override;
     213             : 
     214             :   size_t MaxRtpPacketSize() const override;
     215             : 
     216             :   void SetMaxRtpPacketSize(size_t max_packet_size) override;
     217             : 
     218             :   // (NACK) Negative acknowledgment part.
     219             : 
     220             :   int SelectiveRetransmissions() const override;
     221             : 
     222             :   int SetSelectiveRetransmissions(uint8_t settings) override;
     223             : 
     224             :   // Send a Negative acknowledgment packet.
     225             :   // TODO(philipel): Deprecate SendNACK and use SendNack instead.
     226             :   int32_t SendNACK(const uint16_t* nack_list, uint16_t size) override;
     227             : 
     228             :   void SendNack(const std::vector<uint16_t>& sequence_numbers) override;
     229             : 
     230             :   // Store the sent packets, needed to answer to a negative acknowledgment
     231             :   // requests.
     232             :   void SetStorePacketsStatus(bool enable, uint16_t number_to_store) override;
     233             : 
     234             :   bool StorePackets() const override;
     235             : 
     236             :   // Called on receipt of RTCP report block from remote side.
     237             :   void RegisterRtcpStatisticsCallback(
     238             :       RtcpStatisticsCallback* callback) override;
     239             :   RtcpStatisticsCallback* GetRtcpStatisticsCallback() override;
     240             : 
     241             :   bool SendFeedbackPacket(const rtcp::TransportFeedback& packet) override;
     242             :   // (APP) Application specific data.
     243             :   int32_t SetRTCPApplicationSpecificData(uint8_t sub_type,
     244             :                                          uint32_t name,
     245             :                                          const uint8_t* data,
     246             :                                          uint16_t length) override;
     247             : 
     248             :   // (XR) VOIP metric.
     249             :   int32_t SetRTCPVoIPMetrics(const RTCPVoIPMetric* VoIPMetric) override;
     250             : 
     251             :   // (XR) Receiver reference time report.
     252             :   void SetRtcpXrRrtrStatus(bool enable) override;
     253             : 
     254             :   bool RtcpXrRrtrStatus() const override;
     255             : 
     256             :   // Audio part.
     257             : 
     258             :   // This function is deprecated. It was previously used to determine when it
     259             :   // was time to send a DTMF packet in silence (CNG).
     260             :   int32_t SetAudioPacketSize(uint16_t packet_size_samples) override;
     261             : 
     262             :   // Send a TelephoneEvent tone using RFC 2833 (4733).
     263             :   int32_t SendTelephoneEventOutband(uint8_t key,
     264             :                                     uint16_t time_ms,
     265             :                                     uint8_t level) override;
     266             : 
     267             :   // Store the audio level in d_bov for header-extension-for-audio-level-
     268             :   // indication.
     269             :   int32_t SetAudioLevel(uint8_t level_d_bov) override;
     270             : 
     271             :   // Video part.
     272             : 
     273             :   int32_t SendRTCPSliceLossIndication(uint8_t picture_id) override;
     274             : 
     275             :   // Set method for requesting a new key frame.
     276             :   int32_t SetKeyFrameRequestMethod(KeyFrameRequestMethod method) override;
     277             : 
     278             :   // Send a request for a keyframe.
     279             :   int32_t RequestKeyFrame() override;
     280             : 
     281             :   void SetUlpfecConfig(int red_payload_type, int ulpfec_payload_type) override;
     282             : 
     283             :   bool SetFecParameters(const FecProtectionParams& delta_params,
     284             :                         const FecProtectionParams& key_params) override;
     285             : 
     286             :   bool LastReceivedNTP(uint32_t* NTPsecs,
     287             :                        uint32_t* NTPfrac,
     288             :                        uint32_t* remote_sr) const;
     289             : 
     290             :   std::vector<rtcp::TmmbItem> BoundingSet(bool* tmmbr_owner);
     291             : 
     292             :   void BitrateSent(uint32_t* total_rate,
     293             :                    uint32_t* video_rate,
     294             :                    uint32_t* fec_rate,
     295             :                    uint32_t* nackRate) const override;
     296             : 
     297             :   // Good state of RTP receiver inform sender.
     298             :   int32_t SendRTCPReferencePictureSelection(uint64_t picture_id) override;
     299             : 
     300             :   bool GetSendReportMetadata(const uint32_t send_report,
     301             :                              uint64_t *time_of_send,
     302             :                              uint32_t *packet_count,
     303             :                              uint64_t *octet_count) override;
     304             : 
     305             :   void RegisterSendChannelRtpStatisticsCallback(
     306             :       StreamDataCountersCallback* callback) override;
     307             :   StreamDataCountersCallback* GetSendChannelRtpStatisticsCallback()
     308             :       const override;
     309             : 
     310             :   void OnReceivedNack(
     311             :       const std::vector<uint16_t>& nack_sequence_numbers) override;
     312             :   void OnReceivedRtcpReportBlocks(
     313             :       const ReportBlockList& report_blocks) override;
     314             :   void OnRequestSendReport() override;
     315             : 
     316             :   void SetVideoBitrateAllocation(const BitrateAllocation& bitrate) override;
     317             : 
     318             :  protected:
     319             :   bool UpdateRTCPReceiveInformationTimers();
     320             : 
     321             :   RTPSender rtp_sender_;
     322             : 
     323             :   RTCPSender rtcp_sender_;
     324             :   RTCPReceiver rtcp_receiver_;
     325             : 
     326             :   Clock* clock_;
     327             : 
     328             :  private:
     329             :   FRIEND_TEST_ALL_PREFIXES(RtpRtcpImplTest, Rtt);
     330             :   FRIEND_TEST_ALL_PREFIXES(RtpRtcpImplTest, RttForReceiverOnly);
     331             :   int64_t RtcpReportInterval();
     332             :   void SetRtcpReceiverSsrcs(uint32_t main_ssrc);
     333             : 
     334             :   void set_rtt_ms(int64_t rtt_ms);
     335             :   int64_t rtt_ms() const;
     336             : 
     337             :   bool TimeToSendFullNackList(int64_t now) const;
     338             : 
     339             :   const bool audio_;
     340             :   bool collision_detected_;
     341             :   int64_t last_process_time_;
     342             :   int64_t last_bitrate_process_time_;
     343             :   int64_t last_rtt_process_time_;
     344             :   uint16_t packet_overhead_;
     345             : 
     346             :   // Send side
     347             :   int64_t nack_last_time_sent_full_;
     348             :   uint32_t nack_last_time_sent_full_prev_;
     349             :   uint16_t nack_last_seq_number_sent_;
     350             : 
     351             :   KeyFrameRequestMethod key_frame_req_method_;
     352             : 
     353             :   RemoteBitrateEstimator* remote_bitrate_;
     354             : 
     355             :   RtcpRttStats* rtt_stats_;
     356             : 
     357             :   PacketLossStats send_loss_stats_;
     358             :   PacketLossStats receive_loss_stats_;
     359             : 
     360             :   // The processed RTT from RtcpRttStats.
     361             :   rtc::CriticalSection critical_section_rtt_;
     362             :   int64_t rtt_ms_;
     363             : };
     364             : 
     365             : }  // namespace webrtc
     366             : 
     367             : #endif  // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_RTCP_IMPL_H_

Generated by: LCOV version 1.13