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 WEBRTC_MODULES_VIDEO_CODING_FRAME_BUFFER_H_ 12 #define WEBRTC_MODULES_VIDEO_CODING_FRAME_BUFFER_H_ 13 14 #include <vector> 15 16 #include "webrtc/modules/include/module_common_types.h" 17 #include "webrtc/modules/video_coding/include/video_coding.h" 18 #include "webrtc/modules/video_coding/encoded_frame.h" 19 #include "webrtc/modules/video_coding/jitter_buffer_common.h" 20 #include "webrtc/modules/video_coding/session_info.h" 21 #include "webrtc/typedefs.h" 22 23 namespace webrtc { 24 25 class VCMFrameBuffer : public VCMEncodedFrame { 26 public: 27 VCMFrameBuffer(); 28 virtual ~VCMFrameBuffer(); 29 30 VCMFrameBuffer(const VCMFrameBuffer& rhs); 31 32 virtual void Reset(); 33 34 VCMFrameBufferEnum InsertPacket(const VCMPacket& packet, 35 int64_t timeInMs, 36 VCMDecodeErrorMode decode_error_mode, 37 const FrameData& frame_data); 38 39 // State 40 // Get current state of frame 41 VCMFrameBufferStateEnum GetState() const; 42 // Get current state and timestamp of frame 43 VCMFrameBufferStateEnum GetState(uint32_t& timeStamp) const; 44 void PrepareForDecode(bool continuous); 45 46 bool IsRetransmitted() const; 47 bool IsSessionComplete() const; 48 bool HaveFirstPacket() const; 49 bool HaveLastPacket() const; 50 int NumPackets() const; 51 // Makes sure the session contain a decodable stream. 52 void MakeSessionDecodable(); 53 54 // Sequence numbers 55 // Get lowest packet sequence number in frame 56 int32_t GetLowSeqNum() const; 57 // Get highest packet sequence number in frame 58 int32_t GetHighSeqNum() const; 59 60 int PictureId() const; 61 int TemporalId() const; 62 bool LayerSync() const; 63 int Tl0PicId() const; 64 bool NonReference() const; 65 66 std::vector<NaluInfo> GetNaluInfos() const; 67 68 void SetGofInfo(const GofInfoVP9& gof_info, size_t idx); 69 70 // Increments a counter to keep track of the number of packets of this frame 71 // which were NACKed before they arrived. 72 void IncrementNackCount(); 73 // Returns the number of packets of this frame which were NACKed before they 74 // arrived. 75 int16_t GetNackCount() const; 76 77 int64_t LatestPacketTimeMs() const; 78 79 webrtc::FrameType FrameType() const; 80 void SetPreviousFrameLoss(); 81 82 // The number of packets discarded because the decoder can't make use of them. 83 int NotDecodablePackets() const; 84 85 private: 86 void SetState(VCMFrameBufferStateEnum state); // Set state of frame 87 88 VCMFrameBufferStateEnum _state; // Current state of the frame 89 VCMSessionInfo _sessionInfo; 90 uint16_t _nackCount; 91 int64_t _latestPacketTimeMs; 92 }; 93 94 } // namespace webrtc 95 96 #endif // WEBRTC_MODULES_VIDEO_CODING_FRAME_BUFFER_H_ 97