Note: We no longer publish the latest version of our code here. We primarily use a kumc-bmi github organization. The heron ETL repository, in particular, is not public. Peers in the informatics community should see MultiSiteDev for details on requesting access.

source: webrtc/webrtc/modules/video_coding/main/source/session_info.h @ 0:4bda6873e34c

pub_scrub_3792 tip
Last change on this file since 0:4bda6873e34c was 0:4bda6873e34c, checked in by Michael Prittie <mprittie@…>, 6 years ago

Scrubbed password for publication.

File size: 6.6 KB
Line 
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_MAIN_SOURCE_SESSION_INFO_H_
12#define WEBRTC_MODULES_VIDEO_CODING_MAIN_SOURCE_SESSION_INFO_H_
13
14#include <list>
15
16#include "webrtc/modules/interface/module_common_types.h"
17#include "webrtc/modules/video_coding/main/interface/video_coding.h"
18#include "webrtc/modules/video_coding/main/source/packet.h"
19#include "webrtc/typedefs.h"
20
21namespace webrtc {
22// Used to pass data from jitter buffer to session info.
23// This data is then used in determining whether a frame is decodable.
24struct FrameData {
25  int rtt_ms;
26  float rolling_average_packets_per_frame;
27};
28
29class VCMSessionInfo {
30 public:
31  VCMSessionInfo();
32
33  void UpdateDataPointers(const uint8_t* old_base_ptr,
34                          const uint8_t* new_base_ptr);
35  // NACK - Building the NACK lists.
36  // Build hard NACK list: Zero out all entries in list up to and including
37  // _lowSeqNum.
38  int BuildHardNackList(int* seq_num_list,
39                        int seq_num_list_length,
40                        int nack_seq_nums_index);
41
42  // Build soft NACK list:  Zero out only a subset of the packets, discard
43  // empty packets.
44  int BuildSoftNackList(int* seq_num_list,
45                        int seq_num_list_length,
46                        int nack_seq_nums_index,
47                        int rtt_ms);
48  void Reset();
49  int InsertPacket(const VCMPacket& packet,
50                   uint8_t* frame_buffer,
51                   VCMDecodeErrorMode enable_decodable_state,
52                   const FrameData& frame_data);
53  bool complete() const;
54  bool decodable() const;
55
56  // Builds fragmentation headers for VP8, each fragment being a decodable
57  // VP8 partition. Returns the total number of bytes which are decodable. Is
58  // used instead of MakeDecodable for VP8.
59  int BuildVP8FragmentationHeader(uint8_t* frame_buffer,
60                                  int frame_buffer_length,
61                                  RTPFragmentationHeader* fragmentation);
62
63  // Makes the frame decodable. I.e., only contain decodable NALUs. All
64  // non-decodable NALUs will be deleted and packets will be moved to in
65  // memory to remove any empty space.
66  // Returns the number of bytes deleted from the session.
67  int MakeDecodable();
68
69  // Sets decodable_ to false.
70  // Used by the dual decoder. After the mode is changed to kNoErrors from
71  // kWithErrors or kSelective errors, any states that have been marked
72  // decodable and are not complete are marked as non-decodable.
73  void SetNotDecodableIfIncomplete();
74
75  int SessionLength() const;
76  int NumPackets() const;
77  bool HaveFirstPacket() const;
78  bool HaveLastPacket() const;
79  bool session_nack() const;
80  webrtc::FrameType FrameType() const { return frame_type_; }
81  int LowSequenceNumber() const;
82
83  // Returns highest sequence number, media or empty.
84  int HighSequenceNumber() const;
85  int PictureId() const;
86  int TemporalId() const;
87  bool LayerSync() const;
88  int Tl0PicId() const;
89  bool NonReference() const;
90
91  // The number of packets discarded because the decoder can't make use of
92  // them.
93  int packets_not_decodable() const;
94
95 private:
96  enum { kMaxVP8Partitions = 9 };
97
98  typedef std::list<VCMPacket> PacketList;
99  typedef PacketList::iterator PacketIterator;
100  typedef PacketList::const_iterator PacketIteratorConst;
101  typedef PacketList::reverse_iterator ReversePacketIterator;
102
103  void InformOfEmptyPacket(uint16_t seq_num);
104
105  // Finds the packet of the beginning of the next VP8 partition. If
106  // none is found the returned iterator points to |packets_.end()|.
107  // |it| is expected to point to the last packet of the previous partition,
108  // or to the first packet of the frame. |packets_skipped| is incremented
109  // for each packet found which doesn't have the beginning bit set.
110  PacketIterator FindNextPartitionBeginning(PacketIterator it) const;
111
112  // Returns an iterator pointing to the last packet of the partition pointed to
113  // by |it|.
114  PacketIterator FindPartitionEnd(PacketIterator it) const;
115  static bool InSequence(const PacketIterator& it,
116                         const PacketIterator& prev_it);
117  int InsertBuffer(uint8_t* frame_buffer,
118                   PacketIterator packetIterator);
119  void ShiftSubsequentPackets(PacketIterator it, int steps_to_shift);
120  PacketIterator FindNaluEnd(PacketIterator packet_iter) const;
121  // Deletes the data of all packets between |start| and |end|, inclusively.
122  // Note that this function doesn't delete the actual packets.
123  int DeletePacketData(PacketIterator start,
124                       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  bool previous_frame_loss_;
151  // Packets in this frame.
152  PacketList packets_;
153  int empty_seq_num_low_;
154  int empty_seq_num_high_;
155
156  // The following two variables correspond to the first and last media packets
157  // in a session defined by the first packet flag and the marker bit.
158  // They are not necessarily equal to the front and back packets, as packets
159  // may enter out of order.
160  // TODO(mikhal): Refactor the list to use a map.
161  int first_packet_seq_num_;
162  int last_packet_seq_num_;
163};
164
165}  // namespace webrtc
166
167#endif  // WEBRTC_MODULES_VIDEO_CODING_MAIN_SOURCE_SESSION_INFO_H_
Note: See TracBrowser for help on using the repository browser.