2011-07-07 08:21:25 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2015-11-18 22:00:21 +01:00
|
|
|
#ifndef WEBRTC_MODULES_VIDEO_CODING_SESSION_INFO_H_
|
|
|
|
|
#define WEBRTC_MODULES_VIDEO_CODING_SESSION_INFO_H_
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2011-12-13 07:54:56 +00:00
|
|
|
#include <list>
|
|
|
|
|
|
2015-11-04 08:31:52 +01:00
|
|
|
#include "webrtc/modules/include/module_common_types.h"
|
2015-11-18 22:00:21 +01:00
|
|
|
#include "webrtc/modules/video_coding/include/video_coding.h"
|
|
|
|
|
#include "webrtc/modules/video_coding/packet.h"
|
2013-07-16 12:32:05 +00:00
|
|
|
#include "webrtc/typedefs.h"
|
2011-12-13 07:54:56 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
2013-07-29 21:48:11 +00:00
|
|
|
// Used to pass data from jitter buffer to session info.
|
|
|
|
|
// This data is then used in determining whether a frame is decodable.
|
|
|
|
|
struct FrameData {
|
2015-01-12 21:51:21 +00:00
|
|
|
int64_t rtt_ms;
|
2013-07-29 21:48:11 +00:00
|
|
|
float rolling_average_packets_per_frame;
|
|
|
|
|
};
|
2011-12-13 07:54:56 +00:00
|
|
|
|
|
|
|
|
class VCMSessionInfo {
|
|
|
|
|
public:
|
|
|
|
|
VCMSessionInfo();
|
|
|
|
|
|
2012-01-10 11:45:05 +00:00
|
|
|
void UpdateDataPointers(const uint8_t* old_base_ptr,
|
|
|
|
|
const uint8_t* new_base_ptr);
|
2012-01-03 23:59:42 +00:00
|
|
|
// NACK - Building the NACK lists.
|
|
|
|
|
// Build hard NACK list: Zero out all entries in list up to and including
|
|
|
|
|
// _lowSeqNum.
|
|
|
|
|
int BuildHardNackList(int* seq_num_list,
|
2013-01-28 08:48:13 +00:00
|
|
|
int seq_num_list_length,
|
|
|
|
|
int nack_seq_nums_index);
|
2012-01-03 23:59:42 +00:00
|
|
|
|
|
|
|
|
// Build soft NACK list: Zero out only a subset of the packets, discard
|
|
|
|
|
// empty packets.
|
|
|
|
|
int BuildSoftNackList(int* seq_num_list,
|
|
|
|
|
int seq_num_list_length,
|
2013-01-28 08:48:13 +00:00
|
|
|
int nack_seq_nums_index,
|
2012-01-03 23:59:42 +00:00
|
|
|
int rtt_ms);
|
2011-12-13 07:54:56 +00:00
|
|
|
void Reset();
|
|
|
|
|
int InsertPacket(const VCMPacket& packet,
|
|
|
|
|
uint8_t* frame_buffer,
|
2013-08-01 03:15:08 +00:00
|
|
|
VCMDecodeErrorMode enable_decodable_state,
|
2013-07-29 21:48:11 +00:00
|
|
|
const FrameData& frame_data);
|
2011-12-13 07:54:56 +00:00
|
|
|
bool complete() const;
|
|
|
|
|
bool decodable() const;
|
|
|
|
|
|
|
|
|
|
// Makes the frame decodable. I.e., only contain decodable NALUs. All
|
|
|
|
|
// non-decodable NALUs will be deleted and packets will be moved to in
|
|
|
|
|
// memory to remove any empty space.
|
|
|
|
|
// Returns the number of bytes deleted from the session.
|
Use size_t more consistently for packet/payload lengths.
See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information.
This CL was reviewed and approved in pieces in the following CLs:
https://webrtc-codereview.appspot.com/24209004/
https://webrtc-codereview.appspot.com/24229004/
https://webrtc-codereview.appspot.com/24259004/
https://webrtc-codereview.appspot.com/25109004/
https://webrtc-codereview.appspot.com/26099004/
https://webrtc-codereview.appspot.com/27069004/
https://webrtc-codereview.appspot.com/27969004/
https://webrtc-codereview.appspot.com/27989004/
https://webrtc-codereview.appspot.com/29009004/
https://webrtc-codereview.appspot.com/30929004/
https://webrtc-codereview.appspot.com/30939004/
https://webrtc-codereview.appspot.com/31999004/
Committing as TBR to the original reviewers.
BUG=chromium:81439
TEST=none
TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom
Review URL: https://webrtc-codereview.appspot.com/23129004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-11-20 22:28:14 +00:00
|
|
|
size_t MakeDecodable();
|
2013-08-08 01:12:33 +00:00
|
|
|
|
|
|
|
|
// Sets decodable_ to false.
|
|
|
|
|
// Used by the dual decoder. After the mode is changed to kNoErrors from
|
|
|
|
|
// kWithErrors or kSelective errors, any states that have been marked
|
|
|
|
|
// decodable and are not complete are marked as non-decodable.
|
2013-08-21 20:40:47 +00:00
|
|
|
void SetNotDecodableIfIncomplete();
|
2013-08-08 01:12:33 +00:00
|
|
|
|
Use size_t more consistently for packet/payload lengths.
See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information.
This CL was reviewed and approved in pieces in the following CLs:
https://webrtc-codereview.appspot.com/24209004/
https://webrtc-codereview.appspot.com/24229004/
https://webrtc-codereview.appspot.com/24259004/
https://webrtc-codereview.appspot.com/25109004/
https://webrtc-codereview.appspot.com/26099004/
https://webrtc-codereview.appspot.com/27069004/
https://webrtc-codereview.appspot.com/27969004/
https://webrtc-codereview.appspot.com/27989004/
https://webrtc-codereview.appspot.com/29009004/
https://webrtc-codereview.appspot.com/30929004/
https://webrtc-codereview.appspot.com/30939004/
https://webrtc-codereview.appspot.com/31999004/
Committing as TBR to the original reviewers.
BUG=chromium:81439
TEST=none
TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom
Review URL: https://webrtc-codereview.appspot.com/23129004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-11-20 22:28:14 +00:00
|
|
|
size_t SessionLength() const;
|
2013-07-29 21:48:11 +00:00
|
|
|
int NumPackets() const;
|
2013-04-16 09:38:26 +00:00
|
|
|
bool HaveFirstPacket() const;
|
2011-12-13 07:54:56 +00:00
|
|
|
bool HaveLastPacket() const;
|
|
|
|
|
bool session_nack() const;
|
|
|
|
|
webrtc::FrameType FrameType() const { return frame_type_; }
|
|
|
|
|
int LowSequenceNumber() const;
|
|
|
|
|
|
|
|
|
|
// Returns highest sequence number, media or empty.
|
|
|
|
|
int HighSequenceNumber() const;
|
|
|
|
|
int PictureId() const;
|
|
|
|
|
int TemporalId() const;
|
2011-12-13 14:11:06 +00:00
|
|
|
bool LayerSync() const;
|
2011-12-13 07:54:56 +00:00
|
|
|
int Tl0PicId() const;
|
|
|
|
|
bool NonReference() const;
|
|
|
|
|
|
2015-10-23 00:27:14 -07:00
|
|
|
void SetGofInfo(const GofInfoVP9& gof_info, size_t idx);
|
|
|
|
|
|
2011-12-13 07:54:56 +00:00
|
|
|
// The number of packets discarded because the decoder can't make use of
|
|
|
|
|
// them.
|
|
|
|
|
int packets_not_decodable() const;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
enum { kMaxVP8Partitions = 9 };
|
|
|
|
|
|
|
|
|
|
typedef std::list<VCMPacket> PacketList;
|
|
|
|
|
typedef PacketList::iterator PacketIterator;
|
|
|
|
|
typedef PacketList::const_iterator PacketIteratorConst;
|
|
|
|
|
typedef PacketList::reverse_iterator ReversePacketIterator;
|
|
|
|
|
|
|
|
|
|
void InformOfEmptyPacket(uint16_t seq_num);
|
|
|
|
|
|
|
|
|
|
// Finds the packet of the beginning of the next VP8 partition. If
|
|
|
|
|
// none is found the returned iterator points to |packets_.end()|.
|
|
|
|
|
// |it| is expected to point to the last packet of the previous partition,
|
|
|
|
|
// or to the first packet of the frame. |packets_skipped| is incremented
|
|
|
|
|
// for each packet found which doesn't have the beginning bit set.
|
2013-09-03 19:09:49 +00:00
|
|
|
PacketIterator FindNextPartitionBeginning(PacketIterator it) const;
|
2011-12-13 07:54:56 +00:00
|
|
|
|
|
|
|
|
// Returns an iterator pointing to the last packet of the partition pointed to
|
|
|
|
|
// by |it|.
|
|
|
|
|
PacketIterator FindPartitionEnd(PacketIterator it) const;
|
|
|
|
|
static bool InSequence(const PacketIterator& it,
|
|
|
|
|
const PacketIterator& prev_it);
|
2015-12-21 04:12:39 -08:00
|
|
|
size_t InsertBuffer(uint8_t* frame_buffer, PacketIterator packetIterator);
|
2014-07-31 14:59:24 +00:00
|
|
|
size_t Insert(const uint8_t* buffer,
|
|
|
|
|
size_t length,
|
|
|
|
|
bool insert_start_code,
|
|
|
|
|
uint8_t* frame_buffer);
|
2011-12-13 07:54:56 +00:00
|
|
|
void ShiftSubsequentPackets(PacketIterator it, int steps_to_shift);
|
|
|
|
|
PacketIterator FindNaluEnd(PacketIterator packet_iter) const;
|
|
|
|
|
// Deletes the data of all packets between |start| and |end|, inclusively.
|
|
|
|
|
// Note that this function doesn't delete the actual packets.
|
2015-12-21 04:12:39 -08:00
|
|
|
size_t DeletePacketData(PacketIterator start, PacketIterator end);
|
2011-12-13 07:54:56 +00:00
|
|
|
void UpdateCompleteSession();
|
|
|
|
|
|
|
|
|
|
// When enabled, determine if session is decodable, i.e. incomplete but
|
|
|
|
|
// would be sent to the decoder.
|
2013-07-29 21:48:11 +00:00
|
|
|
// Note: definition assumes random loss.
|
|
|
|
|
// A frame is defined to be decodable when:
|
|
|
|
|
// Round trip time is higher than threshold
|
|
|
|
|
// It is not a key frame
|
|
|
|
|
// It has the first packet: In VP8 the first packet contains all or part of
|
|
|
|
|
// the first partition, which consists of the most relevant information for
|
|
|
|
|
// decoding.
|
|
|
|
|
// Either more than the upper threshold of the average number of packets per
|
|
|
|
|
// frame is present
|
|
|
|
|
// or less than the lower threshold of the average number of packets per
|
|
|
|
|
// frame is present: suggests a small frame. Such a frame is unlikely
|
|
|
|
|
// to contain many motion vectors, so having the first packet will
|
|
|
|
|
// likely suffice. Once we have more than the lower threshold of the
|
|
|
|
|
// frame, we know that the frame is medium or large-sized.
|
|
|
|
|
void UpdateDecodableSession(const FrameData& frame_data);
|
2011-12-13 07:54:56 +00:00
|
|
|
|
|
|
|
|
// If this session has been NACKed by the jitter buffer.
|
|
|
|
|
bool session_nack_;
|
|
|
|
|
bool complete_;
|
|
|
|
|
bool decodable_;
|
|
|
|
|
webrtc::FrameType frame_type_;
|
|
|
|
|
// Packets in this frame.
|
|
|
|
|
PacketList packets_;
|
|
|
|
|
int empty_seq_num_low_;
|
|
|
|
|
int empty_seq_num_high_;
|
2013-08-26 17:10:11 +00:00
|
|
|
|
|
|
|
|
// The following two variables correspond to the first and last media packets
|
|
|
|
|
// in a session defined by the first packet flag and the marker bit.
|
|
|
|
|
// They are not necessarily equal to the front and back packets, as packets
|
|
|
|
|
// may enter out of order.
|
|
|
|
|
// TODO(mikhal): Refactor the list to use a map.
|
|
|
|
|
int first_packet_seq_num_;
|
|
|
|
|
int last_packet_seq_num_;
|
2011-07-07 08:21:25 +00:00
|
|
|
};
|
|
|
|
|
|
2011-12-13 07:54:56 +00:00
|
|
|
} // namespace webrtc
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-11-18 22:00:21 +01:00
|
|
|
#endif // WEBRTC_MODULES_VIDEO_CODING_SESSION_INFO_H_
|