data_src = gst_element_factory_make ("gnomevfssrc", "source");
/* Let's send them to GstPlay object */
- gst_play_set_audio_sink (play, audio_sink);
- gst_play_set_video_sink (play, video_sink);
- gst_play_set_data_src (play, data_src);
- gst_play_set_visualization (play, vis_element);
+ if (!gst_play_set_audio_sink (play, audio_sink))
+ g_warning ("Could not set audio sink");
+ if (!gst_play_set_video_sink (play, video_sink))
+ g_warning ("Could not set video sink");
+ if (!gst_play_set_data_src (play, data_src))
+ g_warning ("Could not set data src");
+ if (!gst_play_set_visualization (play, vis_element))
+ g_warning ("Could not set visualisation");
/* Setting location we want to play */
- gst_play_set_location (play, argv[1]);
+ if (!gst_play_set_location (play, argv[1]))
+ g_warning ("Could not set location");
/* Uncomment that line to get an XML dump of the pipeline */
/* gst_xml_write_file (GST_ELEMENT (play), stdout); */
g_signal_connect (G_OBJECT (play), "eos", G_CALLBACK (got_eos), NULL);
/* Change state to PLAYING */
- gst_element_set_state (GST_ELEMENT (play), GST_STATE_PLAYING);
+ if (gst_element_set_state (GST_ELEMENT (play),
+ GST_STATE_PLAYING) == GST_STATE_FAILURE)
+ g_warning ("Could not set state to PLAYING");
g_idle_add ((GSourceFunc) idle_iterate, play);
g_timeout_add (20000, (GSourceFunc) seek_timer, play);
#define TICK_INTERVAL_MSEC 200
+GST_DEBUG_CATEGORY_STATIC (play_debug);
+#define GST_CAT_DEFAULT play_debug
+
enum
{
TIME_TICK,
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GstPlayClass, have_video_size), NULL, NULL,
gst_marshal_VOID__INT_INT, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
+ GST_DEBUG_CATEGORY_INIT (play_debug, "GST_PLAY", 0, "GStreamer Play library");
+ GST_DEBUG ("Play class initialized");
}
/* ======================================================= */
play->priv->location = g_strdup (location);
- if (GST_STATE (GST_ELEMENT (play)) != GST_STATE_READY)
- gst_element_set_state (GST_ELEMENT (play), GST_STATE_READY);
+ if (GST_STATE (GST_ELEMENT (play)) != GST_STATE_READY) {
+ GstElementStateReturn ret;
+
+ ret = gst_element_set_state (GST_ELEMENT (play), GST_STATE_READY);
+ if (ret == GST_STATE_FAILURE)
+ return FALSE;
+ }
work_thread = g_hash_table_lookup (play->priv->elements, "work_thread");
if (!GST_IS_ELEMENT (work_thread))
g_return_val_if_fail (GST_IS_PLAY (play), FALSE);
/* We bring back the pipeline to READY */
- if (GST_STATE (GST_ELEMENT (play)) != GST_STATE_READY)
- gst_element_set_state (GST_ELEMENT (play), GST_STATE_READY);
+ if (GST_STATE (GST_ELEMENT (play)) != GST_STATE_READY) {
+ GstElementStateReturn ret;
+
+ ret = gst_element_set_state (GST_ELEMENT (play), GST_STATE_READY);
+ if (ret == GST_STATE_FAILURE)
+ return FALSE;
+ }
/* Getting needed objects */
work_thread = g_hash_table_lookup (play->priv->elements, "work_thread");
gst_play_set_video_sink (GstPlay * play, GstElement * video_sink)
{
GstElement *video_thread, *old_video_sink, *video_scaler, *video_sink_element;
+ GstElementStateReturn ret;
g_return_val_if_fail (play != NULL, FALSE);
g_return_val_if_fail (GST_IS_PLAY (play), FALSE);
g_return_val_if_fail (GST_IS_ELEMENT (video_sink), FALSE);
/* We bring back the pipeline to READY */
- if (GST_STATE (GST_ELEMENT (play)) != GST_STATE_READY)
- gst_element_set_state (GST_ELEMENT (play), GST_STATE_READY);
+ if (GST_STATE (GST_ELEMENT (play)) != GST_STATE_READY) {
+ GstElementStateReturn ret;
+
+ ret = gst_element_set_state (GST_ELEMENT (play), GST_STATE_READY);
+ if (ret == GST_STATE_FAILURE)
+ return FALSE;
+ }
/* Getting needed objects */
video_thread = g_hash_table_lookup (play->priv->elements, "video_thread");
}
}
- gst_element_set_state (video_sink, GST_STATE (GST_ELEMENT (play)));
+ ret = gst_element_set_state (video_sink, GST_STATE (GST_ELEMENT (play)));
+ if (ret == GST_STATE_FAILURE)
+ return FALSE;
return TRUE;
}
gst_play_set_audio_sink (GstPlay * play, GstElement * audio_sink)
{
GstElement *old_audio_sink, *audio_thread, *volume, *audio_sink_element;
+ GstElementStateReturn ret;
g_return_val_if_fail (play != NULL, FALSE);
g_return_val_if_fail (GST_IS_PLAY (play), FALSE);
g_return_val_if_fail (GST_IS_ELEMENT (audio_sink), FALSE);
/* We bring back the pipeline to READY */
- if (GST_STATE (GST_ELEMENT (play)) != GST_STATE_READY)
- gst_element_set_state (GST_ELEMENT (play), GST_STATE_READY);
+ if (GST_STATE (GST_ELEMENT (play)) != GST_STATE_READY) {
+ GstElementStateReturn ret;
+
+ ret = gst_element_set_state (GST_ELEMENT (play), GST_STATE_READY);
+ if (ret == GST_STATE_FAILURE)
+ return FALSE;
+ }
/* Getting needed objects */
old_audio_sink = g_hash_table_lookup (play->priv->elements, "audio_sink");
audio_sink_element);
}
- gst_element_set_state (audio_sink, GST_STATE (GST_ELEMENT (play)));
+ ret = gst_element_set_state (audio_sink, GST_STATE (GST_ELEMENT (play)));
+ if (ret == GST_STATE_FAILURE)
+ return FALSE;
return TRUE;
}
/* We bring back the pipeline to PAUSED */
if (GST_STATE (GST_ELEMENT (play)) == GST_STATE_PLAYING) {
- gst_element_set_state (GST_ELEMENT (play), GST_STATE_PAUSED);
+ GstElementStateReturn ret;
+
+ ret = gst_element_set_state (GST_ELEMENT (play), GST_STATE_PAUSED);
+ if (ret == GST_STATE_FAILURE)
+ return FALSE;
was_playing = TRUE;
}
g_hash_table_replace (play->priv->elements, "vis_element", vis_element);
- if (was_playing)
- gst_element_set_state (GST_ELEMENT (play), GST_STATE_PLAYING);
+ if (was_playing) {
+ GstElementStateReturn ret;
+
+ ret = gst_element_set_state (GST_ELEMENT (play), GST_STATE_PLAYING);
+ if (ret == GST_STATE_FAILURE)
+ return FALSE;
+ }
return TRUE;
}
/* We bring back the pipeline to PAUSED */
if (GST_STATE (GST_ELEMENT (play)) == GST_STATE_PLAYING) {
- gst_element_set_state (GST_ELEMENT (play), GST_STATE_PAUSED);
+ GstElementStateReturn ret;
+
+ ret = gst_element_set_state (GST_ELEMENT (play), GST_STATE_PAUSED);
+ if (ret == GST_STATE_FAILURE)
+ return FALSE;
was_playing = TRUE;
}
/* We bring back the pipeline to PAUSED */
if (GST_STATE (GST_ELEMENT (play)) == GST_STATE_PLAYING) {
- gst_element_set_state (GST_ELEMENT (play), GST_STATE_PAUSED);
+ GstElementStateReturn ret;
+
+ ret = gst_element_set_state (GST_ELEMENT (play), GST_STATE_PAUSED);
+ if (ret == GST_STATE_FAILURE)
+ return FALSE;
was_playing = TRUE;
}
gst_element_link (vis_bin, video_switch);
}
- if (was_playing)
- gst_element_set_state (GST_ELEMENT (play), GST_STATE_PLAYING);
+ if (was_playing) {
+ GstElementStateReturn ret;
+
+ ret = gst_element_set_state (GST_ELEMENT (play), GST_STATE_PLAYING);
+ if (ret == GST_STATE_FAILURE)
+ return FALSE;
+ }
return TRUE;
}
data_src = gst_element_factory_make ("gnomevfssrc", "source");
/* Let's send them to GstPlay object */
- gst_play_set_audio_sink (play, audio_sink);
- gst_play_set_video_sink (play, video_sink);
- gst_play_set_data_src (play, data_src);
- gst_play_set_visualization (play, vis_element);
+ if (!gst_play_set_audio_sink (play, audio_sink))
+ g_warning ("Could not set audio sink");
+ if (!gst_play_set_video_sink (play, video_sink))
+ g_warning ("Could not set video sink");
+ if (!gst_play_set_data_src (play, data_src))
+ g_warning ("Could not set data src");
+ if (!gst_play_set_visualization (play, vis_element))
+ g_warning ("Could not set visualisation");
/* Setting location we want to play */
- gst_play_set_location (play, argv[1]);
+ if (!gst_play_set_location (play, argv[1]))
+ g_warning ("Could not set location");
/* Uncomment that line to get an XML dump of the pipeline */
/* gst_xml_write_file (GST_ELEMENT (play), stdout); */
g_signal_connect (G_OBJECT (play), "eos", G_CALLBACK (got_eos), NULL);
/* Change state to PLAYING */
- gst_element_set_state (GST_ELEMENT (play), GST_STATE_PLAYING);
+ if (gst_element_set_state (GST_ELEMENT (play),
+ GST_STATE_PLAYING) == GST_STATE_FAILURE)
+ g_warning ("Could not set state to PLAYING");
g_idle_add ((GSourceFunc) idle_iterate, play);
g_timeout_add (20000, (GSourceFunc) seek_timer, play);