From: Steve B. <sb...@us...> - 2003-01-18 04:37:45
|
CVS Root: /cvsroot/gstreamer Module: gst-plugins Changes by: sbaker3 Date: Fri Jan 17 2003 20:37:44 PST Log message: added func gst_play_set_data_src removed pipeline GST_PLAY_PIPE_VIDEO_THREADSAFE - it never worked and its just taking up space Modified files: gst-libs/gst/play: play.c play.h playpipelines.c Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/gst-libs/gst/play/play.c.diff?r1=1.7&r2=1.8 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/gst-libs/gst/play/play.h.diff?r1=1.3&r2=1.4 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/gst-libs/gst/play/playpipelines.c.diff?r1=1.4&r2=1.5 ====Begin Diffs==== Index: play.c =================================================================== RCS file: /cvsroot/gstreamer/gst-plugins/gst-libs/gst/play/play.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- play.c 7 Jan 2003 19:13:38 -0000 1.7 +++ play.c 18 Jan 2003 04:37:32 -0000 1.8 @@ -312,21 +312,16 @@ case GST_PLAY_PIPE_VIDEO: play->setup_pipeline = gst_play_video_setup; play->teardown_pipeline = NULL; + play->set_data_src = gst_play_video_set_data_src; play->set_autoplugger = gst_play_video_set_auto; play->set_video_sink = gst_play_video_set_video; play->set_audio_sink = gst_play_video_set_audio; break; - case GST_PLAY_PIPE_VIDEO_THREADSAFE: - play->setup_pipeline = gst_play_videots_setup; - play->teardown_pipeline = NULL; - play->set_autoplugger = gst_play_videots_set_auto; - play->set_video_sink = gst_play_videots_set_video; - play->set_audio_sink = gst_play_videots_set_audio; - break; case GST_PLAY_PIPE_AUDIO: /* we can reuse the threaded set functions */ play->setup_pipeline = gst_play_audio_setup; play->teardown_pipeline = NULL; + play->set_data_src = gst_play_simple_set_data_src; play->set_autoplugger = gst_play_audiot_set_auto; play->set_video_sink = NULL; play->set_audio_sink = gst_play_audiot_set_audio; @@ -334,6 +329,7 @@ case GST_PLAY_PIPE_AUDIO_THREADED: play->setup_pipeline = gst_play_audiot_setup; play->teardown_pipeline = NULL; + play->set_data_src = gst_play_simple_set_data_src; play->set_autoplugger = gst_play_audiot_set_auto; play->set_video_sink = NULL; play->set_audio_sink = gst_play_audiot_set_audio; @@ -341,6 +337,7 @@ case GST_PLAY_PIPE_AUDIO_HYPER_THREADED: play->setup_pipeline = gst_play_audioht_setup; play->teardown_pipeline = NULL; + play->set_data_src = gst_play_simple_set_data_src; play->set_autoplugger = gst_play_audioht_set_auto; play->set_video_sink = NULL; play->set_audio_sink = gst_play_audioht_set_audio; @@ -805,6 +802,24 @@ } /* we didn't find a sink element */ return NULL; +} + +gboolean +gst_play_set_data_src (GstPlay *play, GstElement *data_src) +{ + g_return_val_if_fail (GST_IS_PLAY (play), FALSE); + g_return_val_if_fail (GST_IS_ELEMENT (data_src), FALSE); + + if (gst_play_get_state (play) != GST_STATE_READY){ + gst_play_set_state (play, GST_STATE_READY); + } + + if (play->set_data_src){ + return play->set_data_src(play, data_src); + } + + /* if there is no set_data_src func, fail quietly */ + return FALSE; } gboolean Index: play.h =================================================================== RCS file: /cvsroot/gstreamer/gst-plugins/gst-libs/gst/play/play.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- play.h 7 Jan 2003 19:13:41 -0000 1.3 +++ play.h 18 Jan 2003 04:37:32 -0000 1.4 @@ -50,7 +50,6 @@ GST_PLAY_PIPE_AUDIO, GST_PLAY_PIPE_AUDIO_THREADED, GST_PLAY_PIPE_AUDIO_HYPER_THREADED, - GST_PLAY_PIPE_VIDEO_THREADSAFE, GST_PLAY_PIPE_VIDEO, } GstPlayPipeType; @@ -85,8 +84,9 @@ GObject parent; gboolean (*setup_pipeline) (GstPlay *play, GError **error); - void (*teardown_pipeline) (GstPlay *play); - gboolean (*set_autoplugger) (GstPlay *play, GstElement *autoplugger); + void (*teardown_pipeline) (GstPlay *play); + gboolean (*set_data_src) (GstPlay *play, GstElement *datasrc); + gboolean (*set_autoplugger) (GstPlay *play, GstElement *autoplugger); gboolean (*set_video_sink) (GstPlay *play, GstElement *videosink); gboolean (*set_audio_sink) (GstPlay *play, GstElement *audiosink); @@ -155,6 +155,7 @@ GstElement* gst_play_get_sink_element (GstPlay *play, GstElement *element); +gboolean gst_play_set_data_src (GstPlay *play, GstElement *data_src); gboolean gst_play_set_video_sink (GstPlay *play, GstElement *element); gboolean gst_play_set_audio_sink (GstPlay *play, GstElement *element); void gst_play_need_new_video_window (GstPlay *play); Index: playpipelines.c =================================================================== RCS file: /cvsroot/gstreamer/gst-plugins/gst-libs/gst/play/playpipelines.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- playpipelines.c 10 Jan 2003 10:22:24 -0000 1.4 +++ playpipelines.c 18 Jan 2003 04:37:32 -0000 1.5 @@ -21,6 +21,30 @@ * Boston, MA 02111-1307, USA. */ +static gboolean +gst_play_default_set_data_src (GstPlay *play, GstElement *datasrc, GstElement* parent) +{ + g_return_val_if_fail (GST_IS_PLAY (play), FALSE); + g_return_val_if_fail (GST_IS_ELEMENT (datasrc), FALSE); + + if (GST_IS_ELEMENT(play->source)) { + /* we need to remove the existing data source before creating a new one */ + if (GST_IS_ELEMENT(play->autoplugger)){ + gst_element_unlink (play->autoplugger, play->source); + } + gst_bin_remove (GST_BIN(parent), play->source); + } + + play->source = datasrc; + g_return_val_if_fail (play->source != NULL, FALSE); + + gst_bin_add (GST_BIN (parent), play->source); + if (GST_IS_ELEMENT(play->autoplugger)){ + gst_element_link (play->autoplugger, play->source); + } + return TRUE; +} + /* * GST_PLAY_PIPE_AUDIO * gnomevfssrc ! spider ! volume ! osssink @@ -80,6 +104,12 @@ return TRUE; } +static gboolean +gst_play_simple_set_data_src (GstPlay *play, GstElement *datasrc) +{ + return gst_play_default_set_data_src(play, datasrc, play->pipeline); +} + /* * GST_PLAY_PIPE_AUDIO_THREADED * { gnomevfssrc ! spider ! volume ! osssink } @@ -492,6 +522,15 @@ return TRUE; } +static gboolean +gst_play_video_set_data_src (GstPlay *play, GstElement *datasrc) +{ + GstElement *work_thread; + g_return_val_if_fail (GST_IS_PLAY(play), FALSE); + + work_thread = g_hash_table_lookup(play->other_elements, "work_thread"); + return gst_play_default_set_data_src(play, datasrc, work_thread); +} static gboolean gst_play_video_set_auto (GstPlay *play, GstElement *autoplugger) @@ -581,236 +620,6 @@ play->audio_sink_element = gst_play_get_sink_element (play, audio_sink); - if (play->audio_sink_element != NULL) { - g_signal_connect (G_OBJECT (play->audio_sink_element), "eos", - G_CALLBACK (callback_audio_sink_eos), play); - } - - return TRUE; -} - -/* - * GST_PLAY_PIPE_VIDEO_THREADSAFE - * { gnomevfssrc ! spider ! { queue ! volume ! osssink } } - * spider0.src2 ! queue ! videosink - * (note that the xvideosink is not contained by a thread) - */ - -static gboolean -gst_play_videots_setup (GstPlay *play, GError **error) -{ - GstElement *audio_bin, *audio_queue, *video_queue, *auto_identity, *work_thread; - - g_return_val_if_fail (GST_IS_PLAY(play), FALSE); - - /* creating pipeline */ - play->pipeline = gst_pipeline_new ("main_pipeline"); - g_return_val_if_fail (GST_IS_PIPELINE (play->pipeline), FALSE); - - /* creating work thread */ - work_thread = gst_thread_new ("work_thread"); - g_return_val_if_fail (GST_IS_THREAD (work_thread), FALSE); - g_hash_table_insert(play->other_elements, "work_thread", work_thread); - - gst_bin_add (GST_BIN (play->pipeline), work_thread); - - /* create source element */ - play->source = gst_element_factory_make ("gnomevfssrc", "source"); - if (!play->source) - { - gst_play_error_plugin (GST_PLAY_ERROR_GNOMEVFSSRC, error); - return FALSE; - } - gst_bin_add (GST_BIN (work_thread), play->source); - - auto_identity = gst_element_factory_make ("identity", "auto_identity"); - g_return_val_if_fail (auto_identity != NULL, FALSE); - g_hash_table_insert(play->other_elements, "auto_identity", auto_identity); - - gst_bin_add (GST_BIN (work_thread), auto_identity); - gst_element_add_ghost_pad (work_thread, - gst_element_get_pad (auto_identity, "src"), - "src"); - - /* create volume elements */ - play->volume = gst_element_factory_make ("volume", "volume"); - if (!play->volume) - { - gst_play_error_plugin (GST_PLAY_ERROR_VOLUME, error); - return FALSE; - } - - /* creating audio_sink element */ - play->audio_sink = gst_element_factory_make ("fakesink", "fake_audio"); - if (!play->audio_sink) - { - gst_play_error_plugin (GST_PLAY_ERROR_FAKESINK, error); - return FALSE; - } - play->audio_sink_element = NULL; - - audio_queue = gst_element_factory_make ("queue", "audio_queue"); - if (!audio_queue) - { - gst_play_error_plugin (GST_PLAY_ERROR_QUEUE, error); - return FALSE; - } - g_hash_table_insert(play->other_elements, "audio_queue", audio_queue); - - audio_bin = gst_thread_new ("audio_bin"); - if (!audio_bin) - { - gst_play_error_plugin (GST_PLAY_ERROR_THREAD, error); - return FALSE; - } - g_hash_table_insert(play->other_elements, "audio_bin", audio_bin); - - gst_bin_set_pre_iterate_function( - GST_BIN (audio_bin), - (GstBinPrePostIterateFunction) callback_bin_pre_iterate, - play->audio_bin_mutex); - - gst_bin_set_post_iterate_function( - GST_BIN (audio_bin), - (GstBinPrePostIterateFunction) callback_bin_post_iterate, - play->audio_bin_mutex); - - gst_bin_add_many ( - GST_BIN (audio_bin), audio_queue, - play->volume, play->audio_sink, NULL); - - gst_element_link_many ( - audio_queue, play->volume, - play->audio_sink, NULL); - - gst_element_add_ghost_pad ( - audio_bin, - gst_element_get_pad (audio_queue, "sink"), - "sink"); - - gst_bin_add (GST_BIN (work_thread), audio_bin); - - /* create video elements */ - play->video_sink = gst_element_factory_make ("xvideosink", "show"); - - g_object_set (G_OBJECT (play->video_sink), "toplevel", FALSE, NULL); - - g_signal_connect ( - G_OBJECT (play->video_sink), "have_xid", - G_CALLBACK (callback_video_have_xid), play); - - g_signal_connect ( - G_OBJECT (play->video_sink), "have_size", - G_CALLBACK (callback_video_have_size), play); - - g_return_val_if_fail (play->video_sink != NULL, FALSE); - - video_queue = gst_element_factory_make ("queue", "video_queue"); - g_return_val_if_fail (video_queue != NULL, FALSE); - g_hash_table_insert(play->other_elements, "video_queue", video_queue); - g_object_set (G_OBJECT (video_queue), "block_timeout", 1000, NULL); - - gst_bin_add_many ( - GST_BIN (play->pipeline), video_queue, - play->video_sink, NULL); - - gst_element_link (video_queue, play->video_sink); - - gst_bin_set_pre_iterate_function( - GST_BIN (play->pipeline), - (GstBinPrePostIterateFunction) callback_bin_pre_iterate, - play->video_bin_mutex); - - gst_bin_set_post_iterate_function( - GST_BIN (play->pipeline), - (GstBinPrePostIterateFunction) callback_bin_post_iterate, - play->video_bin_mutex); - - gst_element_link (work_thread, video_queue); - - return TRUE; -} - - -static gboolean -gst_play_videots_set_auto (GstPlay *play, GstElement *autoplugger) -{ - - GstElement *audio_bin, *auto_identity, *work_thread; - - g_return_val_if_fail (GST_IS_PLAY(play), FALSE); - g_return_val_if_fail (GST_IS_ELEMENT (autoplugger), FALSE); - - audio_bin = g_hash_table_lookup(play->other_elements, "audio_bin"); - auto_identity = g_hash_table_lookup(play->other_elements, "auto_identity"); - work_thread = g_hash_table_lookup(play->other_elements, "work_thread"); - - if (play->autoplugger) { - /* we need to remove the existing autoplugger - * before creating a new one */ - gst_element_unlink (play->autoplugger, audio_bin); - gst_element_unlink (play->autoplugger, play->source); - gst_element_unlink (play->autoplugger, auto_identity); - - gst_bin_remove (GST_BIN (work_thread), play->autoplugger); - } - - play->autoplugger = autoplugger; - g_return_val_if_fail (play->autoplugger != NULL, FALSE); - - gst_bin_add (GST_BIN (work_thread), play->autoplugger); - gst_element_link (play->source, play->autoplugger); - gst_element_link (play->autoplugger, audio_bin); - gst_element_link (play->autoplugger, auto_identity); - - return TRUE; -} - - -static gboolean -gst_play_videots_set_video (GstPlay *play, GstElement *video_sink) -{ - GstElement *video_mate; - - g_return_val_if_fail (GST_IS_PLAY (play), FALSE); - g_return_val_if_fail (GST_IS_ELEMENT (video_sink), FALSE); - - video_mate = g_hash_table_lookup (play->other_elements, "video_queue"); - - if (play->video_sink) { - gst_element_unlink (video_mate, play->video_sink); - gst_bin_remove (GST_BIN (play->pipeline), play->video_sink); - } - play->video_sink = video_sink; - gst_bin_add (GST_BIN (play->pipeline), play->video_sink); - gst_element_link (video_mate, play->video_sink); - - return TRUE; -} - - -static gboolean -gst_play_videots_set_audio (GstPlay *play, GstElement *audio_sink) -{ - GstElement *audio_bin; - - g_return_val_if_fail (GST_IS_PLAY (play), FALSE); - g_return_val_if_fail (GST_IS_ELEMENT (audio_sink), FALSE); - - audio_bin = g_hash_table_lookup(play->other_elements, "audio_bin"); - - if (play->audio_sink) - { - gst_element_unlink (play->volume, play->audio_sink); - gst_bin_remove (GST_BIN (audio_bin), play->audio_sink); - } - - play->audio_sink = audio_sink; - gst_bin_add (GST_BIN (audio_bin), play->audio_sink); - gst_element_link (play->volume, play->audio_sink); - - play->audio_sink_element = gst_play_get_sink_element (play, audio_sink); - if (play->audio_sink_element != NULL) { g_signal_connect (G_OBJECT (play->audio_sink_element), "eos", G_CALLBACK (callback_audio_sink_eos), play); |