gst_plugins_base/gst/playback/gstplaybasebin.c
branchRCL_3
changeset 30 7e817e7e631c
parent 29 567bb019e3e3
equal deleted inserted replaced
29:567bb019e3e3 30:7e817e7e631c
    27 #include "gststreamselector.h"
    27 #include "gststreamselector.h"
    28 #include "gstplay-marshal.h"
    28 #include "gstplay-marshal.h"
    29 
    29 
    30 #include <gst/pbutils/pbutils.h>
    30 #include <gst/pbutils/pbutils.h>
    31 
    31 
       
    32 #ifdef __SYMBIAN32__
       
    33 #include <glib_global.h>
       
    34 #endif
       
    35 
    32 GST_DEBUG_CATEGORY_STATIC (gst_play_base_bin_debug);
    36 GST_DEBUG_CATEGORY_STATIC (gst_play_base_bin_debug);
    33 #define GST_CAT_DEFAULT gst_play_base_bin_debug
    37 #define GST_CAT_DEFAULT gst_play_base_bin_debug
    34 
    38 
    35 #define DEFAULT_QUEUE_SIZE          (3 * GST_SECOND)
    39 #define DEFAULT_QUEUE_SIZE          (3 * GST_SECOND)
    36 #define DEFAULT_QUEUE_MIN_THRESHOLD ((DEFAULT_QUEUE_SIZE * 30) / 100)
    40 #define DEFAULT_QUEUE_MIN_THRESHOLD ((DEFAULT_QUEUE_SIZE * 30) / 100)
   147   gobject_klass->set_property = gst_play_base_bin_set_property;
   151   gobject_klass->set_property = gst_play_base_bin_set_property;
   148   gobject_klass->get_property = gst_play_base_bin_get_property;
   152   gobject_klass->get_property = gst_play_base_bin_get_property;
   149 
   153 
   150   g_object_class_install_property (gobject_klass, ARG_URI,
   154   g_object_class_install_property (gobject_klass, ARG_URI,
   151       g_param_spec_string ("uri", "URI", "URI of the media to play",
   155       g_param_spec_string ("uri", "URI", "URI of the media to play",
   152           NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
   156           NULL, G_PARAM_READWRITE));
   153   g_object_class_install_property (gobject_klass, ARG_SUBURI,
   157   g_object_class_install_property (gobject_klass, ARG_SUBURI,
   154       g_param_spec_string ("suburi", ".sub-URI", "Optional URI of a subtitle",
   158       g_param_spec_string ("suburi", ".sub-URI", "Optional URI of a subtitle",
   155           NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
   159           NULL, G_PARAM_READWRITE));
   156 
   160 
   157   g_object_class_install_property (gobject_klass, ARG_QUEUE_SIZE,
   161   g_object_class_install_property (gobject_klass, ARG_QUEUE_SIZE,
   158       g_param_spec_uint64 ("queue-size", "Queue size",
   162       g_param_spec_uint64 ("queue-size", "Queue size",
   159           "Size of internal queues in nanoseconds", 0, G_MAXINT64,
   163           "Size of internal queues in nanoseconds", 0, G_MAXINT64,
   160           DEFAULT_QUEUE_SIZE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
   164           DEFAULT_QUEUE_SIZE, G_PARAM_READWRITE));
   161   g_object_class_install_property (gobject_klass, ARG_QUEUE_THRESHOLD,
   165   g_object_class_install_property (gobject_klass, ARG_QUEUE_THRESHOLD,
   162       g_param_spec_uint64 ("queue-threshold", "Queue threshold",
   166       g_param_spec_uint64 ("queue-threshold", "Queue threshold",
   163           "Buffering threshold of internal queues in nanoseconds", 0,
   167           "Buffering threshold of internal queues in nanoseconds", 0,
   164           G_MAXINT64, DEFAULT_QUEUE_THRESHOLD,
   168           G_MAXINT64, DEFAULT_QUEUE_THRESHOLD, G_PARAM_READWRITE));
   165           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
       
   166   g_object_class_install_property (gobject_klass, ARG_QUEUE_MIN_THRESHOLD,
   169   g_object_class_install_property (gobject_klass, ARG_QUEUE_MIN_THRESHOLD,
   167       g_param_spec_uint64 ("queue-min-threshold", "Queue min threshold",
   170       g_param_spec_uint64 ("queue-min-threshold", "Queue min threshold",
   168           "Buffering low threshold of internal queues in nanoseconds", 0,
   171           "Buffering low threshold of internal queues in nanoseconds", 0,
   169           G_MAXINT64, DEFAULT_QUEUE_MIN_THRESHOLD,
   172           G_MAXINT64, DEFAULT_QUEUE_MIN_THRESHOLD, G_PARAM_READWRITE));
   170           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
       
   171 
   173 
   172   g_object_class_install_property (gobject_klass, ARG_NSTREAMS,
   174   g_object_class_install_property (gobject_klass, ARG_NSTREAMS,
   173       g_param_spec_int ("nstreams", "NStreams", "number of streams",
   175       g_param_spec_int ("nstreams", "NStreams", "number of streams",
   174           0, G_MAXINT, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
   176           0, G_MAXINT, 0, G_PARAM_READABLE));
   175   g_object_class_install_property (gobject_klass, ARG_STREAMINFO,
   177   g_object_class_install_property (gobject_klass, ARG_STREAMINFO,
   176       g_param_spec_pointer ("stream-info", "Stream info", "List of streaminfo",
   178       g_param_spec_pointer ("stream-info", "Stream info", "List of streaminfo",
   177           G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
   179           G_PARAM_READABLE));
   178   g_object_class_install_property (gobject_klass, ARG_STREAMINFO_VALUES,
   180   g_object_class_install_property (gobject_klass, ARG_STREAMINFO_VALUES,
   179       g_param_spec_value_array ("stream-info-value-array",
   181       g_param_spec_value_array ("stream-info-value-array",
   180           "StreamInfo GValueArray", "value array of streaminfo",
   182           "StreamInfo GValueArray", "value array of streaminfo",
   181           g_param_spec_object ("streaminfo", "StreamInfo", "Streaminfo object",
   183           g_param_spec_object ("streaminfo", "StreamInfo", "Streaminfo object",
   182               GST_TYPE_STREAM_INFO, G_PARAM_READABLE),
   184               GST_TYPE_STREAM_INFO, G_PARAM_READABLE), G_PARAM_READABLE));
   183           G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
       
   184   g_object_class_install_property (gobject_klass, ARG_SOURCE,
   185   g_object_class_install_property (gobject_klass, ARG_SOURCE,
   185       g_param_spec_object ("source", "Source", "Source element",
   186       g_param_spec_object ("source", "Source", "Source element",
   186           GST_TYPE_ELEMENT, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
   187           GST_TYPE_ELEMENT, G_PARAM_READABLE));
   187 
   188 
   188   g_object_class_install_property (gobject_klass, ARG_VIDEO,
   189   g_object_class_install_property (gobject_klass, ARG_VIDEO,
   189       g_param_spec_int ("current-video", "Current video",
   190       g_param_spec_int ("current-video", "Current video",
   190           "Currently playing video stream (-1 = none)",
   191           "Currently playing video stream (-1 = none)",
   191           -1, G_MAXINT, -1, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
   192           -1, G_MAXINT, -1, G_PARAM_READWRITE));
   192   g_object_class_install_property (gobject_klass, ARG_AUDIO,
   193   g_object_class_install_property (gobject_klass, ARG_AUDIO,
   193       g_param_spec_int ("current-audio", "Current audio",
   194       g_param_spec_int ("current-audio", "Current audio",
   194           "Currently playing audio stream (-1 = none)",
   195           "Currently playing audio stream (-1 = none)",
   195           -1, G_MAXINT, -1, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
   196           -1, G_MAXINT, -1, G_PARAM_READWRITE));
   196   g_object_class_install_property (gobject_klass, ARG_TEXT,
   197   g_object_class_install_property (gobject_klass, ARG_TEXT,
   197       g_param_spec_int ("current-text", "Current text",
   198       g_param_spec_int ("current-text", "Current text",
   198           "Currently playing text stream (-1 = none)",
   199           "Currently playing text stream (-1 = none)",
   199           -1, G_MAXINT, -1, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
   200           -1, G_MAXINT, -1, G_PARAM_READWRITE));
   200   g_object_class_install_property (gobject_klass, ARG_SUBTITLE_ENCODING,
   201   g_object_class_install_property (gobject_klass, ARG_SUBTITLE_ENCODING,
   201       g_param_spec_string ("subtitle-encoding", "subtitle encoding",
   202       g_param_spec_string ("subtitle-encoding", "subtitle encoding",
   202           "Encoding to assume if input subtitles are not in UTF-8 encoding. "
   203           "Encoding to assume if input subtitles are not in UTF-8 encoding. "
   203           "If not set, the GST_SUBTITLE_ENCODING environment variable will "
   204           "If not set, the GST_SUBTITLE_ENCODING environment variable will "
   204           "be checked for an encoding to use. If that is not set either, "
   205           "be checked for an encoding to use. If that is not set either, "
   205           "ISO-8859-15 will be assumed.", NULL,
   206           "ISO-8859-15 will be assumed.", NULL, G_PARAM_READWRITE));
   206           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
       
   207   /**
   207   /**
   208    * GstPlayBaseBin:connection-speed
   208    * GstPlayBin::connection-speed
   209    *
   209    *
   210    * Network connection speed in kbps (0 = unknown)
   210    * Network connection speed in kbps (0 = unknown)
   211    * <note><simpara>
       
   212    * Since version 0.10.10 in #GstPlayBin, at 0.10.15 moved to #GstPlayBaseBin
       
   213    * </simpara></note>
       
   214    *
   211    *
   215    * Since: 0.10.10
   212    * Since: 0.10.10 at gstplaybin.c, 0.10.15 moved to gstplaybasebin
   216    */
   213    **/
   217   g_object_class_install_property (gobject_klass, ARG_CONNECTION_SPEED,
   214   g_object_class_install_property (gobject_klass, ARG_CONNECTION_SPEED,
   218       g_param_spec_uint ("connection-speed", "Connection Speed",
   215       g_param_spec_uint ("connection-speed", "Connection Speed",
   219           "Network connection speed in kbps (0 = unknown)",
   216           "Network connection speed in kbps (0 = unknown)",
   220           0, G_MAXUINT, DEFAULT_CONNECTION_SPEED,
   217           0, G_MAXUINT, DEFAULT_CONNECTION_SPEED, G_PARAM_READWRITE));
   221           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
       
   222 
   218 
   223   GST_DEBUG_CATEGORY_INIT (gst_play_base_bin_debug, "playbasebin", 0,
   219   GST_DEBUG_CATEGORY_INIT (gst_play_base_bin_debug, "playbasebin", 0,
   224       "playbasebin");
   220       "playbasebin");
   225 
   221 
   226   gobject_klass->dispose = GST_DEBUG_FUNCPTR (gst_play_base_bin_dispose);
   222   gobject_klass->dispose = GST_DEBUG_FUNCPTR (gst_play_base_bin_dispose);
   488       return;
   484       return;
   489     }
   485     }
   490 
   486 
   491     setup_substreams (play_base_bin);
   487     setup_substreams (play_base_bin);
   492     GST_DEBUG_OBJECT (play_base_bin, "Emitting signal");
   488     GST_DEBUG_OBJECT (play_base_bin, "Emitting signal");
   493     res =
   489     res = GST_PLAY_BASE_BIN_GET_CLASS (play_base_bin)->
   494         GST_PLAY_BASE_BIN_GET_CLASS (play_base_bin)->setup_output_pads
   490         setup_output_pads (play_base_bin, group);
   495         (play_base_bin, group);
       
   496     GST_DEBUG_OBJECT (play_base_bin, "done");
   491     GST_DEBUG_OBJECT (play_base_bin, "done");
   497 
   492 
   498     GROUP_UNLOCK (play_base_bin);
   493     GROUP_UNLOCK (play_base_bin);
   499 
   494 
   500     g_object_notify (G_OBJECT (play_base_bin), "stream-info");
   495     g_object_notify (G_OBJECT (play_base_bin), "stream-info");
   634 {
   629 {
   635   gpointer data;
   630   gpointer data;
   636   GstPad *sinkpad;
   631   GstPad *sinkpad;
   637 
   632 
   638   data = g_object_get_data (G_OBJECT (queue), "probe");
   633   data = g_object_get_data (G_OBJECT (queue), "probe");
   639   sinkpad = gst_element_get_static_pad (queue, "sink");
   634   sinkpad = gst_element_get_pad (queue, "sink");
   640 
   635 
   641   if (data) {
   636   if (data) {
   642     GST_DEBUG_OBJECT (play_base_bin,
   637     GST_DEBUG_OBJECT (play_base_bin,
   643         "Removing buffer probe from pad %s:%s (%p)",
   638         "Removing buffer probe from pad %s:%s (%p)",
   644         GST_DEBUG_PAD_NAME (sinkpad), sinkpad);
   639         GST_DEBUG_PAD_NAME (sinkpad), sinkpad);
   758    * buffered and is posted in the BUFFERING message. */
   753    * buffered and is posted in the BUFFERING message. */
   759   if (!g_object_get_data (G_OBJECT (queue), "probe")) {
   754   if (!g_object_get_data (G_OBJECT (queue), "probe")) {
   760     GstPad *sinkpad;
   755     GstPad *sinkpad;
   761     guint id;
   756     guint id;
   762 
   757 
   763     sinkpad = gst_element_get_static_pad (queue, "sink");
   758     sinkpad = gst_element_get_pad (queue, "sink");
   764     id = gst_pad_add_buffer_probe (sinkpad, G_CALLBACK (check_queue), queue);
   759     id = gst_pad_add_buffer_probe (sinkpad, G_CALLBACK (check_queue), queue);
   765     g_object_set_data (G_OBJECT (queue), "probe", GINT_TO_POINTER (id));
   760     g_object_set_data (G_OBJECT (queue), "probe", GINT_TO_POINTER (id));
   766     GST_DEBUG_OBJECT (play_base_bin,
   761     GST_DEBUG_OBJECT (play_base_bin,
   767         "Re-attaching buffering probe to pad %s:%s %p",
   762         "Re-attaching buffering probe to pad %s:%s %p",
   768         GST_DEBUG_PAD_NAME (sinkpad), sinkpad);
   763         GST_DEBUG_PAD_NAME (sinkpad), sinkpad);
   797     prename = "video";
   792     prename = "video";
   798   else if (type == GST_STREAM_TYPE_TEXT)
   793   else if (type == GST_STREAM_TYPE_TEXT)
   799     prename = "text";
   794     prename = "text";
   800   else if (type == GST_STREAM_TYPE_AUDIO)
   795   else if (type == GST_STREAM_TYPE_AUDIO)
   801     prename = "audio";
   796     prename = "audio";
   802   else if (type == GST_STREAM_TYPE_SUBPICTURE)
       
   803     prename = "subpicture";
       
   804   else
   797   else
   805     g_return_if_reached ();
   798     g_return_if_reached ();
   806 
   799 
   807   /* create stream selector */
   800   /* create stream selector */
   808   selector = g_object_new (GST_TYPE_STREAM_SELECTOR, NULL);
   801   selector = g_object_new (GST_TYPE_STREAM_SELECTOR, NULL);
   828    * we can then easily do time-based buffering. The better
   821    * we can then easily do time-based buffering. The better
   829    * solution would be to add a specific network queue right
   822    * solution would be to add a specific network queue right
   830    * after the source that measures the datarate and scales this
   823    * after the source that measures the datarate and scales this
   831    * queue of encoded data instead.
   824    * queue of encoded data instead.
   832    */
   825    */
   833   if (play_base_bin->raw_decoding_mode) {
   826   g_object_set (G_OBJECT (preroll),
   834     if (type == GST_STREAM_TYPE_VIDEO) {
   827       "max-size-buffers", 0, "max-size-bytes",
   835       g_object_set (G_OBJECT (preroll),
   828       ((type == GST_STREAM_TYPE_VIDEO) ? 25 : 2) * 1024 * 1024,
   836           "max-size-buffers", 2, "max-size-bytes", 0,
   829       "max-size-time", play_base_bin->queue_size, NULL);
   837           "max-size-time", (guint64) 0, NULL);
       
   838     } else {
       
   839       g_object_set (G_OBJECT (preroll),
       
   840           "max-size-buffers", 0, "max-size-bytes",
       
   841           2 * 1024 * 1024, "max-size-time", play_base_bin->queue_size, NULL);
       
   842     }
       
   843   } else {
       
   844     g_object_set (G_OBJECT (preroll),
       
   845         "max-size-buffers", 0, "max-size-bytes",
       
   846         ((type == GST_STREAM_TYPE_VIDEO) ? 25 : 2) * 1024 * 1024,
       
   847         "max-size-time", play_base_bin->queue_size, NULL);
       
   848   }
       
   849 
   830 
   850   /* the overrun signal is always attached and serves two purposes:
   831   /* the overrun signal is always attached and serves two purposes:
   851    *
   832    *
   852    *  1) when we are building a group and the overrun is called, we commit the 
   833    *  1) when we are building a group and the overrun is called, we commit the 
   853    *     group. The reason being that if we fill the entire queue without a
   834    *     group. The reason being that if we fill the entire queue without a
   883 
   864 
   884     /* attach pointer to playbasebin */
   865     /* attach pointer to playbasebin */
   885     g_object_set_data (G_OBJECT (preroll), "pbb", play_base_bin);
   866     g_object_set_data (G_OBJECT (preroll), "pbb", play_base_bin);
   886 
   867 
   887     /* give updates on queue size */
   868     /* give updates on queue size */
   888     sinkpad = gst_element_get_static_pad (preroll, "sink");
   869     sinkpad = gst_element_get_pad (preroll, "sink");
   889     id = gst_pad_add_buffer_probe (sinkpad, G_CALLBACK (check_queue), preroll);
   870     id = gst_pad_add_buffer_probe (sinkpad, G_CALLBACK (check_queue), preroll);
   890     GST_DEBUG_OBJECT (play_base_bin, "Attaching probe to pad %s:%s (%p)",
   871     GST_DEBUG_OBJECT (play_base_bin, "Attaching probe to pad %s:%s (%p)",
   891         GST_DEBUG_PAD_NAME (sinkpad), sinkpad);
   872         GST_DEBUG_PAD_NAME (sinkpad), sinkpad);
       
   873     gst_object_unref (sinkpad);
   892     g_object_set_data (G_OBJECT (preroll), "probe", GINT_TO_POINTER (id));
   874     g_object_set_data (G_OBJECT (preroll), "probe", GINT_TO_POINTER (id));
   893 
   875 
   894     /* catch eos and flush events so that we can ignore underruns */
   876     /* catch eos and flush events so that we can ignore underruns */
   895     id = gst_pad_add_event_probe (sinkpad, G_CALLBACK (check_queue_event),
   877     id = gst_pad_add_event_probe (sinkpad, G_CALLBACK (check_queue_event),
   896         preroll);
   878         preroll);
   897     g_object_set_data (G_OBJECT (preroll), "eos_probe", GINT_TO_POINTER (id));
   879     g_object_set_data (G_OBJECT (preroll), "eos_probe", GINT_TO_POINTER (id));
   898 
       
   899     gst_object_unref (sinkpad);
       
   900 
   880 
   901     /* When we connect this queue, it will start running and immediatly
   881     /* When we connect this queue, it will start running and immediatly
   902      * fire an underrun. */
   882      * fire an underrun. */
   903     g_signal_connect (G_OBJECT (preroll), "underrun",
   883     g_signal_connect (G_OBJECT (preroll), "underrun",
   904         G_CALLBACK (queue_out_of_data), play_base_bin);
   884         G_CALLBACK (queue_out_of_data), play_base_bin);
   905     /* configure threshold and callbacks */
   885     /* configure threshold and callbacks */
   906     queue_out_of_data (preroll, play_base_bin);
   886     queue_out_of_data (preroll, play_base_bin);
   907   }
   887   }
   908 
   888 
   909   /* listen for EOS so we can switch groups when one ended. */
   889   /* listen for EOS so we can switch groups when one ended. */
   910   preroll_pad = gst_element_get_static_pad (preroll, "src");
   890   preroll_pad = gst_element_get_pad (preroll, "src");
   911   gst_pad_add_event_probe (preroll_pad, G_CALLBACK (probe_triggered), info);
   891   gst_pad_add_event_probe (preroll_pad, G_CALLBACK (probe_triggered), info);
   912   gst_object_unref (preroll_pad);
   892   gst_object_unref (preroll_pad);
   913 
   893 
   914   /* add to group list */
   894   /* add to group list */
   915   group->type[type - 1].selector = selector;
   895   group->type[type - 1].selector = selector;
  1235 
  1215 
  1236       /* now activate the next one */
  1216       /* now activate the next one */
  1237       setup_substreams (play_base_bin);
  1217       setup_substreams (play_base_bin);
  1238       GST_DEBUG ("switching to next group %p - emitting signal", group);
  1218       GST_DEBUG ("switching to next group %p - emitting signal", group);
  1239       /* and signal the new group */
  1219       /* and signal the new group */
  1240       res =
  1220       res = GST_PLAY_BASE_BIN_GET_CLASS (play_base_bin)->
  1241           GST_PLAY_BASE_BIN_GET_CLASS (play_base_bin)->setup_output_pads
  1221           setup_output_pads (play_base_bin, group);
  1242           (play_base_bin, group);
       
  1243 
  1222 
  1244       GROUP_UNLOCK (play_base_bin);
  1223       GROUP_UNLOCK (play_base_bin);
  1245 
  1224 
  1246       g_object_notify (G_OBJECT (play_base_bin), "stream-info");
  1225       g_object_notify (G_OBJECT (play_base_bin), "stream-info");
  1247 
  1226 
  1268   guint sig_id;
  1247   guint sig_id;
  1269   GstPad *srcpad;
  1248   GstPad *srcpad;
  1270 
  1249 
  1271   /* make a fakesrc that will just emit one EOS */
  1250   /* make a fakesrc that will just emit one EOS */
  1272   fakesrc = gst_element_factory_make ("fakesrc", NULL);
  1251   fakesrc = gst_element_factory_make ("fakesrc", NULL);
  1273   g_object_set (G_OBJECT (fakesrc), "num-buffers", 0, NULL);
  1252   g_object_set (G_OBJECT (fakesrc), "num_buffers", 0, NULL);
  1274 
  1253 
  1275   GST_DEBUG ("patching unlinked pad %s:%s", GST_DEBUG_PAD_NAME (pad));
  1254   GST_DEBUG ("patching unlinked pad %s:%s", GST_DEBUG_PAD_NAME (pad));
  1276 
  1255 
  1277   srcpad = gst_element_get_static_pad (fakesrc, "src");
  1256   srcpad = gst_element_get_pad (fakesrc, "src");
  1278   gst_bin_add (GST_BIN_CAST (play_base_bin), fakesrc);
  1257   gst_bin_add (GST_BIN_CAST (play_base_bin), fakesrc);
  1279   gst_pad_link (srcpad, pad);
  1258   gst_pad_link (srcpad, pad);
  1280   gst_object_unref (srcpad);
  1259   gst_object_unref (srcpad);
  1281 
  1260 
  1282   /* keep track of these patch elements */
  1261   /* keep track of these patch elements */
  1359 
  1338 
  1360   parent = gst_object_get_parent (GST_OBJECT_CAST (element));
  1339   parent = gst_object_get_parent (GST_OBJECT_CAST (element));
  1361   if (g_str_has_prefix (mimetype, "audio/") &&
  1340   if (g_str_has_prefix (mimetype, "audio/") &&
  1362       parent != GST_OBJECT_CAST (play_base_bin->subtitle)) {
  1341       parent != GST_OBJECT_CAST (play_base_bin->subtitle)) {
  1363     type = GST_STREAM_TYPE_AUDIO;
  1342     type = GST_STREAM_TYPE_AUDIO;
  1364   } else if (g_str_has_prefix (mimetype, "video/x-dvd-subpicture") &&
       
  1365       parent != GST_OBJECT_CAST (play_base_bin->subtitle)) {
       
  1366     type = GST_STREAM_TYPE_SUBPICTURE;
       
  1367   } else if (g_str_has_prefix (mimetype, "video/") &&
  1343   } else if (g_str_has_prefix (mimetype, "video/") &&
  1368       parent != GST_OBJECT_CAST (play_base_bin->subtitle)) {
  1344       parent != GST_OBJECT_CAST (play_base_bin->subtitle)) {
  1369     type = GST_STREAM_TYPE_VIDEO;
  1345     type = GST_STREAM_TYPE_VIDEO;
  1370   } else if (g_str_has_prefix (mimetype, "text/")) {
  1346   } else if (g_str_has_prefix (mimetype, "text/")) {
  1371     type = GST_STREAM_TYPE_TEXT;
  1347     type = GST_STREAM_TYPE_TEXT;
  1594   "application/zip", "application/x-compress", NULL
  1570   "application/zip", "application/x-compress", NULL
  1595 };
  1571 };
  1596 
  1572 
  1597 /* mime types we consider raw media */
  1573 /* mime types we consider raw media */
  1598 static const gchar *raw_mimes[] = {
  1574 static const gchar *raw_mimes[] = {
  1599   "audio/x-raw", "video/x-raw", "video/x-dvd-subpicture", NULL
  1575   "audio/x-raw", "video/x-raw", NULL
  1600 };
  1576 };
  1601 
  1577 
  1602 #define IS_STREAM_URI(uri)          (array_has_value (stream_uris, uri))
  1578 #define IS_STREAM_URI(uri)          (array_has_value (stream_uris, uri))
  1603 #define IS_BLACKLISTED_URI(uri)     (array_has_value (blacklisted_uris, uri))
  1579 #define IS_BLACKLISTED_URI(uri)     (array_has_value (blacklisted_uris, uri))
  1604 #define IS_NO_MEDIA_MIME(mime)      (array_has_value (no_media_mimes, mime))
  1580 #define IS_NO_MEDIA_MIME(mime)      (array_has_value (no_media_mimes, mime))
  1712   GST_DEBUG_OBJECT (bin, "Found new pad %s.%s in source element %s",
  1688   GST_DEBUG_OBJECT (bin, "Found new pad %s.%s in source element %s",
  1713       GST_DEBUG_PAD_NAME (pad), GST_ELEMENT_NAME (element));
  1689       GST_DEBUG_PAD_NAME (pad), GST_ELEMENT_NAME (element));
  1714 
  1690 
  1715   /* if this is a pad with all raw caps, we can expose it */
  1691   /* if this is a pad with all raw caps, we can expose it */
  1716   if (has_all_raw_caps (pad, &is_raw) && is_raw) {
  1692   if (has_all_raw_caps (pad, &is_raw) && is_raw) {
  1717     bin->raw_decoding_mode = TRUE;
       
  1718     /* it's all raw, create output pads. */
  1693     /* it's all raw, create output pads. */
  1719     new_decoded_pad_full (element, pad, FALSE, bin, FALSE);
  1694     new_decoded_pad_full (element, pad, FALSE, bin, FALSE);
  1720     return;
  1695     return;
  1721   }
  1696   }
  1722 
  1697 
  1962 
  1937 
  1963   for (walk = bin->decoders; walk; walk = g_slist_next (walk)) {
  1938   for (walk = bin->decoders; walk; walk = g_slist_next (walk)) {
  1964     GstElement *decoder = GST_ELEMENT_CAST (walk->data);
  1939     GstElement *decoder = GST_ELEMENT_CAST (walk->data);
  1965 
  1940 
  1966     GST_DEBUG_OBJECT (bin, "removing old decoder element");
  1941     GST_DEBUG_OBJECT (bin, "removing old decoder element");
  1967     /* Disconnect all the signal handlers we attached to the decodebin before
       
  1968      * we dispose of it */
       
  1969     g_signal_handlers_disconnect_by_func (decoder,
       
  1970         (gpointer) (decodebin_element_added_cb), bin);
       
  1971     g_signal_handlers_disconnect_by_func (decoder,
       
  1972         (gpointer) (decodebin_element_removed_cb), bin);
       
  1973     g_signal_handlers_disconnect_by_func (decoder,
       
  1974         (gpointer) (new_decoded_pad), bin);
       
  1975     g_signal_handlers_disconnect_by_func (decoder,
       
  1976         (gpointer) (no_more_pads), bin);
       
  1977     g_signal_handlers_disconnect_by_func (decoder,
       
  1978         (gpointer) (unknown_type), bin);
       
  1979 
       
  1980     gst_element_set_state (decoder, GST_STATE_NULL);
  1942     gst_element_set_state (decoder, GST_STATE_NULL);
  1981     gst_bin_remove (GST_BIN_CAST (bin), decoder);
  1943     gst_bin_remove (GST_BIN_CAST (bin), decoder);
  1982   }
  1944   }
  1983   g_slist_free (bin->decoders);
  1945   g_slist_free (bin->decoders);
  1984   bin->decoders = NULL;
  1946   bin->decoders = NULL;
  2081   GstElement *subbin = NULL;
  2043   GstElement *subbin = NULL;
  2082   gboolean is_raw, have_out, is_dynamic;
  2044   gboolean is_raw, have_out, is_dynamic;
  2083 
  2045 
  2084   if (!play_base_bin->need_rebuild)
  2046   if (!play_base_bin->need_rebuild)
  2085     return TRUE;
  2047     return TRUE;
  2086   play_base_bin->raw_decoding_mode = FALSE;
       
  2087 
  2048 
  2088   GST_DEBUG_OBJECT (play_base_bin, "setup source");
  2049   GST_DEBUG_OBJECT (play_base_bin, "setup source");
  2089 
  2050 
  2090   /* delete old src */
  2051   /* delete old src */
  2091   remove_source (play_base_bin);
  2052   remove_source (play_base_bin);
  2385 mute_group_type (GstPlayBaseGroup * group, GstStreamType type, gboolean mute)
  2346 mute_group_type (GstPlayBaseGroup * group, GstStreamType type, gboolean mute)
  2386 {
  2347 {
  2387   gboolean active = !mute;
  2348   gboolean active = !mute;
  2388   GstPad *pad;
  2349   GstPad *pad;
  2389 
  2350 
  2390   pad = gst_element_get_static_pad (group->type[type - 1].preroll, "src");
  2351   pad = gst_element_get_pad (group->type[type - 1].preroll, "src");
  2391   gst_pad_set_active (pad, active);
  2352   gst_pad_set_active (pad, active);
  2392   gst_object_unref (pad);
  2353   gst_object_unref (pad);
  2393   pad = gst_element_get_static_pad (group->type[type - 1].preroll, "sink");
  2354   pad = gst_element_get_pad (group->type[type - 1].preroll, "sink");
  2394   gst_pad_set_active (pad, active);
  2355   gst_pad_set_active (pad, active);
  2395   gst_object_unref (pad);
  2356   gst_object_unref (pad);
  2396   pad = gst_element_get_static_pad (group->type[type - 1].selector, "src");
  2357   pad = gst_element_get_pad (group->type[type - 1].selector, "src");
  2397   gst_pad_set_active (pad, active);
  2358   gst_pad_set_active (pad, active);
  2398   gst_object_unref (pad);
  2359   gst_object_unref (pad);
  2399 
  2360 
  2400 #if 0
  2361 #if 0
  2401   if (mute) {
  2362   if (mute) {
  2440    * textoverlay element, but playbin does */
  2401    * textoverlay element, but playbin does */
  2441   if (klass != NULL && klass->set_subtitles_visible != NULL)
  2402   if (klass != NULL && klass->set_subtitles_visible != NULL)
  2442     klass->set_subtitles_visible (play_base_bin, visible);
  2403     klass->set_subtitles_visible (play_base_bin, visible);
  2443 }
  2404 }
  2444 
  2405 
  2445 static void
       
  2446 set_audio_mute (GstPlayBaseBin * play_base_bin, gboolean mute)
       
  2447 {
       
  2448   GstPlayBaseBinClass *klass = GST_PLAY_BASE_BIN_GET_CLASS (play_base_bin);
       
  2449 
       
  2450   /* we use a vfunc for this since we don't have a reference to the
       
  2451    * textoverlay element, but playbin does */
       
  2452   if (klass != NULL && klass->set_audio_mute != NULL)
       
  2453     klass->set_audio_mute (play_base_bin, mute);
       
  2454 }
       
  2455 
       
  2456 /*
  2406 /*
  2457  * Caller has group-lock held.
  2407  * Caller has group-lock held.
  2458  */
  2408  */
  2459 
  2409 
  2460 static void
  2410 static void
  2482   if (type == GST_STREAM_TYPE_TEXT) {
  2432   if (type == GST_STREAM_TYPE_TEXT) {
  2483     gboolean visible = (source_num != -1);
  2433     gboolean visible = (source_num != -1);
  2484 
  2434 
  2485     set_subtitles_visible (play_base_bin, visible);
  2435     set_subtitles_visible (play_base_bin, visible);
  2486     if (!visible)
  2436     if (!visible)
  2487       return;
       
  2488   } else if (type == GST_STREAM_TYPE_AUDIO) {
       
  2489     gboolean mute = (source_num == -1);
       
  2490 
       
  2491     set_audio_mute (play_base_bin, mute);
       
  2492 
       
  2493     if (mute)
       
  2494       return;
  2437       return;
  2495   }
  2438   }
  2496 
  2439 
  2497   sel = group->type[type - 1].selector;
  2440   sel = group->type[type - 1].selector;
  2498 
  2441