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