blob: 81ec68d2b6f4afa15eac9952276b0bc2cb155673 [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
Yves Gerey3e707812018-11-28 16:47:49 +010014#include <stddef.h>
15#include <stdint.h>
philipel5ab4c6d2016-03-08 03:36:15 -080016
Yves Gerey3e707812018-11-28 16:47:49 +010017#include "absl/types/optional.h"
18#include "api/video/video_content_type.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020019#include "api/video/video_frame.h"
Yves Gerey3e707812018-11-28 16:47:49 +010020#include "api/video/video_timing.h"
21#include "common_types.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
philipel9d3ab612015-12-21 04:12:39 -080030#define VCM_PARAMETER_ERROR -4
philipel9d3ab612015-12-21 04:12:39 -080031#define VCM_CODEC_ERROR -6
32#define VCM_UNINITIALIZED -7
Henrik Kjellander2557b862015-11-18 22:00:21 +010033#define VCM_NO_CODEC_REGISTERED -8
34#define VCM_JITTER_BUFFER_ERROR -9
philipel9d3ab612015-12-21 04:12:39 -080035#define VCM_OLD_PACKET_ERROR -10
Henrik Kjellander2557b862015-11-18 22:00:21 +010036
ilnik04f4d122017-06-19 07:18:55 -070037enum {
ilnik04f4d122017-06-19 07:18:55 -070038 // Timing frames settings. Timing frames are sent every
39 // |kDefaultTimingFramesDelayMs|, or if the frame is at least
40 // |kDefaultOutliserFrameSizePercent| in size of average frame.
41 kDefaultTimingFramesDelayMs = 200,
Ilya Nikolaevskiy82c07ea2018-11-06 12:54:30 +010042 kDefaultOutlierFrameSizePercent = 500,
Ilya Nikolaevskiyd79314f2017-10-23 10:45:37 +020043 // Maximum number of frames for what we store encode start timing information.
44 kMaxEncodeStartTimeListSize = 50,
ilnik04f4d122017-06-19 07:18:55 -070045};
Henrik Kjellander2557b862015-11-18 22:00:21 +010046
47enum VCMVideoProtection {
48 kProtectionNone,
49 kProtectionNack,
50 kProtectionFEC,
51 kProtectionNackFEC,
52};
53
54enum VCMTemporalDecimation {
55 kBitrateOverUseDecimation,
56};
57
58struct VCMFrameCount {
59 uint32_t numKeyFrames;
60 uint32_t numDeltaFrames;
61};
62
philipel9d3ab612015-12-21 04:12:39 -080063// Callback class used for passing decoded frames which are ready to be
64// rendered.
Henrik Kjellander2557b862015-11-18 22:00:21 +010065class VCMReceiveCallback {
66 public:
sakalcc452e12017-02-09 04:53:45 -080067 virtual int32_t FrameToRender(VideoFrame& videoFrame, // NOLINT
Danil Chapovalov0040b662018-06-18 10:48:16 +020068 absl::optional<uint8_t> qp,
ilnik6d5b4d62017-08-30 03:32:14 -070069 VideoContentType content_type) = 0;
ilnikfc0acc42017-05-08 02:59:38 -070070
Niels Möllerbe682d42018-03-27 08:31:45 +020071 virtual int32_t ReceivedDecodedReferenceFrame(const uint64_t pictureId);
Henrik Kjellander2557b862015-11-18 22:00:21 +010072 // Called when the current receive codec changes.
Niels Möllerbe682d42018-03-27 08:31:45 +020073 virtual void OnIncomingPayloadType(int payload_type);
74 virtual void OnDecoderImplementationName(const char* implementation_name);
Henrik Kjellander2557b862015-11-18 22:00:21 +010075
76 protected:
philipel9d3ab612015-12-21 04:12:39 -080077 virtual ~VCMReceiveCallback() {}
Henrik Kjellander2557b862015-11-18 22:00:21 +010078};
79
philipel9d3ab612015-12-21 04:12:39 -080080// Callback class used for informing the user of the incoming bit rate and frame
81// rate.
Henrik Kjellander2557b862015-11-18 22:00:21 +010082class VCMReceiveStatisticsCallback {
83 public:
ilnik6d5b4d62017-08-30 03:32:14 -070084 virtual void OnCompleteFrame(bool is_keyframe,
85 size_t size_bytes,
86 VideoContentType content_type) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +010087 virtual void OnDiscardedPacketsUpdated(int discarded_packets) = 0;
88 virtual void OnFrameCountsUpdated(const FrameCounts& frame_counts) = 0;
philipela45102f2017-02-22 05:30:39 -080089 virtual void OnFrameBufferTimingsUpdated(int decode_ms,
90 int max_decode_ms,
91 int current_delay_ms,
92 int target_delay_ms,
93 int jitter_buffer_ms,
94 int min_playout_delay_ms,
95 int render_delay_ms) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +010096
ilnik2edc6842017-07-06 03:06:50 -070097 virtual void OnTimingFrameInfoUpdated(const TimingFrameInfo& info) = 0;
98
Henrik Kjellander2557b862015-11-18 22:00:21 +010099 protected:
philipel9d3ab612015-12-21 04:12:39 -0800100 virtual ~VCMReceiveStatisticsCallback() {}
Henrik Kjellander2557b862015-11-18 22:00:21 +0100101};
102
philipel9d3ab612015-12-21 04:12:39 -0800103// Callback class used for telling the user about what frame type needed to
104// continue decoding.
Henrik Kjellander2557b862015-11-18 22:00:21 +0100105// Typically a key frame when the stream has been corrupted in some way.
106class VCMFrameTypeCallback {
107 public:
108 virtual int32_t RequestKeyFrame() = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100109
110 protected:
philipel9d3ab612015-12-21 04:12:39 -0800111 virtual ~VCMFrameTypeCallback() {}
Henrik Kjellander2557b862015-11-18 22:00:21 +0100112};
113
philipel9d3ab612015-12-21 04:12:39 -0800114// Callback class used for telling the user about which packet sequence numbers
115// are currently
Henrik Kjellander2557b862015-11-18 22:00:21 +0100116// missing and need to be resent.
philipel5ab4c6d2016-03-08 03:36:15 -0800117// TODO(philipel): Deprecate VCMPacketRequestCallback
118// and use NackSender instead.
Henrik Kjellander2557b862015-11-18 22:00:21 +0100119class VCMPacketRequestCallback {
120 public:
121 virtual int32_t ResendPackets(const uint16_t* sequenceNumbers,
philipel9d3ab612015-12-21 04:12:39 -0800122 uint16_t length) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100123
124 protected:
philipel9d3ab612015-12-21 04:12:39 -0800125 virtual ~VCMPacketRequestCallback() {}
Henrik Kjellander2557b862015-11-18 22:00:21 +0100126};
127
Henrik Kjellander2557b862015-11-18 22:00:21 +0100128} // namespace webrtc
129
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200130#endif // MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_DEFINES_H_