ges: Add a "discovery-error" signal to GESTimeline

API: GESTimeline::discovery-error signal
This commit is contained in:
Thibault Saunier 2012-01-04 14:46:54 -03:00
parent 3ca5e7bcaa
commit b844ff04de

View file

@ -98,6 +98,7 @@ enum
TRACK_REMOVED, TRACK_REMOVED,
LAYER_ADDED, LAYER_ADDED,
LAYER_REMOVED, LAYER_REMOVED,
DISCOVERY_ERROR,
LAST_SIGNAL LAST_SIGNAL
}; };
@ -262,6 +263,18 @@ ges_timeline_class_init (GESTimelineClass * klass)
G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GESTimelineClass, layer_removed), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GESTimelineClass, layer_removed),
NULL, NULL, ges_marshal_VOID__OBJECT, G_TYPE_NONE, 1, NULL, NULL, ges_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
GES_TYPE_TIMELINE_LAYER); GES_TYPE_TIMELINE_LAYER);
/**
* GESTimeline::discovery-error:
* @formatter: the #GESFormatter
* @source: The #GESTimelineFileSource that could not be discovered properly
* @error: (type GLib.Error): #GError, which will be non-NULL if an error
* occurred during discovery
*/
ges_timeline_signals[DISCOVERY_ERROR] =
g_signal_new ("discovery-error", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST, 0, NULL, NULL, gst_marshal_VOID__OBJECT_BOXED,
G_TYPE_NONE, 2, GES_TYPE_TIMELINE_FILE_SOURCE, GST_TYPE_G_ERROR);
} }
static void static void
@ -508,19 +521,15 @@ discoverer_discovered_cb (GstDiscoverer * discoverer,
GstDiscovererInfo * info, GError * err, GESTimeline * timeline) GstDiscovererInfo * info, GError * err, GESTimeline * timeline)
{ {
GList *tmp; GList *tmp;
GList *stream_list;
GESTrackType tfs_supportedformats;
gboolean found = FALSE; gboolean found = FALSE;
gboolean is_image = FALSE; gboolean is_image = FALSE;
GESTimelineFileSource *tfs = NULL; GESTimelineFileSource *tfs = NULL;
GESTimelinePrivate *priv = timeline->priv; GESTimelinePrivate *priv = timeline->priv;
const gchar *uri = gst_discoverer_info_get_uri (info); const gchar *uri = gst_discoverer_info_get_uri (info);
if (err) {
GST_WARNING ("Error while discovering %s: %s", uri, err->message);
return;
} else
GST_DEBUG ("Discovered uri %s", uri);
GES_TIMELINE_PENDINGOBJS_LOCK (timeline); GES_TIMELINE_PENDINGOBJS_LOCK (timeline);
/* Find corresponding TimelineFileSource in the sources */ /* Find corresponding TimelineFileSource in the sources */
@ -533,9 +542,29 @@ discoverer_discovered_cb (GstDiscoverer * discoverer,
} }
} }
if (found) { if (!found) {
GList *stream_list; GST_WARNING ("Discovered %s, that seems not to be in the list of sources"
GESTrackType tfs_supportedformats; "to discover", uri);
GES_TIMELINE_PENDINGOBJS_UNLOCK (timeline);
return;
}
if (err) {
GError *propagate_error = NULL;
priv->pendingobjects = g_list_delete_link (priv->pendingobjects, tmp);
GES_TIMELINE_PENDINGOBJS_UNLOCK (timeline);
GST_WARNING ("Error while discovering %s: %s", uri, err->message);
g_propagate_error (&propagate_error, err);
g_signal_emit (timeline, ges_timeline_signals[DISCOVERY_ERROR], 0, tfs,
propagate_error);
return;
}
/* Everything went fine... let's do our job! */
GST_DEBUG ("Discovered uri %s", uri);
/* The timeline file source will be updated with discovered information /* The timeline file source will be updated with discovered information
* so it needs to not be finalized during this process */ * so it needs to not be finalized during this process */
@ -558,12 +587,10 @@ discoverer_discovered_cb (GstDiscoverer * discoverer,
if (GST_IS_DISCOVERER_AUDIO_INFO (sinf)) { if (GST_IS_DISCOVERER_AUDIO_INFO (sinf)) {
tfs_supportedformats |= GES_TRACK_TYPE_AUDIO; tfs_supportedformats |= GES_TRACK_TYPE_AUDIO;
ges_timeline_filesource_set_supported_formats (tfs, ges_timeline_filesource_set_supported_formats (tfs, tfs_supportedformats);
tfs_supportedformats);
} else if (GST_IS_DISCOVERER_VIDEO_INFO (sinf)) { } else if (GST_IS_DISCOVERER_VIDEO_INFO (sinf)) {
tfs_supportedformats |= GES_TRACK_TYPE_VIDEO; tfs_supportedformats |= GES_TRACK_TYPE_VIDEO;
ges_timeline_filesource_set_supported_formats (tfs, ges_timeline_filesource_set_supported_formats (tfs, tfs_supportedformats);
tfs_supportedformats);
if (gst_discoverer_video_info_is_image ((GstDiscovererVideoInfo *) if (gst_discoverer_video_info_is_image ((GstDiscovererVideoInfo *)
sinf)) { sinf)) {
tfs_supportedformats |= GES_TRACK_TYPE_AUDIO; tfs_supportedformats |= GES_TRACK_TYPE_AUDIO;
@ -592,14 +619,8 @@ discoverer_discovered_cb (GstDiscoverer * discoverer,
gst_discoverer_info_get_duration (info), NULL); gst_discoverer_info_get_duration (info), NULL);
} }
/* Continue the processing on tfs */
add_object_to_tracks (timeline, GES_TIMELINE_OBJECT (tfs));
/* Remove the ref as the timeline file source is no longer needed here */ /* Remove the ref as the timeline file source is no longer needed here */
g_object_unref (tfs); g_object_unref (tfs);
} else {
GES_TIMELINE_PENDINGOBJS_UNLOCK (timeline);
}
} }
static GstStateChangeReturn static GstStateChangeReturn