blob: 7fb6f58364773f8fa818396e1cb7f684f8edb06f [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"
Henrik Kjellander2557b862015-11-18 22:00:21 +010021
22namespace webrtc {
23
24// Error codes
philipel9d3ab612015-12-21 04:12:39 -080025#define VCM_FRAME_NOT_READY 3
philipel9d3ab612015-12-21 04:12:39 -080026#define VCM_MISSING_CALLBACK 1
27#define VCM_OK 0
28#define VCM_GENERAL_ERROR -1
29#define VCM_LEVEL_EXCEEDED -2
30#define VCM_MEMORY -3
31#define VCM_PARAMETER_ERROR -4
32#define VCM_UNKNOWN_PAYLOAD -5
33#define VCM_CODEC_ERROR -6
34#define VCM_UNINITIALIZED -7
Henrik Kjellander2557b862015-11-18 22:00:21 +010035#define VCM_NO_CODEC_REGISTERED -8
36#define VCM_JITTER_BUFFER_ERROR -9
philipel9d3ab612015-12-21 04:12:39 -080037#define VCM_OLD_PACKET_ERROR -10
38#define VCM_NO_FRAME_DECODED -11
philipel9d3ab612015-12-21 04:12:39 -080039#define VCM_NOT_IMPLEMENTED -20
Henrik Kjellander2557b862015-11-18 22:00:21 +010040
ilnik04f4d122017-06-19 07:18:55 -070041enum {
ilnik04f4d122017-06-19 07:18:55 -070042 // Timing frames settings. Timing frames are sent every
43 // |kDefaultTimingFramesDelayMs|, or if the frame is at least
44 // |kDefaultOutliserFrameSizePercent| in size of average frame.
45 kDefaultTimingFramesDelayMs = 200,
46 kDefaultOutlierFrameSizePercent = 250,
Ilya Nikolaevskiyd79314f2017-10-23 10:45:37 +020047 // Maximum number of frames for what we store encode start timing information.
48 kMaxEncodeStartTimeListSize = 50,
ilnik04f4d122017-06-19 07:18:55 -070049};
Henrik Kjellander2557b862015-11-18 22:00:21 +010050
51enum VCMVideoProtection {
52 kProtectionNone,
53 kProtectionNack,
54 kProtectionFEC,
55 kProtectionNackFEC,
56};
57
58enum VCMTemporalDecimation {
59 kBitrateOverUseDecimation,
60};
61
62struct VCMFrameCount {
63 uint32_t numKeyFrames;
64 uint32_t numDeltaFrames;
65};
66
philipel9d3ab612015-12-21 04:12:39 -080067// Callback class used for passing decoded frames which are ready to be
68// rendered.
Henrik Kjellander2557b862015-11-18 22:00:21 +010069class VCMReceiveCallback {
70 public:
sakalcc452e12017-02-09 04:53:45 -080071 virtual int32_t FrameToRender(VideoFrame& videoFrame, // NOLINT
Danil Chapovalov0040b662018-06-18 10:48:16 +020072 absl::optional<uint8_t> qp,
ilnik6d5b4d62017-08-30 03:32:14 -070073 VideoContentType content_type) = 0;
ilnikfc0acc42017-05-08 02:59:38 -070074
Niels Möllerbe682d42018-03-27 08:31:45 +020075 virtual int32_t ReceivedDecodedReferenceFrame(const uint64_t pictureId);
Henrik Kjellander2557b862015-11-18 22:00:21 +010076 // Called when the current receive codec changes.
Niels Möllerbe682d42018-03-27 08:31:45 +020077 virtual void OnIncomingPayloadType(int payload_type);
78 virtual void OnDecoderImplementationName(const char* implementation_name);
Henrik Kjellander2557b862015-11-18 22:00:21 +010079
80 protected:
philipel9d3ab612015-12-21 04:12:39 -080081 virtual ~VCMReceiveCallback() {}
Henrik Kjellander2557b862015-11-18 22:00:21 +010082};
83
philipel9d3ab612015-12-21 04:12:39 -080084// Callback class used for informing the user of the incoming bit rate and frame
85// rate.
Henrik Kjellander2557b862015-11-18 22:00:21 +010086class VCMReceiveStatisticsCallback {
87 public:
88 virtual void OnReceiveRatesUpdated(uint32_t bitRate, uint32_t frameRate) = 0;
ilnik6d5b4d62017-08-30 03:32:14 -070089 virtual void OnCompleteFrame(bool is_keyframe,
90 size_t size_bytes,
91 VideoContentType content_type) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +010092 virtual void OnDiscardedPacketsUpdated(int discarded_packets) = 0;
93 virtual void OnFrameCountsUpdated(const FrameCounts& frame_counts) = 0;
philipela45102f2017-02-22 05:30:39 -080094 virtual void OnFrameBufferTimingsUpdated(int decode_ms,
95 int max_decode_ms,
96 int current_delay_ms,
97 int target_delay_ms,
98 int jitter_buffer_ms,
99 int min_playout_delay_ms,
100 int render_delay_ms) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100101
ilnik2edc6842017-07-06 03:06:50 -0700102 virtual void OnTimingFrameInfoUpdated(const TimingFrameInfo& info) = 0;
103
Henrik Kjellander2557b862015-11-18 22:00:21 +0100104 protected:
philipel9d3ab612015-12-21 04:12:39 -0800105 virtual ~VCMReceiveStatisticsCallback() {}
Henrik Kjellander2557b862015-11-18 22:00:21 +0100106};
107
philipel9d3ab612015-12-21 04:12:39 -0800108// Callback class used for telling the user about what frame type needed to
109// continue decoding.
Henrik Kjellander2557b862015-11-18 22:00:21 +0100110// Typically a key frame when the stream has been corrupted in some way.
111class VCMFrameTypeCallback {
112 public:
113 virtual int32_t RequestKeyFrame() = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100114
115 protected:
philipel9d3ab612015-12-21 04:12:39 -0800116 virtual ~VCMFrameTypeCallback() {}
Henrik Kjellander2557b862015-11-18 22:00:21 +0100117};
118
philipel9d3ab612015-12-21 04:12:39 -0800119// Callback class used for telling the user about which packet sequence numbers
120// are currently
Henrik Kjellander2557b862015-11-18 22:00:21 +0100121// missing and need to be resent.
philipel5ab4c6d2016-03-08 03:36:15 -0800122// TODO(philipel): Deprecate VCMPacketRequestCallback
123// and use NackSender instead.
Henrik Kjellander2557b862015-11-18 22:00:21 +0100124class VCMPacketRequestCallback {
125 public:
126 virtual int32_t ResendPackets(const uint16_t* sequenceNumbers,
philipel9d3ab612015-12-21 04:12:39 -0800127 uint16_t length) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100128
129 protected:
philipel9d3ab612015-12-21 04:12:39 -0800130 virtual ~VCMPacketRequestCallback() {}
Henrik Kjellander2557b862015-11-18 22:00:21 +0100131};
132
Henrik Kjellander2557b862015-11-18 22:00:21 +0100133} // namespace webrtc
134
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200135#endif // MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_DEFINES_H_