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