зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 09d9b633e335 (bug 1294753)
This commit is contained in:
Родитель
a1568bf7f1
Коммит
612d7d1f4b
|
@ -308,19 +308,17 @@ MediaEncoder::GetEncodedData(nsTArray<nsTArray<uint8_t> >* aOutputBufs,
|
||||||
LOG(LogLevel::Debug, ("ENCODE_TRACK TimeStamp = %f", GetEncodeTimeStamp()));
|
LOG(LogLevel::Debug, ("ENCODE_TRACK TimeStamp = %f", GetEncodeTimeStamp()));
|
||||||
EncodedFrameContainer encodedData;
|
EncodedFrameContainer encodedData;
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
// We're most likely to actually wait for a video frame, so do that first to minimize
|
|
||||||
// capture offset/lipsync issues
|
|
||||||
rv = WriteEncodedDataToMuxer(mVideoEncoder.get());
|
|
||||||
if (NS_FAILED(rv)) {
|
|
||||||
LOG(LogLevel::Error, ("Fail to write video encoder data to muxer"));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
rv = WriteEncodedDataToMuxer(mAudioEncoder.get());
|
rv = WriteEncodedDataToMuxer(mAudioEncoder.get());
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
LOG(LogLevel::Error, ("Error! Fail to write audio encoder data to muxer"));
|
LOG(LogLevel::Error, ("Error! Fail to write audio encoder data to muxer"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
LOG(LogLevel::Debug, ("Audio encoded TimeStamp = %f", GetEncodeTimeStamp()));
|
LOG(LogLevel::Debug, ("Audio encoded TimeStamp = %f", GetEncodeTimeStamp()));
|
||||||
|
rv = WriteEncodedDataToMuxer(mVideoEncoder.get());
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
LOG(LogLevel::Error, ("Fail to write video encoder data to muxer"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
LOG(LogLevel::Debug, ("Video encoded TimeStamp = %f", GetEncodeTimeStamp()));
|
LOG(LogLevel::Debug, ("Video encoded TimeStamp = %f", GetEncodeTimeStamp()));
|
||||||
// In audio only or video only case, let unavailable track's flag to be true.
|
// In audio only or video only case, let unavailable track's flag to be true.
|
||||||
bool isAudioCompleted = (mAudioEncoder && mAudioEncoder->IsEncodingComplete()) || !mAudioEncoder;
|
bool isAudioCompleted = (mAudioEncoder && mAudioEncoder->IsEncodingComplete()) || !mAudioEncoder;
|
||||||
|
|
|
@ -275,10 +275,6 @@ OpusTrackEncoder::GetEncodedTrack(EncodedFrameContainer& aData)
|
||||||
// calculation below depends on the truth that mInitialized is true.
|
// calculation below depends on the truth that mInitialized is true.
|
||||||
MOZ_ASSERT(mInitialized);
|
MOZ_ASSERT(mInitialized);
|
||||||
|
|
||||||
bool wait = true;
|
|
||||||
int result = 0;
|
|
||||||
// Only wait once, then loop until we run out of packets of input data
|
|
||||||
while (result >= 0) {
|
|
||||||
// re-sampled frames left last time which didn't fit into an Opus packet duration.
|
// re-sampled frames left last time which didn't fit into an Opus packet duration.
|
||||||
const int framesLeft = mResampledLeftover.Length() / mChannels;
|
const int framesLeft = mResampledLeftover.Length() / mChannels;
|
||||||
// When framesLeft is 0, (GetPacketDuration() - framesLeft) is a multiple
|
// When framesLeft is 0, (GetPacketDuration() - framesLeft) is a multiple
|
||||||
|
@ -302,12 +298,7 @@ OpusTrackEncoder::GetEncodedTrack(EncodedFrameContainer& aData)
|
||||||
while (!mCanceled && mRawSegment.GetDuration() +
|
while (!mCanceled && mRawSegment.GetDuration() +
|
||||||
mSourceSegment.GetDuration() < framesToFetch &&
|
mSourceSegment.GetDuration() < framesToFetch &&
|
||||||
!mEndOfStream) {
|
!mEndOfStream) {
|
||||||
if (wait) {
|
|
||||||
mReentrantMonitor.Wait();
|
mReentrantMonitor.Wait();
|
||||||
wait = false;
|
|
||||||
} else {
|
|
||||||
goto done; // nested while's...
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mCanceled || mEncodingComplete) {
|
if (mCanceled || mEncodingComplete) {
|
||||||
|
@ -425,7 +416,7 @@ OpusTrackEncoder::GetEncodedTrack(EncodedFrameContainer& aData)
|
||||||
// Encode the data with Opus Encoder.
|
// Encode the data with Opus Encoder.
|
||||||
frameData.SetLength(MAX_DATA_BYTES);
|
frameData.SetLength(MAX_DATA_BYTES);
|
||||||
// result is returned as opus error code if it is negative.
|
// result is returned as opus error code if it is negative.
|
||||||
result = 0;
|
int result = 0;
|
||||||
#ifdef MOZ_SAMPLE_TYPE_S16
|
#ifdef MOZ_SAMPLE_TYPE_S16
|
||||||
const opus_int16* pcmBuf = static_cast<opus_int16*>(pcm.Elements());
|
const opus_int16* pcmBuf = static_cast<opus_int16*>(pcm.Elements());
|
||||||
result = opus_encode(mEncoder, pcmBuf, GetPacketDuration(),
|
result = opus_encode(mEncoder, pcmBuf, GetPacketDuration(),
|
||||||
|
@ -449,13 +440,10 @@ OpusTrackEncoder::GetEncodedTrack(EncodedFrameContainer& aData)
|
||||||
}
|
}
|
||||||
|
|
||||||
audiodata->SwapInFrameData(frameData);
|
audiodata->SwapInFrameData(frameData);
|
||||||
// timestamp should be the time of the first sample
|
|
||||||
audiodata->SetTimeStamp(mOutputTimeStamp);
|
|
||||||
mOutputTimeStamp += FramesToUsecs(GetPacketDuration(), kOpusSamplingRate).value();
|
mOutputTimeStamp += FramesToUsecs(GetPacketDuration(), kOpusSamplingRate).value();
|
||||||
|
audiodata->SetTimeStamp(mOutputTimeStamp);
|
||||||
LOG("[Opus] mOutputTimeStamp %lld.",mOutputTimeStamp);
|
LOG("[Opus] mOutputTimeStamp %lld.",mOutputTimeStamp);
|
||||||
aData.AppendEncodedFrame(audiodata);
|
aData.AppendEncodedFrame(audiodata);
|
||||||
}
|
|
||||||
done:
|
|
||||||
return result >= 0 ? NS_OK : NS_ERROR_FAILURE;
|
return result >= 0 ? NS_OK : NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче