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 { 33 public: 34 RTPSenderVideo(Clock* clock, 35 RTPSenderInterface* rtpSender); 36 virtual ~RTPSenderVideo(); 37 38 virtual RtpVideoCodecTypes VideoCodecType() const; 39 40 uint16_t FECPacketOverhead() const; 41 42 int32_t RegisterVideoPayload( 43 const char payloadName[RTP_PAYLOAD_NAME_SIZE], 44 const int8_t payloadType, 45 const uint32_t maxBitRate, 46 ModuleRTPUtility::Payload*& payload); 47 48 int32_t SendVideo(const RtpVideoCodecTypes videoType, 49 const FrameType frameType, 50 const int8_t payloadType, 51 const uint32_t captureTimeStamp, 52 int64_t capture_time_ms, 53 const uint8_t* payloadData, 54 const uint32_t payloadSize, 55 const RTPFragmentationHeader* fragmentation, 56 VideoCodecInformation* codecInfo, 57 const RTPVideoTypeHeader* rtpTypeHdr); 58 59 int32_t SendRTPIntraRequest(); 60 61 void SetVideoCodecType(RtpVideoCodecTypes type); 62 63 VideoCodecInformation* CodecInformationVideo(); 64 65 void SetMaxConfiguredBitrateVideo(const uint32_t maxBitrate); 66 67 uint32_t MaxConfiguredBitrateVideo() const; 68 69 // FEC 70 int32_t SetGenericFECStatus(const bool enable, 71 const uint8_t payloadTypeRED, 72 const uint8_t payloadTypeFEC); 73 74 int32_t GenericFECStatus(bool& enable, 75 uint8_t& payloadTypeRED, 76 uint8_t& payloadTypeFEC) const; 77 78 int32_t SetFecParameters(const FecProtectionParams* delta_params, 79 const FecProtectionParams* key_params); 80 81 void ProcessBitrate(); 82 83 uint32_t VideoBitrateSent() const; 84 uint32_t FecOverheadRate() const; 85 86 int SelectiveRetransmissions() const; 87 int SetSelectiveRetransmissions(uint8_t settings); 88 89 protected: 90 virtual int32_t SendVideoPacket(uint8_t* dataBuffer, 91 const uint16_t payloadLength, 92 const uint16_t rtpHeaderLength, 93 const uint32_t capture_timestamp, 94 int64_t capture_time_ms, 95 StorageType storage, 96 bool protect); 97 98 private: 99 int32_t SendGeneric(const FrameType frame_type, 100 const int8_t payload_type, 101 const uint32_t capture_timestamp, 102 int64_t capture_time_ms, 103 const uint8_t* payload, const uint32_t size); 104 105 int32_t SendVP8(const FrameType frameType, 106 const int8_t payloadType, 107 const uint32_t captureTimeStamp, 108 int64_t capture_time_ms, 109 const uint8_t* payloadData, 110 const uint32_t payloadSize, 111 const RTPFragmentationHeader* fragmentation, 112 const RTPVideoTypeHeader* rtpTypeHdr); 113 114 private: 115 RTPSenderInterface& _rtpSender; 116 117 CriticalSectionWrapper* _sendVideoCritsect; 118 RtpVideoCodecTypes _videoType; 119 VideoCodecInformation* _videoCodecInformation; 120 uint32_t _maxBitrate; 121 int32_t _retransmissionSettings; 122 123 // FEC 124 ForwardErrorCorrection _fec; 125 bool _fecEnabled; 126 int8_t _payloadTypeRED; 127 int8_t _payloadTypeFEC; 128 unsigned int _numberFirstPartition; 129 FecProtectionParams delta_fec_params_; 130 FecProtectionParams key_fec_params_; 131 ProducerFec producer_fec_; 132 133 // Bitrate used for FEC payload, RED headers, RTP headers for FEC packets 134 // and any padding overhead. 135 Bitrate _fecOverheadRate; 136 // Bitrate used for video payload and RTP headers 137 Bitrate _videoBitrate; 138 }; 139 } // namespace webrtc 140 141 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_VIDEO_H_ 142