niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2011 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_ENCODED_FRAME_H_ |
| 12 | #define MODULES_VIDEO_CODING_ENCODED_FRAME_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | |
stefan@webrtc.org | c530043 | 2012-10-08 07:06:53 +0000 | [diff] [blame] | 14 | #include <vector> |
| 15 | |
Niels Möller | 4dc66c5 | 2018-10-05 14:17:58 +0200 | [diff] [blame] | 16 | #include "api/video/encoded_image.h" |
Danil Chapovalov | 7c06777 | 2019-10-07 12:56:24 +0200 | [diff] [blame] | 17 | #include "modules/rtp_rtcp/source/rtp_video_header.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 18 | #include "modules/video_coding/include/video_codec_interface.h" |
| 19 | #include "modules/video_coding/include/video_coding_defines.h" |
Guido Urdaneta | c8958e5 | 2020-02-28 16:28:34 +0100 | [diff] [blame] | 20 | #include "rtc_base/system/rtc_export.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 21 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 22 | namespace webrtc { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 23 | |
Guido Urdaneta | c8958e5 | 2020-02-28 16:28:34 +0100 | [diff] [blame] | 24 | class RTC_EXPORT VCMEncodedFrame : protected EncodedImage { |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 25 | public: |
| 26 | VCMEncodedFrame(); |
philipel | 6c42d92 | 2019-06-20 11:13:03 +0200 | [diff] [blame] | 27 | VCMEncodedFrame(const VCMEncodedFrame&); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 28 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 29 | ~VCMEncodedFrame(); |
| 30 | /** |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 31 | * Set render time in milliseconds |
| 32 | */ |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 33 | void SetRenderTime(const int64_t renderTimeMs) { |
| 34 | _renderTimeMs = renderTimeMs; |
| 35 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 36 | |
Niels Möller | d381eed | 2020-09-02 15:34:40 +0200 | [diff] [blame] | 37 | void SetPlayoutDelay(VideoPlayoutDelay playout_delay) { |
gnish | b2a318b | 2017-05-10 09:21:33 -0700 | [diff] [blame] | 38 | playout_delay_ = playout_delay; |
| 39 | } |
| 40 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 41 | /** |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 42 | * Get the encoded image |
| 43 | */ |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 44 | const webrtc::EncodedImage& EncodedImage() const { |
| 45 | return static_cast<const webrtc::EncodedImage&>(*this); |
| 46 | } |
Niels Möller | 9c84390 | 2019-01-11 10:21:35 +0100 | [diff] [blame] | 47 | |
Ilya Nikolaevskiy | 2ebf523 | 2019-05-13 16:13:36 +0200 | [diff] [blame] | 48 | using EncodedImage::ColorSpace; |
Niels Möller | 9c84390 | 2019-01-11 10:21:35 +0100 | [diff] [blame] | 49 | using EncodedImage::data; |
Markus Handell | 269ac81 | 2019-12-03 14:31:45 +0100 | [diff] [blame] | 50 | using EncodedImage::GetEncodedData; |
Minyue Li | 21bccae | 2020-03-09 13:28:43 +0100 | [diff] [blame] | 51 | using EncodedImage::NtpTimeMs; |
Chen Xing | f00bf42 | 2019-06-20 10:05:55 +0200 | [diff] [blame] | 52 | using EncodedImage::PacketInfos; |
Markus Handell | 269ac81 | 2019-12-03 14:31:45 +0100 | [diff] [blame] | 53 | using EncodedImage::Retain; |
Ilya Nikolaevskiy | 5546aef | 2018-12-04 15:54:52 +0100 | [diff] [blame] | 54 | using EncodedImage::set_size; |
Ilya Nikolaevskiy | 2ebf523 | 2019-05-13 16:13:36 +0200 | [diff] [blame] | 55 | using EncodedImage::SetColorSpace; |
Niels Möller | 4d504c7 | 2019-06-18 15:56:56 +0200 | [diff] [blame] | 56 | using EncodedImage::SetEncodedData; |
Chen Xing | f00bf42 | 2019-06-20 10:05:55 +0200 | [diff] [blame] | 57 | using EncodedImage::SetPacketInfos; |
Sergey Silkin | 61832dd | 2018-12-20 14:32:14 +0100 | [diff] [blame] | 58 | using EncodedImage::SetSpatialIndex; |
Sergey Silkin | 2799e63 | 2019-05-17 09:51:39 +0200 | [diff] [blame] | 59 | using EncodedImage::SetSpatialLayerFrameSize; |
Niels Möller | 2377588 | 2018-08-16 10:24:12 +0200 | [diff] [blame] | 60 | using EncodedImage::SetTimestamp; |
Niels Möller | f0eee00 | 2018-11-28 16:31:29 +0100 | [diff] [blame] | 61 | using EncodedImage::size; |
Sergey Silkin | 2799e63 | 2019-05-17 09:51:39 +0200 | [diff] [blame] | 62 | using EncodedImage::SpatialIndex; |
| 63 | using EncodedImage::SpatialLayerFrameSize; |
Ilya Nikolaevskiy | 5546aef | 2018-12-04 15:54:52 +0100 | [diff] [blame] | 64 | using EncodedImage::Timestamp; |
| 65 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 66 | /** |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 67 | * Get render time in milliseconds |
| 68 | */ |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 69 | int64_t RenderTimeMs() const { return _renderTimeMs; } |
| 70 | /** |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 71 | * Get frame type |
| 72 | */ |
Niels Möller | 87e2d78 | 2019-03-07 10:18:23 +0100 | [diff] [blame] | 73 | webrtc::VideoFrameType FrameType() const { return _frameType; } |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 74 | /** |
Markus Handell | 269ac81 | 2019-12-03 14:31:45 +0100 | [diff] [blame] | 75 | * Set frame type |
| 76 | */ |
| 77 | void SetFrameType(webrtc::VideoFrameType frame_type) { |
| 78 | _frameType = frame_type; |
| 79 | } |
| 80 | /** |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 81 | * Get frame rotation |
| 82 | */ |
perkj | 414dda1 | 2016-07-04 01:45:23 -0700 | [diff] [blame] | 83 | VideoRotation rotation() const { return rotation_; } |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 84 | /** |
ilnik | 00d802b | 2017-04-11 10:34:31 -0700 | [diff] [blame] | 85 | * Get video content type |
| 86 | */ |
| 87 | VideoContentType contentType() const { return content_type_; } |
| 88 | /** |
ilnik | 04f4d12 | 2017-06-19 07:18:55 -0700 | [diff] [blame] | 89 | * Get video timing |
| 90 | */ |
| 91 | EncodedImage::Timing video_timing() const { return timing_; } |
Ilya Nikolaevskiy | 5546aef | 2018-12-04 15:54:52 +0100 | [diff] [blame] | 92 | EncodedImage::Timing* video_timing_mutable() { return &timing_; } |
ilnik | 04f4d12 | 2017-06-19 07:18:55 -0700 | [diff] [blame] | 93 | /** |
ilnik | 00d802b | 2017-04-11 10:34:31 -0700 | [diff] [blame] | 94 | * True if this frame is complete, false otherwise |
| 95 | */ |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 96 | bool Complete() const { return _completeFrame; } |
| 97 | /** |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 98 | * True if there's a frame missing before this frame |
| 99 | */ |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 100 | bool MissingFrame() const { return _missingFrame; } |
| 101 | /** |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 102 | * Payload type of the encoded payload |
| 103 | */ |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 104 | uint8_t PayloadType() const { return _payloadType; } |
| 105 | /** |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 106 | * Get codec specific info. |
| 107 | * The returned pointer is only valid as long as the VCMEncodedFrame |
| 108 | * is valid. Also, VCMEncodedFrame owns the pointer and will delete |
| 109 | * the object. |
| 110 | */ |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 111 | const CodecSpecificInfo* CodecSpecific() const { return &_codecSpecificInfo; } |
Ilya Nikolaevskiy | 5546aef | 2018-12-04 15:54:52 +0100 | [diff] [blame] | 112 | void SetCodecSpecific(const CodecSpecificInfo* codec_specific) { |
| 113 | _codecSpecificInfo = *codec_specific; |
| 114 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 115 | |
Ilya Nikolaevskiy | 5546aef | 2018-12-04 15:54:52 +0100 | [diff] [blame] | 116 | protected: |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 117 | void Reset(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 118 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 119 | void CopyCodecSpecific(const RTPVideoHeader* header); |
henrik.lundin@webrtc.org | 473bac8 | 2011-08-17 09:47:33 +0000 | [diff] [blame] | 120 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 121 | int64_t _renderTimeMs; |
| 122 | uint8_t _payloadType; |
| 123 | bool _missingFrame; |
| 124 | CodecSpecificInfo _codecSpecificInfo; |
| 125 | webrtc::VideoCodecType _codec; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 126 | }; |
| 127 | |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 128 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 129 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 130 | #endif // MODULES_VIDEO_CODING_ENCODED_FRAME_H_ |