Bug 792935 - Miscellaneous fixes for DASH Mochitests r=cpearce

This commit is contained in:
Steve Workman 2013-01-23 11:24:41 -08:00
parent c65cca2192
commit e30ae6ad32
6 changed files with 38 additions and 24 deletions

View File

@ -969,8 +969,8 @@ void MediaDecoder::NotifyPrincipalChanged()
void MediaDecoder::NotifyBytesConsumed(int64_t aBytes)
{
NS_ENSURE_TRUE_VOID(mDecoderStateMachine);
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
NS_ENSURE_TRUE_VOID(mDecoderStateMachine);
MOZ_ASSERT(OnStateMachineThread() || mDecoderStateMachine->OnDecodeThread());
if (!mIgnoreProgressData) {
mDecoderPosition += aBytes;
@ -1372,8 +1372,7 @@ void MediaDecoder::SetPreservesPitch(bool aPreservesPitch)
}
bool MediaDecoder::OnDecodeThread() const {
NS_ENSURE_TRUE(mDecoderStateMachine, false);
return mDecoderStateMachine->OnDecodeThread();
return mDecoderStateMachine ? mDecoderStateMachine->OnDecodeThread() : false;
}
ReentrantMonitor& MediaDecoder::GetReentrantMonitor() {

View File

@ -232,17 +232,6 @@ ChannelMediaResource::OnStartRequest(nsIRequest* aRequest)
// Check response code for byte-range requests (seeking, chunk requests).
if (!mByteRange.IsNull() && (responseStatus == HTTP_PARTIAL_RESPONSE_CODE)) {
// Byte range requests should get partial response codes and should
// accept ranges.
if (!acceptsRanges) {
CMLOG("Error! HTTP_PARTIAL_RESPONSE_CODE received but server says "
"range requests are not accepted! Channel[%p] decoder[%p]",
hc.get(), mDecoder);
mDecoder->NetworkError();
CloseChannel();
return NS_OK;
}
// Parse Content-Range header.
int64_t rangeStart = 0;
int64_t rangeEnd = 0;
@ -277,6 +266,7 @@ ChannelMediaResource::OnStartRequest(nsIRequest* aRequest)
mCacheStream.NotifyDataStarted(rangeStart);
mOffset = rangeStart;
// We received 'Content-Range', so the server accepts range requests.
acceptsRanges = true;
} else if (((mOffset > 0) || !mByteRange.IsNull())
&& (responseStatus == HTTP_OK_CODE)) {
@ -727,7 +717,7 @@ MediaResource* ChannelMediaResource::CloneData(MediaDecoder* aDecoder)
// and perform a useless HTTP transaction.
resource->mSuspendCount = 1;
resource->mCacheStream.InitAsClone(&mCacheStream);
resource->mChannelStatistics = mChannelStatistics;
resource->mChannelStatistics = new MediaChannelStatistics(mChannelStatistics);
resource->mChannelStatistics->Stop();
}
return resource;
@ -1066,8 +1056,11 @@ ChannelMediaResource::CacheClientSeek(int64_t aOffset, bool aResume)
mByteRange.Clear();
}
mSeekOffset = -1;
} else if (mByteRange.mStart <= aOffset && aOffset <= mByteRange.mEnd) {
CMLOG("Trying to resume download at offset [%lld].", aOffset);
rv = NS_OK;
} else {
LOG("MediaCache [%p] trying to seek independently to offset [%lld].",
CMLOG("MediaCache [%p] trying to seek independently to offset [%lld].",
&mCacheStream, aOffset);
rv = NS_ERROR_NOT_AVAILABLE;
}

View File

@ -47,6 +47,12 @@ class MediaChannelStatistics {
public:
MediaChannelStatistics() { Reset(); }
MediaChannelStatistics(MediaChannelStatistics * aCopyFrom)
{
MOZ_ASSERT(aCopyFrom);
*this = *aCopyFrom;
}
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaChannelStatistics)
void Reset() {

View File

@ -389,7 +389,7 @@ DASHDecoder::CreateRepDecoders()
// Global settings for the presentation.
int64_t startTime = mMPDManager->GetStartTime();
mDuration = mMPDManager->GetDuration();
SetDuration(mMPDManager->GetDuration());
NS_ENSURE_TRUE(startTime >= 0 && mDuration > 0, NS_ERROR_ILLEGAL_VALUE);
// For each audio/video stream, create a |ChannelMediaResource| object.
@ -758,7 +758,7 @@ DASHDecoder::NotifyDownloadEnded(DASHRepDecoder* aRepDecoder,
}
decoder->LoadNextByteRange();
} else if (aStatus == NS_BINDING_ABORTED) {
LOG("MPD download has been cancelled by the user: aStatus [%x].", aStatus);
LOG("Media download has been cancelled by the user: aStatus[%x]", aStatus);
if (mOwner) {
mOwner->LoadAborted();
}
@ -775,9 +775,9 @@ DASHDecoder::LoadAborted()
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
if (!mNotifiedLoadAborted && mOwner) {
LOG1("Load Aborted! Notifying media element.");
mOwner->LoadAborted();
mNotifiedLoadAborted = true;
LOG1("Load Aborted! Notifying media element.");
}
}
@ -786,6 +786,8 @@ DASHDecoder::Shutdown()
{
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
LOG1("Shutting down.");
// Notify reader of shutdown first.
if (mDASHReader) {
mDASHReader->NotifyDecoderShuttingDown();
@ -1076,6 +1078,10 @@ DASHDecoder::IsDecoderAllowedToDownloadData(DASHRepDecoder* aRepDecoder)
NS_ASSERTION(aRepDecoder, "DASHRepDecoder pointer is null.");
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
LOG("Checking aRepDecoder [%p] with AudioRepDecoder [%p] metadataReadCount "
"[%d] and VideoRepDecoder [%p] metadataReadCount [%d]",
aRepDecoder, AudioRepDecoder(), mAudioMetadataReadCount,
VideoRepDecoder(), mVideoMetadataReadCount);
// Only return true if |aRepDecoder| is active and metadata for all
// representations has been downloaded.
return ((aRepDecoder == AudioRepDecoder() && mAudioMetadataReadCount == 0) ||

View File

@ -251,6 +251,9 @@ private:
DASHRepDecoder* AudioRepDecoder() {
ReentrantMonitorConditionallyEnter mon(!OnDecodeThread(),
GetReentrantMonitor());
if (0 == mAudioRepDecoders.Length()) {
return nullptr;
}
NS_ENSURE_TRUE((uint32_t)mAudioRepDecoderIdx < mAudioRepDecoders.Length(),
nullptr);
if (mAudioRepDecoderIdx < 0) {
@ -266,6 +269,9 @@ private:
DASHRepDecoder* VideoRepDecoder() {
ReentrantMonitorConditionallyEnter mon(!OnDecodeThread(),
GetReentrantMonitor());
if (0 == mVideoRepDecoders.Length()) {
return nullptr;
}
NS_ENSURE_TRUE((uint32_t)mVideoRepDecoderIdx < mVideoRepDecoders.Length(),
nullptr);
if (mVideoRepDecoderIdx < 0) {

View File

@ -125,9 +125,11 @@ DASHRepDecoder::NotifyDownloadEnded(nsresult aStatus)
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
if (!mMainDecoder) {
LOG("Error! Main Decoder is reported as null: mMainDecoder [%p]",
mMainDecoder.get());
DecodeError();
if (!mShuttingDown) {
LOG("Error! Main Decoder is null before shutdown: mMainDecoder [%p] ",
mMainDecoder.get());
DecodeError();
}
return;
}
@ -153,7 +155,8 @@ DASHRepDecoder::NotifyDownloadEnded(nsresult aStatus)
mMainDecoder->NotifyDownloadEnded(this, aStatus, mSubsegmentIdx);
}
} else if (aStatus == NS_BINDING_ABORTED) {
LOG("MPD download has been cancelled by the user: aStatus [%x].", aStatus);
LOG("Media download has been cancelled by the user: aStatus [%x].",
aStatus);
if (mMainDecoder) {
mMainDecoder->LoadAborted();
}
@ -413,7 +416,8 @@ DASHRepDecoder::SetInfinite(bool aInfinite)
void
DASHRepDecoder::SetMediaSeekable(bool aMediaSeekable)
{
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
NS_ASSERTION(NS_IsMainThread() || OnDecodeThread(),
"Should be on main thread or decode thread.");
if (mMainDecoder) { mMainDecoder->SetMediaSeekable(aMediaSeekable); }
}