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 | |
perkj | 376b192 | 2016-05-02 11:35:24 -0700 | [diff] [blame] | 14 | #include <string> |
philipel | 5ab4c6d | 2016-03-08 03:36:15 -0800 | [diff] [blame] | 15 | #include <vector> |
| 16 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 17 | #include "api/video/video_frame.h" |
nisse | ea3a798 | 2017-05-15 02:42:11 -0700 | [diff] [blame] | 18 | // For EncodedImage |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 19 | #include "common_video/include/video_frame.h" |
| 20 | #include "modules/include/module_common_types.h" |
| 21 | #include "typedefs.h" |
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 |
| 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 Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 36 | #define VCM_NO_CODEC_REGISTERED -8 |
| 37 | #define VCM_JITTER_BUFFER_ERROR -9 |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 38 | #define VCM_OLD_PACKET_ERROR -10 |
| 39 | #define VCM_NO_FRAME_DECODED -11 |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 40 | #define VCM_NOT_IMPLEMENTED -20 |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 41 | |
ilnik | 04f4d12 | 2017-06-19 07:18:55 -0700 | [diff] [blame] | 42 | enum { |
ilnik | 04f4d12 | 2017-06-19 07:18:55 -0700 | [diff] [blame] | 43 | // 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, |
| 48 | }; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 49 | |
| 50 | enum VCMVideoProtection { |
| 51 | kProtectionNone, |
| 52 | kProtectionNack, |
| 53 | kProtectionFEC, |
| 54 | kProtectionNackFEC, |
| 55 | }; |
| 56 | |
| 57 | enum VCMTemporalDecimation { |
| 58 | kBitrateOverUseDecimation, |
| 59 | }; |
| 60 | |
| 61 | struct VCMFrameCount { |
| 62 | uint32_t numKeyFrames; |
| 63 | uint32_t numDeltaFrames; |
| 64 | }; |
| 65 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 66 | // Callback class used for passing decoded frames which are ready to be |
| 67 | // rendered. |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 68 | class VCMReceiveCallback { |
| 69 | public: |
sakal | cc452e1 | 2017-02-09 04:53:45 -0800 | [diff] [blame] | 70 | virtual int32_t FrameToRender(VideoFrame& videoFrame, // NOLINT |
ilnik | 00d802b | 2017-04-11 10:34:31 -0700 | [diff] [blame] | 71 | rtc::Optional<uint8_t> qp, |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 72 | VideoContentType content_type) = 0; |
ilnik | fc0acc4 | 2017-05-08 02:59:38 -0700 | [diff] [blame] | 73 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 74 | virtual int32_t ReceivedDecodedReferenceFrame(const uint64_t pictureId) { |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 75 | return -1; |
| 76 | } |
| 77 | // Called when the current receive codec changes. |
| 78 | virtual void OnIncomingPayloadType(int payload_type) {} |
Peter Boström | b7d9a97 | 2015-12-18 16:01:11 +0100 | [diff] [blame] | 79 | virtual void OnDecoderImplementationName(const char* implementation_name) {} |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 80 | |
| 81 | protected: |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 82 | virtual ~VCMReceiveCallback() {} |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 83 | }; |
| 84 | |
perkj | 376b192 | 2016-05-02 11:35:24 -0700 | [diff] [blame] | 85 | // Callback class used for informing the user of the bit rate and frame rate, |
| 86 | // and the name of the encoder. |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 87 | class VCMSendStatisticsCallback { |
| 88 | public: |
perkj | 275afc5 | 2016-09-01 00:21:16 -0700 | [diff] [blame] | 89 | virtual void SendStatistics(uint32_t bitRate, uint32_t frameRate) = 0; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 90 | |
| 91 | protected: |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 92 | virtual ~VCMSendStatisticsCallback() {} |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 93 | }; |
| 94 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 95 | // Callback class used for informing the user of the incoming bit rate and frame |
| 96 | // rate. |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 97 | class VCMReceiveStatisticsCallback { |
| 98 | public: |
| 99 | virtual void OnReceiveRatesUpdated(uint32_t bitRate, uint32_t frameRate) = 0; |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 100 | virtual void OnCompleteFrame(bool is_keyframe, |
| 101 | size_t size_bytes, |
| 102 | VideoContentType content_type) = 0; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 103 | virtual void OnDiscardedPacketsUpdated(int discarded_packets) = 0; |
| 104 | virtual void OnFrameCountsUpdated(const FrameCounts& frame_counts) = 0; |
philipel | a45102f | 2017-02-22 05:30:39 -0800 | [diff] [blame] | 105 | virtual void OnFrameBufferTimingsUpdated(int decode_ms, |
| 106 | int max_decode_ms, |
| 107 | int current_delay_ms, |
| 108 | int target_delay_ms, |
| 109 | int jitter_buffer_ms, |
| 110 | int min_playout_delay_ms, |
| 111 | int render_delay_ms) = 0; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 112 | |
ilnik | 2edc684 | 2017-07-06 03:06:50 -0700 | [diff] [blame] | 113 | virtual void OnTimingFrameInfoUpdated(const TimingFrameInfo& info) = 0; |
| 114 | |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 115 | protected: |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 116 | virtual ~VCMReceiveStatisticsCallback() {} |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 117 | }; |
| 118 | |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 119 | // Callback class used for telling the user about how to configure the FEC, |
| 120 | // and the rates sent the last second is returned to the VCM. |
| 121 | class VCMProtectionCallback { |
| 122 | public: |
| 123 | virtual int ProtectionRequest(const FecProtectionParams* delta_params, |
| 124 | const FecProtectionParams* key_params, |
| 125 | uint32_t* sent_video_rate_bps, |
| 126 | uint32_t* sent_nack_rate_bps, |
| 127 | uint32_t* sent_fec_rate_bps) = 0; |
| 128 | |
| 129 | protected: |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 130 | virtual ~VCMProtectionCallback() {} |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 131 | }; |
| 132 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 133 | // Callback class used for telling the user about what frame type needed to |
| 134 | // continue decoding. |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 135 | // Typically a key frame when the stream has been corrupted in some way. |
| 136 | class VCMFrameTypeCallback { |
| 137 | public: |
| 138 | virtual int32_t RequestKeyFrame() = 0; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 139 | |
| 140 | protected: |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 141 | virtual ~VCMFrameTypeCallback() {} |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 142 | }; |
| 143 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 144 | // Callback class used for telling the user about which packet sequence numbers |
| 145 | // are currently |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 146 | // missing and need to be resent. |
philipel | 5ab4c6d | 2016-03-08 03:36:15 -0800 | [diff] [blame] | 147 | // TODO(philipel): Deprecate VCMPacketRequestCallback |
| 148 | // and use NackSender instead. |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 149 | class VCMPacketRequestCallback { |
| 150 | public: |
| 151 | virtual int32_t ResendPackets(const uint16_t* sequenceNumbers, |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 152 | uint16_t length) = 0; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 153 | |
| 154 | protected: |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 155 | virtual ~VCMPacketRequestCallback() {} |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 156 | }; |
| 157 | |
philipel | 5ab4c6d | 2016-03-08 03:36:15 -0800 | [diff] [blame] | 158 | class NackSender { |
| 159 | public: |
| 160 | virtual void SendNack(const std::vector<uint16_t>& sequence_numbers) = 0; |
| 161 | |
| 162 | protected: |
| 163 | virtual ~NackSender() {} |
| 164 | }; |
| 165 | |
| 166 | class KeyFrameRequestSender { |
| 167 | public: |
| 168 | virtual void RequestKeyFrame() = 0; |
| 169 | |
| 170 | protected: |
| 171 | virtual ~KeyFrameRequestSender() {} |
| 172 | }; |
| 173 | |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 174 | } // namespace webrtc |
| 175 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 176 | #endif // MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_DEFINES_H_ |