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