LCOV - code coverage report
Current view: top level - media/webrtc/trunk/webrtc/modules/video_coding - session_info.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 2 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  *  Copyright (c) 2011 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_SESSION_INFO_H_
      12             : #define WEBRTC_MODULES_VIDEO_CODING_SESSION_INFO_H_
      13             : 
      14             : #include <list>
      15             : #include <vector>
      16             : 
      17             : #include "webrtc/modules/include/module_common_types.h"
      18             : #include "webrtc/modules/video_coding/include/video_coding.h"
      19             : #include "webrtc/modules/video_coding/packet.h"
      20             : #include "webrtc/typedefs.h"
      21             : 
      22             : namespace webrtc {
      23             : // Used to pass data from jitter buffer to session info.
      24             : // This data is then used in determining whether a frame is decodable.
      25             : struct FrameData {
      26             :   int64_t rtt_ms;
      27             :   float rolling_average_packets_per_frame;
      28             : };
      29             : 
      30           0 : class VCMSessionInfo {
      31             :  public:
      32             :   VCMSessionInfo();
      33             : 
      34             :   void UpdateDataPointers(const uint8_t* old_base_ptr,
      35             :                           const uint8_t* new_base_ptr);
      36             :   // NACK - Building the NACK lists.
      37             :   // Build hard NACK list: Zero out all entries in list up to and including
      38             :   // _lowSeqNum.
      39             :   int BuildHardNackList(int* seq_num_list,
      40             :                         int seq_num_list_length,
      41             :                         int nack_seq_nums_index);
      42             : 
      43             :   // Build soft NACK list:  Zero out only a subset of the packets, discard
      44             :   // empty packets.
      45             :   int BuildSoftNackList(int* seq_num_list,
      46             :                         int seq_num_list_length,
      47             :                         int nack_seq_nums_index,
      48             :                         int rtt_ms);
      49             :   void Reset();
      50             :   int InsertPacket(const VCMPacket& packet,
      51             :                    uint8_t* frame_buffer,
      52             :                    VCMDecodeErrorMode enable_decodable_state,
      53             :                    const FrameData& frame_data);
      54             :   bool complete() const;
      55             :   bool decodable() const;
      56             : 
      57             :   // Makes the frame decodable. I.e., only contain decodable NALUs. All
      58             :   // non-decodable NALUs will be deleted and packets will be moved to in
      59             :   // memory to remove any empty space.
      60             :   // Returns the number of bytes deleted from the session.
      61             :   size_t MakeDecodable();
      62             : 
      63             :   // Sets decodable_ to false.
      64             :   // Used by the dual decoder. After the mode is changed to kNoErrors from
      65             :   // kWithErrors or kSelective errors, any states that have been marked
      66             :   // decodable and are not complete are marked as non-decodable.
      67             :   void SetNotDecodableIfIncomplete();
      68             : 
      69             :   size_t SessionLength() const;
      70             :   int NumPackets() const;
      71             :   bool HaveFirstPacket() const;
      72             :   bool HaveLastPacket() const;
      73             :   bool session_nack() const;
      74           0 :   webrtc::FrameType FrameType() const { return frame_type_; }
      75             :   int LowSequenceNumber() const;
      76             : 
      77             :   // Returns highest sequence number, media or empty.
      78             :   int HighSequenceNumber() const;
      79             :   int PictureId() const;
      80             :   int TemporalId() const;
      81             :   bool LayerSync() const;
      82             :   int Tl0PicId() const;
      83             :   bool NonReference() const;
      84             : 
      85             :   std::vector<NaluInfo> GetNaluInfos() const;
      86             : 
      87             :   void SetGofInfo(const GofInfoVP9& gof_info, size_t idx);
      88             : 
      89             :   // The number of packets discarded because the decoder can't make use of
      90             :   // them.
      91             :   int packets_not_decodable() const;
      92             : 
      93             :  private:
      94             :   enum { kMaxVP8Partitions = 9 };
      95             : 
      96             :   typedef std::list<VCMPacket> PacketList;
      97             :   typedef PacketList::iterator PacketIterator;
      98             :   typedef PacketList::const_iterator PacketIteratorConst;
      99             :   typedef PacketList::reverse_iterator ReversePacketIterator;
     100             : 
     101             :   void InformOfEmptyPacket(uint16_t seq_num);
     102             : 
     103             :   // Finds the packet of the beginning of the next VP8 partition. If
     104             :   // none is found the returned iterator points to |packets_.end()|.
     105             :   // |it| is expected to point to the last packet of the previous partition,
     106             :   // or to the first packet of the frame. |packets_skipped| is incremented
     107             :   // for each packet found which doesn't have the beginning bit set.
     108             :   PacketIterator FindNextPartitionBeginning(PacketIterator it) const;
     109             : 
     110             :   // Returns an iterator pointing to the last packet of the partition pointed to
     111             :   // by |it|.
     112             :   PacketIterator FindPartitionEnd(PacketIterator it) const;
     113             :   static bool InSequence(const PacketIterator& it,
     114             :                          const PacketIterator& prev_it);
     115             :   size_t InsertBuffer(uint8_t* frame_buffer, PacketIterator packetIterator);
     116             :   size_t Insert(const uint8_t* buffer,
     117             :                 size_t length,
     118             :                 bool insert_start_code,
     119             :                 uint8_t* frame_buffer);
     120             :   void ShiftSubsequentPackets(PacketIterator it, int steps_to_shift);
     121             :   PacketIterator FindNaluEnd(PacketIterator packet_iter) const;
     122             :   // Deletes the data of all packets between |start| and |end|, inclusively.
     123             :   // Note that this function doesn't delete the actual packets.
     124             :   size_t DeletePacketData(PacketIterator start, PacketIterator end);
     125             :   void UpdateCompleteSession();
     126             : 
     127             :   // When enabled, determine if session is decodable, i.e. incomplete but
     128             :   // would be sent to the decoder.
     129             :   // Note: definition assumes random loss.
     130             :   // A frame is defined to be decodable when:
     131             :   //  Round trip time is higher than threshold
     132             :   //  It is not a key frame
     133             :   //  It has the first packet: In VP8 the first packet contains all or part of
     134             :   //    the first partition, which consists of the most relevant information for
     135             :   //    decoding.
     136             :   //  Either more than the upper threshold of the average number of packets per
     137             :   //        frame is present
     138             :   //      or less than the lower threshold of the average number of packets per
     139             :   //        frame is present: suggests a small frame. Such a frame is unlikely
     140             :   //        to contain many motion vectors, so having the first packet will
     141             :   //        likely suffice. Once we have more than the lower threshold of the
     142             :   //        frame, we know that the frame is medium or large-sized.
     143             :   void UpdateDecodableSession(const FrameData& frame_data);
     144             : 
     145             :   // If this session has been NACKed by the jitter buffer.
     146             :   bool session_nack_;
     147             :   bool complete_;
     148             :   bool decodable_;
     149             :   webrtc::FrameType frame_type_;
     150             :   // Packets in this frame.
     151             :   PacketList packets_;
     152             :   int empty_seq_num_low_;
     153             :   int empty_seq_num_high_;
     154             : 
     155             :   // The following two variables correspond to the first and last media packets
     156             :   // in a session defined by the first packet flag and the marker bit.
     157             :   // They are not necessarily equal to the front and back packets, as packets
     158             :   // may enter out of order.
     159             :   // TODO(mikhal): Refactor the list to use a map.
     160             :   int first_packet_seq_num_;
     161             :   int last_packet_seq_num_;
     162             : };
     163             : 
     164             : }  // namespace webrtc
     165             : 
     166             : #endif  // WEBRTC_MODULES_VIDEO_CODING_SESSION_INFO_H_

Generated by: LCOV version 1.13