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 MODULES_VIDEO_CODING_ENCODED_FRAME_H_ 12 #define MODULES_VIDEO_CODING_ENCODED_FRAME_H_ 13 14 #include <vector> 15 16 #include "api/video/encoded_image.h" 17 #include "modules/rtp_rtcp/source/rtp_video_header.h" 18 #include "modules/video_coding/include/video_codec_interface.h" 19 #include "modules/video_coding/include/video_coding_defines.h" 20 #include "rtc_base/system/rtc_export.h" 21 22 namespace webrtc { 23 24 class RTC_EXPORT VCMEncodedFrame : protected EncodedImage { 25 public: 26 VCMEncodedFrame(); 27 VCMEncodedFrame(const VCMEncodedFrame&); 28 29 ~VCMEncodedFrame(); 30 /** 31 * Set render time in milliseconds 32 */ SetRenderTime(const int64_t renderTimeMs)33 void SetRenderTime(const int64_t renderTimeMs) { 34 _renderTimeMs = renderTimeMs; 35 } 36 SetPlayoutDelay(PlayoutDelay playout_delay)37 void SetPlayoutDelay(PlayoutDelay playout_delay) { 38 playout_delay_ = playout_delay; 39 } 40 41 /** 42 * Get the encoded image 43 */ EncodedImage()44 const webrtc::EncodedImage& EncodedImage() const { 45 return static_cast<const webrtc::EncodedImage&>(*this); 46 } 47 48 using EncodedImage::ColorSpace; 49 using EncodedImage::data; 50 using EncodedImage::GetEncodedData; 51 using EncodedImage::NtpTimeMs; 52 using EncodedImage::PacketInfos; 53 using EncodedImage::Retain; 54 using EncodedImage::set_size; 55 using EncodedImage::SetColorSpace; 56 using EncodedImage::SetEncodedData; 57 using EncodedImage::SetPacketInfos; 58 using EncodedImage::SetSpatialIndex; 59 using EncodedImage::SetSpatialLayerFrameSize; 60 using EncodedImage::SetTimestamp; 61 using EncodedImage::size; 62 using EncodedImage::SpatialIndex; 63 using EncodedImage::SpatialLayerFrameSize; 64 using EncodedImage::Timestamp; 65 66 /** 67 * Get render time in milliseconds 68 */ RenderTimeMs()69 int64_t RenderTimeMs() const { return _renderTimeMs; } 70 /** 71 * Get frame type 72 */ FrameType()73 webrtc::VideoFrameType FrameType() const { return _frameType; } 74 /** 75 * Set frame type 76 */ SetFrameType(webrtc::VideoFrameType frame_type)77 void SetFrameType(webrtc::VideoFrameType frame_type) { 78 _frameType = frame_type; 79 } 80 /** 81 * Get frame rotation 82 */ rotation()83 VideoRotation rotation() const { return rotation_; } 84 /** 85 * Get video content type 86 */ contentType()87 VideoContentType contentType() const { return content_type_; } 88 /** 89 * Get video timing 90 */ video_timing()91 EncodedImage::Timing video_timing() const { return timing_; } video_timing_mutable()92 EncodedImage::Timing* video_timing_mutable() { return &timing_; } 93 /** 94 * True if this frame is complete, false otherwise 95 */ Complete()96 bool Complete() const { return _completeFrame; } 97 /** 98 * True if there's a frame missing before this frame 99 */ MissingFrame()100 bool MissingFrame() const { return _missingFrame; } 101 /** 102 * Payload type of the encoded payload 103 */ PayloadType()104 uint8_t PayloadType() const { return _payloadType; } 105 /** 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 */ CodecSpecific()111 const CodecSpecificInfo* CodecSpecific() const { return &_codecSpecificInfo; } SetCodecSpecific(const CodecSpecificInfo * codec_specific)112 void SetCodecSpecific(const CodecSpecificInfo* codec_specific) { 113 _codecSpecificInfo = *codec_specific; 114 } 115 116 protected: 117 void Reset(); 118 119 void CopyCodecSpecific(const RTPVideoHeader* header); 120 121 int64_t _renderTimeMs; 122 uint8_t _payloadType; 123 bool _missingFrame; 124 CodecSpecificInfo _codecSpecificInfo; 125 webrtc::VideoCodecType _codec; 126 }; 127 128 } // namespace webrtc 129 130 #endif // MODULES_VIDEO_CODING_ENCODED_FRAME_H_ 131