Backed out changesets efb217f1897a and c9a22296f311 (bug 935774) due to test_mediarecorder_record_4ch_audiocontext.html perma-fail on all platforms after today's inbound merge.

This commit is contained in:
Ryan VanderMeulen 2013-11-21 11:28:06 -05:00
parent cb198c7dc5
commit b94d4e7bae
8 changed files with 18 additions and 120 deletions

View File

@ -79,13 +79,11 @@ class MediaRecorder::Session: public nsIObserver
MOZ_ASSERT(NS_IsMainThread());
MediaRecorder *recorder = mSession->mRecorder;
if (mSession->IsEncoderError()) {
recorder->NotifyError(NS_ERROR_UNEXPECTED);
}
nsresult rv = recorder->CreateAndDispatchBlobEvent(mSession);
if (NS_FAILED(rv)) {
recorder->NotifyError(rv);
}
return NS_OK;
}
@ -227,13 +225,6 @@ public:
return mEncodedBufferCache->ExtractBlob(mimeType);
}
bool IsEncoderError()
{
if (mEncoder && mEncoder->HasError()) {
return true;
}
return false;
}
private:
// Pull encoded meida data from MediaEncoder and put into EncodedBufferCache.

View File

@ -148,7 +148,7 @@ MediaEncoder::CreateEncoder(const nsAString& aMIMEType)
* If this is the last packet of input stream
* Set mState to ENCODE_DONE
*
* If mState is ENCODE_DONE or ENCODE_ERROR
* If mState is ENCODE_DONE
* Stop the loop
*/
void
@ -164,23 +164,17 @@ MediaEncoder::GetEncodedData(nsTArray<nsTArray<uint8_t> >* aOutputBufs,
switch (mState) {
case ENCODE_METADDATA: {
nsRefPtr<TrackMetadataBase> meta = mAudioEncoder->GetMetadata();
if (meta == nullptr) {
LOG("ERROR! AudioEncoder get null Metadata!");
mState = ENCODE_ERROR;
break;
}
MOZ_ASSERT(meta);
nsresult rv = mWriter->SetMetadata(meta);
if (NS_FAILED(rv)) {
LOG("ERROR! writer can't accept audio metadata!");
mState = ENCODE_ERROR;
mState = ENCODE_DONE;
break;
}
rv = mWriter->GetContainerData(aOutputBufs,
ContainerWriter::GET_HEADER);
if (NS_FAILED(rv)) {
LOG("ERROR! writer fail to generate header!");
mState = ENCODE_ERROR;
mState = ENCODE_DONE;
break;
}
@ -194,7 +188,7 @@ MediaEncoder::GetEncodedData(nsTArray<nsTArray<uint8_t> >* aOutputBufs,
if (NS_FAILED(rv)) {
// Encoding might be canceled.
LOG("ERROR! Fail to get encoded data from encoder.");
mState = ENCODE_ERROR;
mState = ENCODE_DONE;
break;
}
rv = mWriter->WriteEncodedTrack(encodedData,
@ -202,7 +196,7 @@ MediaEncoder::GetEncodedData(nsTArray<nsTArray<uint8_t> >* aOutputBufs,
ContainerWriter::END_OF_STREAM : 0);
if (NS_FAILED(rv)) {
LOG("ERROR! Fail to write encoded track to the media container.");
mState = ENCODE_ERROR;
mState = ENCODE_DONE;
break;
}
@ -223,11 +217,7 @@ MediaEncoder::GetEncodedData(nsTArray<nsTArray<uint8_t> >* aOutputBufs,
mShutdown = true;
reloop = false;
break;
case ENCODE_ERROR:
LOG("ERROR! MediaEncoder got error!");
mShutdown = true;
reloop = false;
break;
default:
MOZ_CRASH("Invalid encode state");
}

View File

@ -54,7 +54,6 @@ public :
ENCODE_METADDATA,
ENCODE_TRACK,
ENCODE_DONE,
ENCODE_ERROR,
};
MediaEncoder(ContainerWriter* aWriter,
@ -122,11 +121,6 @@ public :
}
}
bool HasError()
{
return mState == ENCODE_ERROR;
}
private:
nsAutoPtr<ContainerWriter> mWriter;
nsAutoPtr<AudioTrackEncoder> mAudioEncoder;

View File

@ -136,17 +136,18 @@ OpusTrackEncoder::~OpusTrackEncoder()
nsresult
OpusTrackEncoder::Init(int aChannels, int aSamplingRate)
{
// The track must have 1 or 2 channels.
if (aChannels <= 0 || aChannels > MAX_CHANNELS) {
LOG("[Opus] Fail to create the AudioTrackEncoder! The input has"
" %d channel(s), but expects no more than %d.", aChannels, MAX_CHANNELS);
return NS_ERROR_INVALID_ARG;
}
// This monitor is used to wake up other methods that are waiting for encoder
// to be completely initialized.
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
// This version of encoder API only support 1 or 2 channels,
// So set the mChannels less or equal 2 and
// let InterleaveTrackData downmix pcm data.
mChannels = aChannels > 2 ? 2 : aChannels;
mChannels = aChannels;
if (aChannels <= 0) {
return NS_ERROR_FAILURE;
}
// The granule position is required to be incremented at a rate of 48KHz, and
// it is simply calculated as |granulepos = samples * (48000/source_rate)|,
// that is, the source sampling rate must divide 48000 evenly.

View File

@ -141,10 +141,8 @@ protected:
uint32_t aOutputChannels, AudioDataValue* aOutput);
/**
* The number of channels are used for processing PCM data in the audio encoder.
* This value comes from the first valid audio chunk. If encoder can't support
* the channels in the chunk, downmix PCM stream can be performed.
* This value also be used to initialize the audio encoder.
* The number of channels in the first valid audio chunk, and is being used
* to initialize the audio encoder.
*/
int mChannels;
int mSamplingRate;

View File

@ -169,7 +169,6 @@ OggWriter::GetContainerData(nsTArray<nsTArray<uint8_t> >* aOutputBufs,
nsresult
OggWriter::SetMetadata(TrackMetadataBase* aMetadata)
{
MOZ_ASSERT(aMetadata);
if (aMetadata->GetKind() != TrackMetadataBase::METADATA_OPUS) {
LOG("wrong meta data type!");
return NS_ERROR_FAILURE;

View File

@ -237,7 +237,6 @@ support-files =
[test_mediarecorder_avoid_recursion.html]
[test_mediarecorder_record_timeslice.html]
[test_mediarecorder_record_audiocontext.html]
[test_mediarecorder_record_4ch_audiocontext.html]
[test_mediarecorder_record_stopms.html]
[test_mediarecorder_record_nosrc.html]
[test_mozHasAudio.html]

View File

@ -1,74 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test MediaRecorder Record AudioContext with four channels</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<script type="text/javascript" src="manifest.js"></script>
</head>
<body>
<script class="testbody" type="text/javascript">
function startTest() {
var context = new AudioContext();
var buffer = context.createBuffer(4, 80920, context.sampleRate);
for (var i = 0; i < 80920; ++i) {
for(var j = 0; j < 4; ++j) {
buffer.getChannelData(j)[i] = Math.sin(1000 * 2 * Math.PI * i / context.sampleRate);
}
}
var source = context.createBufferSource();
source.buffer = buffer;
var dest = context.createMediaStreamDestination();
var stopTriggered = false;
var onstopTriggered = false;
dest.channelCount = 4;
var expectedMimeType = 'audio/ogg';
source.channelCountMode = 'explicit';
source.connect(dest);
var elem = document.createElement('audio');
elem.mozSrcObject = dest.stream;
mMediaStream = dest.stream;
source.start(0);
elem.play();
mMediaRecorder = new MediaRecorder(dest.stream);
mMediaRecorder.onwarning = function() {
ok(false, 'onwarning unexpectedly fired');
};
mMediaRecorder.onerror = function() {
ok(false, 'onerror unexpectedly fired');
};
mMediaRecorder.onstop = function() {
ok(true, 'onstop fired successfully');
is(mMediaRecorder.state, 'inactive', 'check recording status is inactive');
onstopTriggered = true;
SimpleTest.finish();
};
mMediaRecorder.ondataavailable = function (e) {
ok(e.data.size > 0, 'check blob has data');
is(mMediaRecorder.mimeType, expectedMimeType, 'blob should has mimetype, return ' + mMediaRecorder.mimeType);
if (!stopTriggered) {
mMediaRecorder.stop();
stopTriggered = true;
} else if (onstopTriggered) {
ok(false, 'ondataavailable should come before onstop event');
}
};
try {
mMediaRecorder.start(1000);
is('recording', mMediaRecorder.state, "check record state recording");
} catch (e) {
ok(false, 'Can t record audio context');
}
}
startTest();
SimpleTest.waitForExplicitFinish();
</script>
</pre>
</body>
</html>