aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmedia/llmediaimplgstreamer.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2009-04-06 01:29:22 -0500
committerJacek Antonelli2009-04-06 01:29:22 -0500
commite06d504a68a72c321794b5e8740ccefcc45f654b (patch)
tree24d844d82b77957e763e6bc9a3103e29aa77f5f3 /linden/indra/llmedia/llmediaimplgstreamer.cpp
parentApply saved MediaDebugLevel at media init time. (diff)
parentCleaned up logic for bad streams (diff)
downloadmeta-impy-e06d504a68a72c321794b5e8740ccefcc45f654b.zip
meta-impy-e06d504a68a72c321794b5e8740ccefcc45f654b.tar.gz
meta-impy-e06d504a68a72c321794b5e8740ccefcc45f654b.tar.bz2
meta-impy-e06d504a68a72c321794b5e8740ccefcc45f654b.tar.xz
Merge commit 'mccabe/gst-revamp' into gst-revamp
Diffstat (limited to 'linden/indra/llmedia/llmediaimplgstreamer.cpp')
-rw-r--r--linden/indra/llmedia/llmediaimplgstreamer.cpp122
1 files changed, 79 insertions, 43 deletions
diff --git a/linden/indra/llmedia/llmediaimplgstreamer.cpp b/linden/indra/llmedia/llmediaimplgstreamer.cpp
index 532ec00..271bb5e 100644
--- a/linden/indra/llmedia/llmediaimplgstreamer.cpp
+++ b/linden/indra/llmedia/llmediaimplgstreamer.cpp
@@ -30,15 +30,28 @@
30 * $/LicenseInfo$ 30 * $/LicenseInfo$
31 */ 31 */
32 32
33#include "llmediaimplgstreamer.h"
34
35///#if LL_GSTREAMER_ENABLED 33///#if LL_GSTREAMER_ENABLED
36 34
35#if LL_WINDOWS
36 // GStreamer 0.10.22 - gstutils.h - conversion from 'guint64' to 'guint8'.
37 // This was an intentional change to make GStreamer more threadsafe, and
38 // is okay. Delete this bit if GStreamer ever gets more VS-friendly -- McCabe
39 #pragma warning(disable : 4244)
40#endif
41
42#include "llmediaimplgstreamer.h"
43
37extern "C" { 44extern "C" {
38#include <gst/gst.h> 45#include <gst/gst.h>
39#include <gst/gstelement.h> 46#include <gst/gstelement.h>
40} 47}
41 48
49#if LL_WINDOWS
50 #pragma warning(default : 4244)
51#include <direct.h>
52#include <stdlib.h>
53#endif
54
42#include "llmediamanager.h" 55#include "llmediamanager.h"
43#include "llmediaimplregister.h" 56#include "llmediaimplregister.h"
44 57
@@ -189,12 +202,14 @@ bool LLMediaImplGStreamer::startup (LLMediaManagerData* init_data)
189 LL_DEBUGS("MediaImpl") << "Found GStreamer plugins:" << LL_ENDL; 202 LL_DEBUGS("MediaImpl") << "Found GStreamer plugins:" << LL_ENDL;
190 GList *list; 203 GList *list;
191 GstRegistry *registry = gst_registry_get_default(); 204 GstRegistry *registry = gst_registry_get_default();
205 std::string loaded = "";
192 for (list = gst_registry_get_plugin_list(registry); 206 for (list = gst_registry_get_plugin_list(registry);
193 list != NULL; 207 list != NULL;
194 list = g_list_next(list)) 208 list = g_list_next(list))
195 { 209 {
196 GstPlugin *list_plugin = (GstPlugin *)list->data; 210 GstPlugin *list_plugin = (GstPlugin *)list->data;
197 LL_DEBUGS("MediaImpl") << gst_plugin_get_name(list_plugin) << LL_ENDL; 211 (bool)gst_plugin_is_loaded(list_plugin) ? loaded = "Yes" : loaded = "No";
212 LL_DEBUGS("MediaImpl") << gst_plugin_get_name(list_plugin) << ", loaded? " << loaded << LL_ENDL;
198 } 213 }
199 gst_plugin_list_free(list); 214 gst_plugin_list_free(list);
200 215
@@ -218,12 +233,12 @@ void LLMediaImplGStreamer::set_gst_plugin_path()
218 233
219 if(imp_cwd == NULL) 234 if(imp_cwd == NULL)
220 { 235 {
221 LL_DEBUGS("LLMediaImpl") << "_getcwd failed, not setting GST_PLUGIN_PATH." 236 LL_DEBUGS("MediaImpl") << "_getcwd failed, not setting GST_PLUGIN_PATH."
222 << LL_ENDL; 237 << LL_ENDL;
223 } 238 }
224 else 239 else
225 { 240 {
226 LL_DEBUGS("LLMediaImpl") << "Imprudence is installed at " 241 LL_DEBUGS("MediaImpl") << "Imprudence is installed at "
227 << imp_cwd << LL_ENDL; 242 << imp_cwd << LL_ENDL;
228 243
229 // Grab the current path, if it's set. 244 // Grab the current path, if it's set.
@@ -231,28 +246,34 @@ void LLMediaImplGStreamer::set_gst_plugin_path()
231 char *old_path = getenv("GST_PLUGIN_PATH"); 246 char *old_path = getenv("GST_PLUGIN_PATH");
232 if(old_path == NULL) 247 if(old_path == NULL)
233 { 248 {
234 LL_DEBUGS("LLMediaImpl") << "Did not find user-set GST_PLUGIN_PATH." 249 LL_DEBUGS("MediaImpl") << "Did not find user-set GST_PLUGIN_PATH."
235 << LL_ENDL; 250 << LL_ENDL;
236 } 251 }
237 else 252 else
238 { 253 {
239 old_plugin_path = std::string( old_path ) + ":"; 254 old_plugin_path = ";" + std::string( old_path );
240 } 255 }
241 256
242 257
243 // Search both Imprudence and Imprudence\lib\gstreamer-plugins. 258 // Search both Imprudence and Imprudence\lib\gstreamer-plugins.
244 // But we also want to first search the path the user has set, if any. 259 // If those fail, search the path the user has set, if any.
245 std::string plugin_path = 260 std::string plugin_path =
246 "GST_PLUGIN_PATH=" + 261 "GST_PLUGIN_PATH=" +
247 old_plugin_path + 262 std::string(imp_cwd) + "\\lib\\gstreamer-plugins;" +
248 std::string(imp_cwd) + ":" + 263 std::string(imp_cwd) +
249 std::string(imp_cwd) + "\\lib\\gstreamer-plugins"; 264 old_plugin_path;
250 265
251 // Place GST_PLUGIN_PATH in the environment settings for imprudence.exe 266 // Place GST_PLUGIN_PATH in the environment settings for imprudence.exe
252 putenv( (char*)plugin_path.c_str() ); 267 // Returns 0 on success
253 268 if(_putenv( (char*)plugin_path.c_str() ))
254 LL_DEBUGS("LLMediaImpl") << "GST_PLUGIN_PATH set to " 269 {
255 << getenv("GST_PLUGIN_PATH") << LL_ENDL; 270 LL_WARNS("MediaImpl") << "Setting environment variable failed!" << LL_ENDL;
271 }
272 else
273 {
274 LL_DEBUGS("MediaImpl") << "GST_PLUGIN_PATH set to "
275 << getenv("GST_PLUGIN_PATH") << LL_ENDL;
276 }
256 } 277 }
257 278
258#endif //LL_WINDOWS 279#endif //LL_WINDOWS
@@ -688,20 +709,23 @@ bool LLMediaImplGStreamer::stop()
688 if (!mPlaybin || mState == GST_STATE_NULL) 709 if (!mPlaybin || mState == GST_STATE_NULL)
689 return true; 710 return true;
690 711
691 GstElement *pipeline = (GstElement *)gst_object_ref(GST_OBJECT(mPlaybin)); 712 GstStateChangeReturn state_change;
692 gst_object_unref(pipeline);
693
694 gst_element_set_state(pipeline, GST_STATE_READY);
695 713
696 if (mState == GST_STATE_PLAYING) 714 state_change = gst_element_set_state(mPlaybin, GST_STATE_READY);
697 mState = GST_STATE_VOID_PENDING;
698 else
699 mState = GST_STATE_READY;
700 715
701 GstStateChangeReturn state_change = gst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE); 716 LL_DEBUGS("MediaImpl") << gst_element_state_change_return_get_name(state_change) << LL_ENDL;
702 LL_DEBUGS("MediaImpl") << "get_state: " << gst_element_state_change_return_get_name(state_change) << LL_ENDL;
703 717
704 return true; 718 if (state_change == GST_STATE_CHANGE_FAILURE)
719 {
720 LL_WARNS("MediaImpl") << "could not stop stream!" << LL_ENDL;
721 return false;
722 }
723 else
724 {
725 // Going into pending after play keeps dead streams from looping
726 (mState == GST_STATE_PLAYING) ? (mState = GST_STATE_VOID_PENDING) : (mState = GST_STATE_READY);
727 return true;
728 }
705} 729}
706 730
707/////////////////////////////////////////////////////////////////////////////// 731///////////////////////////////////////////////////////////////////////////////
@@ -713,25 +737,28 @@ bool LLMediaImplGStreamer::play()
713 if (!mPlaybin || mState == GST_STATE_NULL) 737 if (!mPlaybin || mState == GST_STATE_NULL)
714 return true; 738 return true;
715 739
716 GstElement *pipeline = (GstElement *)gst_object_ref(GST_OBJECT(mPlaybin)); 740 GstStateChangeReturn state_change;
717 gst_object_unref(pipeline); 741
718 742 state_change = gst_element_set_state(mPlaybin, GST_STATE_PLAYING);
719 gst_element_set_state(pipeline, GST_STATE_PLAYING);
720 mState = GST_STATE_PLAYING; 743 mState = GST_STATE_PLAYING;
721 /*gst_element_set_state(mPlaybin, GST_STATE_PLAYING);
722 mState = GST_STATE_PLAYING;*/
723 744
724 GstStateChangeReturn state_change = gst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE); 745 LL_DEBUGS("MediaImpl") << gst_element_state_change_return_get_name(state_change) << LL_ENDL;
725 LL_DEBUGS("MediaImpl") << "get_state: " << gst_element_state_change_return_get_name(state_change) << LL_ENDL;
726 746
727 // Check to make sure playing was successful. If not, stop. 747 // Check to make sure playing was successful. If not, stop.
748 // NOTE: state_change is almost always GST_STATE_CHANGE_ASYNC
728 if (state_change == GST_STATE_CHANGE_FAILURE) 749 if (state_change == GST_STATE_CHANGE_FAILURE)
729 { 750 {
730 setStatus(LLMediaBase::STATUS_STOPPED); 751 // If failing from a bad stream, go into an unknown
752 // state to stop bus_callback from looping back.
753 // We also force a stop in case the operations don't sync
754 setStatus(LLMediaBase::STATUS_UNKNOWN);
731 stop(); 755 stop();
756 return false;
757 }
758 else
759 {
760 return true;
732 } 761 }
733
734 return true;
735} 762}
736 763
737/////////////////////////////////////////////////////////////////////////////// 764///////////////////////////////////////////////////////////////////////////////
@@ -743,13 +770,22 @@ bool LLMediaImplGStreamer::pause()
743 if (!mPlaybin || mState == GST_STATE_NULL) 770 if (!mPlaybin || mState == GST_STATE_NULL)
744 return true; 771 return true;
745 772
746 gst_element_set_state(mPlaybin, GST_STATE_PAUSED); 773 GstStateChangeReturn state_change;
747 mState = GST_STATE_PAUSED;
748
749 GstStateChangeReturn state_change = gst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE);
750 LL_DEBUGS("MediaImpl") << "get_state: " << gst_element_state_change_return_get_name(state_change) << LL_ENDL;
751 774
752 return true; 775 state_change = gst_element_set_state(mPlaybin, GST_STATE_PAUSED);
776
777 LL_DEBUGS("MediaImpl") << gst_element_state_change_return_get_name(state_change) << LL_ENDL;
778
779 if (state_change == GST_STATE_CHANGE_FAILURE)
780 {
781 LL_WARNS("MediaImpl") << "could not pause stream!" << LL_ENDL;
782 return false;
783 }
784 else
785 {
786 mState = GST_STATE_PAUSED;
787 return true;
788 }
753}; 789};
754 790
755 791