Bug 882567 - Handle fatal gstreamer errors by aborting playback r=alessandro.d

This commit is contained in:
Edwin Flores 2013-06-22 11:16:53 +12:00
parent 51153e439c
commit feec6386f4
3 changed files with 27 additions and 3 deletions

View File

@ -26,6 +26,7 @@ GST_FUNC(LIBGSTREAMER, gst_buffer_copy_metadata)
GST_FUNC(LIBGSTREAMER, gst_buffer_get_type)
GST_FUNC(LIBGSTREAMER, gst_buffer_new)
GST_FUNC(LIBGSTREAMER, gst_buffer_new_and_alloc)
GST_FUNC(LIBGSTREAMER, gst_bus_set_sync_handler)
GST_FUNC(LIBGSTREAMER, gst_bus_timed_pop_filtered)
GST_FUNC(LIBGSTREAMER, gst_caps_append)
GST_FUNC(LIBGSTREAMER, gst_caps_can_intersect)
@ -54,6 +55,7 @@ GST_FUNC(LIBGSTREAMER, gst_init)
GST_FUNC(LIBGSTREAMER, gst_init_check)
GST_FUNC(LIBGSTREAMER, gst_iterator_next)
GST_FUNC(LIBGSTREAMER, gst_message_parse_error)
GST_FUNC(LIBGSTREAMER, gst_message_type_get_name)
GST_FUNC(LIBGSTREAMER, gst_mini_object_get_type)
GST_FUNC(LIBGSTREAMER, gst_mini_object_new)
GST_FUNC(LIBGSTREAMER, gst_mini_object_ref)

View File

@ -178,6 +178,22 @@ nsresult GStreamerReader::Init(MediaDecoderReader* aCloneDonor)
return NS_OK;
}
GstBusSyncReply
GStreamerReader::ErrorCb(GstBus *aBus, GstMessage *aMessage, gpointer aUserData)
{
return static_cast<GStreamerReader*>(aUserData)->Error(aBus, aMessage);
}
GstBusSyncReply
GStreamerReader::Error(GstBus *aBus, GstMessage *aMessage)
{
if (GST_MESSAGE_TYPE(aMessage) == GST_MESSAGE_ERROR) {
Eos();
}
return GST_BUS_PASS;
}
void GStreamerReader::PlayBinSourceSetupCb(GstElement* aPlayBin,
GParamSpec* pspec,
gpointer aUserData)
@ -347,6 +363,9 @@ nsresult GStreamerReader::ReadMetadata(VideoInfo* aInfo,
*aTags = nullptr;
// Watch the pipeline for fatal errors
gst_bus_set_sync_handler(mBus, GStreamerReader::ErrorCb, this);
/* set the pipeline to PLAYING so that it starts decoding and queueing data in
* the appsinks */
gst_element_set_state(mPlayBin, GST_STATE_PLAYING);
@ -1004,10 +1023,10 @@ void GStreamerReader::NewAudioBuffer()
void GStreamerReader::EosCb(GstAppSink* aSink, gpointer aUserData)
{
GStreamerReader* reader = reinterpret_cast<GStreamerReader*>(aUserData);
reader->Eos(aSink);
reader->Eos();
}
void GStreamerReader::Eos(GstAppSink* aSink)
void GStreamerReader::Eos()
{
/* We reached the end of the stream */
{

View File

@ -68,6 +68,9 @@ private:
/* Gst callbacks */
static GstBusSyncReply ErrorCb(GstBus *aBus, GstMessage *aMessage, gpointer aUserData);
GstBusSyncReply Error(GstBus *aBus, GstMessage *aMessage);
/* Called on the source-setup signal emitted by playbin. Used to
* configure appsrc .
*/
@ -120,7 +123,7 @@ private:
/* Called at end of stream, when decoding has finished */
static void EosCb(GstAppSink* aSink, gpointer aUserData);
void Eos(GstAppSink* aSink);
void Eos();
GstElement* mPlayBin;
GstBus* mBus;