blob: 043d8c6f29584c4c8ccceaa098af4408f0b41ba9 [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"
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
philipel9d3ab612015-12-21 04:12:39 -080029#define VCM_PARAMETER_ERROR -4
Henrik Kjellander2557b862015-11-18 22:00:21 +010030#define VCM_NO_CODEC_REGISTERED -8
31#define VCM_JITTER_BUFFER_ERROR -9
Henrik Kjellander2557b862015-11-18 22:00:21 +010032
ilnik04f4d122017-06-19 07:18:55 -070033enum {
ilnik04f4d122017-06-19 07:18:55 -070034 // Timing frames settings. Timing frames are sent every
35 // |kDefaultTimingFramesDelayMs|, or if the frame is at least
36 // |kDefaultOutliserFrameSizePercent| in size of average frame.
37 kDefaultTimingFramesDelayMs = 200,
Ilya Nikolaevskiy82c07ea2018-11-06 12:54:30 +010038 kDefaultOutlierFrameSizePercent = 500,
Ilya Nikolaevskiyd79314f2017-10-23 10:45:37 +020039 // Maximum number of frames for what we store encode start timing information.
Ilya Nikolaevskiy1ced8892019-04-24 12:41:16 +020040 kMaxEncodeStartTimeListSize = 150,
ilnik04f4d122017-06-19 07:18:55 -070041};
Henrik Kjellander2557b862015-11-18 22:00:21 +010042
43enum VCMVideoProtection {
44 kProtectionNone,
45 kProtectionNack,
46 kProtectionFEC,
47 kProtectionNackFEC,
48};
49
philipel9d3ab612015-12-21 04:12:39 -080050// Callback class used for passing decoded frames which are ready to be
51// rendered.
Henrik Kjellander2557b862015-11-18 22:00:21 +010052class VCMReceiveCallback {
53 public:
Johannes Kronbfd343b2019-07-01 10:07:50 +020054 // TODO(kron): Remove once downstream projects are updated.
sakalcc452e12017-02-09 04:53:45 -080055 virtual int32_t FrameToRender(VideoFrame& videoFrame, // NOLINT
Danil Chapovalov0040b662018-06-18 10:48:16 +020056 absl::optional<uint8_t> qp,
Johannes Kronbfd343b2019-07-01 10:07:50 +020057 VideoContentType content_type) {
58 // Cannot be pure virtual since this should be removed from derived
59 // classes.
60 return FrameToRender(videoFrame, qp, 0, content_type);
61 }
62
63 virtual int32_t FrameToRender(VideoFrame& videoFrame, // NOLINT
64 absl::optional<uint8_t> qp,
65 int32_t decode_time_ms,
66 VideoContentType content_type) {
67 return FrameToRender(videoFrame, qp, content_type);
68 }
ilnikfc0acc42017-05-08 02:59:38 -070069
Henrik Kjellander2557b862015-11-18 22:00:21 +010070 // Called when the current receive codec changes.
Niels Möllerbe682d42018-03-27 08:31:45 +020071 virtual void OnIncomingPayloadType(int payload_type);
72 virtual void OnDecoderImplementationName(const char* implementation_name);
Henrik Kjellander2557b862015-11-18 22:00:21 +010073
74 protected:
philipel9d3ab612015-12-21 04:12:39 -080075 virtual ~VCMReceiveCallback() {}
Henrik Kjellander2557b862015-11-18 22:00:21 +010076};
77
philipel9d3ab612015-12-21 04:12:39 -080078// Callback class used for informing the user of the incoming bit rate and frame
79// rate.
Henrik Kjellander2557b862015-11-18 22:00:21 +010080class VCMReceiveStatisticsCallback {
81 public:
ilnik6d5b4d62017-08-30 03:32:14 -070082 virtual void OnCompleteFrame(bool is_keyframe,
83 size_t size_bytes,
84 VideoContentType content_type) = 0;
Niels Möllerdd41da62019-03-28 08:59:07 +010085
Johannes Kronbfd343b2019-07-01 10:07:50 +020086 virtual void OnFrameBufferTimingsUpdated(int max_decode_ms,
philipela45102f2017-02-22 05:30:39 -080087 int current_delay_ms,
88 int target_delay_ms,
89 int jitter_buffer_ms,
90 int min_playout_delay_ms,
91 int render_delay_ms) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +010092
ilnik2edc6842017-07-06 03:06:50 -070093 virtual void OnTimingFrameInfoUpdated(const TimingFrameInfo& info) = 0;
94
Henrik Kjellander2557b862015-11-18 22:00:21 +010095 protected:
philipel9d3ab612015-12-21 04:12:39 -080096 virtual ~VCMReceiveStatisticsCallback() {}
Henrik Kjellander2557b862015-11-18 22:00:21 +010097};
98
philipel9d3ab612015-12-21 04:12:39 -080099// Callback class used for telling the user about what frame type needed to
100// continue decoding.
Henrik Kjellander2557b862015-11-18 22:00:21 +0100101// Typically a key frame when the stream has been corrupted in some way.
102class VCMFrameTypeCallback {
103 public:
104 virtual int32_t RequestKeyFrame() = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100105
106 protected:
philipel9d3ab612015-12-21 04:12:39 -0800107 virtual ~VCMFrameTypeCallback() {}
Henrik Kjellander2557b862015-11-18 22:00:21 +0100108};
109
philipel9d3ab612015-12-21 04:12:39 -0800110// Callback class used for telling the user about which packet sequence numbers
111// are currently
Henrik Kjellander2557b862015-11-18 22:00:21 +0100112// missing and need to be resent.
philipel5ab4c6d2016-03-08 03:36:15 -0800113// TODO(philipel): Deprecate VCMPacketRequestCallback
114// and use NackSender instead.
Henrik Kjellander2557b862015-11-18 22:00:21 +0100115class VCMPacketRequestCallback {
116 public:
117 virtual int32_t ResendPackets(const uint16_t* sequenceNumbers,
philipel9d3ab612015-12-21 04:12:39 -0800118 uint16_t length) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100119
120 protected:
philipel9d3ab612015-12-21 04:12:39 -0800121 virtual ~VCMPacketRequestCallback() {}
Henrik Kjellander2557b862015-11-18 22:00:21 +0100122};
123
Henrik Kjellander2557b862015-11-18 22:00:21 +0100124} // namespace webrtc
125
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200126#endif // MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_DEFINES_H_