Bug 991776: 1. Modify the testcase to ensure encoder will receive valid data. 2. Add logs for TrackEncoder. r=roc

This commit is contained in:
Benjamin Chen 2014-07-07 17:33:47 +08:00
Родитель e9e3887261
Коммит 06433b69a5
4 изменённых файлов: 44 добавлений и 8 удалений

Просмотреть файл

@ -5,6 +5,7 @@
#include "TrackEncoder.h"
#include "AudioChannelFormat.h"
#include "MediaStreamGraph.h"
#include "prlog.h"
#include "VideoUtils.h"
#undef LOG
@ -17,12 +18,38 @@
namespace mozilla {
#ifdef PR_LOGGING
PRLogModuleInfo* gTrackEncoderLog;
#define TRACK_LOG(type, msg) PR_LOG(gTrackEncoderLog, type, msg)
#else
#define TRACK_LOG(type, msg)
#endif
static const int DEFAULT_CHANNELS = 1;
static const int DEFAULT_SAMPLING_RATE = 16000;
static const int DEFAULT_FRAME_WIDTH = 640;
static const int DEFAULT_FRAME_HEIGHT = 480;
static const int DEFAULT_TRACK_RATE = USECS_PER_S;
TrackEncoder::TrackEncoder()
: mReentrantMonitor("media.TrackEncoder")
, mEncodingComplete(false)
, mEosSetInEncoder(false)
, mInitialized(false)
, mEndOfStream(false)
, mCanceled(false)
#ifdef PR_LOGGING
, mAudioInitCounter(0)
, mVideoInitCounter(0)
#endif
{
#ifdef PR_LOGGING
if (!gTrackEncoderLog) {
gTrackEncoderLog = PR_NewLogModule("TrackEncoder");
}
#endif
}
void
AudioTrackEncoder::NotifyQueuedTrackChanges(MediaStreamGraph* aGraph,
TrackID aID,
@ -39,6 +66,10 @@ AudioTrackEncoder::NotifyQueuedTrackChanges(MediaStreamGraph* aGraph,
// Check and initialize parameters for codec encoder.
if (!mInitialized) {
#ifdef PR_LOGGING
mAudioInitCounter++;
TRACK_LOG(PR_LOG_DEBUG, ("Init the audio encoder %d times", mAudioInitCounter));
#endif
AudioSegment::ChunkIterator iter(const_cast<AudioSegment&>(audio));
while (!iter.IsEnded()) {
AudioChunk chunk = *iter;
@ -158,6 +189,10 @@ VideoTrackEncoder::NotifyQueuedTrackChanges(MediaStreamGraph* aGraph,
// Check and initialize parameters for codec encoder.
if (!mInitialized) {
#ifdef PR_LOGGING
mVideoInitCounter++;
TRACK_LOG(PR_LOG_DEBUG, ("Init the video encoder %d times", mVideoInitCounter));
#endif
VideoSegment::ChunkIterator iter(const_cast<VideoSegment&>(video));
while (!iter.IsEnded()) {
VideoChunk chunk = *iter;

Просмотреть файл

@ -31,14 +31,7 @@ class MediaStreamGraph;
class TrackEncoder
{
public:
TrackEncoder()
: mReentrantMonitor("media.TrackEncoder")
, mEncodingComplete(false)
, mEosSetInEncoder(false)
, mInitialized(false)
, mEndOfStream(false)
, mCanceled(false)
{}
TrackEncoder();
virtual ~TrackEncoder() {}
@ -131,6 +124,12 @@ protected:
* mReentrantMonitor.
*/
bool mCanceled;
#ifdef PR_LOGGING
// How many times we have tried to initialize the encoder.
uint32_t mAudioInitCounter;
uint32_t mVideoInitCounter;
#endif
};
class AudioTrackEncoder : public TrackEncoder

Просмотреть файл

@ -21,6 +21,7 @@ function startTest() {
var source = context.createBufferSource();
source.buffer = buffer;
source.loop = true;
var dest = context.createMediaStreamDestination();
var stopTriggered = false;
var onstopTriggered = false;

Просмотреть файл

@ -20,6 +20,7 @@ function startTest() {
var source = context.createBufferSource();
source.buffer = buffer;
source.loop = true;
var dest = context.createMediaStreamDestination();
source.connect(dest);