From 29f7ae7e3ecfcde6c7a46d550f43954ac284b12f Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Mon, 16 Mar 2009 07:39:13 -0700 Subject: Visual Studio now ignores C4244 warnings in GStreamer --- linden/indra/llmedia/llmediaimplgstreamer.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'linden/indra/llmedia/llmediaimplgstreamer.cpp') diff --git a/linden/indra/llmedia/llmediaimplgstreamer.cpp b/linden/indra/llmedia/llmediaimplgstreamer.cpp index 30706f1..b37deac 100644 --- a/linden/indra/llmedia/llmediaimplgstreamer.cpp +++ b/linden/indra/llmedia/llmediaimplgstreamer.cpp @@ -30,15 +30,26 @@ * $/LicenseInfo$ */ -#include "llmediaimplgstreamer.h" - ///#if LL_GSTREAMER_ENABLED +#if LL_WINDOWS + // GStreamer 0.10.22 - gstutils.h - conversion from 'guint64' to 'guint8'. + // This was an intentional change to make GStreamer more threadsafe, and + // is okay. Delete this bit if GStreamer ever gets more VS-friendly -- McCabe + #pragma warning(disable : 4244) +#endif + +#include "llmediaimplgstreamer.h" + extern "C" { #include #include } +#if LL_WINDOWS + #pragma warning(default : 4244) +#endif + #include "llmediamanager.h" #include "llmediaimplregister.h" -- cgit v1.1 From 1f8e02f1bff0e38e692e64be9bc1ae413fa62787 Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Fri, 27 Mar 2009 20:36:13 -0700 Subject: Fixed video streams freezing the viewer --- linden/indra/llmedia/llmediaimplgstreamer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'linden/indra/llmedia/llmediaimplgstreamer.cpp') diff --git a/linden/indra/llmedia/llmediaimplgstreamer.cpp b/linden/indra/llmedia/llmediaimplgstreamer.cpp index 98d6459..e38dc29 100644 --- a/linden/indra/llmedia/llmediaimplgstreamer.cpp +++ b/linden/indra/llmedia/llmediaimplgstreamer.cpp @@ -582,7 +582,7 @@ bool LLMediaImplGStreamer::stop() else mState = GST_STATE_READY; - GstStateChangeReturn state_change = gst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE); + GstStateChangeReturn state_change = gst_element_get_state(mPlaybin, NULL, NULL, GST_MSECOND*5); LL_DEBUGS("MediaImpl") << "get_state: " << gst_element_state_change_return_get_name(state_change) << LL_ENDL; return true; @@ -605,7 +605,7 @@ bool LLMediaImplGStreamer::play() /*gst_element_set_state(mPlaybin, GST_STATE_PLAYING); mState = GST_STATE_PLAYING;*/ - GstStateChangeReturn state_change = gst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE); + GstStateChangeReturn state_change = gst_element_get_state(mPlaybin, NULL, NULL, GST_MSECOND*5); LL_DEBUGS("MediaImpl") << "get_state: " << gst_element_state_change_return_get_name(state_change) << LL_ENDL; // Check to make sure playing was successful. If not, stop. @@ -630,7 +630,7 @@ bool LLMediaImplGStreamer::pause() gst_element_set_state(mPlaybin, GST_STATE_PAUSED); mState = GST_STATE_PAUSED; - GstStateChangeReturn state_change = gst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE); + GstStateChangeReturn state_change = gst_element_get_state(mPlaybin, NULL, NULL, GST_MSECOND*5); LL_DEBUGS("MediaImpl") << "get_state: " << gst_element_state_change_return_get_name(state_change) << LL_ENDL; return true; -- cgit v1.1 From c7aedac540588fe86a25da77d18608d237fbb130 Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Sun, 29 Mar 2009 22:44:29 -0700 Subject: Added loading info to log's plugin list, set_gst_plugin_path now compiles for windows --- linden/indra/llmedia/llmediaimplgstreamer.cpp | 36 +++++++++++++++++---------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'linden/indra/llmedia/llmediaimplgstreamer.cpp') diff --git a/linden/indra/llmedia/llmediaimplgstreamer.cpp b/linden/indra/llmedia/llmediaimplgstreamer.cpp index debc95c..3c4d0a0 100644 --- a/linden/indra/llmedia/llmediaimplgstreamer.cpp +++ b/linden/indra/llmedia/llmediaimplgstreamer.cpp @@ -48,6 +48,8 @@ extern "C" { #if LL_WINDOWS #pragma warning(default : 4244) +#include +#include #endif #include "llmediamanager.h" @@ -196,12 +198,14 @@ bool LLMediaImplGStreamer::startup (LLMediaManagerData* init_data) LL_DEBUGS("MediaImpl") << "Found GStreamer plugins:" << LL_ENDL; GList *list; GstRegistry *registry = gst_registry_get_default(); + std::string loaded = ""; for (list = gst_registry_get_plugin_list(registry); list != NULL; list = g_list_next(list)) { GstPlugin *list_plugin = (GstPlugin *)list->data; - LL_DEBUGS("MediaImpl") << gst_plugin_get_name(list_plugin) << LL_ENDL; + (bool)gst_plugin_is_loaded(list_plugin) ? loaded = "Yes" : loaded = "No"; + LL_DEBUGS("MediaImpl") << gst_plugin_get_name(list_plugin) << ", loaded? " << loaded << LL_ENDL; } gst_plugin_list_free(list); @@ -225,12 +229,12 @@ void LLMediaImplGStreamer::set_gst_plugin_path() if(imp_cwd == NULL) { - LL_DEBUGS("LLMediaImpl") << "_getcwd failed, not setting GST_PLUGIN_PATH." + LL_DEBUGS("MediaImpl") << "_getcwd failed, not setting GST_PLUGIN_PATH." << LL_ENDL; } else { - LL_DEBUGS("LLMediaImpl") << "Imprudence is installed at " + LL_DEBUGS("MediaImpl") << "Imprudence is installed at " << imp_cwd << LL_ENDL; // Grab the current path, if it's set. @@ -238,28 +242,34 @@ void LLMediaImplGStreamer::set_gst_plugin_path() char *old_path = getenv("GST_PLUGIN_PATH"); if(old_path == NULL) { - LL_DEBUGS("LLMediaImpl") << "Did not find user-set GST_PLUGIN_PATH." + LL_DEBUGS("MediaImpl") << "Did not find user-set GST_PLUGIN_PATH." << LL_ENDL; } else { - old_plugin_path = std::string( old_path ) + ":"; + old_plugin_path = ";" + std::string( old_path ); } // Search both Imprudence and Imprudence\lib\gstreamer-plugins. - // But we also want to first search the path the user has set, if any. + // If those fail, search the path the user has set, if any. std::string plugin_path = "GST_PLUGIN_PATH=" + - old_plugin_path + - std::string(imp_cwd) + ":" + - std::string(imp_cwd) + "\\lib\\gstreamer-plugins"; + std::string(imp_cwd) + "\\lib\\gstreamer-plugins;" + + std::string(imp_cwd) + + old_plugin_path; // Place GST_PLUGIN_PATH in the environment settings for imprudence.exe - putenv( (char*)plugin_path.c_str() ); - - LL_DEBUGS("LLMediaImpl") << "GST_PLUGIN_PATH set to " - << getenv("GST_PLUGIN_PATH") << LL_ENDL; + // Returns 0 on success + if(_putenv( (char*)plugin_path.c_str() )) + { + LL_WARNS("MediaImpl") << "Setting environment variable failed!" << LL_ENDL; + } + else + { + LL_DEBUGS("MediaImpl") << "GST_PLUGIN_PATH set to " + << getenv("GST_PLUGIN_PATH") << LL_ENDL; + } } #endif //LL_WINDOWS -- cgit v1.1 From b145debcba6af423e990fddea6430ea414a37e06 Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Mon, 30 Mar 2009 01:56:18 -0700 Subject: removed gst_element_get_state --- linden/indra/llmedia/llmediaimplgstreamer.cpp | 74 ++++++++++++++++----------- 1 file changed, 45 insertions(+), 29 deletions(-) (limited to 'linden/indra/llmedia/llmediaimplgstreamer.cpp') diff --git a/linden/indra/llmedia/llmediaimplgstreamer.cpp b/linden/indra/llmedia/llmediaimplgstreamer.cpp index 3c4d0a0..952e22f 100644 --- a/linden/indra/llmedia/llmediaimplgstreamer.cpp +++ b/linden/indra/llmedia/llmediaimplgstreamer.cpp @@ -653,20 +653,23 @@ bool LLMediaImplGStreamer::stop() if (!mPlaybin || mState == GST_STATE_NULL) return true; - GstElement *pipeline = (GstElement *)gst_object_ref(GST_OBJECT(mPlaybin)); - gst_object_unref(pipeline); - - gst_element_set_state(pipeline, GST_STATE_READY); + GstStateChangeReturn state_change; - if (mState == GST_STATE_PLAYING) - mState = GST_STATE_VOID_PENDING; - else - mState = GST_STATE_READY; + state_change = gst_element_set_state(mPlaybin, GST_STATE_READY); - GstStateChangeReturn state_change = gst_element_get_state(mPlaybin, NULL, NULL, GST_MSECOND*5); - LL_DEBUGS("MediaImpl") << "get_state: " << gst_element_state_change_return_get_name(state_change) << LL_ENDL; + LL_DEBUGS("MediaImpl") << "result: " + << gst_element_state_change_return_get_name(state_change) << LL_ENDL; - return true; + if (state_change == GST_STATE_CHANGE_FAILURE) + { + LL_WARNS("MediaImpl") << "could not stop stream!" << LL_ENDL; + return false; + } + else + { + mState = GST_STATE_READY; + return true; + } } /////////////////////////////////////////////////////////////////////////////// @@ -678,25 +681,28 @@ bool LLMediaImplGStreamer::play() if (!mPlaybin || mState == GST_STATE_NULL) return true; - GstElement *pipeline = (GstElement *)gst_object_ref(GST_OBJECT(mPlaybin)); - gst_object_unref(pipeline); - - gst_element_set_state(pipeline, GST_STATE_PLAYING); - mState = GST_STATE_PLAYING; - /*gst_element_set_state(mPlaybin, GST_STATE_PLAYING); - mState = GST_STATE_PLAYING;*/ + GstStateChangeReturn state_change; + + state_change = gst_element_set_state(mPlaybin, GST_STATE_PLAYING); - GstStateChangeReturn state_change = gst_element_get_state(mPlaybin, NULL, NULL, GST_MSECOND*5); - LL_DEBUGS("MediaImpl") << "get_state: " << gst_element_state_change_return_get_name(state_change) << LL_ENDL; + LL_DEBUGS("MediaImpl") << "result: " + << gst_element_state_change_return_get_name(state_change) << LL_ENDL; // Check to make sure playing was successful. If not, stop. + // NOTE: state_change is almost always GST_STATE_CHANGE_ASYNC if (state_change == GST_STATE_CHANGE_FAILURE) { - setStatus(LLMediaBase::STATUS_STOPPED); + // If failing from a bad stream, go into pending state + // (this is stopped at the callback) + mState = GST_STATE_VOID_PENDING; stop(); + return false; + } + else + { + mState = GST_STATE_PLAYING; + return true; } - - return true; } /////////////////////////////////////////////////////////////////////////////// @@ -708,13 +714,23 @@ bool LLMediaImplGStreamer::pause() if (!mPlaybin || mState == GST_STATE_NULL) return true; - gst_element_set_state(mPlaybin, GST_STATE_PAUSED); - mState = GST_STATE_PAUSED; - - GstStateChangeReturn state_change = gst_element_get_state(mPlaybin, NULL, NULL, GST_MSECOND*5); - LL_DEBUGS("MediaImpl") << "get_state: " << gst_element_state_change_return_get_name(state_change) << LL_ENDL; + GstStateChangeReturn state_change; - return true; + state_change = gst_element_set_state(mPlaybin, GST_STATE_PAUSED); + + LL_DEBUGS("MediaImpl") << "result: " + << gst_element_state_change_return_get_name(state_change) << LL_ENDL; + + if (state_change == GST_STATE_CHANGE_FAILURE) + { + LL_WARNS("MediaImpl") << "could not pause stream!" << LL_ENDL; + return false; + } + else + { + mState = GST_STATE_PAUSED; + return true; + } }; -- cgit v1.1 From c45ebced5a8a8209bdc55144d5e746b3e9ffa739 Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Tue, 31 Mar 2009 02:24:11 -0700 Subject: Cleaned up logic for bad streams --- linden/indra/llmedia/llmediaimplgstreamer.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'linden/indra/llmedia/llmediaimplgstreamer.cpp') diff --git a/linden/indra/llmedia/llmediaimplgstreamer.cpp b/linden/indra/llmedia/llmediaimplgstreamer.cpp index 952e22f..8ffb7c8 100644 --- a/linden/indra/llmedia/llmediaimplgstreamer.cpp +++ b/linden/indra/llmedia/llmediaimplgstreamer.cpp @@ -657,8 +657,7 @@ bool LLMediaImplGStreamer::stop() state_change = gst_element_set_state(mPlaybin, GST_STATE_READY); - LL_DEBUGS("MediaImpl") << "result: " - << gst_element_state_change_return_get_name(state_change) << LL_ENDL; + LL_DEBUGS("MediaImpl") << gst_element_state_change_return_get_name(state_change) << LL_ENDL; if (state_change == GST_STATE_CHANGE_FAILURE) { @@ -667,7 +666,8 @@ bool LLMediaImplGStreamer::stop() } else { - mState = GST_STATE_READY; + // Going into pending after play keeps dead streams from looping + (mState == GST_STATE_PLAYING) ? (mState = GST_STATE_VOID_PENDING) : (mState = GST_STATE_READY); return true; } } @@ -684,23 +684,23 @@ bool LLMediaImplGStreamer::play() GstStateChangeReturn state_change; state_change = gst_element_set_state(mPlaybin, GST_STATE_PLAYING); + mState = GST_STATE_PLAYING; - LL_DEBUGS("MediaImpl") << "result: " - << gst_element_state_change_return_get_name(state_change) << LL_ENDL; + LL_DEBUGS("MediaImpl") << gst_element_state_change_return_get_name(state_change) << LL_ENDL; // Check to make sure playing was successful. If not, stop. // NOTE: state_change is almost always GST_STATE_CHANGE_ASYNC if (state_change == GST_STATE_CHANGE_FAILURE) { - // If failing from a bad stream, go into pending state - // (this is stopped at the callback) - mState = GST_STATE_VOID_PENDING; + // If failing from a bad stream, go into an unknown + // state to stop bus_callback from looping back. + // We also force a stop in case the operations don't sync + setStatus(LLMediaBase::STATUS_UNKNOWN); stop(); return false; } else { - mState = GST_STATE_PLAYING; return true; } } @@ -718,8 +718,7 @@ bool LLMediaImplGStreamer::pause() state_change = gst_element_set_state(mPlaybin, GST_STATE_PAUSED); - LL_DEBUGS("MediaImpl") << "result: " - << gst_element_state_change_return_get_name(state_change) << LL_ENDL; + LL_DEBUGS("MediaImpl") << gst_element_state_change_return_get_name(state_change) << LL_ENDL; if (state_change == GST_STATE_CHANGE_FAILURE) { -- cgit v1.1