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 | |
Mirko Bonadei | 7120742 | 2017-09-15 13:58:09 +0200 | [diff] [blame] | 16 | #include "common_types.h" // NOLINT(build/include) |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 17 | #include "common_video/include/video_frame.h" |
| 18 | #include "modules/include/module_common_types.h" |
| 19 | #include "modules/video_coding/include/video_codec_interface.h" |
| 20 | #include "modules/video_coding/include/video_coding_defines.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 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 24 | class VCMEncodedFrame : protected EncodedImage { |
| 25 | public: |
| 26 | VCMEncodedFrame(); |
| 27 | explicit VCMEncodedFrame(const webrtc::EncodedImage& rhs); |
| 28 | VCMEncodedFrame(const VCMEncodedFrame& rhs); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 29 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 30 | ~VCMEncodedFrame(); |
| 31 | /** |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame^] | 32 | * Delete VideoFrame and resets members to zero |
| 33 | */ |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 34 | void Free(); |
| 35 | /** |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame^] | 36 | * Set render time in milliseconds |
| 37 | */ |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 38 | void SetRenderTime(const int64_t renderTimeMs) { |
| 39 | _renderTimeMs = renderTimeMs; |
| 40 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 41 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 42 | /** |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame^] | 43 | * Set the encoded frame size |
| 44 | */ |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 45 | void SetEncodedSize(uint32_t width, uint32_t height) { |
| 46 | _encodedWidth = width; |
| 47 | _encodedHeight = height; |
| 48 | } |
gnish | b2a318b | 2017-05-10 09:21:33 -0700 | [diff] [blame] | 49 | |
| 50 | void SetPlayoutDelay(PlayoutDelay playout_delay) { |
| 51 | playout_delay_ = playout_delay; |
| 52 | } |
| 53 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 54 | /** |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame^] | 55 | * Get the encoded image |
| 56 | */ |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 57 | const webrtc::EncodedImage& EncodedImage() const { |
| 58 | return static_cast<const webrtc::EncodedImage&>(*this); |
| 59 | } |
| 60 | /** |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame^] | 61 | * Get pointer to frame buffer |
| 62 | */ |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 63 | const uint8_t* Buffer() const { return _buffer; } |
| 64 | /** |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame^] | 65 | * Get frame length |
| 66 | */ |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 67 | size_t Length() const { return _length; } |
| 68 | /** |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame^] | 69 | * Get frame timestamp (90kHz) |
| 70 | */ |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 71 | uint32_t TimeStamp() const { return _timeStamp; } |
| 72 | /** |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame^] | 73 | * Get render time in milliseconds |
| 74 | */ |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 75 | int64_t RenderTimeMs() const { return _renderTimeMs; } |
| 76 | /** |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame^] | 77 | * Get frame type |
| 78 | */ |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 79 | webrtc::FrameType FrameType() const { return _frameType; } |
| 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_; } |
| 92 | /** |
ilnik | 00d802b | 2017-04-11 10:34:31 -0700 | [diff] [blame] | 93 | * True if this frame is complete, false otherwise |
| 94 | */ |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 95 | bool Complete() const { return _completeFrame; } |
| 96 | /** |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame^] | 97 | * True if there's a frame missing before this frame |
| 98 | */ |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 99 | bool MissingFrame() const { return _missingFrame; } |
| 100 | /** |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame^] | 101 | * Payload type of the encoded payload |
| 102 | */ |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 103 | uint8_t PayloadType() const { return _payloadType; } |
| 104 | /** |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame^] | 105 | * Get codec specific info. |
| 106 | * The returned pointer is only valid as long as the VCMEncodedFrame |
| 107 | * is valid. Also, VCMEncodedFrame owns the pointer and will delete |
| 108 | * the object. |
| 109 | */ |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 110 | const CodecSpecificInfo* CodecSpecific() const { return &_codecSpecificInfo; } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 111 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 112 | protected: |
| 113 | /** |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame^] | 114 | * Verifies that current allocated buffer size is larger than or equal to the |
| 115 | * input size. |
| 116 | * If the current buffer size is smaller, a new allocation is made and the old |
| 117 | * buffer data |
| 118 | * is copied to the new buffer. |
| 119 | * Buffer size is updated to minimumSize. |
| 120 | */ |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 121 | void VerifyAndAllocate(size_t minimumSize); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 122 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 123 | void Reset(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 124 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 125 | void CopyCodecSpecific(const RTPVideoHeader* header); |
henrik.lundin@webrtc.org | 473bac8 | 2011-08-17 09:47:33 +0000 | [diff] [blame] | 126 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 127 | int64_t _renderTimeMs; |
| 128 | uint8_t _payloadType; |
| 129 | bool _missingFrame; |
| 130 | CodecSpecificInfo _codecSpecificInfo; |
| 131 | webrtc::VideoCodecType _codec; |
guoweis@webrtc.org | 54d072e | 2015-03-17 21:54:50 +0000 | [diff] [blame] | 132 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 133 | // Video rotation is only set along with the last packet for each frame |
| 134 | // (same as marker bit). This |_rotation_set| is only for debugging purpose |
| 135 | // to ensure we don't set it twice for a frame. |
| 136 | bool _rotation_set; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 137 | }; |
| 138 | |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 139 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 140 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 141 | #endif // MODULES_VIDEO_CODING_ENCODED_FRAME_H_ |