[totem] Split out the subtitle loading



commit 9eab91849905a403ac9309351edba39a3fcb0995
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Jul 23 17:53:26 2009 +0100

    Split out the subtitle loading
    
    Split out the subtitle loading from _open() so it could
    eventually be handled on-the-fly (without reloading the movie
    itself).

 browser-plugin/totem-plugin-viewer.c      |    2 +-
 src/backend/bacon-video-widget-gst-0.10.c |   34 +++++++++++++++++++++-------
 src/backend/bacon-video-widget.h          |    3 +-
 src/backend/bvw-test.c                    |    2 +-
 src/totem-audio-preview.c                 |    2 +-
 src/totem-object.c                        |    5 ++-
 src/totem-properties-view.c               |    2 +-
 src/totem-video-indexer.c                 |    2 +-
 src/totem-video-thumbnailer.c             |    2 +-
 9 files changed, 36 insertions(+), 18 deletions(-)
---
diff --git a/browser-plugin/totem-plugin-viewer.c b/browser-plugin/totem-plugin-viewer.c
index f1809f5..1956473 100644
--- a/browser-plugin/totem-plugin-viewer.c
+++ b/browser-plugin/totem-plugin-viewer.c
@@ -478,7 +478,7 @@ totem_embedded_open_internal (TotemEmbedded *emb,
 
 	/* FIXME: remove |err| and rely on async on_error? */
 	g_message ("BEFORE _open");
-	retval = bacon_video_widget_open (emb->bvw, uri, NULL, &err);
+	retval = bacon_video_widget_open (emb->bvw, uri, &err);
 	g_message ("AFTER _open (ret: %d)", retval);
 	if (retval == FALSE)
 	{
diff --git a/src/backend/bacon-video-widget-gst-0.10.c b/src/backend/bacon-video-widget-gst-0.10.c
index 0a9d740..4d58592 100644
--- a/src/backend/bacon-video-widget-gst-0.10.c
+++ b/src/backend/bacon-video-widget-gst-0.10.c
@@ -3129,13 +3129,10 @@ error:
  * bacon_video_widget_open:
  * @bvw: a #BaconVideoWidget
  * @mrl: an MRL
- * @subtitle_uri: the URI of a subtitle file, or %NULL
  * @error: a #GError, or %NULL
  *
  * Opens the given @mrl in @bvw for playing. If @subtitle_uri is not %NULL, the given
- * subtitle file is also loaded. Alternatively, the subtitle URI can be passed in @mrl
- * by adding it after <literal>#subtitle:</literal>. For example:
- * <literal>http://example.com/video.mpg#subtitle:/home/user/subtitle.ass</literal>.
+ * subtitle file is also loaded.
  *
  * If there was a filesystem error, a %BVW_ERROR_GENERIC error will be returned. Otherwise,
  * more specific #BvwError errors will be returned.
@@ -3146,7 +3143,7 @@ error:
  **/
 gboolean
 bacon_video_widget_open (BaconVideoWidget * bvw,
-                         const gchar * mrl, const gchar *subtitle_uri, GError ** error)
+                         const gchar * mrl, GError ** error)
 {
   GstMessage *err_msg = NULL;
   GFile *file;
@@ -3164,8 +3161,7 @@ bacon_video_widget_open (BaconVideoWidget * bvw,
   }
   
   GST_DEBUG ("mrl = %s", GST_STR_NULL (mrl));
-  GST_DEBUG ("subtitle_uri = %s", GST_STR_NULL (subtitle_uri));
-  
+
   /* this allows non-URI type of files in the thumbnailer and so on */
   file = g_file_new_for_commandline_arg (mrl);
 
@@ -3222,8 +3218,7 @@ bacon_video_widget_open (BaconVideoWidget * bvw,
     setup_vis (bvw);
   }
 
-  g_object_set (bvw->priv->play, "uri", bvw->priv->mrl,
-                "suburi", subtitle_uri, NULL);
+  g_object_set (bvw->priv->play, "uri", bvw->priv->mrl, NULL);
 
   bvw->priv->seekable = -1;
   bvw->priv->target_state = GST_STATE_PAUSED;
@@ -3533,6 +3528,27 @@ bvw_do_navigation_command (BaconVideoWidget * bvw, GstNavigationCommand command)
   gst_object_unref (GST_OBJECT (nav));
 }
 
+/** bacon_video_widget_set_text_subtitle:
+ * @bvw: a #BaconVideoWidget
+ * @subtitle_uri: the URI of a subtitle file, or %NULL
+ *
+ * Sets the URI for the text subtitle file to be displayed alongside
+ * the current video. Use %NULL is you * want to unload the current text subtitle
+ * file  being used.
+ */
+void
+bacon_video_widget_set_text_subtitle (BaconVideoWidget * bvw,
+				      const gchar * subtitle_uri)
+{
+  g_return_if_fail (bvw != NULL);
+  g_return_if_fail (BACON_IS_VIDEO_WIDGET (bvw));
+  g_return_if_fail (GST_IS_ELEMENT (bvw->priv->play));
+  
+  GST_LOG ("Setting subtitle as %s", GST_STR_NULL (subtitle_uri));
+  g_object_set (bvw->priv->play, "suburi", subtitle_uri, NULL);
+}
+
+
 /**
  * bacon_video_widget_dvd_event:
  * @bvw: a #BaconVideoWidget
diff --git a/src/backend/bacon-video-widget.h b/src/backend/bacon-video-widget.h
index d4ffd0c..caf1b52 100644
--- a/src/backend/bacon-video-widget.h
+++ b/src/backend/bacon-video-widget.h
@@ -168,7 +168,6 @@ char *bacon_video_widget_get_backend_name (BaconVideoWidget *bvw);
 /* Actions */
 gboolean bacon_video_widget_open		 (BaconVideoWidget *bvw,
 						  const char *mrl,
-						  const char *subtitle_uri,
 						  GError **error);
 gboolean bacon_video_widget_play                 (BaconVideoWidget *bvw,
 						  GError **error);
@@ -200,6 +199,8 @@ void bacon_video_widget_set_volume               (BaconVideoWidget *bvw,
 double bacon_video_widget_get_volume             (BaconVideoWidget *bvw);
 
 /* Properties */
+void bacon_video_widget_set_text_subtitle	(BaconVideoWidget * bvw,
+						 const gchar * subtitle_uri);
 void bacon_video_widget_set_logo		 (BaconVideoWidget *bvw,
 						  const char *filename);
 void bacon_video_widget_set_logo_pixbuf		 (BaconVideoWidget *bvw,
diff --git a/src/backend/bvw-test.c b/src/backend/bvw-test.c
index 4cde296..b9e09a4 100644
--- a/src/backend/bvw-test.c
+++ b/src/backend/bvw-test.c
@@ -14,7 +14,7 @@ static void
 test_bvw_set_mrl (GtkWidget *bvw, const char *path)
 {
 	mrl = g_strdup (path);
-	bacon_video_widget_open (BACON_VIDEO_WIDGET (bvw), mrl, NULL, NULL);
+	bacon_video_widget_open (BACON_VIDEO_WIDGET (bvw), mrl, NULL);
 }
 
 static void
diff --git a/src/totem-audio-preview.c b/src/totem-audio-preview.c
index 4b4dd86..dc24b39 100644
--- a/src/totem-audio-preview.c
+++ b/src/totem-audio-preview.c
@@ -126,7 +126,7 @@ int main (int argc, char **argv)
 	bvw = BACON_VIDEO_WIDGET (widget);
 
 	totem_resources_monitor_start (NULL, -1);
-	if (bacon_video_widget_open (bvw, path, NULL, &error) == FALSE) {
+	if (bacon_video_widget_open (bvw, path, &error) == FALSE) {
 		g_print ("Can't open %s: %s\n", path, error->message);
 		return 1;
 	}
diff --git a/src/totem-object.c b/src/totem-object.c
index dda6db7..1485f35 100644
--- a/src/totem-object.c
+++ b/src/totem-object.c
@@ -1711,7 +1711,8 @@ totem_action_set_mrl_with_warning (Totem *totem,
 			autoload_sub = totem_uri_get_subtitle_uri (mrl);
 
 		totem_gdk_window_set_waiting_cursor (totem->win->window);
-		retval = bacon_video_widget_open (totem->bvw, mrl, subtitle ? subtitle : autoload_sub, &err);
+		retval = bacon_video_widget_open (totem->bvw, mrl, &err);
+		bacon_video_widget_set_text_subtitle (totem->bvw, subtitle ? subtitle : autoload_sub);
 		g_free (autoload_sub);
 		gdk_window_set_cursor (totem->win->window, NULL);
 		totem->mrl = g_strdup (mrl);
@@ -2363,7 +2364,7 @@ on_got_redirect (BaconVideoWidget *bvw, const char *mrl, Totem *totem)
 	bacon_video_widget_close (totem->bvw);
 	totem_file_closed (totem);
 	totem_gdk_window_set_waiting_cursor (totem->win->window);
-	bacon_video_widget_open (totem->bvw, new_mrl ? new_mrl : mrl, NULL, NULL);
+	bacon_video_widget_open (totem->bvw, new_mrl ? new_mrl : mrl, NULL);
 	totem_file_opened (totem, new_mrl ? new_mrl : mrl);
 	gdk_window_set_cursor (totem->win->window, NULL);
 	bacon_video_widget_play (bvw, NULL);
diff --git a/src/totem-properties-view.c b/src/totem-properties-view.c
index 07de850..a89de13 100644
--- a/src/totem-properties-view.c
+++ b/src/totem-properties-view.c
@@ -176,7 +176,7 @@ totem_properties_view_set_location (TotemPropertiesView *props,
 		bacon_video_widget_close (props->priv->bvw);
 		bacon_video_widget_properties_reset (props->priv->props);
 
-		if (bacon_video_widget_open (props->priv->bvw, location, NULL, &error) == FALSE) {
+		if (bacon_video_widget_open (props->priv->bvw, location, &error) == FALSE) {
 			g_warning ("Couldn't open %s: %s", location, error->message);
 			g_error_free (error);
 			return;
diff --git a/src/totem-video-indexer.c b/src/totem-video-indexer.c
index d9b3d44..51b6ff5 100644
--- a/src/totem-video-indexer.c
+++ b/src/totem-video-indexer.c
@@ -204,7 +204,7 @@ int main (int argc, char **argv)
 	path = filenames[0];
 	if (time_limit != FALSE)
 		totem_resources_monitor_start (path, 0);
-	if (bacon_video_widget_open (bvw, path, NULL, &error) == FALSE) {
+	if (bacon_video_widget_open (bvw, path, &error) == FALSE) {
 		g_print ("Can't open %s: %s\n", path, error->message);
 		return 1;
 	}
diff --git a/src/totem-video-thumbnailer.c b/src/totem-video-thumbnailer.c
index 3850c7a..904914e 100644
--- a/src/totem-video-thumbnailer.c
+++ b/src/totem-video-thumbnailer.c
@@ -843,7 +843,7 @@ int main (int argc, char *argv[])
 
 	PROGRESS_DEBUG("About to open video file");
 
-	if (bacon_video_widget_open (bvw, input, NULL, &err) == FALSE) {
+	if (bacon_video_widget_open (bvw, input, &err) == FALSE) {
 		g_print ("totem-video-thumbnailer couldn't open file '%s'\n"
 				"Reason: %s.\n",
 				input, err->message);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]