encoded_frame.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Copyright (c) 2016 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 API_VIDEO_ENCODED_FRAME_H_
  11. #define API_VIDEO_ENCODED_FRAME_H_
  12. #include <stddef.h>
  13. #include <stdint.h>
  14. #include "modules/video_coding/encoded_frame.h"
  15. namespace webrtc {
  16. namespace video_coding {
  17. // NOTE: This class is still under development and may change without notice.
  18. struct VideoLayerFrameId {
  19. // TODO(philipel): The default ctor is currently used internaly, but have a
  20. // look if we can remove it.
  21. VideoLayerFrameId() : picture_id(-1), spatial_layer(0) {}
  22. VideoLayerFrameId(int64_t picture_id, uint8_t spatial_layer)
  23. : picture_id(picture_id), spatial_layer(spatial_layer) {}
  24. bool operator==(const VideoLayerFrameId& rhs) const {
  25. return picture_id == rhs.picture_id && spatial_layer == rhs.spatial_layer;
  26. }
  27. bool operator!=(const VideoLayerFrameId& rhs) const {
  28. return !(*this == rhs);
  29. }
  30. bool operator<(const VideoLayerFrameId& rhs) const {
  31. if (picture_id == rhs.picture_id)
  32. return spatial_layer < rhs.spatial_layer;
  33. return picture_id < rhs.picture_id;
  34. }
  35. bool operator<=(const VideoLayerFrameId& rhs) const { return !(rhs < *this); }
  36. bool operator>(const VideoLayerFrameId& rhs) const { return rhs < *this; }
  37. bool operator>=(const VideoLayerFrameId& rhs) const { return rhs <= *this; }
  38. int64_t picture_id;
  39. uint8_t spatial_layer;
  40. };
  41. // TODO(philipel): Remove webrtc::VCMEncodedFrame inheritance.
  42. // TODO(philipel): Move transport specific info out of EncodedFrame.
  43. // NOTE: This class is still under development and may change without notice.
  44. class EncodedFrame : public webrtc::VCMEncodedFrame {
  45. public:
  46. static const uint8_t kMaxFrameReferences = 5;
  47. EncodedFrame() = default;
  48. EncodedFrame(const EncodedFrame&) = default;
  49. virtual ~EncodedFrame() {}
  50. // When this frame was received.
  51. virtual int64_t ReceivedTime() const = 0;
  52. // When this frame should be rendered.
  53. virtual int64_t RenderTime() const = 0;
  54. // This information is currently needed by the timing calculation class.
  55. // TODO(philipel): Remove this function when a new timing class has
  56. // been implemented.
  57. virtual bool delayed_by_retransmission() const;
  58. bool is_keyframe() const { return num_references == 0; }
  59. VideoLayerFrameId id;
  60. // TODO(philipel): Add simple modify/access functions to prevent adding too
  61. // many |references|.
  62. size_t num_references = 0;
  63. int64_t references[kMaxFrameReferences];
  64. bool inter_layer_predicted = false;
  65. // Is this subframe the last one in the superframe (In RTP stream that would
  66. // mean that the last packet has a marker bit set).
  67. bool is_last_spatial_layer = true;
  68. };
  69. } // namespace video_coding
  70. } // namespace webrtc
  71. #endif // API_VIDEO_ENCODED_FRAME_H_