Home | History | Annotate | Download | only in video_coding
      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 "webrtc/modules/include/module_common_types.h"
     15 #include "webrtc/modules/video_coding/include/video_coding.h"
     16 #include "webrtc/modules/video_coding/encoded_frame.h"
     17 #include "webrtc/modules/video_coding/jitter_buffer_common.h"
     18 #include "webrtc/modules/video_coding/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   void SetGofInfo(const GofInfoVP9& gof_info, size_t idx);
     65 
     66   // Increments a counter to keep track of the number of packets of this frame
     67   // which were NACKed before they arrived.
     68   void IncrementNackCount();
     69   // Returns the number of packets of this frame which were NACKed before they
     70   // arrived.
     71   int16_t GetNackCount() const;
     72 
     73   int64_t LatestPacketTimeMs() const;
     74 
     75   webrtc::FrameType FrameType() const;
     76   void SetPreviousFrameLoss();
     77 
     78   // The number of packets discarded because the decoder can't make use of them.
     79   int NotDecodablePackets() const;
     80 
     81  private:
     82   void SetState(VCMFrameBufferStateEnum state);  // Set state of frame
     83 
     84   VCMFrameBufferStateEnum _state;  // Current state of the frame
     85   VCMSessionInfo _sessionInfo;
     86   uint16_t _nackCount;
     87   int64_t _latestPacketTimeMs;
     88 };
     89 
     90 }  // namespace webrtc
     91 
     92 #endif  // WEBRTC_MODULES_VIDEO_CODING_FRAME_BUFFER_H_
     93