Bug 833628 - GStreamer backend has shutdown hang in content/media mochitests; r=cdouble

Fix stream length detection so that we don't report size=-1 to gst. Fixes issues
with qtdemux not liking unknown upstream byte size.
This commit is contained in:
Alessandro Decina 2013-03-13 16:09:20 -04:00
parent ebd9e05a72
commit b31fa67829

View File

@ -184,6 +184,16 @@ void GStreamerReader::PlayBinSourceSetup(GstAppSrc *aSource)
mSource = GST_APP_SRC(aSource);
gst_app_src_set_callbacks(mSource, &mSrcCallbacks, (gpointer) this, NULL);
MediaResource* resource = mDecoder->GetResource();
/* do a short read to trigger a network request so that GetLength() below
* returns something meaningful and not -1
*/
char buf[512];
unsigned int size = 0;
resource->Read(buf, sizeof(buf), &size);
resource->Seek(SEEK_SET, 0);
/* now we should have a length */
int64_t len = resource->GetLength();
gst_app_src_set_size(mSource, len);
if (resource->IsDataCachedToEndOfResource(0) ||
@ -191,11 +201,12 @@ void GStreamerReader::PlayBinSourceSetup(GstAppSrc *aSource)
/* let the demuxer work in pull mode for local files (or very short files)
* so that we get optimal seeking accuracy/performance
*/
LOG(PR_LOG_ERROR, ("configuring random access"));
LOG(PR_LOG_DEBUG, ("configuring random access, len %lld", len));
gst_app_src_set_stream_type(mSource, GST_APP_STREAM_TYPE_RANDOM_ACCESS);
} else {
/* make the demuxer work in push mode so that seeking is kept to a minimum
*/
LOG(PR_LOG_DEBUG, ("configuring push mode, len %lld", len));
gst_app_src_set_stream_type(mSource, GST_APP_STREAM_TYPE_SEEKABLE);
}
}