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