Line data Source code
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 <string>
15 : #include <vector>
16 :
17 : #include "webrtc/api/video/video_frame.h"
18 : #include "webrtc/modules/include/module_common_types.h"
19 : #include "webrtc/typedefs.h"
20 : // For EncodedImage
21 : #include "webrtc/video_frame.h"
22 :
23 : namespace webrtc {
24 :
25 : // Error codes
26 : #define VCM_FRAME_NOT_READY 3
27 : #define VCM_REQUEST_SLI 2
28 : #define VCM_MISSING_CALLBACK 1
29 : #define VCM_OK 0
30 : #define VCM_GENERAL_ERROR -1
31 : #define VCM_LEVEL_EXCEEDED -2
32 : #define VCM_MEMORY -3
33 : #define VCM_PARAMETER_ERROR -4
34 : #define VCM_UNKNOWN_PAYLOAD -5
35 : #define VCM_CODEC_ERROR -6
36 : #define VCM_UNINITIALIZED -7
37 : #define VCM_NO_CODEC_REGISTERED -8
38 : #define VCM_JITTER_BUFFER_ERROR -9
39 : #define VCM_OLD_PACKET_ERROR -10
40 : #define VCM_NO_FRAME_DECODED -11
41 : #define VCM_ERROR_REQUEST_SLI -12
42 : #define VCM_NOT_IMPLEMENTED -20
43 :
44 : enum { kDefaultStartBitrateKbps = 300 };
45 :
46 : enum VCMVideoProtection {
47 : kProtectionNone,
48 : kProtectionNack,
49 : kProtectionFEC,
50 : kProtectionNackFEC,
51 : };
52 :
53 : enum VCMTemporalDecimation {
54 : kBitrateOverUseDecimation,
55 : };
56 :
57 : struct VCMFrameCount {
58 : uint32_t numKeyFrames;
59 : uint32_t numDeltaFrames;
60 : };
61 :
62 : // Callback class used for passing decoded frames which are ready to be
63 : // rendered.
64 0 : class VCMReceiveCallback {
65 : public:
66 : virtual int32_t FrameToRender(VideoFrame& videoFrame) = 0; // NOLINT
67 0 : virtual int32_t ReceivedDecodedReferenceFrame(const uint64_t pictureId) {
68 0 : return -1;
69 : }
70 : // Called when the current receive codec changes.
71 0 : virtual void OnIncomingPayloadType(int payload_type) {}
72 0 : virtual void OnDecoderImplementationName(const char* implementation_name) {}
73 :
74 : protected:
75 0 : virtual ~VCMReceiveCallback() {}
76 : };
77 :
78 : // Callback class used for informing the user of the bit rate and frame rate,
79 : // and the name of the encoder.
80 0 : class VCMSendStatisticsCallback {
81 : public:
82 : virtual void SendStatistics(uint32_t bitRate, uint32_t frameRate) = 0;
83 :
84 : protected:
85 0 : virtual ~VCMSendStatisticsCallback() {}
86 : };
87 :
88 : // Callback class used for informing the user of the incoming bit rate and frame
89 : // rate.
90 0 : class VCMReceiveStatisticsCallback {
91 : public:
92 : virtual void OnReceiveRatesUpdated(uint32_t bitRate, uint32_t frameRate) = 0;
93 : virtual void OnDiscardedPacketsUpdated(int discarded_packets) = 0;
94 : virtual void OnFrameCountsUpdated(const FrameCounts& frame_counts) = 0;
95 :
96 : protected:
97 0 : virtual ~VCMReceiveStatisticsCallback() {}
98 : };
99 :
100 : // Callback class used for informing the user of decode timing info.
101 0 : class VCMDecoderTimingCallback {
102 : public:
103 : virtual void OnDecoderTiming(int decode_ms,
104 : int max_decode_ms,
105 : int current_delay_ms,
106 : int target_delay_ms,
107 : int jitter_buffer_ms,
108 : int min_playout_delay_ms,
109 : int render_delay_ms) = 0;
110 :
111 : protected:
112 0 : virtual ~VCMDecoderTimingCallback() {}
113 : };
114 :
115 : // Callback class used for telling the user about how to configure the FEC,
116 : // and the rates sent the last second is returned to the VCM.
117 0 : class VCMProtectionCallback {
118 : public:
119 : virtual int ProtectionRequest(const FecProtectionParams* delta_params,
120 : const FecProtectionParams* key_params,
121 : uint32_t* sent_video_rate_bps,
122 : uint32_t* sent_nack_rate_bps,
123 : uint32_t* sent_fec_rate_bps) = 0;
124 :
125 : protected:
126 0 : virtual ~VCMProtectionCallback() {}
127 : };
128 :
129 : // Callback class used for telling the user about what frame type needed to
130 : // continue decoding.
131 : // Typically a key frame when the stream has been corrupted in some way.
132 0 : class VCMFrameTypeCallback {
133 : public:
134 : virtual int32_t RequestKeyFrame() = 0;
135 0 : virtual int32_t SliceLossIndicationRequest(const uint64_t pictureId) {
136 0 : return -1;
137 : }
138 :
139 : protected:
140 0 : virtual ~VCMFrameTypeCallback() {}
141 : };
142 :
143 : // Callback class used for telling the user about which packet sequence numbers
144 : // are currently
145 : // missing and need to be resent.
146 : // TODO(philipel): Deprecate VCMPacketRequestCallback
147 : // and use NackSender instead.
148 0 : class VCMPacketRequestCallback {
149 : public:
150 : virtual int32_t ResendPackets(const uint16_t* sequenceNumbers,
151 : uint16_t length) = 0;
152 :
153 : protected:
154 0 : virtual ~VCMPacketRequestCallback() {}
155 : };
156 :
157 : // Callback class used for telling the user about the state of the decoder & jitter buffer.
158 : //
159 : class VCMReceiveStateCallback {
160 : public:
161 : virtual void ReceiveStateChange(VideoReceiveState state) = 0;
162 :
163 : protected:
164 : virtual ~VCMReceiveStateCallback() {
165 : }
166 : };
167 :
168 0 : class NackSender {
169 : public:
170 : virtual void SendNack(const std::vector<uint16_t>& sequence_numbers) = 0;
171 :
172 : protected:
173 0 : virtual ~NackSender() {}
174 : };
175 :
176 0 : class KeyFrameRequestSender {
177 : public:
178 : virtual void RequestKeyFrame() = 0;
179 :
180 : protected:
181 0 : virtual ~KeyFrameRequestSender() {}
182 : };
183 :
184 : } // namespace webrtc
185 :
186 : #endif // WEBRTC_MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_DEFINES_H_
|