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/base/scoped_ptr.h" 17 #include "webrtc/base/thread_annotations.h" 18 #include "webrtc/common_types.h" 19 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" 20 #include "webrtc/modules/rtp_rtcp/source/bitrate.h" 21 #include "webrtc/modules/rtp_rtcp/source/forward_error_correction.h" 22 #include "webrtc/modules/rtp_rtcp/source/producer_fec.h" 23 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h" 24 #include "webrtc/modules/rtp_rtcp/source/rtp_sender.h" 25 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" 26 #include "webrtc/modules/rtp_rtcp/source/video_codec_information.h" 27 #include "webrtc/typedefs.h" 28 29 namespace webrtc { 30 class CriticalSectionWrapper; 31 struct RtpPacket; 32 33 class RTPSenderVideo { 34 public: 35 RTPSenderVideo(Clock* clock, RTPSenderInterface* rtpSender); 36 virtual ~RTPSenderVideo(); 37 38 virtual RtpVideoCodecTypes VideoCodecType() const; 39 40 size_t FECPacketOverhead() const; 41 42 static RtpUtility::Payload* CreateVideoPayload( 43 const char payloadName[RTP_PAYLOAD_NAME_SIZE], 44 const int8_t payloadType, 45 const uint32_t maxBitRate); 46 47 int32_t SendVideo(const RtpVideoCodecTypes videoType, 48 const FrameType frameType, 49 const int8_t payloadType, 50 const uint32_t captureTimeStamp, 51 int64_t capture_time_ms, 52 const uint8_t* payloadData, 53 const size_t payloadSize, 54 const RTPFragmentationHeader* fragmentation, 55 const RTPVideoHeader* rtpHdr); 56 57 int32_t SendRTPIntraRequest(); 58 59 void SetVideoCodecType(RtpVideoCodecTypes type); 60 61 void SetMaxConfiguredBitrateVideo(const uint32_t maxBitrate); 62 63 uint32_t MaxConfiguredBitrateVideo() const; 64 65 // FEC 66 void SetGenericFECStatus(const bool enable, 67 const uint8_t payloadTypeRED, 68 const uint8_t payloadTypeFEC); 69 70 void GenericFECStatus(bool* enable, 71 uint8_t* payloadTypeRED, 72 uint8_t* payloadTypeFEC) const; 73 74 void SetFecParameters(const FecProtectionParams* delta_params, 75 const FecProtectionParams* key_params); 76 77 void ProcessBitrate(); 78 79 uint32_t VideoBitrateSent() const; 80 uint32_t FecOverheadRate() const; 81 82 int SelectiveRetransmissions() const; 83 void SetSelectiveRetransmissions(uint8_t settings); 84 85 private: 86 void SendVideoPacket(uint8_t* dataBuffer, 87 const size_t payloadLength, 88 const size_t rtpHeaderLength, 89 uint16_t seq_num, 90 const uint32_t capture_timestamp, 91 int64_t capture_time_ms, 92 StorageType storage); 93 94 void SendVideoPacketAsRed(uint8_t* dataBuffer, 95 const size_t payloadLength, 96 const size_t rtpHeaderLength, 97 uint16_t video_seq_num, 98 const uint32_t capture_timestamp, 99 int64_t capture_time_ms, 100 StorageType media_packet_storage, 101 bool protect); 102 103 RTPSenderInterface& _rtpSender; 104 105 // Should never be held when calling out of this class. 106 const rtc::scoped_ptr<CriticalSectionWrapper> crit_; 107 108 RtpVideoCodecTypes _videoType; 109 uint32_t _maxBitrate; 110 int32_t _retransmissionSettings GUARDED_BY(crit_); 111 112 // FEC 113 ForwardErrorCorrection fec_; 114 bool fec_enabled_ GUARDED_BY(crit_); 115 int8_t red_payload_type_ GUARDED_BY(crit_); 116 int8_t fec_payload_type_ GUARDED_BY(crit_); 117 FecProtectionParams delta_fec_params_ GUARDED_BY(crit_); 118 FecProtectionParams key_fec_params_ GUARDED_BY(crit_); 119 ProducerFec producer_fec_ GUARDED_BY(crit_); 120 121 // Bitrate used for FEC payload, RED headers, RTP headers for FEC packets 122 // and any padding overhead. 123 Bitrate _fecOverheadRate; 124 // Bitrate used for video payload and RTP headers 125 Bitrate _videoBitrate; 126 }; 127 } // namespace webrtc 128 129 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_VIDEO_H_ 130