frame_buffer.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * Copyright (c) 2012 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_FRAME_BUFFER_H_
  11. #define MODULES_VIDEO_CODING_FRAME_BUFFER_H_
  12. #include <stddef.h>
  13. #include <stdint.h>
  14. #include <vector>
  15. #include "modules/video_coding/codecs/h264/include/h264_globals.h"
  16. #include "modules/video_coding/codecs/vp9/include/vp9_globals.h"
  17. #include "modules/video_coding/encoded_frame.h"
  18. #include "modules/video_coding/include/video_coding.h"
  19. #include "modules/video_coding/jitter_buffer_common.h"
  20. #include "modules/video_coding/packet.h"
  21. #include "modules/video_coding/session_info.h"
  22. namespace webrtc {
  23. class VCMFrameBuffer : public VCMEncodedFrame {
  24. public:
  25. VCMFrameBuffer();
  26. virtual ~VCMFrameBuffer();
  27. virtual void Reset();
  28. VCMFrameBufferEnum InsertPacket(const VCMPacket& packet,
  29. int64_t timeInMs,
  30. const FrameData& frame_data);
  31. // State
  32. // Get current state of frame
  33. VCMFrameBufferStateEnum GetState() const;
  34. void PrepareForDecode(bool continuous);
  35. bool IsSessionComplete() const;
  36. bool HaveFirstPacket() const;
  37. int NumPackets() const;
  38. // Sequence numbers
  39. // Get lowest packet sequence number in frame
  40. int32_t GetLowSeqNum() const;
  41. // Get highest packet sequence number in frame
  42. int32_t GetHighSeqNum() const;
  43. int PictureId() const;
  44. int TemporalId() const;
  45. bool LayerSync() const;
  46. int Tl0PicId() const;
  47. std::vector<NaluInfo> GetNaluInfos() const;
  48. void SetGofInfo(const GofInfoVP9& gof_info, size_t idx);
  49. // Increments a counter to keep track of the number of packets of this frame
  50. // which were NACKed before they arrived.
  51. void IncrementNackCount();
  52. // Returns the number of packets of this frame which were NACKed before they
  53. // arrived.
  54. int16_t GetNackCount() const;
  55. int64_t LatestPacketTimeMs() const;
  56. webrtc::VideoFrameType FrameType() const;
  57. private:
  58. void SetState(VCMFrameBufferStateEnum state); // Set state of frame
  59. VCMFrameBufferStateEnum _state; // Current state of the frame
  60. // Set with SetEncodedData, but keep pointer to the concrete class here, to
  61. // enable reallocation and mutation.
  62. rtc::scoped_refptr<EncodedImageBuffer> encoded_image_buffer_;
  63. VCMSessionInfo _sessionInfo;
  64. uint16_t _nackCount;
  65. int64_t _latestPacketTimeMs;
  66. };
  67. } // namespace webrtc
  68. #endif // MODULES_VIDEO_CODING_FRAME_BUFFER_H_