blob: 5bf019df1dbc9f415f4aa5d861296c7e884b4d83 [file] [log] [blame]
Henrik Kjellander2557b862015-11-18 22:00:21 +01001/*
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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_DEFINES_H_
12#define MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_DEFINES_H_
Henrik Kjellander2557b862015-11-18 22:00:21 +010013
perkj376b1922016-05-02 11:35:24 -070014#include <string>
philipel5ab4c6d2016-03-08 03:36:15 -080015#include <vector>
16
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020017#include "api/video/video_frame.h"
nisseea3a7982017-05-15 02:42:11 -070018// For EncodedImage
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020019#include "common_video/include/video_frame.h"
20#include "modules/include/module_common_types.h"
Mirko Bonadei71207422017-09-15 13:58:09 +020021#include "typedefs.h" // NOLINT(build/include)
Henrik Kjellander2557b862015-11-18 22:00:21 +010022
23namespace webrtc {
24
25// Error codes
philipel9d3ab612015-12-21 04:12:39 -080026#define VCM_FRAME_NOT_READY 3
philipel9d3ab612015-12-21 04:12:39 -080027#define VCM_MISSING_CALLBACK 1
28#define VCM_OK 0
29#define VCM_GENERAL_ERROR -1
30#define VCM_LEVEL_EXCEEDED -2
31#define VCM_MEMORY -3
32#define VCM_PARAMETER_ERROR -4
33#define VCM_UNKNOWN_PAYLOAD -5
34#define VCM_CODEC_ERROR -6
35#define VCM_UNINITIALIZED -7
Henrik Kjellander2557b862015-11-18 22:00:21 +010036#define VCM_NO_CODEC_REGISTERED -8
37#define VCM_JITTER_BUFFER_ERROR -9
philipel9d3ab612015-12-21 04:12:39 -080038#define VCM_OLD_PACKET_ERROR -10
39#define VCM_NO_FRAME_DECODED -11
philipel9d3ab612015-12-21 04:12:39 -080040#define VCM_NOT_IMPLEMENTED -20
Henrik Kjellander2557b862015-11-18 22:00:21 +010041
ilnik04f4d122017-06-19 07:18:55 -070042enum {
ilnik04f4d122017-06-19 07:18:55 -070043 // Timing frames settings. Timing frames are sent every
44 // |kDefaultTimingFramesDelayMs|, or if the frame is at least
45 // |kDefaultOutliserFrameSizePercent| in size of average frame.
46 kDefaultTimingFramesDelayMs = 200,
47 kDefaultOutlierFrameSizePercent = 250,
Ilya Nikolaevskiyd79314f2017-10-23 10:45:37 +020048 // Maximum number of frames for what we store encode start timing information.
49 kMaxEncodeStartTimeListSize = 50,
ilnik04f4d122017-06-19 07:18:55 -070050};
Henrik Kjellander2557b862015-11-18 22:00:21 +010051
52enum VCMVideoProtection {
53 kProtectionNone,
54 kProtectionNack,
55 kProtectionFEC,
56 kProtectionNackFEC,
57};
58
59enum VCMTemporalDecimation {
60 kBitrateOverUseDecimation,
61};
62
63struct VCMFrameCount {
64 uint32_t numKeyFrames;
65 uint32_t numDeltaFrames;
66};
67
philipel9d3ab612015-12-21 04:12:39 -080068// Callback class used for passing decoded frames which are ready to be
69// rendered.
Henrik Kjellander2557b862015-11-18 22:00:21 +010070class VCMReceiveCallback {
71 public:
sakalcc452e12017-02-09 04:53:45 -080072 virtual int32_t FrameToRender(VideoFrame& videoFrame, // NOLINT
ilnik00d802b2017-04-11 10:34:31 -070073 rtc::Optional<uint8_t> qp,
ilnik6d5b4d62017-08-30 03:32:14 -070074 VideoContentType content_type) = 0;
ilnikfc0acc42017-05-08 02:59:38 -070075
philipel9d3ab612015-12-21 04:12:39 -080076 virtual int32_t ReceivedDecodedReferenceFrame(const uint64_t pictureId) {
Henrik Kjellander2557b862015-11-18 22:00:21 +010077 return -1;
78 }
79 // Called when the current receive codec changes.
80 virtual void OnIncomingPayloadType(int payload_type) {}
Peter Boströmb7d9a972015-12-18 16:01:11 +010081 virtual void OnDecoderImplementationName(const char* implementation_name) {}
Henrik Kjellander2557b862015-11-18 22:00:21 +010082
83 protected:
philipel9d3ab612015-12-21 04:12:39 -080084 virtual ~VCMReceiveCallback() {}
Henrik Kjellander2557b862015-11-18 22:00:21 +010085};
86
perkj376b1922016-05-02 11:35:24 -070087// Callback class used for informing the user of the bit rate and frame rate,
88// and the name of the encoder.
Henrik Kjellander2557b862015-11-18 22:00:21 +010089class VCMSendStatisticsCallback {
90 public:
perkj275afc52016-09-01 00:21:16 -070091 virtual void SendStatistics(uint32_t bitRate, uint32_t frameRate) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +010092
93 protected:
philipel9d3ab612015-12-21 04:12:39 -080094 virtual ~VCMSendStatisticsCallback() {}
Henrik Kjellander2557b862015-11-18 22:00:21 +010095};
96
philipel9d3ab612015-12-21 04:12:39 -080097// Callback class used for informing the user of the incoming bit rate and frame
98// rate.
Henrik Kjellander2557b862015-11-18 22:00:21 +010099class VCMReceiveStatisticsCallback {
100 public:
101 virtual void OnReceiveRatesUpdated(uint32_t bitRate, uint32_t frameRate) = 0;
ilnik6d5b4d62017-08-30 03:32:14 -0700102 virtual void OnCompleteFrame(bool is_keyframe,
103 size_t size_bytes,
104 VideoContentType content_type) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100105 virtual void OnDiscardedPacketsUpdated(int discarded_packets) = 0;
106 virtual void OnFrameCountsUpdated(const FrameCounts& frame_counts) = 0;
philipela45102f2017-02-22 05:30:39 -0800107 virtual void OnFrameBufferTimingsUpdated(int decode_ms,
108 int max_decode_ms,
109 int current_delay_ms,
110 int target_delay_ms,
111 int jitter_buffer_ms,
112 int min_playout_delay_ms,
113 int render_delay_ms) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100114
ilnik2edc6842017-07-06 03:06:50 -0700115 virtual void OnTimingFrameInfoUpdated(const TimingFrameInfo& info) = 0;
116
Henrik Kjellander2557b862015-11-18 22:00:21 +0100117 protected:
philipel9d3ab612015-12-21 04:12:39 -0800118 virtual ~VCMReceiveStatisticsCallback() {}
Henrik Kjellander2557b862015-11-18 22:00:21 +0100119};
120
Henrik Kjellander2557b862015-11-18 22:00:21 +0100121// Callback class used for telling the user about how to configure the FEC,
122// and the rates sent the last second is returned to the VCM.
123class VCMProtectionCallback {
124 public:
125 virtual int ProtectionRequest(const FecProtectionParams* delta_params,
126 const FecProtectionParams* key_params,
127 uint32_t* sent_video_rate_bps,
128 uint32_t* sent_nack_rate_bps,
129 uint32_t* sent_fec_rate_bps) = 0;
130
131 protected:
philipel9d3ab612015-12-21 04:12:39 -0800132 virtual ~VCMProtectionCallback() {}
Henrik Kjellander2557b862015-11-18 22:00:21 +0100133};
134
philipel9d3ab612015-12-21 04:12:39 -0800135// Callback class used for telling the user about what frame type needed to
136// continue decoding.
Henrik Kjellander2557b862015-11-18 22:00:21 +0100137// Typically a key frame when the stream has been corrupted in some way.
138class VCMFrameTypeCallback {
139 public:
140 virtual int32_t RequestKeyFrame() = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100141
142 protected:
philipel9d3ab612015-12-21 04:12:39 -0800143 virtual ~VCMFrameTypeCallback() {}
Henrik Kjellander2557b862015-11-18 22:00:21 +0100144};
145
philipel9d3ab612015-12-21 04:12:39 -0800146// Callback class used for telling the user about which packet sequence numbers
147// are currently
Henrik Kjellander2557b862015-11-18 22:00:21 +0100148// missing and need to be resent.
philipel5ab4c6d2016-03-08 03:36:15 -0800149// TODO(philipel): Deprecate VCMPacketRequestCallback
150// and use NackSender instead.
Henrik Kjellander2557b862015-11-18 22:00:21 +0100151class VCMPacketRequestCallback {
152 public:
153 virtual int32_t ResendPackets(const uint16_t* sequenceNumbers,
philipel9d3ab612015-12-21 04:12:39 -0800154 uint16_t length) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100155
156 protected:
philipel9d3ab612015-12-21 04:12:39 -0800157 virtual ~VCMPacketRequestCallback() {}
Henrik Kjellander2557b862015-11-18 22:00:21 +0100158};
159
philipel5ab4c6d2016-03-08 03:36:15 -0800160class NackSender {
161 public:
162 virtual void SendNack(const std::vector<uint16_t>& sequence_numbers) = 0;
163
164 protected:
165 virtual ~NackSender() {}
166};
167
168class KeyFrameRequestSender {
169 public:
170 virtual void RequestKeyFrame() = 0;
171
172 protected:
173 virtual ~KeyFrameRequestSender() {}
174};
175
Henrik Kjellander2557b862015-11-18 22:00:21 +0100176} // namespace webrtc
177
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200178#endif // MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_DEFINES_H_