CVSROOT: /sources/gnash Module name: gnash Changes by: Bastiaan Jacques <bjacques> 08/01/22 08:39:08
Modified files: . : ChangeLog server/asobj : NetConnection.cpp NetStreamGst.cpp NetStreamGst.h Log message: * server/asobj/NetConnection.cpp: Remove duplicate URL announcement message. * server/asobj/NetStreamGst.{cpp,h}: Separate the video and audio decoding modules into bins and dynamically plug them when corresponding streams are encountered. This allows NetStream to play video-only or audio-only streams. Also, only play audio if a sound handler exists (in other words, if sound was enabled). Emit the playStop onStatus signal when an error is encountered. CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5457&r2=1.5458 http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetConnection.cpp?cvsroot=gnash&r1=1.54&r2=1.55 http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetStreamGst.cpp?cvsroot=gnash&r1=1.69&r2=1.70 http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetStreamGst.h?cvsroot=gnash&r1=1.31&r2=1.32 Patches: Index: ChangeLog =================================================================== RCS file: /sources/gnash/gnash/ChangeLog,v retrieving revision 1.5457 retrieving revision 1.5458 diff -u -b -r1.5457 -r1.5458 --- ChangeLog 22 Jan 2008 08:25:31 -0000 1.5457 +++ ChangeLog 22 Jan 2008 08:39:07 -0000 1.5458 @@ -1,3 +1,14 @@ +2008-01-21 Bastiaan Jacques <[EMAIL PROTECTED]> + + * server/asobj/NetConnection.cpp: Remove duplicate URL announcement + message. + * server/asobj/NetStreamGst.{cpp,h}: Separate the video and audio + decoding modules into bins and dynamically plug them when + corresponding streams are encountered. This allows NetStream to play + video-only or audio-only streams. Also, only play audio if a sound + handler exists (in other words, if sound was enabled). Emit the + playStop onStatus signal when an error is encountered. + 2008-01-22 Sandro Santilli <[EMAIL PROTECTED]> * server/asobj/NetStream.cpp: use as_object::callMethod to dispatch Index: server/asobj/NetConnection.cpp =================================================================== RCS file: /sources/gnash/gnash/server/asobj/NetConnection.cpp,v retrieving revision 1.54 retrieving revision 1.55 diff -u -b -r1.54 -r1.55 --- server/asobj/NetConnection.cpp 21 Jan 2008 20:55:56 -0000 1.54 +++ server/asobj/NetConnection.cpp 22 Jan 2008 08:39:08 -0000 1.55 @@ -17,7 +17,7 @@ // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // -/* $Id: NetConnection.cpp,v 1.54 2008/01/21 20:55:56 rsavoye Exp $ */ +/* $Id: NetConnection.cpp,v 1.55 2008/01/22 08:39:08 bjacques Exp $ */ #ifdef HAVE_CONFIG_H #include "gnashconfig.h" @@ -64,7 +64,6 @@ /*public*/ std::string NetConnection::validateURL(const std::string& url) { - std::string completeUrl; if (_prefixUrl.size() > 0) { completeUrl += _prefixUrl + "/" + url; @@ -83,9 +82,7 @@ return ""; } - log_msg(_("Connecting to movie: %s"), uriStr.c_str()); - - log_msg(_("Connection etablished to movie: %s"), uriStr.c_str()); + log_msg(_("Connection to movie: %s"), uriStr.c_str()); return uriStr; } Index: server/asobj/NetStreamGst.cpp =================================================================== RCS file: /sources/gnash/gnash/server/asobj/NetStreamGst.cpp,v retrieving revision 1.69 retrieving revision 1.70 diff -u -b -r1.69 -r1.70 --- server/asobj/NetStreamGst.cpp 21 Jan 2008 23:01:12 -0000 1.69 +++ server/asobj/NetStreamGst.cpp 22 Jan 2008 08:39:08 -0000 1.70 @@ -33,7 +33,6 @@ // | // audio -> audioconvert -> autoaudiosink - namespace gnash { NetStreamGst::NetStreamGst() @@ -43,6 +42,9 @@ gst_init(NULL, NULL); _pipeline = gst_pipeline_new ("gnash_pipeline"); + _audiobin = gst_bin_new(NULL); + _videobin = gst_bin_new(NULL); + // Figure out if flvdemux is present on the system. If not load the one from // the Gnash tree. @@ -57,6 +59,7 @@ gst_object_unref(GST_OBJECT(factory)); } + // Setup general decoders _dataqueue = gst_element_factory_make ("queue", "gnash_dataqueue"); g_signal_connect (_dataqueue, "underrun", G_CALLBACK (NetStreamGst::queue_underrun_cb), this); @@ -95,19 +98,30 @@ // Create the video pipeline and link the elements. The pipeline will // dereference the elements when they are destroyed. - gst_bin_add_many (GST_BIN (_pipeline), colorspace, videoscale, videocaps, videosink, NULL); + gst_bin_add_many (GST_BIN (_videobin), colorspace, videoscale, videocaps, videosink, NULL); gst_element_link_many(colorspace, videoscale, videocaps, videosink, NULL); // Setup audio sink GstElement* audioconvert = gst_element_factory_make ("audioconvert", NULL); - GstElement* audiosink = gst_element_factory_make ("autoaudiosink", NULL); + GstElement* audiosink; + if (get_sound_handler()) { + audiosink = gst_element_factory_make ("autoaudiosink", NULL); + } else { + audiosink = gst_element_factory_make ("fakesink", NULL); + } - gst_bin_add_many(GST_BIN(_pipeline), audioconvert, audiosink, NULL); + gst_bin_add_many(GST_BIN(_audiobin), audioconvert, audiosink, NULL); gst_element_link(audioconvert, audiosink); - _audiopad = gst_element_get_static_pad (audioconvert, "sink"); - _videopad = gst_element_get_static_pad (colorspace, "sink"); + GstPad* target_audiopad = gst_element_get_static_pad (audioconvert, "sink"); + GstPad* target_videopad = gst_element_get_static_pad (colorspace, "sink"); + + gst_element_add_pad(_videobin, gst_ghost_pad_new ("sink", target_videopad)); + gst_element_add_pad(_audiobin, gst_ghost_pad_new ("sink", target_audiopad)); + + gst_object_unref(GST_OBJECT(target_videopad)); + gst_object_unref(GST_OBJECT(target_audiopad)); } NetStreamGst::~NetStreamGst() @@ -118,9 +132,6 @@ gst_element_get_state(_pipeline, NULL, NULL, 0); // wait for a response gst_object_unref(GST_OBJECT(_pipeline)); - - gst_object_unref(GST_OBJECT(_videopad)); - gst_object_unref(GST_OBJECT(_audiopad)); } void @@ -147,17 +158,16 @@ { GstState cur_state; - GstStateChangeReturn statereturn = gst_element_get_state(_pipeline, - &cur_state, NULL, - 1000000 /* wait 1 ms */); - if (statereturn != GST_STATE_CHANGE_SUCCESS) { + GstStateChangeReturn statereturn + = gst_element_get_state(_pipeline, &cur_state, NULL, 1 * GST_MSECOND); + + if (statereturn == GST_STATE_CHANGE_ASYNC) { return; } if (cur_state == GST_STATE_PLAYING) { newstate = GST_STATE_PAUSED; } else { - gst_element_set_base_time(_pipeline, 0); newstate = GST_STATE_PLAYING; } @@ -193,6 +203,9 @@ gst_element_set_state (_pipeline, GST_STATE_NULL); gst_bin_remove(GST_BIN(_pipeline), _downloader); // will also unref + + // FIXME: we should probably disconnect the currently connected pads + // and remove the video and audio bins from the pipeline. } _downloader = gst_element_make_from_uri(GST_URI_SRC, valid_url.c_str(), @@ -204,9 +217,14 @@ gst_element_link(_downloader, _dataqueue); - // if everything went well, start playback - gst_element_set_state (_pipeline, GST_STATE_PLAYING); + // Pause the pipeline. This will give decodebin a chance to detect streams. + gst_element_set_state (_pipeline, GST_STATE_PAUSED); + + // Wait for pause return; by this time, decodebin should be about finished. + gst_element_get_state (_pipeline, NULL, NULL, 0); + // Commence playback. + gst_element_set_state (_pipeline, GST_STATE_PLAYING); } @@ -262,7 +280,7 @@ double NetStreamGst::getCurrentFPS() { - GstElement* colorspace = gst_bin_get_by_name (GST_BIN(_pipeline), "gnash_colorspace"); + GstElement* colorspace = gst_bin_get_by_name (GST_BIN(_videobin), "gnash_colorspace"); GstPad* videopad = gst_element_get_static_pad (colorspace, "src"); @@ -413,6 +431,7 @@ g_free (debug); setStatus(streamNotFound); + setStatus(playStop); // Clear any buffers. gst_element_set_state (_pipeline, GST_STATE_NULL); @@ -491,7 +510,7 @@ { NetStreamGst* ns = reinterpret_cast<NetStreamGst*>(user_data); - GstElement* colorspace = gst_bin_get_by_name (GST_BIN(ns->_pipeline), + GstElement* colorspace = gst_bin_get_by_name (GST_BIN(ns->_videobin), "gnash_colorspace"); GstPad* videopad = gst_element_get_static_pad (colorspace, "src"); @@ -521,7 +540,6 @@ gst_caps_unref(caps); } - void NetStreamGst::decodebin_newpad_cb(GstElement* /*decodebin*/, GstPad* pad, gboolean /*last*/, gpointer user_data) @@ -532,26 +550,36 @@ GstStructure* str = gst_caps_get_structure (caps, 0); const gchar* structure_name = gst_structure_get_name (str); - gst_caps_unref (caps); + GstElement* sink; if (g_strrstr (structure_name, "audio")) { - if (GST_PAD_IS_LINKED (ns->_audiopad)) { + sink = ns->_audiobin; + } else if (g_strrstr (structure_name, "video")) { + sink = ns->_videobin; + } else { + log_unimpl(_("Streams of type %s are not supported!"), structure_name); return; } - gst_pad_link (pad, ns->_audiopad); + log_msg("%s: linking %s stream.", structure_name, __FUNCTION__); - } else if (g_strrstr (structure_name, "video")) { + gst_caps_unref (caps); + + gst_bin_add (GST_BIN(ns->_pipeline), sink); + + gst_element_set_state (sink, GST_STATE_PAUSED); - if (GST_PAD_IS_LINKED (ns->_videopad)) { + GstPad* sinkpad = gst_element_get_pad (sink, "sink"); + + if (GST_PAD_IS_LINKED(sinkpad)) { + // already linked + gst_object_unref(G_OBJECT(sinkpad)); return; } - gst_pad_link (pad, ns->_videopad); + gst_pad_link(pad, sinkpad); - } else { - log_unimpl(_("Streams of type %s are not expected!"), structure_name); - } + gst_object_unref(G_OBJECT(sinkpad)); } void Index: server/asobj/NetStreamGst.h =================================================================== RCS file: /sources/gnash/gnash/server/asobj/NetStreamGst.h,v retrieving revision 1.31 retrieving revision 1.32 diff -u -b -r1.31 -r1.32 --- server/asobj/NetStreamGst.h 21 Jan 2008 20:55:57 -0000 1.31 +++ server/asobj/NetStreamGst.h 22 Jan 2008 08:39:08 -0000 1.32 @@ -15,7 +15,7 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -/* $Id: NetStreamGst.h,v 1.31 2008/01/21 20:55:57 rsavoye Exp $ */ +/* $Id: NetStreamGst.h,v 1.32 2008/01/22 08:39:08 bjacques Exp $ */ #ifndef __NETSTREAMGST_H__ #define __NETSTREAMGST_H__ @@ -77,8 +77,8 @@ GstElement* _pipeline; GstElement* _dataqueue; GstElement* _downloader; - GstPad* _videopad; - GstPad* _audiopad; + GstElement* _audiobin; + GstElement* _videobin; gint64 _duration; }; _______________________________________________ Gnash-commit mailing list Gnash-commit@gnu.org http://lists.gnu.org/mailman/listinfo/gnash-commit