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