blob: 9cc769277d65470cde8aa4b17fba0b88c23fdd42 [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"
Danil Chapovalov7c067772019-10-07 12:56:24 +020017#include "modules/rtp_rtcp/source/rtp_video_header.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020018#include "modules/video_coding/include/video_codec_interface.h"
19#include "modules/video_coding/include/video_coding_defines.h"
Guido Urdanetac8958e52020-02-28 16:28:34 +010020#include "rtc_base/system/rtc_export.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000021
philipel9d3ab612015-12-21 04:12:39 -080022namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000023
philipel0cb73262020-12-08 17:36:53 +010024class RTC_EXPORT VCMEncodedFrame : public EncodedImage {
philipel9d3ab612015-12-21 04:12:39 -080025 public:
26 VCMEncodedFrame();
philipel6c42d922019-06-20 11:13:03 +020027 VCMEncodedFrame(const VCMEncodedFrame&);
niklase@google.com470e71d2011-07-07 08:21:25 +000028
philipel9d3ab612015-12-21 04:12:39 -080029 ~VCMEncodedFrame();
30 /**
Yves Gerey665174f2018-06-19 15:03:05 +020031 * Set render time in milliseconds
32 */
philipel9d3ab612015-12-21 04:12:39 -080033 void SetRenderTime(const int64_t renderTimeMs) {
34 _renderTimeMs = renderTimeMs;
35 }
niklase@google.com470e71d2011-07-07 08:21:25 +000036
Johannes Kron111e9812020-10-26 13:54:40 +010037 VideoPlayoutDelay PlayoutDelay() const { return playout_delay_; }
38
Niels Möllerd381eed2020-09-02 15:34:40 +020039 void SetPlayoutDelay(VideoPlayoutDelay playout_delay) {
gnishb2a318b2017-05-10 09:21:33 -070040 playout_delay_ = playout_delay;
41 }
42
philipel9d3ab612015-12-21 04:12:39 -080043 /**
Yves Gerey665174f2018-06-19 15:03:05 +020044 * Get the encoded image
45 */
philipel9d3ab612015-12-21 04:12:39 -080046 const webrtc::EncodedImage& EncodedImage() const {
47 return static_cast<const webrtc::EncodedImage&>(*this);
48 }
Niels Möller9c843902019-01-11 10:21:35 +010049
Ilya Nikolaevskiy2ebf5232019-05-13 16:13:36 +020050 using EncodedImage::ColorSpace;
Niels Möller9c843902019-01-11 10:21:35 +010051 using EncodedImage::data;
Markus Handell269ac812019-12-03 14:31:45 +010052 using EncodedImage::GetEncodedData;
Minyue Li21bccae2020-03-09 13:28:43 +010053 using EncodedImage::NtpTimeMs;
Chen Xingf00bf422019-06-20 10:05:55 +020054 using EncodedImage::PacketInfos;
Ilya Nikolaevskiy5546aef2018-12-04 15:54:52 +010055 using EncodedImage::set_size;
Ilya Nikolaevskiy2ebf5232019-05-13 16:13:36 +020056 using EncodedImage::SetColorSpace;
Niels Möller4d504c72019-06-18 15:56:56 +020057 using EncodedImage::SetEncodedData;
Chen Xingf00bf422019-06-20 10:05:55 +020058 using EncodedImage::SetPacketInfos;
Sergey Silkin61832dd2018-12-20 14:32:14 +010059 using EncodedImage::SetSpatialIndex;
Sergey Silkin2799e632019-05-17 09:51:39 +020060 using EncodedImage::SetSpatialLayerFrameSize;
Niels Möller23775882018-08-16 10:24:12 +020061 using EncodedImage::SetTimestamp;
Niels Möllerf0eee002018-11-28 16:31:29 +010062 using EncodedImage::size;
Sergey Silkin2799e632019-05-17 09:51:39 +020063 using EncodedImage::SpatialIndex;
64 using EncodedImage::SpatialLayerFrameSize;
Ilya Nikolaevskiy5546aef2018-12-04 15:54:52 +010065 using EncodedImage::Timestamp;
66
philipel9d3ab612015-12-21 04:12:39 -080067 /**
Yves Gerey665174f2018-06-19 15:03:05 +020068 * Get render time in milliseconds
69 */
philipel9d3ab612015-12-21 04:12:39 -080070 int64_t RenderTimeMs() const { return _renderTimeMs; }
71 /**
Yves Gerey665174f2018-06-19 15:03:05 +020072 * Get frame type
73 */
Niels Möller87e2d782019-03-07 10:18:23 +010074 webrtc::VideoFrameType FrameType() const { return _frameType; }
philipel9d3ab612015-12-21 04:12:39 -080075 /**
Markus Handell269ac812019-12-03 14:31:45 +010076 * Set frame type
77 */
78 void SetFrameType(webrtc::VideoFrameType frame_type) {
79 _frameType = frame_type;
80 }
81 /**
Yves Gerey665174f2018-06-19 15:03:05 +020082 * Get frame rotation
83 */
perkj414dda12016-07-04 01:45:23 -070084 VideoRotation rotation() const { return rotation_; }
philipel9d3ab612015-12-21 04:12:39 -080085 /**
ilnik00d802b2017-04-11 10:34:31 -070086 * Get video content type
87 */
88 VideoContentType contentType() const { return content_type_; }
89 /**
ilnik04f4d122017-06-19 07:18:55 -070090 * Get video timing
91 */
92 EncodedImage::Timing video_timing() const { return timing_; }
Ilya Nikolaevskiy5546aef2018-12-04 15:54:52 +010093 EncodedImage::Timing* video_timing_mutable() { return &timing_; }
ilnik04f4d122017-06-19 07:18:55 -070094 /**
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
Ilya Nikolaevskiy5546aef2018-12-04 15:54:52 +0100113 protected:
philipel9d3ab612015-12-21 04:12:39 -0800114 void Reset();
niklase@google.com470e71d2011-07-07 08:21:25 +0000115
philipel9d3ab612015-12-21 04:12:39 -0800116 void CopyCodecSpecific(const RTPVideoHeader* header);
henrik.lundin@webrtc.org473bac82011-08-17 09:47:33 +0000117
philipel9d3ab612015-12-21 04:12:39 -0800118 int64_t _renderTimeMs;
119 uint8_t _payloadType;
120 bool _missingFrame;
121 CodecSpecificInfo _codecSpecificInfo;
122 webrtc::VideoCodecType _codec;
niklase@google.com470e71d2011-07-07 08:21:25 +0000123};
124
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +0000125} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +0000126
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200127#endif // MODULES_VIDEO_CODING_ENCODED_FRAME_H_