Refactoring jitter_buffer.h/.cc to Google style.

BUG=

Review URL: https://webrtc-codereview.appspot.com/872006

git-svn-id: http://webrtc.googlecode.com/svn/trunk@2920 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
stefan@webrtc.org 2012-10-12 07:04:52 +00:00
parent df42df5bd6
commit 912981fd0c
7 changed files with 1540 additions and 1868 deletions

View File

@ -199,7 +199,7 @@ VCMFrameBuffer::InsertPacket(const VCMPacket& packet, WebRtc_Word64 timeInMs,
}
WebRtc_Word64
VCMFrameBuffer::LatestPacketTimeMs()
VCMFrameBuffer::LatestPacketTimeMs() const
{
return _latestPacketTimeMs;
}

View File

@ -74,7 +74,7 @@ public:
void IncrementNackCount();
WebRtc_Word16 GetNackCount() const;
WebRtc_Word64 LatestPacketTimeMs();
WebRtc_Word64 LatestPacketTimeMs() const;
webrtc::FrameType FrameType() const;
void SetPreviousFrameLoss();

File diff suppressed because it is too large Load Diff

View File

@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef WEBRTC_MODULES_VIDEO_CODING_JITTER_BUFFER_H_
#define WEBRTC_MODULES_VIDEO_CODING_JITTER_BUFFER_H_
#ifndef WEBRTC_MODULES_VIDEO_CODING_MAIN_SOURCE_JITTER_BUFFER_H_
#define WEBRTC_MODULES_VIDEO_CODING_MAIN_SOURCE_JITTER_BUFFER_H_
#include <list>
@ -24,14 +24,12 @@
#include "system_wrappers/interface/critical_section_wrapper.h"
#include "typedefs.h"
namespace webrtc
{
namespace webrtc {
enum VCMNackMode
{
kNackInfinite,
kNackHybrid,
kNoNack
enum VCMNackMode {
kNackInfinite,
kNackHybrid,
kNoNack
};
typedef std::list<VCMFrameBuffer*> FrameList;
@ -42,218 +40,227 @@ class VCMFrameBuffer;
class VCMPacket;
class VCMEncodedFrame;
class VCMJitterSample
{
public:
VCMJitterSample() : timestamp(0), frameSize(0), latestPacketTime(-1) {}
WebRtc_UWord32 timestamp;
WebRtc_UWord32 frameSize;
WebRtc_Word64 latestPacketTime;
struct VCMJitterSample {
VCMJitterSample() : timestamp(0), frame_size(0), latest_packet_time(-1) {}
uint32_t timestamp;
uint32_t frame_size;
int64_t latest_packet_time;
};
class VCMJitterBuffer
{
public:
VCMJitterBuffer(TickTimeBase* clock,
WebRtc_Word32 vcmId = -1,
WebRtc_Word32 receiverId = -1,
bool master = true);
virtual ~VCMJitterBuffer();
class VCMJitterBuffer {
public:
VCMJitterBuffer(TickTimeBase* clock, int vcm_id = -1, int receiver_id = -1,
bool master = true);
virtual ~VCMJitterBuffer();
void CopyFrom(const VCMJitterBuffer& rhs);
// Makes |this| a deep copy of |rhs|.
void CopyFrom(const VCMJitterBuffer& rhs);
// We need a start and stop to break out of the wait event
// used in GetCompleteFrameForDecoding
void Start();
void Stop();
bool Running() const;
// Initializes and starts jitter buffer.
void Start();
// Empty the Jitter buffer of all its data
void Flush();
// Signals all internal events and stops the jitter buffer.
void Stop();
// Statistics, Get received key and delta frames
WebRtc_Word32 GetFrameStatistics(WebRtc_UWord32& receivedDeltaFrames,
WebRtc_UWord32& receivedKeyFrames) const;
// Returns true if the jitter buffer is running.
bool Running() const;
// The number of packets discarded by the jitter buffer because the decoder
// won't be able to decode them.
WebRtc_UWord32 NumNotDecodablePackets() const;
// Get number of packets discarded by the jitter buffer
WebRtc_UWord32 DiscardedPackets() const;
// Empty the jitter buffer of all its data.
void Flush();
// Statistics, Calculate frame and bit rates
WebRtc_Word32 GetUpdate(WebRtc_UWord32& frameRate, WebRtc_UWord32& bitRate);
// Get the number of received key and delta frames since the jitter buffer
// was started.
void FrameStatistics(uint32_t* received_delta_frames,
uint32_t* received_key_frames) const;
// Wait for the first packet in the next frame to arrive, blocks
// for <= maxWaitTimeMS ms
WebRtc_Word64 GetNextTimeStamp(WebRtc_UWord32 maxWaitTimeMS,
FrameType& incomingFrameType,
WebRtc_Word64& renderTimeMs);
// The number of packets discarded by the jitter buffer because the decoder
// won't be able to decode them.
int num_not_decodable_packets() const;
// Will the packet sequence be complete if the next frame is grabbed
// for decoding right now? That is, have we lost a frame between the
// last decoded frame and the next, or is the next frame missing one
// or more packets?
bool CompleteSequenceWithNextFrame();
// Gets number of packets discarded by the jitter buffer.
int num_discarded_packets() const;
// TODO (mikhal/stefan): Merge all GetFrameForDecoding into one.
// Wait maxWaitTimeMS for a complete frame to arrive. After timeout NULL
// is returned.
VCMEncodedFrame* GetCompleteFrameForDecoding(WebRtc_UWord32 maxWaitTimeMS);
// Statistics, Calculate frame and bit rates.
void IncomingRateStatistics(unsigned int* framerate,
unsigned int* bitrate);
// Get a frame for decoding (even an incomplete) without delay.
VCMEncodedFrame* GetFrameForDecoding();
// Waits for the first packet in the next frame to arrive and then returns
// the timestamp of that frame. |incoming_frame_type| and |render_time_ms| are
// set to the frame type and render time of the next frame.
// Blocks for up to |max_wait_time_ms| ms. Returns -1 if no packet has arrived
// after |max_wait_time_ms| ms.
int64_t NextTimestamp(uint32_t max_wait_time_ms,
FrameType* incoming_frame_type,
int64_t* render_time_ms);
VCMEncodedFrame* GetFrameForDecodingNACK();
// Checks if the packet sequence will be complete if the next frame would be
// grabbed for decoding. That is, if a frame has been lost between the
// last decoded frame and the next, or if the next frame is missing one
// or more packets.
bool CompleteSequenceWithNextFrame();
// Release frame (when done with decoding)
void ReleaseFrame(VCMEncodedFrame* frame);
// TODO(mikhal/stefan): Merge all GetFrameForDecoding into one.
// Wait |max_wait_time_ms| for a complete frame to arrive. After timeout NULL
// is returned.
VCMEncodedFrame* GetCompleteFrameForDecoding(uint32_t max_wait_time_ms);
// Get frame to use for this timestamp
WebRtc_Word32 GetFrame(const VCMPacket& packet, VCMEncodedFrame*&);
VCMEncodedFrame* GetFrame(const VCMPacket& packet); // deprecated
// Get a frame for decoding (even an incomplete) without delay.
VCMEncodedFrame* GetFrameForDecoding();
// Returns the time in ms when the latest packet was inserted into the frame.
// Retransmitted is set to true if any of the packets belonging to the frame
// has been retransmitted.
WebRtc_Word64 LastPacketTime(VCMEncodedFrame* frame,
bool& retransmitted) const;
// Releases a frame returned from the jitter buffer, should be called when
// done with decoding.
void ReleaseFrame(VCMEncodedFrame* frame);
// Insert a packet into a frame
VCMFrameBufferEnum InsertPacket(VCMEncodedFrame* frame,
const VCMPacket& packet);
// Returns the frame assigned to this timestamp.
int GetFrame(const VCMPacket& packet, VCMEncodedFrame*&);
VCMEncodedFrame* GetFrame(const VCMPacket& packet); // Deprecated.
// Sync
WebRtc_UWord32 GetEstimatedJitterMS();
void UpdateRtt(WebRtc_UWord32 rttMs);
// Returns the time in ms when the latest packet was inserted into the frame.
// Retransmitted is set to true if any of the packets belonging to the frame
// has been retransmitted.
int64_t LastPacketTime(VCMEncodedFrame* frame, bool* retransmitted) const;
// NACK
// Set the NACK mode. "highRttNackThreshold" is an RTT threshold in ms above
// which NACK will be disabled if the NACK mode is "kNackHybrid",
// -1 meaning that NACK is always enabled in the Hybrid mode.
// "lowRttNackThreshold" is an RTT threshold in ms below which we expect to
// rely on NACK only, and therefore are using larger buffers to have time to
// wait for retransmissions.
void SetNackMode(VCMNackMode mode,
int lowRttNackThresholdMs,
int highRttNackThresholdMs);
VCMNackMode GetNackMode() const; // Get nack mode
// Get list of missing sequence numbers (size in number of elements)
WebRtc_UWord16* GetNackList(WebRtc_UWord16& nackSize,
bool& listExtended);
// Inserts a packet into a frame returned from GetFrame().
VCMFrameBufferEnum InsertPacket(VCMEncodedFrame* frame,
const VCMPacket& packet);
WebRtc_Word64 LastDecodedTimestamp() const;
// Returns the estimated jitter in milliseconds.
uint32_t EstimatedJitterMs();
private:
// Misc help functions
// Recycle (release) frame, used if we didn't receive whole frame
void RecycleFrame(VCMFrameBuffer* frame);
void ReleaseFrameInternal(VCMFrameBuffer* frame);
// Flush and reset the jitter buffer. Call under critical section.
void FlushInternal();
// Updates the round-trip time estimate.
void UpdateRtt(uint32_t rtt_ms);
// Help functions for insert packet
// Get empty frame, creates new (i.e. increases JB size) if necessary
VCMFrameBuffer* GetEmptyFrame();
// Recycle oldest frames up to a key frame, used if JB is completely full
bool RecycleFramesUntilKeyFrame();
// Update frame state
// (set as complete or reconstructable if conditions are met)
VCMFrameBufferEnum UpdateFrameState(VCMFrameBuffer* frameListItem);
// Set the NACK mode. |highRttNackThreshold| is an RTT threshold in ms above
// which NACK will be disabled if the NACK mode is |kNackHybrid|, -1 meaning
// that NACK is always enabled in the hybrid mode.
// |lowRttNackThreshold| is an RTT threshold in ms below which we expect to
// rely on NACK only, and therefore are using larger buffers to have time to
// wait for retransmissions.
void SetNackMode(VCMNackMode mode, int low_rtt_nack_threshold_ms,
int high_rtt_nack_threshold_ms);
// Help functions for getting a frame
// Find oldest complete frame, used for getting next frame to decode
// When enabled, will return a decodable frame
FrameList::iterator FindOldestCompleteContinuousFrame(bool enableDecodable);
// Returns the current NACK mode.
VCMNackMode nack_mode() const;
void CleanUpOldFrames();
// Creates a list of missing sequence numbers.
uint16_t* CreateNackList(uint16_t* nack_list_size, bool* list_extended);
void VerifyAndSetPreviousFrameLost(VCMFrameBuffer& frame);
bool IsPacketRetransmitted(const VCMPacket& packet) const;
int64_t LastDecodedTimestamp() const;
void UpdateJitterAndDelayEstimates(VCMJitterSample& sample,
bool incompleteFrame);
void UpdateJitterAndDelayEstimates(VCMFrameBuffer& frame,
bool incompleteFrame);
void UpdateJitterAndDelayEstimates(WebRtc_Word64 latestPacketTimeMs,
WebRtc_UWord32 timestamp,
WebRtc_UWord32 frameSize,
bool incompleteFrame);
void UpdateOldJitterSample(const VCMPacket& packet);
WebRtc_UWord32 GetEstimatedJitterMsInternal();
private:
// In NACK-only mode this function doesn't return or release non-complete
// frames unless we have a complete key frame. In hybrid mode, we may release
// "decodable", incomplete frames.
VCMEncodedFrame* GetFrameForDecodingNACK();
// NACK help
WebRtc_UWord16* CreateNackList(WebRtc_UWord16& nackSize,
bool& listExtended);
WebRtc_Word32 GetLowHighSequenceNumbers(WebRtc_Word32& lowSeqNum,
WebRtc_Word32& highSeqNum) const;
void ReleaseFrameIfNotDecoding(VCMFrameBuffer* frame);
// Decide whether should wait for NACK (mainly relevant for hybrid mode)
bool WaitForNack();
// Gets an empty frame, creating a new frame if necessary (i.e. increases
// jitter buffer size).
VCMFrameBuffer* GetEmptyFrame();
WebRtc_Word32 _vcmId;
WebRtc_Word32 _receiverId;
TickTimeBase* _clock;
// If we are running (have started) or not
bool _running;
CriticalSectionWrapper* _critSect;
bool _master;
// Event to signal when we have a frame ready for decoder
VCMEvent _frameEvent;
// Event to signal when we have received a packet
VCMEvent _packetEvent;
// Number of allocated frames
WebRtc_Word32 _maxNumberOfFrames;
// Array of pointers to the frames in JB
VCMFrameBuffer* _frameBuffers[kMaxNumberOfFrames];
FrameList _frameList;
// Recycles oldest frames until a key frame is found. Used if jitter buffer is
// completely full. Returns true if a key frame was found.
bool RecycleFramesUntilKeyFrame();
// timing
VCMDecodingState _lastDecodedState;
WebRtc_UWord32 _packetsNotDecodable;
// Sets the state of |frame| to complete if it's not too old to be decoded.
// Also updates the frame statistics. Signals the |frame_event| if this is
// the next frame to be decoded.
VCMFrameBufferEnum UpdateFrameState(VCMFrameBuffer* frame);
// Statistics
// Frame counter for each type (key, delta, golden, key-delta)
WebRtc_UWord8 _receiveStatistics[4];
// Latest calculated frame rates of incoming stream
WebRtc_UWord8 _incomingFrameRate;
// Frame counter, reset in GetUpdate
WebRtc_UWord32 _incomingFrameCount;
// Real time for last _frameCount reset
WebRtc_Word64 _timeLastIncomingFrameCount;
// Received bits counter, reset in GetUpdate
WebRtc_UWord32 _incomingBitCount;
WebRtc_UWord32 _incomingBitRate;
WebRtc_UWord32 _dropCount; // Frame drop counter
// Number of frames in a row that have been too old
WebRtc_UWord32 _numConsecutiveOldFrames;
// Number of packets in a row that have been too old
WebRtc_UWord32 _numConsecutiveOldPackets;
// Number of packets discarded by the jitter buffer
WebRtc_UWord32 _discardedPackets;
// Finds the oldest complete frame, used for getting next frame to decode.
// Can return a decodable, incomplete frame if |enable_decodable| is true.
FrameList::iterator FindOldestCompleteContinuousFrame(bool enable_decodable);
// Filters for estimating jitter
VCMJitterEstimator _jitterEstimate;
// Calculates network delays used for jitter calculations
VCMInterFrameDelay _delayEstimate;
VCMJitterSample _waitingForCompletion;
WebRtc_UWord32 _rttMs;
void CleanUpOldFrames();
// NACK
VCMNackMode _nackMode;
int _lowRttNackThresholdMs;
int _highRttNackThresholdMs;
// Holds the internal nack list (the missing sequence numbers)
WebRtc_Word32 _NACKSeqNumInternal[kNackHistoryLength];
WebRtc_UWord16 _NACKSeqNum[kNackHistoryLength];
WebRtc_UWord32 _NACKSeqNumLength;
bool _waitingForKeyFrame;
// Sets the "decodable" and "frame loss" flags of a frame depending on which
// packets have been received and which are missing.
// A frame is "decodable" if enough packets of that frame has been received
// for it to be usable by the decoder.
// A frame has the "frame loss" flag set if packets are missing after the
// last decoded frame and before |frame|.
void VerifyAndSetPreviousFrameLost(VCMFrameBuffer* frame);
bool _firstPacket;
// Returns true if |packet| is likely to have been retransmitted.
bool IsPacketRetransmitted(const VCMPacket& packet) const;
DISALLOW_COPY_AND_ASSIGN(VCMJitterBuffer);
// The following three functions update the jitter estimate with the
// payload size, receive time and RTP timestamp of a frame.
void UpdateJitterEstimate(const VCMJitterSample& sample,
bool incomplete_frame);
void UpdateJitterEstimate(const VCMFrameBuffer& frame, bool incomplete_frame);
void UpdateJitterEstimate(int64_t latest_packet_time_ms,
uint32_t timestamp,
unsigned int frame_size,
bool incomplete_frame);
// Returns the lowest and highest known sequence numbers, where the lowest is
// the last decoded sequence number if a frame has been decoded.
// -1 is returned if a sequence number cannot be determined.
void GetLowHighSequenceNumbers(int32_t* low_seq_num,
int32_t* high_seq_num) const;
// Returns true if we should wait for retransmissions, false otherwise.
bool WaitForRetransmissions();
int vcm_id_;
int receiver_id_;
TickTimeBase* clock_;
// If we are running (have started) or not.
bool running_;
CriticalSectionWrapper* crit_sect_;
bool master_;
// Event to signal when we have a frame ready for decoder.
VCMEvent frame_event_;
// Event to signal when we have received a packet.
VCMEvent packet_event_;
// Number of allocated frames.
int max_number_of_frames_;
// Array of pointers to the frames in jitter buffer.
VCMFrameBuffer* frame_buffers_[kMaxNumberOfFrames];
FrameList frame_list_;
VCMDecodingState last_decoded_state_;
bool first_packet_;
// Statistics.
int num_not_decodable_packets_;
// Frame counter for each type (key, delta, golden, key-delta).
unsigned int receive_statistics_[4];
// Latest calculated frame rates of incoming stream.
unsigned int incoming_frame_rate_;
unsigned int incoming_frame_count_;
int64_t time_last_incoming_frame_count_;
unsigned int incoming_bit_count_;
unsigned int incoming_bit_rate_;
unsigned int drop_count_; // Frame drop counter.
// Number of frames in a row that have been too old.
int num_consecutive_old_frames_;
// Number of packets in a row that have been too old.
int num_consecutive_old_packets_;
// Number of packets discarded by the jitter buffer.
int num_discarded_packets_;
// Jitter estimation.
// Filter for estimating jitter.
VCMJitterEstimator jitter_estimate_;
// Calculates network delays used for jitter calculations.
VCMInterFrameDelay inter_frame_delay_;
VCMJitterSample waiting_for_completion_;
WebRtc_UWord32 rtt_ms_;
// NACK and retransmissions.
VCMNackMode nack_mode_;
int low_rtt_nack_threshold_ms_;
int high_rtt_nack_threshold_ms_;
// Holds the internal NACK list (the missing sequence numbers).
int32_t nack_seq_nums_internal_[kNackHistoryLength];
uint16_t nack_seq_nums_[kNackHistoryLength];
unsigned int nack_seq_nums_length_;
bool waiting_for_key_frame_;
DISALLOW_COPY_AND_ASSIGN(VCMJitterBuffer);
};
} // namespace webrtc
} // namespace webrtc
#endif // WEBRTC_MODULES_VIDEO_CODING_JITTER_BUFFER_H_
#endif // WEBRTC_MODULES_VIDEO_CODING_MAIN_SOURCE_JITTER_BUFFER_H_

View File

@ -287,7 +287,8 @@ TEST_F(TestJitterBufferNack, TestNackListFull) {
uint16_t nack_list_length = kNackHistoryLength;
bool extended;
uint16_t* nack_list = jitter_buffer_->GetNackList(nack_list_length, extended);
uint16_t* nack_list = jitter_buffer_->CreateNackList(&nack_list_length,
&extended);
// Verify that the jitter buffer requests a key frame.
EXPECT_TRUE(nack_list_length == 0xffff && nack_list == NULL);
@ -302,14 +303,14 @@ TEST_F(TestJitterBufferNack, TestNackBeforeDecode) {
InsertFrame(kVideoFrameDelta);
uint16_t nack_list_size = 0;
bool extended = false;
uint16_t* list = jitter_buffer_->GetNackList(nack_list_size, extended);
uint16_t* list = jitter_buffer_->CreateNackList(&nack_list_size, &extended);
// No list generated, and a key frame request is signaled.
EXPECT_TRUE(list == NULL);
EXPECT_EQ(0xFFFF, nack_list_size);
}
TEST_F(TestJitterBufferNack, TestNormalOperation) {
EXPECT_EQ(kNackInfinite, jitter_buffer_->GetNackMode());
EXPECT_EQ(kNackInfinite, jitter_buffer_->nack_mode());
InsertFrame(kVideoFrameKey);
EXPECT_TRUE(DecodeFrame());
@ -335,7 +336,7 @@ TEST_F(TestJitterBufferNack, TestNormalOperation) {
EXPECT_FALSE(DecodeFrame());
uint16_t nack_list_size = 0;
bool extended = false;
uint16_t* list = jitter_buffer_->GetNackList(nack_list_size, extended);
uint16_t* list = jitter_buffer_->CreateNackList(&nack_list_size, &extended);
// Verify the NACK list.
const int kExpectedNackSize = 9;
ASSERT_EQ(kExpectedNackSize, nack_list_size);
@ -365,7 +366,7 @@ TEST_F(TestJitterBufferNack, TestNormalOperationWrap) {
EXPECT_FALSE(DecodeCompleteFrame());
uint16_t nack_list_size = 0;
bool extended = false;
uint16_t* list = jitter_buffer_->GetNackList(nack_list_size, extended);
uint16_t* list = jitter_buffer_->CreateNackList(&nack_list_size, &extended);
// Verify the NACK list.
const int kExpectedNackSize = 10;
ASSERT_EQ(kExpectedNackSize, nack_list_size);

View File

@ -200,9 +200,9 @@ VCMEncodedFrame* VCMReceiver::FrameForDecoding(WebRtc_UWord16 maxWaitTimeMs,
FrameType incomingFrameType = kVideoFrameDelta;
nextRenderTimeMs = -1;
const WebRtc_Word64 startTimeMs = _clock->MillisecondTimestamp();
WebRtc_Word64 ret = _jitterBuffer.GetNextTimeStamp(maxWaitTimeMs,
incomingFrameType,
nextRenderTimeMs);
WebRtc_Word64 ret = _jitterBuffer.NextTimestamp(maxWaitTimeMs,
&incomingFrameType,
&nextRenderTimeMs);
if (ret < 0)
{
// No timestamp in jitter buffer at the moment
@ -211,7 +211,7 @@ VCMEncodedFrame* VCMReceiver::FrameForDecoding(WebRtc_UWord16 maxWaitTimeMs,
const WebRtc_UWord32 timeStamp = static_cast<WebRtc_UWord32>(ret);
// Update the timing
_timing.SetRequiredDelay(_jitterBuffer.GetEstimatedJitterMS());
_timing.SetRequiredDelay(_jitterBuffer.EstimatedJitterMs());
_timing.UpdateCurrentDelay(timeStamp);
const WebRtc_Word32 tempWaitTime = maxWaitTimeMs -
@ -233,7 +233,7 @@ VCMEncodedFrame* VCMReceiver::FrameForDecoding(WebRtc_UWord16 maxWaitTimeMs,
{
bool retransmitted = false;
const WebRtc_Word64 lastPacketTimeMs =
_jitterBuffer.LastPacketTime(frame, retransmitted);
_jitterBuffer.LastPacketTime(frame, &retransmitted);
if (lastPacketTimeMs >= 0 && !retransmitted)
{
// We don't want to include timestamps which have suffered from retransmission
@ -367,20 +367,21 @@ VCMReceiver::ReleaseFrame(VCMEncodedFrame* frame)
WebRtc_Word32
VCMReceiver::ReceiveStatistics(WebRtc_UWord32& bitRate, WebRtc_UWord32& frameRate)
{
const WebRtc_Word32 ret = _jitterBuffer.GetUpdate(frameRate, bitRate);
_jitterBuffer.IncomingRateStatistics(&frameRate, &bitRate);
bitRate /= 1000; // Should be in kbps
return ret;
return 0;
}
WebRtc_Word32
VCMReceiver::ReceivedFrameCount(VCMFrameCount& frameCount) const
{
return _jitterBuffer.GetFrameStatistics(frameCount.numDeltaFrames,
frameCount.numKeyFrames);
_jitterBuffer.FrameStatistics(&frameCount.numDeltaFrames,
&frameCount.numKeyFrames);
return 0;
}
WebRtc_UWord32 VCMReceiver::DiscardedPackets() const {
return _jitterBuffer.DiscardedPackets();
return _jitterBuffer.num_discarded_packets();
}
void
@ -399,7 +400,7 @@ VCMNackMode
VCMReceiver::NackMode() const
{
CriticalSectionScoped cs(_critSect);
return _jitterBuffer.GetNackMode();
return _jitterBuffer.nack_mode();
}
VCMNackStatus
@ -407,7 +408,8 @@ VCMReceiver::NackList(WebRtc_UWord16* nackList, WebRtc_UWord16& size)
{
bool extended = false;
WebRtc_UWord16 nackListSize = 0;
WebRtc_UWord16* internalNackList = _jitterBuffer.GetNackList(nackListSize, extended);
WebRtc_UWord16* internalNackList = _jitterBuffer.CreateNackList(
&nackListSize, &extended);
if (internalNackList == NULL && nackListSize == 0xffff)
{
// This combination is used to trigger key frame requests.
@ -468,7 +470,7 @@ VCMReceiver::UpdateState(VCMReceiverState newState)
void
VCMReceiver::UpdateState(VCMEncodedFrame& frame)
{
if (_jitterBuffer.GetNackMode() == kNoNack)
if (_jitterBuffer.nack_mode() == kNoNack)
{
// Dual decoder mode has not been enabled.
return;

View File

@ -135,13 +135,9 @@ int JitterBufferTest(CmdArgs& args)
}
}
// Test out of range inputs
TEST(kSizeError == jb.InsertPacket(0, packet));
jb.ReleaseFrame(0);
// Not started
TEST(0 == jb.GetFrame(packet));
TEST(-1 == jb.GetNextTimeStamp(10, incomingFrameType, renderTimeMs));
TEST(-1 == jb.NextTimestamp(10, &incomingFrameType, &renderTimeMs));
TEST(0 == jb.GetCompleteFrameForDecoding(10));
TEST(0 == jb.GetFrameForDecoding());
@ -179,7 +175,7 @@ int JitterBufferTest(CmdArgs& args)
TEST(kFirstPacket == jb.InsertPacket(frameIn, packet));
// get packet notification
TEST(timeStamp == jb.GetNextTimeStamp(10, incomingFrameType, renderTimeMs));
TEST(timeStamp == jb.NextTimestamp(10, &incomingFrameType, &renderTimeMs));
// check incoming frame type
TEST(incomingFrameType == kVideoFrameDelta);
@ -220,7 +216,7 @@ int JitterBufferTest(CmdArgs& args)
TEST(kFirstPacket == jb.InsertPacket(frameIn, packet));
// get packet notification
TEST(timeStamp == jb.GetNextTimeStamp(10, incomingFrameType, renderTimeMs));
TEST(timeStamp == jb.NextTimestamp(10, &incomingFrameType, &renderTimeMs));
// check incoming frame type
TEST(incomingFrameType == kVideoFrameDelta);
@ -279,7 +275,7 @@ int JitterBufferTest(CmdArgs& args)
TEST(kFirstPacket == jb.InsertPacket(frameIn, packet));
// get packet notification
TEST(timeStamp == jb.GetNextTimeStamp(10, incomingFrameType, renderTimeMs));
TEST(timeStamp == jb.NextTimestamp(10, &incomingFrameType, &renderTimeMs));
// check incoming frame type
TEST(incomingFrameType == kVideoFrameKey);
@ -355,7 +351,7 @@ int JitterBufferTest(CmdArgs& args)
TEST(kFirstPacket == jb.InsertPacket(frameIn, packet));
// get packet notification
TEST(timeStamp == jb.GetNextTimeStamp(10, incomingFrameType, renderTimeMs));
TEST(timeStamp == jb.NextTimestamp(10, &incomingFrameType, &renderTimeMs));
// check incoming frame type
TEST(incomingFrameType == kVideoFrameDelta);
@ -432,7 +428,7 @@ int JitterBufferTest(CmdArgs& args)
TEST(kFirstPacket == jb.InsertPacket(frameIn, packet));
// get packet notification
TEST(timeStamp == jb.GetNextTimeStamp(10, incomingFrameType, renderTimeMs));
TEST(timeStamp == jb.NextTimestamp(10, &incomingFrameType, &renderTimeMs));
// check incoming frame type
TEST(incomingFrameType == kVideoFrameDelta);
@ -509,7 +505,7 @@ int JitterBufferTest(CmdArgs& args)
TEST(kFirstPacket == jb.InsertPacket(frameIn, packet));
// get packet notification
TEST(timeStamp == jb.GetNextTimeStamp(10, incomingFrameType, renderTimeMs));
TEST(timeStamp == jb.NextTimestamp(10, &incomingFrameType, &renderTimeMs));
// check incoming frame type
TEST(incomingFrameType == kVideoFrameDelta);
@ -550,7 +546,7 @@ int JitterBufferTest(CmdArgs& args)
TEST(kFirstPacket == jb.InsertPacket(frameIn, packet));
// get packet notification
TEST(timeStamp == jb.GetNextTimeStamp(10, incomingFrameType, renderTimeMs));
TEST(timeStamp == jb.NextTimestamp(10, &incomingFrameType, &renderTimeMs));
// check incoming frame type
TEST(incomingFrameType == kVideoFrameDelta);
@ -624,7 +620,7 @@ int JitterBufferTest(CmdArgs& args)
TEST(kFirstPacket == jb.InsertPacket(frameIn, packet));
// get packet notification
TEST(timeStamp == jb.GetNextTimeStamp(10, incomingFrameType, renderTimeMs));
TEST(timeStamp == jb.NextTimestamp(10, &incomingFrameType, &renderTimeMs));
// check incoming frame type
TEST(incomingFrameType == kVideoFrameDelta);
@ -686,7 +682,7 @@ int JitterBufferTest(CmdArgs& args)
TEST(kFirstPacket == jb.InsertPacket(frameIn, packet));
// get packet notification
TEST(timeStamp == jb.GetNextTimeStamp(10, incomingFrameType, renderTimeMs));
TEST(timeStamp == jb.NextTimestamp(10, &incomingFrameType, &renderTimeMs));
// check incoming frame type
TEST(incomingFrameType == kVideoFrameDelta);
@ -728,14 +724,14 @@ int JitterBufferTest(CmdArgs& args)
//
WebRtc_UWord32 numDeltaFrames = 0;
WebRtc_UWord32 numKeyFrames = 0;
TEST(jb.GetFrameStatistics(numDeltaFrames, numKeyFrames) == 0);
jb.FrameStatistics(&numDeltaFrames, &numKeyFrames);
TEST(numDeltaFrames == 8);
TEST(numKeyFrames == 1);
WebRtc_UWord32 frameRate;
WebRtc_UWord32 bitRate;
TEST(jb.GetUpdate(frameRate, bitRate) == 0);
jb.IncomingRateStatistics(&frameRate, &bitRate);
// these depend on CPU speed works on a T61
TEST(frameRate > 30);
@ -786,8 +782,8 @@ int JitterBufferTest(CmdArgs& args)
TEST(kFirstPacket == jb.InsertPacket(frameIn, packet));
// Get packet notification
TEST(timeStamp - 33 * 90 == jb.GetNextTimeStamp(10, incomingFrameType,
renderTimeMs));
TEST(timeStamp - 33 * 90 == jb.NextTimestamp(10, &incomingFrameType,
&renderTimeMs));
// Check incoming frame type
if (i == 0)
@ -858,7 +854,7 @@ int JitterBufferTest(CmdArgs& args)
jb.ReleaseFrame(frameOut);
}
TEST(jb.NumNotDecodablePackets() == 10);
TEST(jb.num_not_decodable_packets() == 10);
// Insert 3 old packets and verify that we have 3 discarded packets
// Match value to actual latest timestamp decoded
@ -875,12 +871,12 @@ int JitterBufferTest(CmdArgs& args)
frameIn = jb.GetFrame(packet);
TEST(frameIn == NULL);
TEST(jb.DiscardedPackets() == 3);
TEST(jb.num_discarded_packets() == 3);
jb.Flush();
// This statistic shouldn't be reset by a flush.
TEST(jb.DiscardedPackets() == 3);
TEST(jb.num_discarded_packets() == 3);
//printf("DONE Statistics\n");
@ -916,7 +912,7 @@ int JitterBufferTest(CmdArgs& args)
TEST(kFirstPacket == jb.InsertPacket(frameIn, packet));
// get packet notification
TEST(timeStamp == jb.GetNextTimeStamp(10, incomingFrameType, renderTimeMs));
TEST(timeStamp == jb.NextTimestamp(10, &incomingFrameType, &renderTimeMs));
// check incoming frame type
TEST(incomingFrameType == kVideoFrameDelta);
@ -943,7 +939,8 @@ int JitterBufferTest(CmdArgs& args)
TEST(kIncomplete == jb.InsertPacket(frameIn, packet));
// get packet notification
TEST(timeStamp == jb.GetNextTimeStamp(2, incomingFrameType, renderTimeMs));
TEST(timeStamp == jb.NextTimestamp(2, &incomingFrameType,
&renderTimeMs));
// check incoming frame type
TEST(incomingFrameType == kVideoFrameDelta);
@ -1009,7 +1006,7 @@ int JitterBufferTest(CmdArgs& args)
TEST(kFirstPacket == jb.InsertPacket(frameIn, packet));
// get packet notification
TEST(timeStamp == jb.GetNextTimeStamp(10, incomingFrameType, renderTimeMs));
TEST(timeStamp == jb.NextTimestamp(10, &incomingFrameType, &renderTimeMs));
// check incoming frame type
TEST(incomingFrameType == kVideoFrameDelta);
@ -1036,7 +1033,8 @@ int JitterBufferTest(CmdArgs& args)
TEST(kIncomplete == jb.InsertPacket(frameIn, packet));
// get packet notification
TEST(timeStamp == jb.GetNextTimeStamp(2, incomingFrameType, renderTimeMs));
TEST(timeStamp == jb.NextTimestamp(2, &incomingFrameType,
&renderTimeMs));
// check incoming frame type
TEST(incomingFrameType == kVideoFrameDelta);
@ -1101,7 +1099,7 @@ int JitterBufferTest(CmdArgs& args)
TEST(kFirstPacket == jb.InsertPacket(frameIn, packet));
// get packet notification
TEST(timeStamp == jb.GetNextTimeStamp(10, incomingFrameType, renderTimeMs));
TEST(timeStamp == jb.NextTimestamp(10, &incomingFrameType, &renderTimeMs));
// check incoming frame type
TEST(incomingFrameType == kVideoFrameDelta);
@ -1125,7 +1123,7 @@ int JitterBufferTest(CmdArgs& args)
TEST(kIncomplete == jb.InsertPacket(frameIn, packet));
// get packet notification
TEST(timeStamp == jb.GetNextTimeStamp(10, incomingFrameType, renderTimeMs));
TEST(timeStamp == jb.NextTimestamp(10, &incomingFrameType, &renderTimeMs));
// check incoming frame type
TEST(incomingFrameType == kVideoFrameDelta);
@ -1186,7 +1184,7 @@ int JitterBufferTest(CmdArgs& args)
TEST(kFirstPacket == jb.InsertPacket(frameIn, packet));
// get packet notification
TEST(3000 == jb.GetNextTimeStamp(10, incomingFrameType, renderTimeMs));
TEST(3000 == jb.NextTimestamp(10, &incomingFrameType, &renderTimeMs));
TEST(kVideoFrameDelta == incomingFrameType);
// Get the frame
@ -1240,7 +1238,7 @@ int JitterBufferTest(CmdArgs& args)
TEST(kFirstPacket == jb.InsertPacket(frameIn, packet));
// get packet notification
TEST(timeStamp == jb.GetNextTimeStamp(10, incomingFrameType, renderTimeMs));
TEST(timeStamp == jb.NextTimestamp(10, &incomingFrameType, &renderTimeMs));
TEST(kVideoFrameDelta == incomingFrameType);
// Get the frame
@ -1291,7 +1289,7 @@ int JitterBufferTest(CmdArgs& args)
TEST(kFirstPacket == jb.InsertPacket(frameIn, packet));
// get packet notification
TEST(timeStamp == jb.GetNextTimeStamp(10, incomingFrameType, renderTimeMs));
TEST(timeStamp == jb.NextTimestamp(10, &incomingFrameType, &renderTimeMs));
// check incoming frame type
TEST(incomingFrameType == kVideoFrameDelta);
@ -1334,7 +1332,7 @@ int JitterBufferTest(CmdArgs& args)
TEST(kFirstPacket == jb.InsertPacket(frameIn, packet));
// get packet notification
TEST(timeStamp == jb.GetNextTimeStamp(10, incomingFrameType, renderTimeMs));
TEST(timeStamp == jb.NextTimestamp(10, &incomingFrameType, &renderTimeMs));
// check incoming frame type
TEST(incomingFrameType == kVideoFrameDelta);
@ -1394,7 +1392,7 @@ int JitterBufferTest(CmdArgs& args)
TEST(kFirstPacket == jb.InsertPacket(frameIn, packet));
// Get packet notification
TEST(0xffffff00 == jb.GetNextTimeStamp(10, incomingFrameType, renderTimeMs));
TEST(0xffffff00 == jb.NextTimestamp(10, &incomingFrameType, &renderTimeMs));
TEST(kVideoFrameDelta == incomingFrameType);
// Insert next frame
@ -1413,7 +1411,7 @@ int JitterBufferTest(CmdArgs& args)
TEST(kFirstPacket == jb.InsertPacket(frameIn, packet));
// Get packet notification
TEST(0xffffff00 == jb.GetNextTimeStamp(10, incomingFrameType, renderTimeMs));
TEST(0xffffff00 == jb.NextTimestamp(10, &incomingFrameType, &renderTimeMs));
TEST(kVideoFrameDelta == incomingFrameType);
// Get frame
@ -1426,7 +1424,7 @@ int JitterBufferTest(CmdArgs& args)
TEST(frameOut->FrameType() == kVideoFrameDelta);
// Get packet notification
TEST(2700 == jb.GetNextTimeStamp(0, incomingFrameType, renderTimeMs));
TEST(2700 == jb.NextTimestamp(0, &incomingFrameType, &renderTimeMs));
TEST(kVideoFrameDelta == incomingFrameType);
// Get frame
@ -1469,7 +1467,7 @@ int JitterBufferTest(CmdArgs& args)
TEST(kFirstPacket == jb.InsertPacket(frameIn, packet));
// Get packet notification
TEST(2700 == jb.GetNextTimeStamp(10, incomingFrameType, renderTimeMs));
TEST(2700 == jb.NextTimestamp(10, &incomingFrameType, &renderTimeMs));
TEST(kVideoFrameDelta == incomingFrameType);
// Insert second frame
@ -1488,7 +1486,7 @@ int JitterBufferTest(CmdArgs& args)
TEST(kFirstPacket == jb.InsertPacket(frameIn, packet));
// Get packet notification
TEST(0xffffff00 == jb.GetNextTimeStamp(10, incomingFrameType, renderTimeMs));
TEST(0xffffff00 == jb.NextTimestamp(10, &incomingFrameType, &renderTimeMs));
TEST(kVideoFrameDelta == incomingFrameType);
// Get frame
@ -1501,7 +1499,7 @@ int JitterBufferTest(CmdArgs& args)
TEST(frameOut->FrameType() == kVideoFrameDelta);
// get packet notification
TEST(2700 == jb.GetNextTimeStamp(0, incomingFrameType, renderTimeMs));
TEST(2700 == jb.NextTimestamp(0, &incomingFrameType, &renderTimeMs));
TEST(kVideoFrameDelta == incomingFrameType);
// Get frame
@ -1551,7 +1549,8 @@ int JitterBufferTest(CmdArgs& args)
}
// get packet notification
TEST(packet.timestamp == jb.GetNextTimeStamp(10, incomingFrameType, renderTimeMs));
TEST(packet.timestamp == jb.NextTimestamp(10, &incomingFrameType,
&renderTimeMs));
// check incoming frame type
TEST(incomingFrameType == kVideoFrameDelta);
@ -1622,8 +1621,8 @@ int JitterBufferTest(CmdArgs& args)
TEST(kFirstPacket == jb.InsertPacket(frameIn, packet));
// Get packet notification, should be first inserted frame
TEST(timeStampStart == jb.GetNextTimeStamp(10, incomingFrameType,
renderTimeMs));
TEST(timeStampStart == jb.NextTimestamp(10, &incomingFrameType,
&renderTimeMs));
// check incoming frame type
TEST(incomingFrameType == kVideoFrameDelta);
@ -1650,8 +1649,8 @@ int JitterBufferTest(CmdArgs& args)
TEST(kFirstPacket == jb.InsertPacket(frameIn, packet));
// First inserted key frame should be oldest in buffer
TEST(timeStampFirstKey == jb.GetNextTimeStamp(10, incomingFrameType,
renderTimeMs));
TEST(timeStampFirstKey == jb.NextTimestamp(10, &incomingFrameType,
&renderTimeMs));
// check incoming frame type
TEST(incomingFrameType == kVideoFrameKey);
@ -1764,7 +1763,8 @@ int JitterBufferTest(CmdArgs& args)
TEST(kFirstPacket == jb.InsertPacket(frameIn, packet));
// Get packet notification
TEST(timeStamp == jb.GetNextTimeStamp(10, incomingFrameType, renderTimeMs));
TEST(timeStamp == jb.NextTimestamp(10, &incomingFrameType,
&renderTimeMs));
frameOut = jb.GetFrameForDecoding();
// We can decode everything from a NALU until a packet has been lost.