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 | |
| 11 | #ifndef WEBRTC_MODULES_VIDEO_CODING_ENCODED_FRAME_H_ |
| 12 | #define WEBRTC_MODULES_VIDEO_CODING_ENCODED_FRAME_H_ |
| 13 | |
stefan@webrtc.org | c530043 | 2012-10-08 07:06:53 +0000 | [diff] [blame] | 14 | #include <vector> |
| 15 | |
pbos@webrtc.org | a440732 | 2013-07-16 12:32:05 +0000 | [diff] [blame] | 16 | #include "webrtc/common_types.h" |
kjellander | 6f8ce06 | 2015-11-16 13:52:24 -0800 | [diff] [blame] | 17 | #include "webrtc/common_video/include/video_image.h" |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 18 | #include "webrtc/modules/include/module_common_types.h" |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 19 | #include "webrtc/modules/video_coding/include/video_codec_interface.h" |
| 20 | #include "webrtc/modules/video_coding/include/video_coding_defines.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 21 | |
| 22 | namespace webrtc |
| 23 | { |
| 24 | |
| 25 | class VCMEncodedFrame : protected EncodedImage |
| 26 | { |
| 27 | public: |
| 28 | VCMEncodedFrame(); |
| 29 | VCMEncodedFrame(const webrtc::EncodedImage& rhs); |
| 30 | VCMEncodedFrame(const VCMEncodedFrame& rhs); |
| 31 | |
| 32 | ~VCMEncodedFrame(); |
| 33 | /** |
| 34 | * Delete VideoFrame and resets members to zero |
| 35 | */ |
| 36 | void Free(); |
| 37 | /** |
| 38 | * Set render time in milliseconds |
| 39 | */ |
pbos@webrtc.org | 7b859cc | 2013-04-02 15:54:38 +0000 | [diff] [blame] | 40 | void SetRenderTime(const int64_t renderTimeMs) {_renderTimeMs = renderTimeMs;} |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 41 | |
| 42 | /** |
| 43 | * Set the encoded frame size |
| 44 | */ |
pbos@webrtc.org | 7b859cc | 2013-04-02 15:54:38 +0000 | [diff] [blame] | 45 | void SetEncodedSize(uint32_t width, uint32_t height) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 46 | { _encodedWidth = width; _encodedHeight = height; } |
| 47 | /** |
| 48 | * Get the encoded image |
| 49 | */ |
| 50 | const webrtc::EncodedImage& EncodedImage() const |
| 51 | { return static_cast<const webrtc::EncodedImage&>(*this); } |
| 52 | /** |
| 53 | * Get pointer to frame buffer |
| 54 | */ |
pbos@webrtc.org | 7b859cc | 2013-04-02 15:54:38 +0000 | [diff] [blame] | 55 | const uint8_t* Buffer() const {return _buffer;} |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 56 | /** |
| 57 | * Get frame length |
| 58 | */ |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 59 | size_t Length() const {return _length;} |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 60 | /** |
| 61 | * Get frame timestamp (90kHz) |
| 62 | */ |
pbos@webrtc.org | 7b859cc | 2013-04-02 15:54:38 +0000 | [diff] [blame] | 63 | uint32_t TimeStamp() const {return _timeStamp;} |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 64 | /** |
| 65 | * Get render time in milliseconds |
| 66 | */ |
pbos@webrtc.org | 7b859cc | 2013-04-02 15:54:38 +0000 | [diff] [blame] | 67 | int64_t RenderTimeMs() const {return _renderTimeMs;} |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 68 | /** |
| 69 | * Get frame type |
| 70 | */ |
pbos | 22993e1 | 2015-10-19 02:39:06 -0700 | [diff] [blame] | 71 | webrtc::FrameType FrameType() const { return _frameType; } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 72 | /** |
guoweis@webrtc.org | 54d072e | 2015-03-17 21:54:50 +0000 | [diff] [blame] | 73 | * Get frame rotation |
| 74 | */ |
| 75 | VideoRotation rotation() const { return _rotation; } |
| 76 | /** |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 77 | * True if this frame is complete, false otherwise |
| 78 | */ |
| 79 | bool Complete() const { return _completeFrame; } |
| 80 | /** |
| 81 | * True if there's a frame missing before this frame |
| 82 | */ |
| 83 | bool MissingFrame() const { return _missingFrame; } |
| 84 | /** |
| 85 | * Payload type of the encoded payload |
| 86 | */ |
pbos@webrtc.org | 7b859cc | 2013-04-02 15:54:38 +0000 | [diff] [blame] | 87 | uint8_t PayloadType() const { return _payloadType; } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 88 | /** |
henrik.lundin@webrtc.org | 473bac8 | 2011-08-17 09:47:33 +0000 | [diff] [blame] | 89 | * Get codec specific info. |
| 90 | * The returned pointer is only valid as long as the VCMEncodedFrame |
| 91 | * is valid. Also, VCMEncodedFrame owns the pointer and will delete |
| 92 | * the object. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 93 | */ |
henrik.lundin@webrtc.org | 473bac8 | 2011-08-17 09:47:33 +0000 | [diff] [blame] | 94 | const CodecSpecificInfo* CodecSpecific() const {return &_codecSpecificInfo;} |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 95 | |
stefan@webrtc.org | c3d8910 | 2011-09-08 06:50:28 +0000 | [diff] [blame] | 96 | const RTPFragmentationHeader* FragmentationHeader() const; |
| 97 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 98 | protected: |
| 99 | /** |
| 100 | * Verifies that current allocated buffer size is larger than or equal to the input size. |
| 101 | * If the current buffer size is smaller, a new allocation is made and the old buffer data |
| 102 | * is copied to the new buffer. |
| 103 | * Buffer size is updated to minimumSize. |
| 104 | */ |
Magnus Jedvert | ab00404 | 2015-05-05 11:37:12 +0200 | [diff] [blame] | 105 | void VerifyAndAllocate(size_t minimumSize); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 106 | |
| 107 | void Reset(); |
| 108 | |
henrik.lundin@webrtc.org | 473bac8 | 2011-08-17 09:47:33 +0000 | [diff] [blame] | 109 | void CopyCodecSpecific(const RTPVideoHeader* header); |
| 110 | |
pbos@webrtc.org | 7b859cc | 2013-04-02 15:54:38 +0000 | [diff] [blame] | 111 | int64_t _renderTimeMs; |
| 112 | uint8_t _payloadType; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 113 | bool _missingFrame; |
henrik.lundin@webrtc.org | 473bac8 | 2011-08-17 09:47:33 +0000 | [diff] [blame] | 114 | CodecSpecificInfo _codecSpecificInfo; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 115 | webrtc::VideoCodecType _codec; |
stefan@webrtc.org | c3d8910 | 2011-09-08 06:50:28 +0000 | [diff] [blame] | 116 | RTPFragmentationHeader _fragmentation; |
guoweis@webrtc.org | 54d072e | 2015-03-17 21:54:50 +0000 | [diff] [blame] | 117 | VideoRotation _rotation; |
| 118 | |
| 119 | // Video rotation is only set along with the last packet for each frame |
| 120 | // (same as marker bit). This |_rotation_set| is only for debugging purpose |
| 121 | // to ensure we don't set it twice for a frame. |
| 122 | bool _rotation_set; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 123 | }; |
| 124 | |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 125 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 126 | |
| 127 | #endif // WEBRTC_MODULES_VIDEO_CODING_ENCODED_FRAME_H_ |