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