encoded_frame.h 3.6 KB

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