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 : public 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 PlayoutDelay()37 VideoPlayoutDelay PlayoutDelay() const { return playout_delay_; } 38 SetPlayoutDelay(VideoPlayoutDelay playout_delay)39 void SetPlayoutDelay(VideoPlayoutDelay playout_delay) { 40 playout_delay_ = playout_delay; 41 } 42 43 /** 44 * Get the encoded image 45 */ EncodedImage()46 const webrtc::EncodedImage& EncodedImage() const { 47 return static_cast<const webrtc::EncodedImage&>(*this); 48 } 49 50 using EncodedImage::ColorSpace; 51 using EncodedImage::data; 52 using EncodedImage::GetEncodedData; 53 using EncodedImage::NtpTimeMs; 54 using EncodedImage::PacketInfos; 55 using EncodedImage::set_size; 56 using EncodedImage::SetColorSpace; 57 using EncodedImage::SetEncodedData; 58 using EncodedImage::SetPacketInfos; 59 using EncodedImage::SetSpatialIndex; 60 using EncodedImage::SetSpatialLayerFrameSize; 61 using EncodedImage::SetTimestamp; 62 using EncodedImage::size; 63 using EncodedImage::SpatialIndex; 64 using EncodedImage::SpatialLayerFrameSize; 65 using EncodedImage::Timestamp; 66 67 /** 68 * Get render time in milliseconds 69 */ RenderTimeMs()70 int64_t RenderTimeMs() const { return _renderTimeMs; } 71 /** 72 * Get frame type 73 */ FrameType()74 webrtc::VideoFrameType FrameType() const { return _frameType; } 75 /** 76 * Set frame type 77 */ SetFrameType(webrtc::VideoFrameType frame_type)78 void SetFrameType(webrtc::VideoFrameType frame_type) { 79 _frameType = frame_type; 80 } 81 /** 82 * Get frame rotation 83 */ rotation()84 VideoRotation rotation() const { return rotation_; } 85 /** 86 * Get video content type 87 */ contentType()88 VideoContentType contentType() const { return content_type_; } 89 /** 90 * Get video timing 91 */ video_timing()92 EncodedImage::Timing video_timing() const { return timing_; } video_timing_mutable()93 EncodedImage::Timing* video_timing_mutable() { return &timing_; } 94 /** 95 * True if there's a frame missing before this frame 96 */ MissingFrame()97 bool MissingFrame() const { return _missingFrame; } 98 /** 99 * Payload type of the encoded payload 100 */ PayloadType()101 uint8_t PayloadType() const { return _payloadType; } 102 /** 103 * 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 */ CodecSpecific()108 const CodecSpecificInfo* CodecSpecific() const { return &_codecSpecificInfo; } SetCodecSpecific(const CodecSpecificInfo * codec_specific)109 void SetCodecSpecific(const CodecSpecificInfo* codec_specific) { 110 _codecSpecificInfo = *codec_specific; 111 } 112 113 protected: 114 void Reset(); 115 116 void CopyCodecSpecific(const RTPVideoHeader* header); 117 118 int64_t _renderTimeMs; 119 uint8_t _payloadType; 120 bool _missingFrame; 121 CodecSpecificInfo _codecSpecificInfo; 122 webrtc::VideoCodecType _codec; 123 }; 124 125 } // namespace webrtc 126 127 #endif // MODULES_VIDEO_CODING_ENCODED_FRAME_H_ 128