• 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_INTERFACE_VIDEO_CODING_DEFINES_H_
12 #define WEBRTC_MODULES_INTERFACE_VIDEO_CODING_DEFINES_H_
13 
14 #include "webrtc/common_video/interface/i420_video_frame.h"
15 #include "webrtc/modules/interface/module_common_types.h"
16 #include "webrtc/typedefs.h"
17 
18 namespace webrtc {
19 
20 // Error codes
21 #define VCM_FRAME_NOT_READY      3
22 #define VCM_REQUEST_SLI          2
23 #define VCM_MISSING_CALLBACK     1
24 #define VCM_OK                   0
25 #define VCM_GENERAL_ERROR       -1
26 #define VCM_LEVEL_EXCEEDED      -2
27 #define VCM_MEMORY              -3
28 #define VCM_PARAMETER_ERROR     -4
29 #define VCM_UNKNOWN_PAYLOAD     -5
30 #define VCM_CODEC_ERROR         -6
31 #define VCM_UNINITIALIZED       -7
32 #define VCM_NO_CODEC_REGISTERED -8
33 #define VCM_JITTER_BUFFER_ERROR -9
34 #define VCM_OLD_PACKET_ERROR    -10
35 #define VCM_NO_FRAME_DECODED    -11
36 #define VCM_ERROR_REQUEST_SLI   -12
37 #define VCM_NOT_IMPLEMENTED     -20
38 
39 #define VCM_RED_PAYLOAD_TYPE        96
40 #define VCM_ULPFEC_PAYLOAD_TYPE     97
41 #define VCM_VP8_PAYLOAD_TYPE       100
42 #define VCM_I420_PAYLOAD_TYPE      124
43 #define VCM_H264_PAYLOAD_TYPE      127
44 
45 enum VCMVideoProtection {
46   kProtectionNack,                // Both send-side and receive-side
47   kProtectionNackSender,          // Send-side only
48   kProtectionNackReceiver,        // Receive-side only
49   kProtectionDualDecoder,
50   kProtectionFEC,
51   kProtectionNackFEC,
52   kProtectionKeyOnLoss,
53   kProtectionKeyOnKeyLoss,
54   kProtectionPeriodicKeyFrames
55 };
56 
57 enum VCMTemporalDecimation {
58   kBitrateOverUseDecimation,
59 };
60 
61 struct VCMFrameCount {
62   uint32_t numKeyFrames;
63   uint32_t numDeltaFrames;
64 };
65 
66 // Callback class used for sending data ready to be packetized
67 class VCMPacketizationCallback {
68  public:
69   virtual int32_t SendData(
70       FrameType frameType,
71       uint8_t payloadType,
72       uint32_t timeStamp,
73       int64_t capture_time_ms,
74       const uint8_t* payloadData,
75       uint32_t payloadSize,
76       const RTPFragmentationHeader& fragmentationHeader,
77       const RTPVideoHeader* rtpVideoHdr) = 0;
78  protected:
~VCMPacketizationCallback()79   virtual ~VCMPacketizationCallback() {
80   }
81 };
82 
83 // Callback class used for passing decoded frames which are ready to be rendered.
84 class VCMReceiveCallback {
85  public:
86   virtual int32_t FrameToRender(I420VideoFrame& videoFrame) = 0;
ReceivedDecodedReferenceFrame(const uint64_t pictureId)87   virtual int32_t ReceivedDecodedReferenceFrame(
88       const uint64_t pictureId) {
89     return -1;
90   }
91   // Called when the current receive codec changes.
IncomingCodecChanged(const VideoCodec & codec)92   virtual void IncomingCodecChanged(const VideoCodec& codec) {}
93 
94  protected:
~VCMReceiveCallback()95   virtual ~VCMReceiveCallback() {
96   }
97 };
98 
99 // Callback class used for informing the user of the bit rate and frame rate produced by the
100 // encoder.
101 class VCMSendStatisticsCallback {
102  public:
103   virtual int32_t SendStatistics(const uint32_t bitRate,
104                                        const uint32_t frameRate) = 0;
105 
106  protected:
~VCMSendStatisticsCallback()107   virtual ~VCMSendStatisticsCallback() {
108   }
109 };
110 
111 // Callback class used for informing the user of the incoming bit rate and frame rate.
112 class VCMReceiveStatisticsCallback {
113  public:
114   virtual int32_t OnReceiveStatisticsUpdate(const uint32_t bitRate,
115                                             const uint32_t frameRate) = 0;
116 
117  protected:
~VCMReceiveStatisticsCallback()118   virtual ~VCMReceiveStatisticsCallback() {
119   }
120 };
121 
122 // Callback class used for informing the user of decode timing info.
123 class VCMDecoderTimingCallback {
124  public:
125   virtual void OnDecoderTiming(int decode_ms,
126                                int max_decode_ms,
127                                int current_delay_ms,
128                                int target_delay_ms,
129                                int jitter_buffer_ms,
130                                int min_playout_delay_ms,
131                                int render_delay_ms) = 0;
132 
133  protected:
~VCMDecoderTimingCallback()134   virtual ~VCMDecoderTimingCallback() {}
135 };
136 
137 // Callback class used for telling the user about how to configure the FEC,
138 // and the rates sent the last second is returned to the VCM.
139 class VCMProtectionCallback {
140  public:
141   virtual int ProtectionRequest(const FecProtectionParams* delta_params,
142                                 const FecProtectionParams* key_params,
143                                 uint32_t* sent_video_rate_bps,
144                                 uint32_t* sent_nack_rate_bps,
145                                 uint32_t* sent_fec_rate_bps) = 0;
146 
147  protected:
~VCMProtectionCallback()148   virtual ~VCMProtectionCallback() {
149   }
150 };
151 
152 // Callback class used for telling the user about what frame type needed to continue decoding.
153 // Typically a key frame when the stream has been corrupted in some way.
154 class VCMFrameTypeCallback {
155  public:
156   virtual int32_t RequestKeyFrame() = 0;
SliceLossIndicationRequest(const uint64_t pictureId)157   virtual int32_t SliceLossIndicationRequest(
158       const uint64_t pictureId) {
159     return -1;
160   }
161 
162  protected:
~VCMFrameTypeCallback()163   virtual ~VCMFrameTypeCallback() {
164   }
165 };
166 
167 // Callback class used for telling the user about which packet sequence numbers are currently
168 // missing and need to be resent.
169 class VCMPacketRequestCallback {
170  public:
171   virtual int32_t ResendPackets(const uint16_t* sequenceNumbers,
172                                       uint16_t length) = 0;
173 
174  protected:
~VCMPacketRequestCallback()175   virtual ~VCMPacketRequestCallback() {
176   }
177 };
178 
179 // Callback used to inform the user of the the desired resolution
180 // as subscribed by Media Optimization (Quality Modes)
181 class VCMQMSettingsCallback {
182  public:
183   virtual int32_t SetVideoQMSettings(const uint32_t frameRate,
184                                            const uint32_t width,
185                                            const uint32_t height) = 0;
186 
187  protected:
~VCMQMSettingsCallback()188   virtual ~VCMQMSettingsCallback() {
189   }
190 };
191 
192 // Callback class used for telling the user about the size (in time) of the
193 // render buffer, that is the size in time of the complete continuous frames.
194 class VCMRenderBufferSizeCallback {
195  public:
196   virtual void RenderBufferSizeMs(int buffer_size_ms) = 0;
197 
198  protected:
~VCMRenderBufferSizeCallback()199   virtual ~VCMRenderBufferSizeCallback() {
200   }
201 };
202 
203 }  // namespace webrtc
204 
205 #endif // WEBRTC_MODULES_INTERFACE_VIDEO_CODING_DEFINES_H_
206