blob: 27ad107850a67da652f7343b09936e3e88457b51 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
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 Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_VIDEO_CODING_ENCODED_FRAME_H_
12#define MODULES_VIDEO_CODING_ENCODED_FRAME_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
stefan@webrtc.orgc5300432012-10-08 07:06:53 +000014#include <vector>
15
Niels Möller4dc66c52018-10-05 14:17:58 +020016#include "api/video/encoded_image.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020017#include "modules/video_coding/include/video_codec_interface.h"
18#include "modules/video_coding/include/video_coding_defines.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000019
philipel9d3ab612015-12-21 04:12:39 -080020namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000021
philipel9d3ab612015-12-21 04:12:39 -080022class VCMEncodedFrame : protected EncodedImage {
23 public:
24 VCMEncodedFrame();
philipel6c42d922019-06-20 11:13:03 +020025 VCMEncodedFrame(const VCMEncodedFrame&);
niklase@google.com470e71d2011-07-07 08:21:25 +000026
philipel9d3ab612015-12-21 04:12:39 -080027 ~VCMEncodedFrame();
28 /**
Yves Gerey665174f2018-06-19 15:03:05 +020029 * Set render time in milliseconds
30 */
philipel9d3ab612015-12-21 04:12:39 -080031 void SetRenderTime(const int64_t renderTimeMs) {
32 _renderTimeMs = renderTimeMs;
33 }
niklase@google.com470e71d2011-07-07 08:21:25 +000034
philipel9d3ab612015-12-21 04:12:39 -080035 /**
Yves Gerey665174f2018-06-19 15:03:05 +020036 * Set the encoded frame size
37 */
philipel9d3ab612015-12-21 04:12:39 -080038 void SetEncodedSize(uint32_t width, uint32_t height) {
39 _encodedWidth = width;
40 _encodedHeight = height;
41 }
gnishb2a318b2017-05-10 09:21:33 -070042
43 void SetPlayoutDelay(PlayoutDelay playout_delay) {
44 playout_delay_ = playout_delay;
45 }
46
philipel9d3ab612015-12-21 04:12:39 -080047 /**
Yves Gerey665174f2018-06-19 15:03:05 +020048 * Get the encoded image
49 */
philipel9d3ab612015-12-21 04:12:39 -080050 const webrtc::EncodedImage& EncodedImage() const {
51 return static_cast<const webrtc::EncodedImage&>(*this);
52 }
Niels Möller9c843902019-01-11 10:21:35 +010053
Ilya Nikolaevskiy2ebf5232019-05-13 16:13:36 +020054 using EncodedImage::ColorSpace;
Niels Möller9c843902019-01-11 10:21:35 +010055 using EncodedImage::data;
Chen Xingf00bf422019-06-20 10:05:55 +020056 using EncodedImage::PacketInfos;
Ilya Nikolaevskiy5546aef2018-12-04 15:54:52 +010057 using EncodedImage::set_size;
Ilya Nikolaevskiy2ebf5232019-05-13 16:13:36 +020058 using EncodedImage::SetColorSpace;
Niels Möller4d504c72019-06-18 15:56:56 +020059 using EncodedImage::SetEncodedData;
Chen Xingf00bf422019-06-20 10:05:55 +020060 using EncodedImage::SetPacketInfos;
Sergey Silkin61832dd2018-12-20 14:32:14 +010061 using EncodedImage::SetSpatialIndex;
Sergey Silkin2799e632019-05-17 09:51:39 +020062 using EncodedImage::SetSpatialLayerFrameSize;
Niels Möller23775882018-08-16 10:24:12 +020063 using EncodedImage::SetTimestamp;
Niels Möllerf0eee002018-11-28 16:31:29 +010064 using EncodedImage::size;
Sergey Silkin2799e632019-05-17 09:51:39 +020065 using EncodedImage::SpatialIndex;
66 using EncodedImage::SpatialLayerFrameSize;
Ilya Nikolaevskiy5546aef2018-12-04 15:54:52 +010067 using EncodedImage::Timestamp;
68
philipel9d3ab612015-12-21 04:12:39 -080069 /**
Yves Gerey665174f2018-06-19 15:03:05 +020070 * Get render time in milliseconds
71 */
philipel9d3ab612015-12-21 04:12:39 -080072 int64_t RenderTimeMs() const { return _renderTimeMs; }
73 /**
Yves Gerey665174f2018-06-19 15:03:05 +020074 * Get frame type
75 */
Niels Möller87e2d782019-03-07 10:18:23 +010076 webrtc::VideoFrameType FrameType() const { return _frameType; }
philipel9d3ab612015-12-21 04:12:39 -080077 /**
Yves Gerey665174f2018-06-19 15:03:05 +020078 * Get frame rotation
79 */
perkj414dda12016-07-04 01:45:23 -070080 VideoRotation rotation() const { return rotation_; }
philipel9d3ab612015-12-21 04:12:39 -080081 /**
ilnik00d802b2017-04-11 10:34:31 -070082 * Get video content type
83 */
84 VideoContentType contentType() const { return content_type_; }
85 /**
ilnik04f4d122017-06-19 07:18:55 -070086 * Get video timing
87 */
88 EncodedImage::Timing video_timing() const { return timing_; }
Ilya Nikolaevskiy5546aef2018-12-04 15:54:52 +010089 EncodedImage::Timing* video_timing_mutable() { return &timing_; }
ilnik04f4d122017-06-19 07:18:55 -070090 /**
ilnik00d802b2017-04-11 10:34:31 -070091 * True if this frame is complete, false otherwise
92 */
philipel9d3ab612015-12-21 04:12:39 -080093 bool Complete() const { return _completeFrame; }
94 /**
Yves Gerey665174f2018-06-19 15:03:05 +020095 * True if there's a frame missing before this frame
96 */
philipel9d3ab612015-12-21 04:12:39 -080097 bool MissingFrame() const { return _missingFrame; }
98 /**
Yves Gerey665174f2018-06-19 15:03:05 +020099 * Payload type of the encoded payload
100 */
philipel9d3ab612015-12-21 04:12:39 -0800101 uint8_t PayloadType() const { return _payloadType; }
102 /**
Yves Gerey665174f2018-06-19 15:03:05 +0200103 * Get codec specific info.
104 * The returned pointer is only valid as long as the VCMEncodedFrame
105 * is valid. Also, VCMEncodedFrame owns the pointer and will delete
106 * the object.
107 */
philipel9d3ab612015-12-21 04:12:39 -0800108 const CodecSpecificInfo* CodecSpecific() const { return &_codecSpecificInfo; }
Ilya Nikolaevskiy5546aef2018-12-04 15:54:52 +0100109 void SetCodecSpecific(const CodecSpecificInfo* codec_specific) {
110 _codecSpecificInfo = *codec_specific;
111 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000112
philipel9d3ab612015-12-21 04:12:39 -0800113 /**
Yves Gerey665174f2018-06-19 15:03:05 +0200114 * 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 */
philipel9d3ab612015-12-21 04:12:39 -0800121 void VerifyAndAllocate(size_t minimumSize);
niklase@google.com470e71d2011-07-07 08:21:25 +0000122
Ilya Nikolaevskiy5546aef2018-12-04 15:54:52 +0100123 protected:
philipel9d3ab612015-12-21 04:12:39 -0800124 void Reset();
niklase@google.com470e71d2011-07-07 08:21:25 +0000125
philipel9d3ab612015-12-21 04:12:39 -0800126 void CopyCodecSpecific(const RTPVideoHeader* header);
henrik.lundin@webrtc.org473bac82011-08-17 09:47:33 +0000127
philipel9d3ab612015-12-21 04:12:39 -0800128 int64_t _renderTimeMs;
129 uint8_t _payloadType;
130 bool _missingFrame;
131 CodecSpecificInfo _codecSpecificInfo;
132 webrtc::VideoCodecType _codec;
niklase@google.com470e71d2011-07-07 08:21:25 +0000133};
134
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +0000135} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +0000136
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200137#endif // MODULES_VIDEO_CODING_ENCODED_FRAME_H_