• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_SENDER_VIDEO_H_
12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_VIDEO_H_
13 
14 #include <list>
15 
16 #include "webrtc/common_types.h"
17 #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h"
18 #include "webrtc/modules/rtp_rtcp/source/bitrate.h"
19 #include "webrtc/modules/rtp_rtcp/source/forward_error_correction.h"
20 #include "webrtc/modules/rtp_rtcp/source/producer_fec.h"
21 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h"
22 #include "webrtc/modules/rtp_rtcp/source/rtp_sender.h"
23 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
24 #include "webrtc/modules/rtp_rtcp/source/video_codec_information.h"
25 #include "webrtc/typedefs.h"
26 
27 namespace webrtc {
28 class CriticalSectionWrapper;
29 struct RtpPacket;
30 
31 class RTPSenderVideo {
32  public:
33   RTPSenderVideo(Clock* clock, RTPSenderInterface* rtpSender);
34   virtual ~RTPSenderVideo();
35 
36   virtual RtpVideoCodecTypes VideoCodecType() const;
37 
38   uint16_t FECPacketOverhead() const;
39 
40   int32_t RegisterVideoPayload(const char payloadName[RTP_PAYLOAD_NAME_SIZE],
41                                const int8_t payloadType,
42                                const uint32_t maxBitRate,
43                                RtpUtility::Payload*& payload);
44 
45   int32_t SendVideo(const RtpVideoCodecTypes videoType,
46                     const FrameType frameType,
47                     const int8_t payloadType,
48                     const uint32_t captureTimeStamp,
49                     int64_t capture_time_ms,
50                     const uint8_t* payloadData,
51                     const uint32_t payloadSize,
52                     const RTPFragmentationHeader* fragmentation,
53                     VideoCodecInformation* codecInfo,
54                     const RTPVideoTypeHeader* rtpTypeHdr);
55 
56   int32_t SendRTPIntraRequest();
57 
58   void SetVideoCodecType(RtpVideoCodecTypes type);
59 
60   VideoCodecInformation* CodecInformationVideo();
61 
62   void SetMaxConfiguredBitrateVideo(const uint32_t maxBitrate);
63 
64   uint32_t MaxConfiguredBitrateVideo() const;
65 
66   // FEC
67   int32_t SetGenericFECStatus(const bool enable,
68                               const uint8_t payloadTypeRED,
69                               const uint8_t payloadTypeFEC);
70 
71   int32_t GenericFECStatus(bool& enable,
72                            uint8_t& payloadTypeRED,
73                            uint8_t& payloadTypeFEC) const;
74 
75   int32_t SetFecParameters(const FecProtectionParams* delta_params,
76                            const FecProtectionParams* key_params);
77 
78   void ProcessBitrate();
79 
80   uint32_t VideoBitrateSent() const;
81   uint32_t FecOverheadRate() const;
82 
83   int SelectiveRetransmissions() const;
84   int SetSelectiveRetransmissions(uint8_t settings);
85 
86  protected:
87   virtual int32_t SendVideoPacket(uint8_t* dataBuffer,
88                                   const uint16_t payloadLength,
89                                   const uint16_t rtpHeaderLength,
90                                   const uint32_t capture_timestamp,
91                                   int64_t capture_time_ms,
92                                   StorageType storage,
93                                   bool protect);
94 
95  private:
96   bool Send(const RtpVideoCodecTypes videoType,
97             const FrameType frameType,
98             const int8_t payloadType,
99             const uint32_t captureTimeStamp,
100             int64_t capture_time_ms,
101             const uint8_t* payloadData,
102             const uint32_t payloadSize,
103             const RTPFragmentationHeader* fragmentation,
104             const RTPVideoTypeHeader* rtpTypeHdr);
105 
106  private:
107   RTPSenderInterface& _rtpSender;
108 
109   CriticalSectionWrapper* _sendVideoCritsect;
110   RtpVideoCodecTypes _videoType;
111   VideoCodecInformation* _videoCodecInformation;
112   uint32_t _maxBitrate;
113   int32_t _retransmissionSettings;
114 
115   // FEC
116   ForwardErrorCorrection _fec;
117   bool _fecEnabled;
118   int8_t _payloadTypeRED;
119   int8_t _payloadTypeFEC;
120   unsigned int _numberFirstPartition;
121   FecProtectionParams delta_fec_params_;
122   FecProtectionParams key_fec_params_;
123   ProducerFec producer_fec_;
124 
125   // Bitrate used for FEC payload, RED headers, RTP headers for FEC packets
126   // and any padding overhead.
127   Bitrate _fecOverheadRate;
128   // Bitrate used for video payload and RTP headers
129   Bitrate _videoBitrate;
130 };
131 }  // namespace webrtc
132 
133 #endif  // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_VIDEO_H_
134