Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_DEFINES_H_ |
| 12 | #define MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_DEFINES_H_ |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 13 | |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 14 | #include <stddef.h> |
| 15 | #include <stdint.h> |
philipel | 5ab4c6d | 2016-03-08 03:36:15 -0800 | [diff] [blame] | 16 | |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 17 | #include "absl/types/optional.h" |
| 18 | #include "api/video/video_content_type.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 19 | #include "api/video/video_frame.h" |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 20 | #include "api/video/video_timing.h" |
| 21 | #include "common_types.h" // NOLINT(build/include) |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 22 | |
| 23 | namespace webrtc { |
| 24 | |
| 25 | // Error codes |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 26 | #define VCM_FRAME_NOT_READY 3 |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 27 | #define VCM_MISSING_CALLBACK 1 |
| 28 | #define VCM_OK 0 |
| 29 | #define VCM_GENERAL_ERROR -1 |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 30 | #define VCM_PARAMETER_ERROR -4 |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 31 | #define VCM_CODEC_ERROR -6 |
| 32 | #define VCM_UNINITIALIZED -7 |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 33 | #define VCM_NO_CODEC_REGISTERED -8 |
| 34 | #define VCM_JITTER_BUFFER_ERROR -9 |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 35 | #define VCM_OLD_PACKET_ERROR -10 |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 36 | |
ilnik | 04f4d12 | 2017-06-19 07:18:55 -0700 | [diff] [blame] | 37 | enum { |
ilnik | 04f4d12 | 2017-06-19 07:18:55 -0700 | [diff] [blame] | 38 | // 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 Nikolaevskiy | 82c07ea | 2018-11-06 12:54:30 +0100 | [diff] [blame] | 42 | kDefaultOutlierFrameSizePercent = 500, |
Ilya Nikolaevskiy | d79314f | 2017-10-23 10:45:37 +0200 | [diff] [blame] | 43 | // Maximum number of frames for what we store encode start timing information. |
| 44 | kMaxEncodeStartTimeListSize = 50, |
ilnik | 04f4d12 | 2017-06-19 07:18:55 -0700 | [diff] [blame] | 45 | }; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 46 | |
| 47 | enum VCMVideoProtection { |
| 48 | kProtectionNone, |
| 49 | kProtectionNack, |
| 50 | kProtectionFEC, |
| 51 | kProtectionNackFEC, |
| 52 | }; |
| 53 | |
| 54 | enum VCMTemporalDecimation { |
| 55 | kBitrateOverUseDecimation, |
| 56 | }; |
| 57 | |
| 58 | struct VCMFrameCount { |
| 59 | uint32_t numKeyFrames; |
| 60 | uint32_t numDeltaFrames; |
| 61 | }; |
| 62 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 63 | // Callback class used for passing decoded frames which are ready to be |
| 64 | // rendered. |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 65 | class VCMReceiveCallback { |
| 66 | public: |
sakal | cc452e1 | 2017-02-09 04:53:45 -0800 | [diff] [blame] | 67 | virtual int32_t FrameToRender(VideoFrame& videoFrame, // NOLINT |
Danil Chapovalov | 0040b66 | 2018-06-18 10:48:16 +0200 | [diff] [blame] | 68 | absl::optional<uint8_t> qp, |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 69 | VideoContentType content_type) = 0; |
ilnik | fc0acc4 | 2017-05-08 02:59:38 -0700 | [diff] [blame] | 70 | |
Niels Möller | be682d4 | 2018-03-27 08:31:45 +0200 | [diff] [blame] | 71 | virtual int32_t ReceivedDecodedReferenceFrame(const uint64_t pictureId); |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 72 | // Called when the current receive codec changes. |
Niels Möller | be682d4 | 2018-03-27 08:31:45 +0200 | [diff] [blame] | 73 | virtual void OnIncomingPayloadType(int payload_type); |
| 74 | virtual void OnDecoderImplementationName(const char* implementation_name); |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 75 | |
| 76 | protected: |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 77 | virtual ~VCMReceiveCallback() {} |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 78 | }; |
| 79 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 80 | // Callback class used for informing the user of the incoming bit rate and frame |
| 81 | // rate. |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 82 | class VCMReceiveStatisticsCallback { |
| 83 | public: |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 84 | virtual void OnCompleteFrame(bool is_keyframe, |
| 85 | size_t size_bytes, |
| 86 | VideoContentType content_type) = 0; |
Niels Möller | b8fffa1 | 2019-03-27 15:16:39 +0100 | [diff] [blame] | 87 | // TODO(nisse): Delete. |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 88 | virtual void OnDiscardedPacketsUpdated(int discarded_packets) = 0; |
Niels Möller | b8fffa1 | 2019-03-27 15:16:39 +0100 | [diff] [blame] | 89 | // TODO(nisse): Delete. |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 90 | virtual void OnFrameCountsUpdated(const FrameCounts& frame_counts) = 0; |
philipel | a45102f | 2017-02-22 05:30:39 -0800 | [diff] [blame] | 91 | virtual void OnFrameBufferTimingsUpdated(int decode_ms, |
| 92 | int max_decode_ms, |
| 93 | int current_delay_ms, |
| 94 | int target_delay_ms, |
| 95 | int jitter_buffer_ms, |
| 96 | int min_playout_delay_ms, |
| 97 | int render_delay_ms) = 0; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 98 | |
ilnik | 2edc684 | 2017-07-06 03:06:50 -0700 | [diff] [blame] | 99 | virtual void OnTimingFrameInfoUpdated(const TimingFrameInfo& info) = 0; |
| 100 | |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 101 | protected: |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 102 | virtual ~VCMReceiveStatisticsCallback() {} |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 103 | }; |
| 104 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 105 | // Callback class used for telling the user about what frame type needed to |
| 106 | // continue decoding. |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 107 | // Typically a key frame when the stream has been corrupted in some way. |
| 108 | class VCMFrameTypeCallback { |
| 109 | public: |
| 110 | virtual int32_t RequestKeyFrame() = 0; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 111 | |
| 112 | protected: |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 113 | virtual ~VCMFrameTypeCallback() {} |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 114 | }; |
| 115 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 116 | // Callback class used for telling the user about which packet sequence numbers |
| 117 | // are currently |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 118 | // missing and need to be resent. |
philipel | 5ab4c6d | 2016-03-08 03:36:15 -0800 | [diff] [blame] | 119 | // TODO(philipel): Deprecate VCMPacketRequestCallback |
| 120 | // and use NackSender instead. |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 121 | class VCMPacketRequestCallback { |
| 122 | public: |
| 123 | virtual int32_t ResendPackets(const uint16_t* sequenceNumbers, |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 124 | uint16_t length) = 0; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 125 | |
| 126 | protected: |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 127 | virtual ~VCMPacketRequestCallback() {} |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 128 | }; |
| 129 | |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 130 | } // namespace webrtc |
| 131 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 132 | #endif // MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_DEFINES_H_ |