Adding an API that allows recording of video data

removing vie_codec from cl

Moving debug call from Codec to File impl.

Updating cl following review

Updating file name

Updating cl following review.

Updating CL following review.

Adding an API that allows recording of video data

updating cl

Adding debug options

BUG=

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@2678 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
mikhal@webrtc.org 2012-08-28 16:15:16 +00:00
parent 7b2e919f7d
commit e41bbdfecc
9 changed files with 87 additions and 16 deletions

View File

@ -544,6 +544,12 @@ public:
// < 0, on error.
virtual int SetReceiverRobustnessMode(ReceiverRobustness robustnessMode,
DecodeErrors errorMode) = 0;
// Enables recording of debugging information.
virtual int StartDebugRecording(const char* file_name_utf8) = 0;
// Disables recording of debugging information.
virtual int StopDebugRecording() = 0;
};
} // namespace webrtc

View File

@ -21,7 +21,6 @@ namespace webrtc
{
//#define DEBUG_DECODER_BIT_STREAM
//#define DEBUG_ENCODER_INPUT
WebRtc_UWord32
VCMProcessTimer::Period() const
@ -78,10 +77,7 @@ _nextFrameType(kVideoFrameDelta),
_mediaOpt(id, clock_),
_sendCodecType(kVideoCodecUnknown),
_sendStatsCallback(NULL),
#ifdef DEBUG_ENCODER_INPUT
_encoderInputFile(NULL),
#endif
_codecDataBase(id),
_receiveStatsTimer(1000, clock_),
_sendStatsTimer(1000, clock_),
@ -92,9 +88,6 @@ _keyRequestTimer(500, clock_)
#ifdef DEBUG_DECODER_BIT_STREAM
_bitStreamBeforeDecoder = fopen("decoderBitStream.bit", "wb");
#endif
#ifdef DEBUG_ENCODER_INPUT
_encoderInputFile = fopen("encoderInput.yuv", "wb");
#endif
}
VideoCodingModuleImpl::~VideoCodingModuleImpl()
@ -109,9 +102,10 @@ VideoCodingModuleImpl::~VideoCodingModuleImpl()
#ifdef DEBUG_DECODER_BIT_STREAM
fclose(_bitStreamBeforeDecoder);
#endif
#ifdef DEBUG_ENCODER_INPUT
fclose(_encoderInputFile);
#endif
if (_encoderInputFile != NULL)
{
fclose(_encoderInputFile);
}
}
VideoCodingModule*
@ -686,7 +680,6 @@ VideoCodingModuleImpl::AddVideoFrame(const VideoFrame& videoFrame,
WebRtc_Word32 ret = _encoder->Encode(videoFrame,
codecSpecificInfo,
_nextFrameType);
#ifdef DEBUG_ENCODER_INPUT
if (_encoderInputFile != NULL)
{
if (fwrite(videoFrame.Buffer(), 1, videoFrame.Length(),
@ -694,7 +687,6 @@ VideoCodingModuleImpl::AddVideoFrame(const VideoFrame& videoFrame,
return -1;
}
}
#endif
if (ret < 0)
{
WEBRTC_TRACE(webrtc::kTraceError,
@ -1374,4 +1366,19 @@ int VideoCodingModuleImpl::SetReceiverRobustnessMode(
return VCM_OK;
}
int VideoCodingModuleImpl::StartDebugRecording(const char* file_name_utf8) {
_encoderInputFile = fopen(file_name_utf8, "wb");
if (_encoderInputFile == NULL)
return VCM_GENERAL_ERROR;
return VCM_OK;
}
int VideoCodingModuleImpl::StopDebugRecording(){
if (_encoderInputFile != NULL) {
fclose(_encoderInputFile);
_encoderInputFile = NULL;
}
return VCM_OK;
}
} // namespace webrtc

View File

@ -259,6 +259,11 @@ public:
// Set the receiver robustness mode.
virtual int SetReceiverRobustnessMode(ReceiverRobustness robustnessMode,
DecodeErrors errorMode);
// Enables recording of debugging information.
virtual int StartDebugRecording(const char* file_name_utf8);
// Disables recording of debugging information.
virtual int StopDebugRecording();
protected:
WebRtc_Word32 Decode(const webrtc::VCMEncodedFrame& frame);
@ -299,10 +304,7 @@ private:
VCMMediaOptimization _mediaOpt;
VideoCodecType _sendCodecType;
VCMSendStatisticsCallback* _sendStatsCallback;
#ifdef DEBUG_ENCODER_INPUT
FILE* _encoderInputFile;
#endif
VCMCodecDataBase _codecDataBase;
VCMProcessTimer _receiveStatsTimer;
VCMProcessTimer _sendStatsTimer;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -211,6 +211,13 @@ class WEBRTC_DLLEXPORT ViEFile {
const ViEPicture& picture,
const unsigned int timeout_ms) = 0;
// Enables recording of debugging information.
virtual int StartDebugRecording(int video_channel,
const char* file_name_utf8) = 0;
// Disables recording of debugging information.
virtual int StopDebugRecording(int video_channel) = 0;
protected:
ViEFile() {}
virtual ~ViEFile() {}

View File

@ -169,6 +169,10 @@ void ViEAutoTest::ViEFileStandardTest()
AutoTestSleep(TEST_SPACING);
// Test debug information recording.
EXPECT_EQ(0, ptrViEFile->StartDebugRecording(videoChannel,
"vie_autotest_debug.yuv"));
// testing StartRecordIncomingVideo and StopRecordIncomingVideo
{
ViETest::Log("Recording incoming video (currently no audio) for %d "
@ -457,6 +461,9 @@ void ViEAutoTest::ViEFileStandardTest()
EXPECT_NE(0, ptrViEFile->DeregisterObserver(fileId, fileObserver));
}
// Stop debug record.
EXPECT_EQ(0, ptrViEFile->StopDebugRecording(videoChannel));
//***************************************************************
// Testing finished. Tear down Video Engine
//***************************************************************

View File

@ -868,6 +868,14 @@ ViEFileRecorder& ViEEncoder::GetOutgoingFileRecorder() {
return file_recorder_;
}
int ViEEncoder::StartDebugRecording(const char* fileNameUTF8) {
return vcm_.StartDebugRecording(fileNameUTF8);
}
int ViEEncoder::StopDebugRecording() {
return vcm_.StopDebugRecording();
}
QMVideoSettingsCallback::QMVideoSettingsCallback(VideoProcessingModule* vpm)
: vpm_(vpm) {
}

View File

@ -143,6 +143,12 @@ class ViEEncoder
// Recording.
ViEFileRecorder& GetOutgoingFileRecorder();
// Enables recording of debugging information.
virtual int StartDebugRecording(const char* fileNameUTF8);
// Disables recording of debugging information.
virtual int StopDebugRecording();
protected:
// Called by BitrateObserver.
void OnNetworkChanged(const uint32_t bitrate_bps,

View File

@ -949,6 +949,31 @@ WebRtc_Word32 ViEFileImpl::GetNextCapturedFrame(WebRtc_Word32 capture_id,
return -1;
}
int ViEFileImpl::StartDebugRecording(int video_channel,
const char* file_name_utf8) {
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEEncoder* vie_encoder = cs.Encoder(video_channel);
if (!vie_encoder) {
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: No encoder %d", __FUNCTION__, video_channel);
return -1;
}
return vie_encoder->StartDebugRecording(file_name_utf8);
}
int ViEFileImpl::StopDebugRecording(int video_channel) {
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEEncoder* vie_encoder = cs.Encoder(video_channel);
if (!vie_encoder) {
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: No encoder %d", __FUNCTION__, video_channel);
return -1;
}
return vie_encoder->StopDebugRecording();
}
ViECaptureSnapshot::ViECaptureSnapshot()
: crit_(CriticalSectionWrapper::CreateCriticalSection()),
condition_varaible_(ConditionVariableWrapper::CreateConditionVariable()),

View File

@ -120,6 +120,9 @@ class ViEFileImpl
virtual int SetRenderTimeoutImage(const int video_channel,
const ViEPicture& picture,
const unsigned int timeout_ms);
virtual int StartDebugRecording(int video_channel,
const char* file_name_utf8);
virtual int StopDebugRecording(int video_channel);
protected:
explicit ViEFileImpl(ViESharedData* shared_data);