Cleaned up logging in video_coding.

Converted all calls to WEBRTC_TRACE to LOG(). Also removed a large number of less useful logs.

BUG=3153
R=mflodman@webrtc.org, pbos@webrtc.org

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@5887 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
stefan@webrtc.org 2014-04-11 14:08:35 +00:00
parent 8b2ec15d1e
commit 34c5da6b5e
48 changed files with 207 additions and 552 deletions

View File

@ -417,7 +417,7 @@ int32_t FilePlayerImpl::SetUpAudioDecoder()
VideoFilePlayerImpl::VideoFilePlayerImpl(uint32_t instanceID,
FileFormats fileFormat)
: FilePlayerImpl(instanceID, fileFormat),
video_decoder_(new VideoCoder(instanceID)),
video_decoder_(new VideoCoder()),
video_codec_info_(),
_decodedVideoFrames(0),
_encodedData(*new EncodedVideoData()),
@ -481,7 +481,7 @@ int32_t VideoFilePlayerImpl::StopPlayingFile()
CriticalSectionScoped lock( _critSec);
_decodedVideoFrames = 0;
video_decoder_.reset(new VideoCoder(_instanceID));
video_decoder_.reset(new VideoCoder());
return FilePlayerImpl::StopPlayingFile();
}

View File

@ -328,7 +328,7 @@ AviRecorder::AviRecorder(uint32_t instanceID, FileFormats fileFormat)
_writtenAudioMS(0),
_writtenVideoMS(0)
{
_videoEncoder = new VideoCoder(instanceID);
_videoEncoder = new VideoCoder();
_frameScaler = new FrameScaler();
_videoFramesQueue = new VideoFramesQueue();
_thread = ThreadWrapper::CreateThread(Run, this, kNormalPriority,

View File

@ -13,10 +13,7 @@
#include "webrtc/modules/utility/source/video_coder.h"
namespace webrtc {
VideoCoder::VideoCoder(uint32_t instanceID)
: _vcm(VideoCodingModule::Create(instanceID)),
_decodedVideo(0)
{
VideoCoder::VideoCoder() : _vcm(VideoCodingModule::Create()), _decodedVideo(0) {
_vcm->InitializeSender();
_vcm->InitializeReceiver();

View File

@ -20,7 +20,7 @@ namespace webrtc {
class VideoCoder : public VCMPacketizationCallback, public VCMReceiveCallback
{
public:
VideoCoder(uint32_t instanceID);
VideoCoder();
~VideoCoder();
int32_t SetEncodeCodec(VideoCodec& videoCodecInst,

View File

@ -72,11 +72,9 @@ public:
kReferenceSelection
};
static VideoCodingModule* Create(const int32_t id);
static VideoCodingModule* Create();
static VideoCodingModule* Create(const int32_t id,
Clock* clock,
EventFactory* event_factory);
static VideoCodingModule* Create(Clock* clock, EventFactory* event_factory);
static void Destroy(VideoCodingModule* module);

View File

@ -20,7 +20,7 @@
#include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h"
#endif
#include "webrtc/modules/video_coding/main/source/internal_defines.h"
#include "webrtc/system_wrappers/interface/trace.h"
#include "webrtc/system_wrappers/interface/logging.h"
namespace webrtc {
@ -42,9 +42,8 @@ VCMExtDecoderMapItem::VCMExtDecoderMapItem(
internal_render_timing(internal_render_timing) {
}
VCMCodecDataBase::VCMCodecDataBase(int id)
: id_(id),
number_of_cores_(0),
VCMCodecDataBase::VCMCodecDataBase()
: number_of_cores_(0),
max_payload_size_(kDefaultPayloadSize),
periodic_key_frames_(false),
pending_encoder_reset_(true),
@ -58,8 +57,7 @@ VCMCodecDataBase::VCMCodecDataBase(int id)
ptr_decoder_(NULL),
current_dec_is_external_(false),
dec_map_(),
dec_external_map_() {
}
dec_external_map_() {}
VCMCodecDataBase::~VCMCodecDataBase() {
ResetSender();
@ -221,24 +219,14 @@ bool VCMCodecDataBase::SetSendCodec(
} else {
ptr_encoder_ = CreateEncoder(send_codec->codecType);
current_enc_is_external_ = false;
if (!ptr_encoder_) {
return false;
}
}
encoded_frame_callback->SetPayloadType(send_codec->plType);
if (!ptr_encoder_) {
WEBRTC_TRACE(webrtc::kTraceError,
webrtc::kTraceVideoCoding,
VCMId(id_),
"Failed to create encoder: %s.",
send_codec->plName);
return false;
}
if (ptr_encoder_->InitEncode(send_codec,
number_of_cores_,
max_payload_size_) < 0) {
WEBRTC_TRACE(webrtc::kTraceError,
webrtc::kTraceVideoCoding,
VCMId(id_),
"Failed to initialize encoder: %s.",
send_codec->plName);
DeleteEncoder();
return false;
} else if (ptr_encoder_->RegisterEncodeCallback(encoded_frame_callback) < 0) {
@ -257,8 +245,6 @@ bool VCMCodecDataBase::SetSendCodec(
}
bool VCMCodecDataBase::SendCodec(VideoCodec* current_send_codec) const {
WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideoCoding, VCMId(id_),
"SendCodec");
if (!ptr_encoder_) {
return false;
}
@ -267,8 +253,6 @@ bool VCMCodecDataBase::SendCodec(VideoCodec* current_send_codec) const {
}
VideoCodecType VCMCodecDataBase::SendCodec() const {
WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideoCoding, VCMId(id_),
"SendCodec type");
if (!ptr_encoder_) {
return kVideoCodecUnknown;
}
@ -437,12 +421,6 @@ bool VCMCodecDataBase::RegisterReceiveCodec(
if (number_of_cores < 0) {
return false;
}
WEBRTC_TRACE(webrtc::kTraceStateInfo, webrtc::kTraceVideoCoding, VCMId(id_),
"Codec: %s, Payload type %d, Height %d, Width %d, Bitrate %d,"
"Framerate %d.",
receive_codec->plName, receive_codec->plType,
receive_codec->height, receive_codec->width,
receive_codec->startBitrate, receive_codec->maxFramerate);
// Check if payload value already exists, if so - erase old and insert new.
DeregisterReceiveCodec(receive_codec->plType);
if (receive_codec->codecType == kVideoCodecUnknown) {
@ -524,7 +502,7 @@ VCMGenericDecoder* VCMCodecDataBase::CreateDecoderCopy() const {
if (!decoder_copy) {
return NULL;
}
return new VCMGenericDecoder(*decoder_copy, id_, ptr_decoder_->External());
return new VCMGenericDecoder(*decoder_copy, ptr_decoder_->External());
}
void VCMCodecDataBase::ReleaseDecoder(VCMGenericDecoder* decoder) const {
@ -543,8 +521,7 @@ void VCMCodecDataBase::CopyDecoder(const VCMGenericDecoder& decoder) {
if (decoder_copy) {
VCMDecodedFrameCallback* cb = ptr_decoder_->_callback;
ReleaseDecoder(ptr_decoder_);
ptr_decoder_ = new VCMGenericDecoder(*decoder_copy, id_,
decoder.External());
ptr_decoder_ = new VCMGenericDecoder(*decoder_copy, decoder.External());
if (cb && ptr_decoder_->RegisterDecodeCompleteCallback(cb)) {
assert(false);
}
@ -569,8 +546,8 @@ VCMGenericDecoder* VCMCodecDataBase::CreateAndInitDecoder(
assert(new_codec);
const VCMDecoderMapItem* decoder_item = FindDecoderItem(payload_type);
if (!decoder_item) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCoding, VCMId(id_),
"Unknown payload type: %u", payload_type);
LOG(LS_ERROR) << "Can't find a decoder associated with payload type: "
<< payload_type;
return NULL;
}
VCMGenericDecoder* ptr_decoder = NULL;
@ -579,7 +556,7 @@ VCMGenericDecoder* VCMCodecDataBase::CreateAndInitDecoder(
if (external_dec_item) {
// External codec.
ptr_decoder = new VCMGenericDecoder(
*external_dec_item->external_decoder_instance, id_, true);
*external_dec_item->external_decoder_instance, true);
*external = true;
} else {
// Create decoder.
@ -611,6 +588,7 @@ VCMGenericEncoder* VCMCodecDataBase::CreateEncoder(
return new VCMGenericEncoder(*(new I420Encoder));
#endif
default:
LOG(LS_WARNING) << "No internal encoder of this type exists.";
return NULL;
}
}
@ -630,11 +608,11 @@ VCMGenericDecoder* VCMCodecDataBase::CreateDecoder(VideoCodecType type) const {
switch (type) {
#ifdef VIDEOCODEC_VP8
case kVideoCodecVP8:
return new VCMGenericDecoder(*(VP8Decoder::Create()), id_);
return new VCMGenericDecoder(*(VP8Decoder::Create()));
#endif
#ifdef VIDEOCODEC_I420
case kVideoCodecI420:
return new VCMGenericDecoder(*(new I420Decoder), id_);
return new VCMGenericDecoder(*(new I420Decoder));
#endif
default:
return NULL;

View File

@ -50,7 +50,7 @@ struct VCMExtDecoderMapItem {
class VCMCodecDataBase {
public:
explicit VCMCodecDataBase(int id);
VCMCodecDataBase();
~VCMCodecDataBase();
// Sender Side
@ -174,7 +174,6 @@ class VCMCodecDataBase {
const VCMExtDecoderMapItem* FindExternalDecoderItem(
uint8_t payload_type) const;
int id_;
int number_of_cores_;
int max_payload_size_;
bool periodic_key_frames_;

View File

@ -149,17 +149,12 @@ const RTPFragmentationHeader* VCMEncodedFrame::FragmentationHeader() const {
return &_fragmentation;
}
int32_t
VCMEncodedFrame::VerifyAndAllocate(const uint32_t minimumSize)
void VCMEncodedFrame::VerifyAndAllocate(const uint32_t minimumSize)
{
if(minimumSize > _size)
{
// create buffer of sufficient size
uint8_t* newBuffer = new uint8_t[minimumSize];
if (newBuffer == NULL)
{
return -1;
}
if(_buffer)
{
// copy old data
@ -169,7 +164,6 @@ VCMEncodedFrame::VerifyAndAllocate(const uint32_t minimumSize)
_buffer = newBuffer;
_size = minimumSize;
}
return 0;
}
webrtc::FrameType VCMEncodedFrame::ConvertFrameType(VideoFrameType frameType)

View File

@ -104,7 +104,7 @@ protected:
* is copied to the new buffer.
* Buffer size is updated to minimumSize.
*/
int32_t VerifyAndAllocate(const uint32_t minimumSize);
void VerifyAndAllocate(const uint32_t minimumSize);
void Reset();

View File

@ -14,6 +14,7 @@
#include <string.h>
#include "webrtc/modules/video_coding/main/source/packet.h"
#include "webrtc/system_wrappers/interface/logging.h"
namespace webrtc {
@ -86,20 +87,7 @@ VCMFrameBuffer::InsertPacket(const VCMPacket& packet,
int64_t timeInMs,
VCMDecodeErrorMode decode_error_mode,
const FrameData& frame_data) {
// Is this packet part of this frame?
if (TimeStamp() && (TimeStamp() != packet.timestamp)) {
return kTimeStampError;
}
// sanity checks
if (_size + packet.sizeBytes +
(packet.insertStartCode ? kH264StartCodeLengthBytes : 0 )
> kMaxJBFrameSizeBytes) {
return kSizeError;
}
if (NULL == packet.dataPtr && packet.sizeBytes > 0) {
return kSizeError;
}
assert(!(NULL == packet.dataPtr && packet.sizeBytes > 0));
if (packet.dataPtr != NULL) {
_payloadType = packet.payloadType;
}
@ -126,11 +114,11 @@ VCMFrameBuffer::InsertPacket(const VCMPacket& packet,
const uint32_t newSize = _size +
increments * kBufferIncStepSizeBytes;
if (newSize > kMaxJBFrameSizeBytes) {
LOG(LS_ERROR) << "Failed to insert packet due to frame being too "
"big.";
return kSizeError;
}
if (VerifyAndAllocate(newSize) == -1) {
return kSizeError;
}
VerifyAndAllocate(newSize);
_sessionInfo.UpdateDataPointers(prevBuffer, _buffer);
}

View File

@ -12,8 +12,7 @@
#include "webrtc/modules/video_coding/main/source/generic_decoder.h"
#include "webrtc/modules/video_coding/main/source/internal_defines.h"
#include "webrtc/system_wrappers/interface/clock.h"
#include "webrtc/system_wrappers/interface/trace.h"
#include "webrtc/system_wrappers/interface/trace_event.h"
#include "webrtc/system_wrappers/interface/logging.h"
namespace webrtc {
@ -59,11 +58,7 @@ int32_t VCMDecodedFrameCallback::Decoded(I420VideoFrame& decodedImage)
_timestampMap.Pop(decodedImage.timestamp()));
callback = _receiveCallback;
}
if (frameInfo == NULL)
{
// The map should never be empty or full if this callback is called.
return WEBRTC_VIDEO_CODEC_ERROR;
}
assert(frameInfo != NULL);
_timing.StopDecodeTimer(
decodedImage.timestamp(),
@ -73,14 +68,7 @@ int32_t VCMDecodedFrameCallback::Decoded(I420VideoFrame& decodedImage)
if (callback != NULL)
{
decodedImage.set_render_time_ms(frameInfo->renderTimeMs);
int32_t callbackReturn = callback->FrameToRender(decodedImage);
if (callbackReturn < 0)
{
WEBRTC_TRACE(webrtc::kTraceDebug,
webrtc::kTraceVideoCoding,
-1,
"Render callback returned error: %d", callbackReturn);
}
callback->FrameToRender(decodedImage);
}
return WEBRTC_VIDEO_CODEC_OK;
}
@ -125,15 +113,15 @@ int32_t VCMDecodedFrameCallback::Pop(uint32_t timestamp)
return VCM_OK;
}
VCMGenericDecoder::VCMGenericDecoder(VideoDecoder& decoder, int32_t id, bool isExternal)
VCMGenericDecoder::VCMGenericDecoder(VideoDecoder& decoder, bool isExternal)
:
_id(id),
_callback(NULL),
_frameInfos(),
_nextFrameInfoIdx(0),
_decoder(decoder),
_codecType(kVideoCodecUnknown),
_isExternal(isExternal)
_isExternal(isExternal),
_keyFrameDecoded(false)
{
}
@ -156,11 +144,6 @@ int32_t VCMGenericDecoder::Decode(const VCMEncodedFrame& frame,
_frameInfos[_nextFrameInfoIdx].renderTimeMs = frame.RenderTimeMs();
_callback->Map(frame.TimeStamp(), &_frameInfos[_nextFrameInfoIdx]);
WEBRTC_TRACE(webrtc::kTraceDebug,
webrtc::kTraceVideoCoding,
VCMId(_id),
"Decoding timestamp %u", frame.TimeStamp());
_nextFrameInfoIdx = (_nextFrameInfoIdx + 1) % kDecoderFrameMemoryLength;
int32_t ret = _decoder.Decode(frame.EncodedImage(),
frame.MissingFrame(),
@ -170,7 +153,8 @@ int32_t VCMGenericDecoder::Decode(const VCMEncodedFrame& frame,
if (ret < WEBRTC_VIDEO_CODEC_OK)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCoding, VCMId(_id), "Decoder error: %d\n", ret);
LOG(LS_WARNING) << "Failed to decode frame with timestamp "
<< frame.TimeStamp() << ", error code: " << ret;
_callback->Pop(frame.TimeStamp());
return ret;
}

View File

@ -63,7 +63,7 @@ class VCMGenericDecoder
{
friend class VCMCodecDataBase;
public:
VCMGenericDecoder(VideoDecoder& decoder, int32_t id = 0, bool isExternal = false);
VCMGenericDecoder(VideoDecoder& decoder, bool isExternal = false);
~VCMGenericDecoder();
/**
@ -105,17 +105,14 @@ public:
bool External() const;
protected:
int32_t _id;
private:
VCMDecodedFrameCallback* _callback;
VCMFrameInformation _frameInfos[kDecoderFrameMemoryLength];
uint32_t _nextFrameInfoIdx;
uint32_t _nextFrameInfoIdx;
VideoDecoder& _decoder;
VideoCodecType _codecType;
bool _isExternal;
bool _keyFrameDecoded;
};
} // namespace webrtc

View File

@ -13,6 +13,7 @@
#include "webrtc/modules/video_coding/main/source/generic_encoder.h"
#include "webrtc/modules/video_coding/main/source/media_optimization.h"
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
#include "webrtc/system_wrappers/interface/logging.h"
namespace webrtc {
namespace {
@ -83,7 +84,12 @@ VCMGenericEncoder::InitEncode(const VideoCodec* settings,
_bitRate = settings->startBitrate * 1000;
_frameRate = settings->maxFramerate;
_codecType = settings->codecType;
return _encoder.InitEncode(settings, numberOfCores, maxPayloadSize);
if (_encoder.InitEncode(settings, numberOfCores, maxPayloadSize) != 0) {
LOG(LS_ERROR) << "Failed to initialize the encoder associated with "
"payload name: " << settings->plName;
return -1;
}
return 0;
}
int32_t

View File

@ -25,7 +25,6 @@
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
#include "webrtc/system_wrappers/interface/event_wrapper.h"
#include "webrtc/system_wrappers/interface/logging.h"
#include "webrtc/system_wrappers/interface/trace.h"
#include "webrtc/system_wrappers/interface/trace_event.h"
namespace webrtc {
@ -77,10 +76,6 @@ int FrameList::RecycleFramesUntilKeyFrame(FrameList::iterator* key_frame_it,
FrameList::iterator it = begin();
while (!empty()) {
// Throw at least one frame.
WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceVideoCoding, -1,
"Recycling: type=%s, low seqnum=%u",
it->second->FrameType() == kVideoFrameKey ?
"key" : "delta", it->second->GetLowSeqNum());
it->second->Reset();
free_frames->push_back(it->second);
erase(it++);
@ -128,16 +123,10 @@ void FrameList::Reset(UnorderedFrameList* free_frames) {
}
VCMJitterBuffer::VCMJitterBuffer(Clock* clock,
EventFactory* event_factory,
int vcm_id,
int receiver_id,
bool master)
: vcm_id_(vcm_id),
receiver_id_(receiver_id),
clock_(clock),
EventFactory* event_factory)
: clock_(clock),
running_(false),
crit_sect_(CriticalSectionWrapper::CreateCriticalSection()),
master_(master),
frame_event_(event_factory->CreateEvent()),
packet_event_(event_factory->CreateEvent()),
max_number_of_frames_(kStartNumberOfFrames),
@ -156,7 +145,7 @@ VCMJitterBuffer::VCMJitterBuffer(Clock* clock,
num_consecutive_old_frames_(0),
num_consecutive_old_packets_(0),
num_discarded_packets_(0),
jitter_estimate_(vcm_id, receiver_id),
jitter_estimate_(),
inter_frame_delay_(clock_->TimeInMilliseconds()),
rtt_ms_(kDefaultRtt),
nack_mode_(kNoNack),
@ -192,10 +181,7 @@ void VCMJitterBuffer::CopyFrom(const VCMJitterBuffer& rhs) {
if (this != &rhs) {
crit_sect_->Enter();
rhs.crit_sect_->Enter();
vcm_id_ = rhs.vcm_id_;
receiver_id_ = rhs.receiver_id_;
running_ = rhs.running_;
master_ = !rhs.master_;
max_number_of_frames_ = rhs.max_number_of_frames_;
incoming_frame_rate_ = rhs.incoming_frame_rate_;
incoming_frame_count_ = rhs.incoming_frame_count_;
@ -276,10 +262,6 @@ void VCMJitterBuffer::Start() {
first_packet_since_reset_ = true;
rtt_ms_ = kDefaultRtt;
last_decoded_state_.Reset();
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCoding,
VCMId(vcm_id_, receiver_id_), "JB(0x%x): Jitter buffer: start",
this);
}
void VCMJitterBuffer::Stop() {
@ -300,9 +282,6 @@ void VCMJitterBuffer::Stop() {
// Make sure we wake up any threads waiting on these events.
frame_event_->Set();
packet_event_->Set();
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCoding,
VCMId(vcm_id_, receiver_id_), "JB(0x%x): Jitter buffer: stop",
this);
}
bool VCMJitterBuffer::Running() const {
@ -327,9 +306,6 @@ void VCMJitterBuffer::Flush() {
waiting_for_completion_.latest_packet_time = -1;
first_packet_since_reset_ = true;
missing_sequence_numbers_.clear();
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCoding,
VCMId(vcm_id_, receiver_id_), "JB(0x%x): Jitter buffer: flush",
this);
}
// Get received key and delta frames
@ -583,6 +559,8 @@ VCMFrameBufferEnum VCMJitterBuffer::GetFrame(const VCMPacket& packet,
DropPacketsFromNackList(last_decoded_state_.sequence_num());
if (num_consecutive_old_packets_ > kMaxConsecutiveOldPackets) {
LOG(LS_WARNING) << num_consecutive_old_packets_ << " consecutive old "
"packets received. Flushing the jitter buffer.";
Flush();
return kFlushIndicator;
}
@ -602,13 +580,13 @@ VCMFrameBufferEnum VCMJitterBuffer::GetFrame(const VCMPacket& packet,
VCMFrameBufferEnum ret = kNoError;
if (!*frame) {
// No free frame! Try to reclaim some...
LOG_F(LS_INFO) << "Unable to get empty frame; Recycling.";
LOG(LS_WARNING) << "Unable to get empty frame; Recycling.";
bool found_key_frame = RecycleFramesUntilKeyFrame();
*frame = GetEmptyFrame();
if (!*frame)
return kGeneralError;
else if (!found_key_frame)
assert(*frame);
if (!found_key_frame) {
ret = kFlushIndicator;
}
}
(*frame)->Reset();
return ret;
@ -650,6 +628,8 @@ VCMFrameBufferEnum VCMJitterBuffer::InsertPacket(const VCMPacket& packet,
// Flush if this happens consistently.
num_consecutive_old_frames_++;
if (num_consecutive_old_frames_ > kMaxConsecutiveOldFrames) {
LOG(LS_WARNING) << num_consecutive_old_packets_ << " consecutive old "
"frames received. Flushing the jitter buffer.";
Flush();
return kFlushIndicator;
}
@ -703,7 +683,6 @@ VCMFrameBufferEnum VCMJitterBuffer::InsertPacket(const VCMPacket& packet,
frame->IncrementNackCount();
}
if (!UpdateNackList(packet.seqNum)) {
LOG_F(LS_INFO) << "Requesting key frame due to flushed NACK list.";
buffer_return = kFlushIndicator;
}
latest_received_sequence_number_ = LatestSequenceNumber(
@ -725,15 +704,6 @@ VCMFrameBufferEnum VCMJitterBuffer::InsertPacket(const VCMPacket& packet,
}
case kCompleteSession: {
if (update_decodable_list) {
if (master_) {
// Only trace the primary jitter buffer to make it possible to parse
// and plot the trace file.
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCoding,
VCMId(vcm_id_, receiver_id_),
"JB(0x%x) FB(0x%x): Complete frame added to jitter"
"buffer, size:%d type %d",
this, frame, frame->Length(), frame->FrameType());
}
CountFrame(*frame);
frame->SetCountedFrame(true);
if (continuous) {
@ -960,8 +930,6 @@ uint16_t* VCMJitterBuffer::GetNackList(uint16_t* nack_list_size,
incomplete_frames_.begin(), incomplete_frames_.end(),
HasNonEmptyState);
}
if (have_non_empty_frame)
LOG_F(LS_INFO) << "First frame is not key; Recycling.";
bool found_key_frame = RecycleFramesUntilKeyFrame();
if (!found_key_frame) {
*request_key_frame = have_non_empty_frame;
@ -977,9 +945,9 @@ uint16_t* VCMJitterBuffer::GetNackList(uint16_t* nack_list_size,
int non_continuous_incomplete_duration =
NonContinuousOrIncompleteDuration();
if (non_continuous_incomplete_duration > 90 * max_incomplete_time_ms_) {
LOG_F(LS_INFO) << "Too long non-decodable duration: " <<
non_continuous_incomplete_duration << " > " <<
90 * max_incomplete_time_ms_;
LOG_F(LS_WARNING) << "Too long non-decodable duration: "
<< non_continuous_incomplete_duration << " > "
<< 90 * max_incomplete_time_ms_;
FrameList::reverse_iterator rit = find_if(incomplete_frames_.rbegin(),
incomplete_frames_.rend(), IsKeyFrame);
if (rit == incomplete_frames_.rend()) {
@ -1038,10 +1006,12 @@ bool VCMJitterBuffer::UpdateNackList(uint16_t sequence_number) {
TRACE_EVENT_INSTANT1("webrtc", "AddNack", "seqnum", i);
}
if (TooLargeNackList() && !HandleTooLargeNackList()) {
LOG(LS_WARNING) << "Requesting key frame due to too large NACK list.";
return false;
}
if (MissingTooOldPacket(sequence_number) &&
!HandleTooOldPackets(sequence_number)) {
LOG(LS_WARNING) << "Requesting key frame due to missing too old packets";
return false;
}
} else {
@ -1058,8 +1028,9 @@ bool VCMJitterBuffer::TooLargeNackList() const {
bool VCMJitterBuffer::HandleTooLargeNackList() {
// Recycle frames until the NACK list is small enough. It is likely cheaper to
// request a key frame than to retransmit this many missing packets.
LOG_F(LS_INFO) << "NACK list has grown too large: " <<
missing_sequence_numbers_.size() << " > " << max_nack_list_size_;
LOG_F(LS_WARNING) << "NACK list has grown too large: "
<< missing_sequence_numbers_.size() << " > "
<< max_nack_list_size_;
bool key_frame_found = false;
while (TooLargeNackList()) {
key_frame_found = RecycleFramesUntilKeyFrame();
@ -1083,8 +1054,9 @@ bool VCMJitterBuffer::HandleTooOldPackets(uint16_t latest_sequence_number) {
bool key_frame_found = false;
const uint16_t age_of_oldest_missing_packet = latest_sequence_number -
*missing_sequence_numbers_.begin();
LOG_F(LS_INFO) << "NACK list contains too old sequence numbers: " <<
age_of_oldest_missing_packet << " > " << max_packet_age_to_nack_;
LOG_F(LS_WARNING) << "NACK list contains too old sequence numbers: "
<< age_of_oldest_missing_packet << " > "
<< max_packet_age_to_nack_;
while (MissingTooOldPacket(latest_sequence_number)) {
key_frame_found = RecycleFramesUntilKeyFrame();
}
@ -1136,10 +1108,6 @@ bool VCMJitterBuffer::TryToIncreaseJitterBufferSize() {
frame_buffers_[max_number_of_frames_] = new_frame;
free_frames_.push_back(new_frame);
++max_number_of_frames_;
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCoding,
VCMId(vcm_id_, receiver_id_),
"JB(0x%x) FB(0x%x): Jitter buffer increased to:%d frames",
this, new_frame, max_number_of_frames_);
TRACE_COUNTER1("webrtc", "JBMaxFrames", max_number_of_frames_);
return true;
}
@ -1161,13 +1129,9 @@ bool VCMJitterBuffer::RecycleFramesUntilKeyFrame() {
key_frame_found = key_frame_it != decodable_frames_.end();
}
drop_count_ += dropped_frames;
if (dropped_frames) {
WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceVideoCoding,
VCMId(vcm_id_, receiver_id_),
"Jitter buffer drop count:%u", drop_count_);
}
TRACE_EVENT_INSTANT0("webrtc", "JB::RecycleFramesUntilKeyFrame");
if (key_frame_found) {
LOG(LS_INFO) << "Found key frame while dropping frames.";
// Reset last decoded state to make sure the next frame decoded is a key
// frame, and start NACKing from here.
last_decoded_state_.Reset();
@ -1246,19 +1210,6 @@ void VCMJitterBuffer::UpdateJitterEstimate(const VCMJitterSample& sample,
if (sample.latest_packet_time == -1) {
return;
}
if (incomplete_frame) {
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCoding,
VCMId(vcm_id_, receiver_id_), "Received incomplete frame "
"timestamp %u frame size %u at time %u",
sample.timestamp, sample.frame_size,
MaskWord64ToUWord32(sample.latest_packet_time));
} else {
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCoding,
VCMId(vcm_id_, receiver_id_), "Received complete frame "
"timestamp %u frame size %u at time %u",
sample.timestamp, sample.frame_size,
MaskWord64ToUWord32(sample.latest_packet_time));
}
UpdateJitterEstimate(sample.latest_packet_time, sample.timestamp,
sample.frame_size, incomplete_frame);
}
@ -1273,23 +1224,6 @@ void VCMJitterBuffer::UpdateJitterEstimate(const VCMFrameBuffer& frame,
}
// No retransmitted frames should be a part of the jitter
// estimate.
if (incomplete_frame) {
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCoding,
VCMId(vcm_id_, receiver_id_),
"Received incomplete frame timestamp %u frame type %d "
"frame size %u at time %u, jitter estimate was %u",
frame.TimeStamp(), frame.FrameType(), frame.Length(),
MaskWord64ToUWord32(frame.LatestPacketTimeMs()),
EstimatedJitterMs());
} else {
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCoding,
VCMId(vcm_id_, receiver_id_), "Received complete frame "
"timestamp %u frame type %d frame size %u at time %u, "
"jitter estimate was %u",
frame.TimeStamp(), frame.FrameType(), frame.Length(),
MaskWord64ToUWord32(frame.LatestPacketTimeMs()),
EstimatedJitterMs());
}
UpdateJitterEstimate(frame.LatestPacketTimeMs(), frame.TimeStamp(),
frame.Length(), incomplete_frame);
}
@ -1306,12 +1240,6 @@ void VCMJitterBuffer::UpdateJitterEstimate(
return;
}
int64_t frame_delay;
// Calculate the delay estimate
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCoding,
VCMId(vcm_id_, receiver_id_),
"Packet received and sent to jitter estimate with: "
"timestamp=%u wall_clock=%u", timestamp,
MaskWord64ToUWord32(latest_packet_time_ms));
bool not_reordered = inter_frame_delay_.CalculateDelay(timestamp,
&frame_delay,
latest_packet_time_ms);

View File

@ -77,10 +77,7 @@ class FrameList
class VCMJitterBuffer {
public:
VCMJitterBuffer(Clock* clock,
EventFactory* event_factory,
int vcm_id,
int receiver_id,
bool master);
EventFactory* event_factory);
virtual ~VCMJitterBuffer();
// Makes |this| a deep copy of |rhs|.
@ -274,13 +271,10 @@ class VCMJitterBuffer {
uint16_t EstimatedLowSequenceNumber(const VCMFrameBuffer& frame) const;
int vcm_id_;
int receiver_id_;
Clock* 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.
scoped_ptr<EventWrapper> frame_event_;
// Event to signal when we have received a packet.

View File

@ -27,8 +27,8 @@ class TestBasicJitterBuffer : public ::testing::Test {
protected:
virtual void SetUp() {
clock_.reset(new SimulatedClock(0));
jitter_buffer_.reset(new VCMJitterBuffer(clock_.get(),
&event_factory_, -1, -1, true));
jitter_buffer_.reset(
new VCMJitterBuffer(clock_.get(), &event_factory_));
jitter_buffer_->Start();
seq_num_ = 1234;
timestamp_ = 0;
@ -126,8 +126,7 @@ class TestRunningJitterBuffer : public ::testing::Test {
clock_.reset(new SimulatedClock(0));
max_nack_list_size_ = 150;
oldest_packet_to_nack_ = 250;
jitter_buffer_ = new VCMJitterBuffer(clock_.get(), &event_factory_, -1, -1,
true);
jitter_buffer_ = new VCMJitterBuffer(clock_.get(), &event_factory_);
stream_generator_ = new StreamGenerator(0, 0, clock_->TimeInMilliseconds());
jitter_buffer_->Start();
jitter_buffer_->SetNackSettings(max_nack_list_size_,

View File

@ -11,7 +11,6 @@
#include "webrtc/modules/video_coding/main/source/internal_defines.h"
#include "webrtc/modules/video_coding/main/source/jitter_estimator.h"
#include "webrtc/modules/video_coding/main/source/rtt_filter.h"
#include "webrtc/system_wrappers/interface/trace.h"
#include <assert.h>
#include <math.h>
@ -20,20 +19,20 @@
namespace webrtc {
VCMJitterEstimator::VCMJitterEstimator(int32_t vcmId, int32_t receiverId) :
_vcmId(vcmId),
_receiverId(receiverId),
_phi(0.97),
_psi(0.9999),
_alphaCountMax(400),
_thetaLow(0.000001),
_nackLimit(3),
_numStdDevDelayOutlier(15),
_numStdDevFrameSizeOutlier(3),
_noiseStdDevs(2.33), // ~Less than 1% chance
// (look up in normal distribution table)...
_noiseStdDevOffset(30.0), // ...of getting 30 ms freezes
_rttFilter(vcmId, receiverId) {
VCMJitterEstimator::VCMJitterEstimator(int32_t vcmId, int32_t receiverId)
: _vcmId(vcmId),
_receiverId(receiverId),
_phi(0.97),
_psi(0.9999),
_alphaCountMax(400),
_thetaLow(0.000001),
_nackLimit(3),
_numStdDevDelayOutlier(15),
_numStdDevFrameSizeOutlier(3),
_noiseStdDevs(2.33), // ~Less than 1% chance
// (look up in normal distribution table)...
_noiseStdDevOffset(30.0), // ...of getting 30 ms freezes
_rttFilter() {
Reset();
}
@ -108,10 +107,6 @@ void
VCMJitterEstimator::UpdateEstimate(int64_t frameDelayMS, uint32_t frameSizeBytes,
bool incompleteFrame /* = false */)
{
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCoding,
VCMId(_vcmId, _receiverId),
"Jitter estimate updated with: frameSize=%d frameDelayMS=%d",
frameSizeBytes, frameDelayMS);
if (frameSizeBytes == 0)
{
return;
@ -195,16 +190,6 @@ VCMJitterEstimator::UpdateEstimate(int64_t frameDelayMS, uint32_t frameSizeBytes
{
_startupCount++;
}
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCoding, VCMId(_vcmId, _receiverId),
"Framesize statistics: max=%f average=%f", _maxFrameSize, _avgFrameSize);
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCoding, VCMId(_vcmId, _receiverId),
"The estimated slope is: theta=(%f, %f)", _theta[0], _theta[1]);
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCoding, VCMId(_vcmId, _receiverId),
"Random jitter: mean=%f variance=%f", _avgNoise, _varNoise);
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCoding, VCMId(_vcmId, _receiverId),
"Current jitter estimate: %f", _filterJitterEstimate);
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCoding, VCMId(_vcmId, _receiverId),
"Current max RTT: %u", _rttFilter.RttMs());
}
// Updates the nack/packet ratio

View File

@ -14,6 +14,7 @@
#include "webrtc/modules/video_coding/main/source/qm_select.h"
#include "webrtc/modules/video_coding/utility/include/frame_dropper.h"
#include "webrtc/system_wrappers/interface/clock.h"
#include "webrtc/system_wrappers/interface/logging.h"
namespace webrtc {
namespace media_optimization {
@ -73,9 +74,8 @@ struct MediaOptimization::EncodedFrameSample {
int64_t time_complete_ms;
};
MediaOptimization::MediaOptimization(int32_t id, Clock* clock)
: id_(id),
clock_(clock),
MediaOptimization::MediaOptimization(Clock* clock)
: clock_(clock),
max_bit_rate_(0),
send_codec_type_(kVideoCodecUnknown),
codec_width_(0),
@ -537,13 +537,9 @@ bool MediaOptimization::QMUpdate(
codec_height_ = qm->codec_height;
}
WEBRTC_TRACE(webrtc::kTraceDebug,
webrtc::kTraceVideoCoding,
id_,
"Resolution change from QM select: W = %d, H = %d, FR = %f",
qm->codec_width,
qm->codec_height,
qm->frame_rate);
LOG(LS_INFO) << "Media optimizer requests the video resolution to be changed "
"to " << qm->codec_width << "x" << qm->codec_height << "@"
<< qm->frame_rate;
// Update VPM with new target frame rate and frame size.
// Note: use |qm->frame_rate| instead of |_incoming_frame_rate| for updating

View File

@ -18,7 +18,6 @@
#include "webrtc/modules/video_coding/main/source/media_opt_util.h"
#include "webrtc/modules/video_coding/main/source/qm_select.h"
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
#include "webrtc/system_wrappers/interface/trace.h"
namespace webrtc {
@ -32,7 +31,7 @@ namespace media_optimization {
// TODO(andresp): Make thread safe.
class MediaOptimization {
public:
MediaOptimization(int32_t id, Clock* clock);
explicit MediaOptimization(Clock* clock);
~MediaOptimization();
// TODO(andresp): Can Reset and SetEncodingData be done at construction time
@ -124,7 +123,6 @@ class MediaOptimization {
// the state of |video_suspended_| accordingly.
void CheckSuspendConditions();
int32_t id_;
Clock* clock_;
int32_t max_bit_rate_;
VideoCodecType send_codec_type_;

View File

@ -17,9 +17,6 @@ namespace media_optimization {
class TestMediaOptimization : public ::testing::Test {
protected:
enum {
kId = 4711 // Id number for the MediaOptimization class.
};
enum {
kSampleRate = 90000 // RTP timestamps per second.
};
@ -28,7 +25,7 @@ class TestMediaOptimization : public ::testing::Test {
// a special case (e.g. frame rate in media optimization).
TestMediaOptimization()
: clock_(1000),
media_opt_(kId, &clock_),
media_opt_(&clock_),
frame_time_ms_(33),
next_timestamp_(0) {}

View File

@ -18,7 +18,7 @@
#include "webrtc/modules/video_coding/main/source/internal_defines.h"
#include "webrtc/modules/video_coding/main/source/media_opt_util.h"
#include "webrtc/system_wrappers/interface/clock.h"
#include "webrtc/system_wrappers/interface/trace.h"
#include "webrtc/system_wrappers/interface/logging.h"
#include "webrtc/system_wrappers/interface/trace_event.h"
namespace webrtc {
@ -28,15 +28,11 @@ enum { kMaxReceiverDelayMs = 10000 };
VCMReceiver::VCMReceiver(VCMTiming* timing,
Clock* clock,
EventFactory* event_factory,
int32_t vcm_id,
int32_t receiver_id,
bool master)
: crit_sect_(CriticalSectionWrapper::CreateCriticalSection()),
vcm_id_(vcm_id),
clock_(clock),
receiver_id_(receiver_id),
master_(master),
jitter_buffer_(clock_, event_factory, vcm_id, receiver_id, master),
jitter_buffer_(clock_, event_factory),
timing_(timing),
render_wait_event_(event_factory->CreateEvent()),
state_(kPassive),
@ -78,13 +74,6 @@ void VCMReceiver::UpdateRtt(uint32_t rtt) {
int32_t VCMReceiver::InsertPacket(const VCMPacket& packet,
uint16_t frame_width,
uint16_t frame_height) {
if (packet.frameType == kVideoFrameKey) {
WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideoCoding,
VCMId(vcm_id_, receiver_id_),
"Inserting key frame packet seqnum=%u, timestamp=%u",
packet.seqNum, packet.timestamp);
}
// Insert the packet into the jitter buffer. The packet can either be empty or
// contain media at this point.
bool retransmitted = false;
@ -95,10 +84,6 @@ int32_t VCMReceiver::InsertPacket(const VCMPacket& packet,
} else if (ret == kFlushIndicator) {
return VCM_FLUSH_INDICATOR;
} else if (ret < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCoding,
VCMId(vcm_id_, receiver_id_),
"Error inserting packet seqnum=%u, timestamp=%u",
packet.seqNum, packet.timestamp);
return VCM_JITTER_BUFFER_ERROR;
}
if (ret == kCompleteSession && !retransmitted) {
@ -107,15 +92,6 @@ int32_t VCMReceiver::InsertPacket(const VCMPacket& packet,
// delay within the jitter estimate.
timing_->IncomingTimestamp(packet.timestamp, clock_->TimeInMilliseconds());
}
if (master_) {
// Only trace the primary receiver to make it possible to parse and plot
// the trace file.
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCoding,
VCMId(vcm_id_, receiver_id_),
"Packet seqnum=%u timestamp=%u inserted at %u",
packet.seqNum, packet.timestamp,
MaskWord64ToUWord32(clock_->TimeInMilliseconds()));
}
return VCM_OK;
}
@ -159,19 +135,16 @@ VCMEncodedFrame* VCMReceiver::FrameForDecoding(
if (next_render_time_ms < 0) {
timing_error = true;
} else if (std::abs(next_render_time_ms - now_ms) > max_video_delay_ms_) {
WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceVideoCoding,
VCMId(vcm_id_, receiver_id_),
"This frame is out of our delay bounds, resetting jitter "
"buffer: %d > %d",
static_cast<int>(std::abs(next_render_time_ms - now_ms)),
max_video_delay_ms_);
int frame_delay = static_cast<int>(std::abs(next_render_time_ms - now_ms));
LOG(LS_WARNING) << "A frame about to be decoded is out of the configured "
<< "delay bounds (" << frame_delay << " > "
<< max_video_delay_ms_
<< "). Resetting the video jitter buffer.";
timing_error = true;
} else if (static_cast<int>(timing_->TargetVideoDelay()) >
max_video_delay_ms_) {
WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceVideoCoding,
VCMId(vcm_id_, receiver_id_),
"More than %u ms target delay. Flushing jitter buffer and"
"resetting timing.", max_video_delay_ms_);
LOG(LS_WARNING) << "The video target delay has grown larger than "
<< max_video_delay_ms_ << " ms. Resetting jitter buffer.";
timing_error = true;
}
@ -280,10 +253,7 @@ VCMNackStatus VCMReceiver::NackList(uint16_t* nack_list,
bool request_key_frame = false;
uint16_t* internal_nack_list = jitter_buffer_.GetNackList(
nack_list_length, &request_key_frame);
if (*nack_list_length > size) {
*nack_list_length = 0;
return kNackNeedMoreMemory;
}
assert(*nack_list_length <= size);
if (internal_nack_list != NULL && *nack_list_length > 0) {
memcpy(nack_list, internal_nack_list, *nack_list_length * sizeof(uint16_t));
}

View File

@ -25,7 +25,6 @@ class VCMEncodedFrame;
enum VCMNackStatus {
kNackOk,
kNackNeedMoreMemory,
kNackKeyFrameRequest
};
@ -40,8 +39,6 @@ class VCMReceiver {
VCMReceiver(VCMTiming* timing,
Clock* clock,
EventFactory* event_factory,
int32_t vcm_id,
int32_t receiver_id,
bool master);
~VCMReceiver();
@ -95,9 +92,7 @@ class VCMReceiver {
static int32_t GenerateReceiverId();
CriticalSectionWrapper* crit_sect_;
int32_t vcm_id_;
Clock* clock_;
int32_t receiver_id_;
bool master_;
VCMJitterBuffer jitter_buffer_;
VCMTiming* timing_;

View File

@ -31,7 +31,7 @@ class TestVCMReceiver : public ::testing::Test {
TestVCMReceiver()
: clock_(new SimulatedClock(0)),
timing_(clock_.get()),
receiver_(&timing_, clock_.get(), &event_factory_, 1, 1, true) {
receiver_(&timing_, clock_.get(), &event_factory_, true) {
stream_generator_.reset(new
StreamGenerator(0, 0, clock_->TimeInMilliseconds()));
memset(data_buffer_, 0, kDataBufferSize);

View File

@ -10,7 +10,6 @@
#include "webrtc/modules/video_coding/main/source/internal_defines.h"
#include "webrtc/modules/video_coding/main/source/rtt_filter.h"
#include "webrtc/system_wrappers/interface/trace.h"
#include <math.h>
#include <stdlib.h>
@ -18,15 +17,11 @@
namespace webrtc {
VCMRttFilter::VCMRttFilter(int32_t vcmId, int32_t receiverId)
:
_vcmId(vcmId),
_receiverId(receiverId),
_filtFactMax(35),
_jumpStdDevs(2.5),
_driftStdDevs(3.5),
_detectThreshold(kMaxDriftJumpCount)
{
VCMRttFilter::VCMRttFilter()
: _filtFactMax(35),
_jumpStdDevs(2.5),
_driftStdDevs(3.5),
_detectThreshold(kMaxDriftJumpCount) {
Reset();
}
@ -105,9 +100,6 @@ VCMRttFilter::Update(uint32_t rttMs)
_avgRtt = oldAvg;
_varRtt = oldVar;
}
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCoding, VCMId(_vcmId, _receiverId),
"RttFilter Update: sample=%u avgRtt=%f varRtt=%f maxRtt=%u",
rttMs, _avgRtt, _varRtt, _maxRtt);
}
bool
@ -141,8 +133,6 @@ VCMRttFilter::JumpDetection(uint32_t rttMs)
ShortRttFilter(_jumpBuf, abs(_jumpCount));
_filtFactCount = _detectThreshold + 1;
_jumpCount = 0;
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCoding, VCMId(_vcmId, _receiverId),
"Detected an RTT jump");
}
else
{
@ -174,8 +164,6 @@ VCMRttFilter::DriftDetection(uint32_t rttMs)
ShortRttFilter(_driftBuf, _driftCount);
_filtFactCount = _detectThreshold + 1;
_driftCount = 0;
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCoding, VCMId(_vcmId, _receiverId),
"Detected an RTT drift");
}
}
else

View File

@ -19,7 +19,7 @@ namespace webrtc
class VCMRttFilter
{
public:
VCMRttFilter(int32_t vcmId = 0, int32_t receiverId = 0);
VCMRttFilter();
VCMRttFilter& operator=(const VCMRttFilter& rhs);
@ -48,8 +48,6 @@ private:
// Computes the short time average and maximum of the vector buf.
void ShortRttFilter(uint32_t* buf, uint32_t length);
int32_t _vcmId;
int32_t _receiverId;
bool _gotNonZeroUpdate;
double _avgRtt;
double _varRtt;

View File

@ -11,6 +11,7 @@
#include "webrtc/modules/video_coding/main/source/session_info.h"
#include "webrtc/modules/video_coding/main/source/packet.h"
#include "webrtc/system_wrappers/interface/logging.h"
namespace webrtc {
@ -403,6 +404,7 @@ int VCMSessionInfo::InsertPacket(const VCMPacket& packet,
}
if (packets_.size() == kMaxPacketsInSession) {
LOG(LS_ERROR) << "Max number of packets per frame has been reached.";
return -1;
}
@ -429,6 +431,8 @@ int VCMSessionInfo::InsertPacket(const VCMPacket& packet,
first_packet_seq_num_ = static_cast<int>(packet.seqNum);
} else if (first_packet_seq_num_ != -1 &&
!IsNewerSequenceNumber(packet.seqNum, first_packet_seq_num_)) {
LOG(LS_WARNING) << "Received packet with a sequence number which is out of"
"frame boundaries";
return -3;
} else if (frame_type_ == kFrameEmpty && packet.frameType != kFrameEmpty) {
// Update the frame type with the type of the first media packet.
@ -441,6 +445,8 @@ int VCMSessionInfo::InsertPacket(const VCMPacket& packet,
last_packet_seq_num_ = static_cast<int>(packet.seqNum);
} else if (last_packet_seq_num_ != -1 &&
IsNewerSequenceNumber(packet.seqNum, last_packet_seq_num_)) {
LOG(LS_WARNING) << "Received packet with a sequence number which is out of"
"frame boundaries";
return -3;
}

View File

@ -147,7 +147,6 @@ class VCMSessionInfo {
bool complete_;
bool decodable_;
webrtc::FrameType frame_type_;
bool previous_frame_loss_;
// Packets in this frame.
PacketList packets_;
int empty_seq_num_low_;

View File

@ -11,34 +11,27 @@
#include "webrtc/modules/video_coding/main/source/internal_defines.h"
#include "webrtc/modules/video_coding/main/source/timestamp_extrapolator.h"
#include "webrtc/system_wrappers/interface/clock.h"
#include "webrtc/system_wrappers/interface/trace.h"
namespace webrtc {
VCMTimestampExtrapolator::VCMTimestampExtrapolator(Clock* clock,
int32_t vcmId,
int32_t id)
:
_rwLock(RWLockWrapper::CreateRWLock()),
_vcmId(vcmId),
_id(id),
_clock(clock),
_startMs(0),
_firstTimestamp(0),
_wrapArounds(0),
_prevUnwrappedTimestamp(-1),
_prevWrapTimestamp(-1),
_lambda(1),
_firstAfterReset(true),
_packetCount(0),
_startUpFilterDelayInPackets(2),
_detectorAccumulatorPos(0),
_detectorAccumulatorNeg(0),
_alarmThreshold(60e3),
_accDrift(6600), // in timestamp ticks, i.e. 15 ms
_accMaxError(7000),
_P11(1e10)
{
VCMTimestampExtrapolator::VCMTimestampExtrapolator(Clock* clock)
: _rwLock(RWLockWrapper::CreateRWLock()),
_clock(clock),
_startMs(0),
_firstTimestamp(0),
_wrapArounds(0),
_prevUnwrappedTimestamp(-1),
_prevWrapTimestamp(-1),
_lambda(1),
_firstAfterReset(true),
_packetCount(0),
_startUpFilterDelayInPackets(2),
_detectorAccumulatorPos(0),
_detectorAccumulatorNeg(0),
_alarmThreshold(60e3),
_accDrift(6600), // in timestamp ticks, i.e. 15 ms
_accMaxError(7000),
_P11(1e10) {
Reset();
}
@ -69,7 +62,7 @@ VCMTimestampExtrapolator::Reset()
}
void
VCMTimestampExtrapolator::Update(int64_t tMs, uint32_t ts90khz, bool trace)
VCMTimestampExtrapolator::Update(int64_t tMs, uint32_t ts90khz)
{
_rwLock->AcquireLockExclusive();
@ -115,7 +108,7 @@ VCMTimestampExtrapolator::Update(int64_t tMs, uint32_t ts90khz, bool trace)
double residual =
(static_cast<double>(unwrapped_ts90khz) - _firstTimestamp) -
static_cast<double>(tMs) * _w[0] - _w[1];
if (DelayChangeDetection(residual, trace) &&
if (DelayChangeDetection(residual) &&
_packetCount >= _startUpFilterDelayInPackets)
{
// A sudden change of average network delay has been detected.
@ -147,10 +140,6 @@ VCMTimestampExtrapolator::Update(int64_t tMs, uint32_t ts90khz, bool trace)
{
_packetCount++;
}
if (trace)
{
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCoding, VCMId(_vcmId, _id), "w[0]=%f w[1]=%f ts=%u tMs=%u", _w[0], _w[1], ts90khz, tMs);
}
_rwLock->ReleaseLockExclusive();
}
@ -222,7 +211,7 @@ VCMTimestampExtrapolator::CheckForWrapArounds(uint32_t ts90khz)
}
bool
VCMTimestampExtrapolator::DelayChangeDetection(double error, bool trace)
VCMTimestampExtrapolator::DelayChangeDetection(double error)
{
// CUSUM detection of sudden delay changes
error = (error > 0) ? VCM_MIN(error, _accMaxError) : VCM_MAX(error, -_accMaxError);
@ -231,17 +220,9 @@ VCMTimestampExtrapolator::DelayChangeDetection(double error, bool trace)
if (_detectorAccumulatorPos > _alarmThreshold || _detectorAccumulatorNeg < -_alarmThreshold)
{
// Alarm
if (trace)
{
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCoding, VCMId(_vcmId, _id), "g1=%f g2=%f alarm=1", _detectorAccumulatorPos, _detectorAccumulatorNeg);
}
_detectorAccumulatorPos = _detectorAccumulatorNeg = 0;
return true;
}
if (trace)
{
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCoding, VCMId(_vcmId, _id), "g1=%f g2=%f alarm=0", _detectorAccumulatorPos, _detectorAccumulatorNeg);
}
return false;
}

View File

@ -22,20 +22,16 @@ class Clock;
class VCMTimestampExtrapolator
{
public:
VCMTimestampExtrapolator(Clock* clock,
int32_t vcmId = 0,
int32_t receiverId = 0);
explicit VCMTimestampExtrapolator(Clock* clock);
~VCMTimestampExtrapolator();
void Update(int64_t tMs, uint32_t ts90khz, bool trace = true);
void Update(int64_t tMs, uint32_t ts90khz);
int64_t ExtrapolateLocalTime(uint32_t timestamp90khz);
void Reset();
private:
void CheckForWrapArounds(uint32_t ts90khz);
bool DelayChangeDetection(double error, bool trace = true);
bool DelayChangeDetection(double error);
RWLockWrapper* _rwLock;
int32_t _vcmId;
int32_t _id;
Clock* _clock;
double _w[2];
double _P[2][2];

View File

@ -15,20 +15,15 @@
#include "webrtc/modules/video_coding/main/source/jitter_buffer_common.h"
#include "webrtc/modules/video_coding/main/source/timestamp_extrapolator.h"
#include "webrtc/system_wrappers/interface/clock.h"
#include "webrtc/system_wrappers/interface/trace.h"
namespace webrtc {
VCMTiming::VCMTiming(Clock* clock,
int32_t vcm_id,
int32_t timing_id,
VCMTiming* master_timing)
: crit_sect_(CriticalSectionWrapper::CreateCriticalSection()),
vcm_id_(vcm_id),
clock_(clock),
timing_id_(timing_id),
master_(false),
ts_extrapolator_(),
codec_timer_(),
@ -40,7 +35,7 @@ VCMTiming::VCMTiming(Clock* clock,
prev_frame_timestamp_(0) {
if (master_timing == NULL) {
master_ = true;
ts_extrapolator_ = new VCMTimestampExtrapolator(clock_, vcm_id, timing_id);
ts_extrapolator_ = new VCMTimestampExtrapolator(clock_);
} else {
ts_extrapolator_ = master_timing->ts_extrapolator_;
}
@ -81,11 +76,6 @@ void VCMTiming::set_min_playout_delay(uint32_t min_playout_delay_ms) {
void VCMTiming::SetJitterDelay(uint32_t jitter_delay_ms) {
CriticalSectionScoped cs(crit_sect_);
if (jitter_delay_ms != jitter_delay_ms_) {
if (master_) {
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCoding,
VCMId(vcm_id_, timing_id_),
"Desired jitter buffer level: %u ms", jitter_delay_ms);
}
jitter_delay_ms_ = jitter_delay_ms;
// When in initial state, set current delay to minimum delay.
if (current_delay_ms_ == 0) {
@ -152,39 +142,21 @@ int32_t VCMTiming::StopDecodeTimer(uint32_t time_stamp,
int64_t start_time_ms,
int64_t now_ms) {
CriticalSectionScoped cs(crit_sect_);
const int32_t max_dec_time = MaxDecodeTimeMs();
int32_t time_diff_ms = codec_timer_.StopTimer(start_time_ms, now_ms);
if (time_diff_ms < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCoding, VCMId(vcm_id_,
timing_id_), "Codec timer error: %d", time_diff_ms);
assert(false);
}
assert(time_diff_ms >= 0);
last_decode_ms_ = time_diff_ms;
if (master_) {
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCoding, VCMId(vcm_id_,
timing_id_),
"Frame decoded: time_stamp=%u dec_time=%d max_dec_time=%u, at %u",
time_stamp, time_diff_ms, max_dec_time, MaskWord64ToUWord32(now_ms));
}
return 0;
}
void VCMTiming::IncomingTimestamp(uint32_t time_stamp, int64_t now_ms) {
CriticalSectionScoped cs(crit_sect_);
ts_extrapolator_->Update(now_ms, time_stamp, master_);
ts_extrapolator_->Update(now_ms, time_stamp);
}
int64_t VCMTiming::RenderTimeMs(uint32_t frame_timestamp, int64_t now_ms)
const {
CriticalSectionScoped cs(crit_sect_);
const int64_t render_time_ms = RenderTimeMsInternal(frame_timestamp, now_ms);
if (master_) {
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCoding, VCMId(vcm_id_,
timing_id_), "Render frame %u at %u. Render delay %u",
"jitter delay %u, max decode time %u, playout delay %u",
frame_timestamp, MaskWord64ToUWord32(render_time_ms), render_delay_ms_,
jitter_delay_ms_, MaxDecodeTimeMs(), min_playout_delay_ms_);
}
return render_time_ms;
}
@ -192,11 +164,6 @@ int64_t VCMTiming::RenderTimeMsInternal(uint32_t frame_timestamp,
int64_t now_ms) const {
int64_t estimated_complete_time_ms =
ts_extrapolator_->ExtrapolateLocalTime(frame_timestamp);
if (master_) {
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCoding,
VCMId(vcm_id_, timing_id_), "ExtrapolateLocalTime(%u)=%u ms",
frame_timestamp, MaskWord64ToUWord32(estimated_complete_time_ms));
}
if (estimated_complete_time_ms == -1) {
estimated_complete_time_ms = now_ms;
}
@ -210,11 +177,7 @@ int64_t VCMTiming::RenderTimeMsInternal(uint32_t frame_timestamp,
int32_t VCMTiming::MaxDecodeTimeMs(FrameType frame_type /*= kVideoFrameDelta*/)
const {
const int32_t decode_time_ms = codec_timer_.RequiredDecodeTimeMs(frame_type);
if (decode_time_ms < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCoding, VCMId(vcm_id_,
timing_id_), "Negative maximum decode time: %d", decode_time_ms);
return -1;
}
assert(decode_time_ms >= 0);
return decode_time_ms;
}
@ -254,11 +217,6 @@ uint32_t VCMTiming::TargetVideoDelay() const {
}
uint32_t VCMTiming::TargetDelayInternal() const {
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCoding,
VCMId(vcm_id_, timing_id_),
"Delay: min_playout=%u jitter=%u max_decode=%u render=%u",
min_playout_delay_ms_, jitter_delay_ms_, MaxDecodeTimeMs(),
render_delay_ms_);
return std::max(min_playout_delay_ms_,
jitter_delay_ms_ + MaxDecodeTimeMs() + render_delay_ms_);
}

View File

@ -25,8 +25,6 @@ class VCMTiming {
// The primary timing component should be passed
// if this is the dual timing component.
VCMTiming(Clock* clock,
int32_t vcm_id = 0,
int32_t timing_id = 0,
VCMTiming* master_timing = NULL);
~VCMTiming();
@ -101,9 +99,7 @@ class VCMTiming {
private:
CriticalSectionWrapper* crit_sect_;
int32_t vcm_id_;
Clock* clock_;
int32_t timing_id_;
bool master_;
VCMTimestampExtrapolator* ts_extrapolator_;
VCMCodecTimer codec_timer_;

View File

@ -16,7 +16,6 @@
#include "webrtc/modules/video_coding/main/source/packet.h"
#include "webrtc/modules/video_coding/main/source/video_coding_impl.h"
#include "webrtc/system_wrappers/interface/clock.h"
#include "webrtc/system_wrappers/interface/trace.h"
#include "webrtc/system_wrappers/interface/trace_event.h"
namespace webrtc {
@ -77,13 +76,12 @@ class EncodedImageCallbackWrapper : public EncodedImageCallback {
class VideoCodingModuleImpl : public VideoCodingModule {
public:
VideoCodingModuleImpl(const int32_t id,
Clock* clock,
VideoCodingModuleImpl(Clock* clock,
EventFactory* event_factory,
bool owns_event_factory)
: VideoCodingModule(),
sender_(new vcm::VideoSender(id, clock, &post_encode_callback_)),
receiver_(new vcm::VideoReceiver(id, clock, event_factory)),
sender_(new vcm::VideoSender(clock, &post_encode_callback_)),
receiver_(new vcm::VideoReceiver(clock, event_factory)),
own_event_factory_(owns_event_factory ? event_factory : NULL) {}
virtual ~VideoCodingModuleImpl() {
@ -386,17 +384,16 @@ int32_t VideoCodingModule::Codec(VideoCodecType codecType, VideoCodec* codec) {
return VCMCodecDataBase::Codec(codecType, codec) ? 0 : -1;
}
VideoCodingModule* VideoCodingModule::Create(const int32_t id) {
VideoCodingModule* VideoCodingModule::Create() {
return new VideoCodingModuleImpl(
id, Clock::GetRealTimeClock(), new EventFactoryImpl, true);
Clock::GetRealTimeClock(), new EventFactoryImpl, true);
}
VideoCodingModule* VideoCodingModule::Create(const int32_t id,
Clock* clock,
VideoCodingModule* VideoCodingModule::Create(Clock* clock,
EventFactory* event_factory) {
assert(clock);
assert(event_factory);
return new VideoCodingModuleImpl(id, clock, event_factory, false);
return new VideoCodingModuleImpl(clock, event_factory, false);
}
void VideoCodingModule::Destroy(VideoCodingModule* module) {

View File

@ -54,9 +54,7 @@ class VideoSender {
public:
typedef VideoCodingModule::SenderNackMode SenderNackMode;
VideoSender(const int32_t id,
Clock* clock,
EncodedImageCallback* post_encode_callback);
VideoSender(Clock* clock, EncodedImageCallback* post_encode_callback);
~VideoSender();
@ -110,7 +108,6 @@ class VideoSender {
int32_t Process();
private:
int32_t _id;
Clock* clock_;
scoped_ptr<DebugRecorder> recorder_;
@ -134,7 +131,7 @@ class VideoReceiver {
public:
typedef VideoCodingModule::ReceiverRobustness ReceiverRobustness;
VideoReceiver(const int32_t id, Clock* clock, EventFactory* event_factory);
VideoReceiver(Clock* clock, EventFactory* event_factory);
~VideoReceiver();
int32_t InitializeReceiver();
@ -202,7 +199,6 @@ class VideoReceiver {
// in any frame
};
int32_t _id;
Clock* clock_;
scoped_ptr<CriticalSectionWrapper> process_crit_sect_;
CriticalSectionWrapper* _receiveCritSect;

View File

@ -35,7 +35,7 @@ class VCMRobustnessTest : public ::testing::Test {
virtual void SetUp() {
clock_.reset(new SimulatedClock(0));
ASSERT_TRUE(clock_.get() != NULL);
vcm_ = VideoCodingModule::Create(0, clock_.get(), &event_factory_);
vcm_ = VideoCodingModule::Create(clock_.get(), &event_factory_);
ASSERT_TRUE(vcm_ != NULL);
ASSERT_EQ(0, vcm_->InitializeReceiver());
const size_t kMaxNackListSize = 250;

View File

@ -16,7 +16,7 @@
#include "webrtc/modules/video_coding/main/source/packet.h"
#include "webrtc/modules/video_coding/main/source/video_coding_impl.h"
#include "webrtc/system_wrappers/interface/clock.h"
#include "webrtc/system_wrappers/interface/trace.h"
#include "webrtc/system_wrappers/interface/logging.h"
#include "webrtc/system_wrappers/interface/trace_event.h"
// #define DEBUG_DECODER_BIT_STREAM
@ -24,18 +24,15 @@
namespace webrtc {
namespace vcm {
VideoReceiver::VideoReceiver(const int32_t id,
Clock* clock,
EventFactory* event_factory)
: _id(id),
clock_(clock),
VideoReceiver::VideoReceiver(Clock* clock, EventFactory* event_factory)
: clock_(clock),
process_crit_sect_(CriticalSectionWrapper::CreateCriticalSection()),
_receiveCritSect(CriticalSectionWrapper::CreateCriticalSection()),
_receiverInited(false),
_timing(clock_, id, 1),
_dualTiming(clock_, id, 2, &_timing),
_receiver(&_timing, clock_, event_factory, id, 1, true),
_dualReceiver(&_dualTiming, clock_, event_factory, id, 2, false),
_timing(clock_),
_dualTiming(clock_, &_timing),
_receiver(&_timing, clock_, event_factory, true),
_dualReceiver(&_dualTiming, clock_, event_factory, false),
_decodedFrameCallback(_timing, clock_),
_dualDecodedFrameCallback(_dualTiming, clock_),
_frameTypeCallback(NULL),
@ -53,7 +50,7 @@ VideoReceiver::VideoReceiver(const int32_t id,
_scheduleKeyRequest(false),
max_nack_list_size_(0),
pre_decode_image_callback_(NULL),
_codecDataBase(id),
_codecDataBase(),
_receiveStatsTimer(1000, clock_),
_retransmissionTimer(10, clock_),
_keyRequestTimer(500, clock_) {
@ -446,17 +443,9 @@ int32_t VideoReceiver::RequestSliceLossIndication(
const int32_t ret =
_frameTypeCallback->SliceLossIndicationRequest(pictureID);
if (ret < 0) {
WEBRTC_TRACE(webrtc::kTraceError,
webrtc::kTraceVideoCoding,
VCMId(_id),
"Failed to request key frame");
return ret;
}
} else {
WEBRTC_TRACE(webrtc::kTraceWarning,
webrtc::kTraceVideoCoding,
VCMId(_id),
"No frame type request callback registered");
return VCM_MISSING_CALLBACK;
}
return VCM_OK;
@ -468,18 +457,10 @@ int32_t VideoReceiver::RequestKeyFrame() {
if (_frameTypeCallback != NULL) {
const int32_t ret = _frameTypeCallback->RequestKeyFrame();
if (ret < 0) {
WEBRTC_TRACE(webrtc::kTraceError,
webrtc::kTraceVideoCoding,
VCMId(_id),
"Failed to request key frame");
return ret;
}
_scheduleKeyRequest = false;
} else {
WEBRTC_TRACE(webrtc::kTraceWarning,
webrtc::kTraceVideoCoding,
VCMId(_id),
"No frame type request callback registered");
return VCM_MISSING_CALLBACK;
}
return VCM_OK;
@ -502,29 +483,18 @@ int32_t VideoReceiver::DecodeDualFrame(uint16_t maxWaitTimeMs) {
VCMEncodedFrame* dualFrame =
_dualReceiver.FrameForDecoding(maxWaitTimeMs, dummyRenderTime);
if (dualFrame != NULL && _dualDecoder != NULL) {
WEBRTC_TRACE(webrtc::kTraceStream,
webrtc::kTraceVideoCoding,
VCMId(_id),
"Decoding frame %u with dual decoder",
dualFrame->TimeStamp());
// Decode dualFrame and try to catch up
int32_t ret =
_dualDecoder->Decode(*dualFrame, clock_->TimeInMilliseconds());
if (ret != WEBRTC_VIDEO_CODEC_OK) {
WEBRTC_TRACE(webrtc::kTraceWarning,
webrtc::kTraceVideoCoding,
VCMId(_id),
"Failed to decode frame with dual decoder");
LOG(LS_ERROR) << "Failed to decode frame with dual decoder. Error code: "
<< ret;
_dualReceiver.ReleaseFrame(dualFrame);
return VCM_CODEC_ERROR;
}
if (_receiver.DualDecoderCaughtUp(dualFrame, _dualReceiver)) {
// Copy the complete decoder state of the dual decoder
// to the primary decoder.
WEBRTC_TRACE(webrtc::kTraceStream,
webrtc::kTraceVideoCoding,
VCMId(_id),
"Dual decoder caught up");
_codecDataBase.CopyDecoder(*_dualDecoder);
_codecDataBase.ReleaseDecoder(_dualDecoder);
_dualDecoder = NULL;
@ -565,11 +535,6 @@ int32_t VideoReceiver::Decode(const VCMEncodedFrame& frame) {
return RequestSliceLossIndication(
_decodedFrameCallback.LastReceivedPictureID() + 1);
} else {
WEBRTC_TRACE(webrtc::kTraceError,
webrtc::kTraceVideoCoding,
VCMId(_id),
"Failed to decode frame %u, requesting key frame",
frame.TimeStamp());
request_key_frame = true;
}
} else if (ret == VCM_REQUEST_SLI) {
@ -730,24 +695,8 @@ int32_t VideoReceiver::NackList(uint16_t* nackList, uint16_t* size) {
nackStatus = _dualReceiver.NackList(nackList, *size, &nack_list_length);
}
*size = nack_list_length;
switch (nackStatus) {
case kNackNeedMoreMemory: {
WEBRTC_TRACE(webrtc::kTraceError,
webrtc::kTraceVideoCoding,
VCMId(_id),
"Out of memory");
return VCM_MEMORY;
}
case kNackKeyFrameRequest: {
WEBRTC_TRACE(webrtc::kTraceWarning,
webrtc::kTraceVideoCoding,
VCMId(_id),
"Failed to get NACK list, requesting key frame");
if (nackStatus == kNackKeyFrameRequest) {
return RequestKeyFrame();
}
default:
break;
}
return VCM_OK;
}

View File

@ -33,7 +33,7 @@ class TestVideoReceiver : public ::testing::Test {
TestVideoReceiver() : clock_(0) {}
virtual void SetUp() {
receiver_.reset(new VideoReceiver(0, &clock_, &event_factory_));
receiver_.reset(new VideoReceiver(&clock_, &event_factory_));
EXPECT_EQ(0, receiver_->InitializeReceiver());
EXPECT_EQ(0,
receiver_->RegisterExternalDecoder(

View File

@ -17,6 +17,7 @@
#include "webrtc/modules/video_coding/main/source/encoded_frame.h"
#include "webrtc/modules/video_coding/main/source/video_coding_impl.h"
#include "webrtc/system_wrappers/interface/clock.h"
#include "webrtc/system_wrappers/interface/logging.h"
namespace webrtc {
namespace vcm {
@ -57,20 +58,18 @@ class DebugRecorder {
FILE* file_ GUARDED_BY(cs_);
};
VideoSender::VideoSender(const int32_t id,
Clock* clock,
VideoSender::VideoSender(Clock* clock,
EncodedImageCallback* post_encode_callback)
: _id(id),
clock_(clock),
: clock_(clock),
recorder_(new DebugRecorder()),
process_crit_sect_(CriticalSectionWrapper::CreateCriticalSection()),
_sendCritSect(CriticalSectionWrapper::CreateCriticalSection()),
_encoder(),
_encodedFrameCallback(post_encode_callback),
_nextFrameTypes(1, kVideoFrameDelta),
_mediaOpt(id, clock_),
_mediaOpt(clock_),
_sendStatsCallback(NULL),
_codecDataBase(id),
_codecDataBase(),
frame_dropper_enabled_(true),
_sendStatsTimer(1000, clock_),
qm_settings_callback_(NULL),
@ -132,10 +131,8 @@ int32_t VideoSender::RegisterSendCodec(const VideoCodec* sendCodec,
_encoder = _codecDataBase.GetEncoder();
if (!ret) {
WEBRTC_TRACE(webrtc::kTraceError,
webrtc::kTraceVideoCoding,
VCMId(_id),
"Failed to initialize encoder");
LOG(LS_ERROR) << "Failed to initialize the encoder with payload name "
<< sendCodec->plName << ". Error code: " << ret;
return VCM_CODEC_ERROR;
}
@ -363,26 +360,18 @@ int32_t VideoSender::AddVideoFrame(const I420VideoFrame& videoFrame,
return VCM_OK;
}
if (_mediaOpt.DropFrame()) {
WEBRTC_TRACE(webrtc::kTraceStream,
webrtc::kTraceVideoCoding,
VCMId(_id),
"Drop frame due to bitrate");
} else {
_mediaOpt.UpdateContentData(contentMetrics);
int32_t ret =
_encoder->Encode(videoFrame, codecSpecificInfo, _nextFrameTypes);
recorder_->Add(videoFrame);
if (ret < 0) {
WEBRTC_TRACE(webrtc::kTraceError,
webrtc::kTraceVideoCoding,
VCMId(_id),
"Encode error: %d",
ret);
return ret;
}
for (size_t i = 0; i < _nextFrameTypes.size(); ++i) {
_nextFrameTypes[i] = kVideoFrameDelta; // Default frame type.
}
return VCM_OK;
}
_mediaOpt.UpdateContentData(contentMetrics);
int32_t ret =
_encoder->Encode(videoFrame, codecSpecificInfo, _nextFrameTypes);
recorder_->Add(videoFrame);
if (ret < 0) {
LOG(LS_ERROR) << "Failed to encode frame. Error code: " << ret;
return ret;
}
for (size_t i = 0; i < _nextFrameTypes.size(); ++i) {
_nextFrameTypes[i] = kVideoFrameDelta; // Default frame type.
}
return VCM_OK;
}

View File

@ -173,7 +173,7 @@ class TestVideoSender : public ::testing::Test {
TestVideoSender() : clock_(1000), packetization_callback_(&clock_) {}
virtual void SetUp() {
sender_.reset(new VideoSender(0, &clock_, &post_encode_callback_));
sender_.reset(new VideoSender(&clock_, &post_encode_callback_));
EXPECT_EQ(0, sender_->InitializeSender());
EXPECT_EQ(0, sender_->RegisterTransportCallback(&packetization_callback_));
}

View File

@ -29,7 +29,7 @@ using namespace webrtc;
int CodecDataBaseTest::RunTest(CmdArgs& args)
{
VideoCodingModule* vcm = VideoCodingModule::Create(1);
VideoCodingModule* vcm = VideoCodingModule::Create();
CodecDataBaseTest* cdbt = new CodecDataBaseTest(vcm);
cdbt->Perform(args);
VideoCodingModule::Destroy(vcm);

View File

@ -28,8 +28,7 @@ int GenericCodecTest::RunTest(CmdArgs& args)
{
SimulatedClock clock(0);
NullEventFactory event_factory;
VideoCodingModule* vcm = VideoCodingModule::Create(1, &clock,
&event_factory);
VideoCodingModule* vcm = VideoCodingModule::Create(&clock, &event_factory);
GenericCodecTest* get = new GenericCodecTest(vcm, &clock);
Trace::CreateTrace();
Trace::SetTraceFile(

View File

@ -32,7 +32,7 @@ int MediaOptTest::RunTest(int testNum, CmdArgs& args)
Trace::CreateTrace();
Trace::SetTraceFile((test::OutputPath() + "mediaOptTestTrace.txt").c_str());
Trace::set_level_filter(webrtc::kTraceAll);
VideoCodingModule* vcm = VideoCodingModule::Create(1);
VideoCodingModule* vcm = VideoCodingModule::Create();
Clock* clock = Clock::GetRealTimeClock();
MediaOptTest* mot = new MediaOptTest(vcm, clock);
if (testNum == 0)

View File

@ -145,7 +145,7 @@ int MTRxTxTest(CmdArgs& args)
printf("Cannot read file %s.\n", outname.c_str());
return -1;
}
VideoCodingModule* vcm = VideoCodingModule::Create(1);
VideoCodingModule* vcm = VideoCodingModule::Create();
RtpDataCallback dataCallback(vcm);
RTPSendCompleteCallback* outgoingTransport =

View File

@ -37,8 +37,7 @@ int NormalTest::RunTest(const CmdArgs& args)
Trace::SetTraceFile(
(test::OutputPath() + "VCMNormalTestTrace.txt").c_str());
Trace::set_level_filter(webrtc::kTraceAll);
VideoCodingModule* vcm = VideoCodingModule::Create(1, clock,
&event_factory);
VideoCodingModule* vcm = VideoCodingModule::Create(clock, &event_factory);
NormalTest VCMNTest(vcm, clock);
VCMNTest.Perform(args);
VideoCodingModule::Destroy(vcm);

View File

@ -32,7 +32,7 @@ int qualityModeTest(const CmdArgs& args)
{
SimulatedClock clock(0);
NullEventFactory event_factory;
VideoCodingModule* vcm = VideoCodingModule::Create(1, &clock, &event_factory);
VideoCodingModule* vcm = VideoCodingModule::Create(&clock, &event_factory);
QualityModesTest QMTest(vcm, &clock);
QMTest.Perform(args);
VideoCodingModule::Destroy(vcm);

View File

@ -108,9 +108,13 @@ class VcmPayloadSinkFactory::VcmPayloadSink
};
VcmPayloadSinkFactory::VcmPayloadSinkFactory(
const std::string& base_out_filename, Clock* clock, bool protection_enabled,
VCMVideoProtection protection_method, uint32_t rtt_ms,
uint32_t render_delay_ms, uint32_t min_playout_delay_ms)
const std::string& base_out_filename,
Clock* clock,
bool protection_enabled,
VCMVideoProtection protection_method,
uint32_t rtt_ms,
uint32_t render_delay_ms,
uint32_t min_playout_delay_ms)
: base_out_filename_(base_out_filename),
clock_(clock),
protection_enabled_(protection_enabled),
@ -120,8 +124,7 @@ VcmPayloadSinkFactory::VcmPayloadSinkFactory(
min_playout_delay_ms_(min_playout_delay_ms),
null_event_factory_(new NullEventFactory()),
crit_sect_(CriticalSectionWrapper::CreateCriticalSection()),
sinks_(),
next_id_(1) {
sinks_() {
assert(clock);
assert(crit_sect_.get());
}
@ -136,7 +139,7 @@ PayloadSinkInterface* VcmPayloadSinkFactory::Create(
CriticalSectionScoped cs(crit_sect_.get());
scoped_ptr<VideoCodingModule> vcm(
VideoCodingModule::Create(next_id_++, clock_, null_event_factory_.get()));
VideoCodingModule::Create(clock_, null_event_factory_.get()));
if (vcm.get() == NULL) {
return NULL;
}

View File

@ -56,7 +56,6 @@ class VcmPayloadSinkFactory : public PayloadSinkFactoryInterface {
scoped_ptr<NullEventFactory> null_event_factory_;
scoped_ptr<CriticalSectionWrapper> crit_sect_;
Sinks sinks_;
int next_id_;
DISALLOW_IMPLICIT_CONSTRUCTORS(VcmPayloadSinkFactory);
};

View File

@ -76,7 +76,7 @@ ViEChannel::ViEChannel(int32_t channel_id,
callback_cs_(CriticalSectionWrapper::CreateCriticalSection()),
rtp_rtcp_cs_(CriticalSectionWrapper::CreateCriticalSection()),
default_rtp_rtcp_(default_rtp_rtcp),
vcm_(*VideoCodingModule::Create(ViEModuleId(engine_id, channel_id))),
vcm_(*VideoCodingModule::Create()),
vie_receiver_(channel_id, &vcm_, remote_bitrate_estimator, this),
vie_sender_(channel_id),
vie_sync_(&vcm_, this),

View File

@ -139,8 +139,7 @@ ViEEncoder::ViEEncoder(int32_t engine_id,
: engine_id_(engine_id),
channel_id_(channel_id),
number_of_cores_(number_of_cores),
vcm_(*webrtc::VideoCodingModule::Create(ViEModuleId(engine_id,
channel_id))),
vcm_(*webrtc::VideoCodingModule::Create()),
vpm_(*webrtc::VideoProcessingModule::Create(ViEModuleId(engine_id,
channel_id))),
callback_cs_(CriticalSectionWrapper::CreateCriticalSection()),