2005-05-12 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
+ * gst/playback/gstdecodebin.c: (gst_decode_bin_class_init),
+ (try_to_link_1):
+ * gst/playback/gstplaybasebin.c: (gst_play_base_bin_class_init),
+ (group_commit), (probe_triggered), (setup_source),
+ (gst_play_base_bin_change_state):
+ * gst/playback/gstplaybasebin.h:
+ * gst/playback/gstplaybin.c: (gst_play_bin_class_init),
+ (gst_play_bin_init), (remove_sinks), (setup_sinks),
+ (gst_play_bin_change_state):
+ Move setup_output_pads into a virtual function, remove
+ group-switch (no longer needed) and redirect (handled by bus
+ now) signals.
+
+2005-05-12 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
+
* gst/playback/gstplaybasebin.c: (gst_play_base_bin_get_type),
(gst_play_base_bin_class_init), (gst_play_base_bin_finalize),
(get_active_group), (get_building_group), (group_destroy),
void (*removed_decoded_pad) (GstElement * element, GstPad * pad);
/* signal fired when we found a pad that we cannot decode */
void (*unknown_type) (GstElement * element, GstPad * pad, GstCaps * caps);
- /* signal fired when we got a redirect attempt */
- void (*got_redirect) (GstElement * element, const gchar * new_location);
};
#define DEFAULT_THREADED FALSE
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstDecodeBinClass, unknown_type),
NULL, NULL, gst_marshal_VOID__OBJECT_BOXED, G_TYPE_NONE, 2,
GST_TYPE_PAD, GST_TYPE_CAPS);
- gst_decode_bin_signals[SIGNAL_REDIRECT] =
- g_signal_new ("got-redirect", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstDecodeBinClass, got_redirect),
- NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1,
- G_TYPE_STRING);
gobject_klass->dispose = GST_DEBUG_FUNCPTR (gst_decode_bin_dispose);
}
}
-/*
- * Called when we're redirected to a new URI.
- */
-static void
-got_redirect (GstElement * element,
- const gchar * new_location, GstDecodeBin * decode_bin)
-{
- g_signal_emit (decode_bin, gst_decode_bin_signals[SIGNAL_REDIRECT], 0,
- new_location);
-}
-
/**
* given a list of element factories, try to link one of the factories
* to the given pad.
* because that would consume less memory. */
}
}
- /* catch redirects */
- if (g_signal_lookup ("got-redirect", G_OBJECT_TYPE (element))) {
- g_signal_connect (element, "got-redirect",
- G_CALLBACK (got_redirect), decode_bin);
- }
/* make sure we catch unlink signals */
sig = g_signal_connect (G_OBJECT (GST_PAD_REALIZE (pad)), "unlinked",
/* signals */
enum
{
- SIGNAL_SETUP_OUTPUT_PADS,
SIGNAL_BUFFERING,
- SIGNAL_GROUP_SWITCH,
- SIGNAL_REDIRECT,
LAST_SIGNAL
};
"playbasebin");
/* signals */
- gst_play_base_bin_signals[SIGNAL_SETUP_OUTPUT_PADS] =
- g_signal_new ("setup-output-pads", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstPlayBaseBinClass, setup_output_pads),
- NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
gst_play_base_bin_signals[SIGNAL_BUFFERING] =
g_signal_new ("buffering", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstPlayBaseBinClass, buffering),
NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
- gst_play_base_bin_signals[SIGNAL_GROUP_SWITCH] =
- g_signal_new ("group-switch", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstPlayBaseBinClass, group_switch),
- NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
- gst_play_base_bin_signals[SIGNAL_REDIRECT] =
- g_signal_new ("got-redirect", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstPlayBaseBinClass, got_redirect),
- NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1,
- G_TYPE_STRING);
gobject_klass->dispose = GST_DEBUG_FUNCPTR (gst_play_base_bin_dispose);
gobject_klass->finalize = GST_DEBUG_FUNCPTR (gst_play_base_bin_finalize);
setup_substreams (play_base_bin);
GST_DEBUG ("Emitting signal");
- g_signal_emit (play_base_bin,
- gst_play_base_bin_signals[SIGNAL_SETUP_OUTPUT_PADS], 0);
+ GST_PLAY_BASE_BIN_GET_CLASS (play_base_bin)->
+ setup_output_pads (play_base_bin, group);
GST_DEBUG ("done");
GROUP_UNLOCK (play_base_bin);
GST_DEBUG ("switching to next group %p - emitting signal",
play_base_bin->queued_groups->data);
/* and signal the new group */
- g_signal_emit (play_base_bin,
- gst_play_base_bin_signals[SIGNAL_SETUP_OUTPUT_PADS], 0);
+ GST_PLAY_BASE_BIN_GET_CLASS (play_base_bin)->
+ setup_output_pads (play_base_bin, group);
GROUP_UNLOCK (play_base_bin);
- g_signal_emit (play_base_bin,
- gst_play_base_bin_signals[SIGNAL_GROUP_SWITCH], 0);
+ g_object_notify (G_OBJECT (play_base_bin), "streaminfo");
/* get rid of the EOS event */
return FALSE;
}
}
-/*
- * Called when we're redirected to a new URI.
- */
-static void
-got_redirect (GstElement * element, const gchar * new_location, gpointer data)
-{
- gchar **location = data;
-
- if (!*location)
- *location = g_strdup (new_location);
-}
-
/* construct and run the source and decoder elements until we found
* all the streams or until a preroll queue has been filled.
*/
/* set up callbacks to create the links between decoded data
* and video/audio/subtitle rendering/output. */
- g_signal_connect (play_base_bin->decoder, "got_redirect",
- G_CALLBACK (got_redirect), new_location);
g_signal_connect (G_OBJECT (play_base_bin->decoder),
"new-decoded-pad", G_CALLBACK (new_decoded_pad), play_base_bin);
g_signal_connect (G_OBJECT (play_base_bin->decoder), "no-more-pads",
switch (transition) {
case GST_STATE_READY_TO_PAUSED:
- if (new_location) {
- g_signal_emit (play_base_bin,
- gst_play_base_bin_signals[SIGNAL_REDIRECT], 0, new_location);
- g_free (new_location);
- ret = GST_STATE_FAILURE;
- } else if (ret == GST_STATE_SUCCESS) {
+ if (ret == GST_STATE_SUCCESS) {
finish_source (play_base_bin);
- }
-
- if (ret != GST_STATE_SUCCESS) {
+ } else {
/* clean up leftover groups */
remove_groups (play_base_bin);
play_base_bin->need_rebuild = TRUE;
#define GST_PLAY_BASE_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_PLAY_BASE_BIN,GstPlayBaseBinClass))
#define GST_IS_PLAY_BASE_BIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_PLAY_BASE_BIN))
#define GST_IS_PLAY_BASE_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_PLAY_BASE_BIN))
+#define GST_PLAY_BASE_BIN_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_PLAY_BASE_BIN, \
+ GstPlayBaseBinClass))
typedef struct _GstPlayBaseBin GstPlayBaseBin;
typedef struct _GstPlayBaseBinClass GstPlayBaseBinClass;
struct _GstPlayBaseBinClass {
GstPipelineClass parent_class;
- /* signals */
- void (*setup_output_pads) (GstPlayBaseBin *play_base_bin);
- void (*removed_output_pad) (GstPlayBaseBin *play_base_bin,
- GstStreamInfo *info);
+ /* virtual fuctions */
+ void (*setup_output_pads) (GstPlayBaseBin *play_base_bin,
+ GstPlayBaseGroup *group);
+ /* signals */
/* 0: buf=empty (underrun) - will re-cache,
* 100: buf=full (overrun) - will flush head of cache (latency) */
void (*buffering) (GstPlayBaseBin *play_base_bin,
gint percentage);
- void (*group_switch) (GstPlayBaseBin *play_base_bin);
-
- /* Called on redirect */
- void (*got_redirect) (GstPlayBaseBin *play_base_bin,
- const gchar *new_location);
};
GType gst_play_base_bin_get_type (void);
/* our cache for the sinks */
GHashTable *cache;
- /* boolean to see if we're currently switching groups */
- gboolean group_switch;
-
/* font description */
gchar *font_desc;
};
static void gst_play_bin_init (GstPlayBin * play_bin);
static void gst_play_bin_dispose (GObject * object);
-static void group_switch (GstPlayBaseBin * play_base_bin);
-static void setup_sinks (GstPlayBaseBin * play_base_bin);
+static void setup_sinks (GstPlayBaseBin * play_base_bin,
+ GstPlayBaseGroup * group);
static void remove_sinks (GstPlayBin * play_bin);
static void gst_play_bin_set_property (GObject * object, guint prop_id,
GST_DEBUG_FUNCPTR (gst_play_bin_change_state);
playbasebin_klass->setup_output_pads = setup_sinks;
- playbasebin_klass->group_switch = group_switch;
}
static void
play_bin->font_desc = NULL;
play_bin->cache = g_hash_table_new_full (g_str_hash, g_str_equal,
NULL, (GDestroyNotify) gst_object_unref);
- play_bin->group_switch = FALSE;
}
static void
return element;
}
-/* set for group switch */
-static void
-group_switch (GstPlayBaseBin * play_base_bin)
-{
- GST_PLAY_BIN (play_base_bin)->group_switch = TRUE;
-}
-
/* get rid of all installed sinks */
static void
remove_sinks (GstPlayBin * play_bin)
GstElement *element;
GST_DEBUG ("removesinks");
- play_bin->group_switch = FALSE;
element = g_hash_table_lookup (play_bin->cache, "abin");
if (element != NULL) {
parent = gst_element_get_parent (element);
}
static void
-setup_sinks (GstPlayBaseBin * play_base_bin)
+setup_sinks (GstPlayBaseBin * play_base_bin, GstPlayBaseGroup * group)
{
GstPlayBin *play_bin = GST_PLAY_BIN (play_base_bin);
- GstPlayBaseGroup *group;
GList *streaminfo = NULL, *s;
gboolean need_vis = FALSE;
gboolean need_text = FALSE;
GST_DEBUG ("setupsinks");
/* find out what to do */
- group = play_base_bin->queued_groups->data;
if (group->type[GST_STREAM_TYPE_VIDEO - 1].npads > 0 &&
group->type[GST_STREAM_TYPE_TEXT - 1].npads > 0) {
need_text = TRUE;
case GST_STATE_PLAYING_TO_PAUSED:
/* Set audio sink state to NULL to release the sound device,
* but only if we own it (else we might be in chain-transition). */
- //if (play_bin->audio_sink != NULL && !play_bin->group_switch &&
+ //if (play_bin->audio_sink != NULL &&
// GST_STATE (play_bin->audio_sink) == GST_STATE_PAUSED) {
// gst_element_set_state (play_bin->audio_sink, GST_STATE_NULL);
//}