aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmedia
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llmedia')
-rw-r--r--linden/indra/llmedia/llmediaimplgstreamer.cpp108
-rw-r--r--linden/indra/llmedia/llmediamanager.cpp14
2 files changed, 86 insertions, 36 deletions
diff --git a/linden/indra/llmedia/llmediaimplgstreamer.cpp b/linden/indra/llmedia/llmediaimplgstreamer.cpp
index c8f793d..7ae6b02 100644
--- a/linden/indra/llmedia/llmediaimplgstreamer.cpp
+++ b/linden/indra/llmedia/llmediaimplgstreamer.cpp
@@ -32,8 +32,14 @@
32 32
33///#if LL_GSTREAMER_ENABLED 33///#if LL_GSTREAMER_ENABLED
34 34
35#include "linden_common.h" 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
36 41
42#include "linden_common.h"
37#include "llmediaimplgstreamer.h" 43#include "llmediaimplgstreamer.h"
38 44
39extern "C" { 45extern "C" {
@@ -41,6 +47,12 @@ extern "C" {
41#include <gst/gstelement.h> 47#include <gst/gstelement.h>
42} 48}
43 49
50#if LL_WINDOWS
51 #pragma warning(default : 4244)
52#include <direct.h>
53#include <stdlib.h>
54#endif
55
44#include "llmediamanager.h" 56#include "llmediamanager.h"
45#include "llmediaimplregister.h" 57#include "llmediaimplregister.h"
46 58
@@ -191,12 +203,14 @@ bool LLMediaImplGStreamer::startup (LLMediaManagerData* init_data)
191 LL_DEBUGS("MediaImpl") << "Found GStreamer plugins:" << LL_ENDL; 203 LL_DEBUGS("MediaImpl") << "Found GStreamer plugins:" << LL_ENDL;
192 GList *list; 204 GList *list;
193 GstRegistry *registry = gst_registry_get_default(); 205 GstRegistry *registry = gst_registry_get_default();
206 std::string loaded = "";
194 for (list = gst_registry_get_plugin_list(registry); 207 for (list = gst_registry_get_plugin_list(registry);
195 list != NULL; 208 list != NULL;
196 list = g_list_next(list)) 209 list = g_list_next(list))
197 { 210 {
198 GstPlugin *list_plugin = (GstPlugin *)list->data; 211 GstPlugin *list_plugin = (GstPlugin *)list->data;
199 LL_DEBUGS("MediaImpl") << gst_plugin_get_name(list_plugin) << LL_ENDL; 212 (bool)gst_plugin_is_loaded(list_plugin) ? loaded = "Yes" : loaded = "No";
213 LL_DEBUGS("MediaImpl") << gst_plugin_get_name(list_plugin) << ", loaded? " << loaded << LL_ENDL;
200 } 214 }
201 gst_plugin_list_free(list); 215 gst_plugin_list_free(list);
202 216
@@ -220,12 +234,12 @@ void LLMediaImplGStreamer::set_gst_plugin_path()
220 234
221 if(imp_cwd == NULL) 235 if(imp_cwd == NULL)
222 { 236 {
223 LL_DEBUGS("LLMediaImpl") << "_getcwd failed, not setting GST_PLUGIN_PATH." 237 LL_DEBUGS("MediaImpl") << "_getcwd failed, not setting GST_PLUGIN_PATH."
224 << LL_ENDL; 238 << LL_ENDL;
225 } 239 }
226 else 240 else
227 { 241 {
228 LL_DEBUGS("LLMediaImpl") << "Imprudence is installed at " 242 LL_DEBUGS("MediaImpl") << "Imprudence is installed at "
229 << imp_cwd << LL_ENDL; 243 << imp_cwd << LL_ENDL;
230 244
231 // Grab the current path, if it's set. 245 // Grab the current path, if it's set.
@@ -233,28 +247,34 @@ void LLMediaImplGStreamer::set_gst_plugin_path()
233 char *old_path = getenv("GST_PLUGIN_PATH"); 247 char *old_path = getenv("GST_PLUGIN_PATH");
234 if(old_path == NULL) 248 if(old_path == NULL)
235 { 249 {
236 LL_DEBUGS("LLMediaImpl") << "Did not find user-set GST_PLUGIN_PATH." 250 LL_DEBUGS("MediaImpl") << "Did not find user-set GST_PLUGIN_PATH."
237 << LL_ENDL; 251 << LL_ENDL;
238 } 252 }
239 else 253 else
240 { 254 {
241 old_plugin_path = std::string( old_path ) + ":"; 255 old_plugin_path = ";" + std::string( old_path );
242 } 256 }
243 257
244 258
245 // Search both Imprudence and Imprudence\lib\gstreamer-plugins. 259 // Search both Imprudence and Imprudence\lib\gstreamer-plugins.
246 // But we also want to first search the path the user has set, if any. 260 // If those fail, search the path the user has set, if any.
247 std::string plugin_path = 261 std::string plugin_path =
248 "GST_PLUGIN_PATH=" + 262 "GST_PLUGIN_PATH=" +
249 old_plugin_path + 263 std::string(imp_cwd) + "\\lib\\gstreamer-plugins;" +
250 std::string(imp_cwd) + ":" + 264 std::string(imp_cwd) +
251 std::string(imp_cwd) + "\\lib\\gstreamer-plugins"; 265 old_plugin_path;
252 266
253 // Place GST_PLUGIN_PATH in the environment settings for imprudence.exe 267 // Place GST_PLUGIN_PATH in the environment settings for imprudence.exe
254 putenv( (char*)plugin_path.c_str() ); 268 // Returns 0 on success
255 269 if(_putenv( (char*)plugin_path.c_str() ))
256 LL_DEBUGS("LLMediaImpl") << "GST_PLUGIN_PATH set to " 270 {
257 << getenv("GST_PLUGIN_PATH") << LL_ENDL; 271 LL_WARNS("MediaImpl") << "Setting environment variable failed!" << LL_ENDL;
272 }
273 else
274 {
275 LL_DEBUGS("MediaImpl") << "GST_PLUGIN_PATH set to "
276 << getenv("GST_PLUGIN_PATH") << LL_ENDL;
277 }
258 } 278 }
259 279
260#endif //LL_WINDOWS 280#endif //LL_WINDOWS
@@ -690,20 +710,23 @@ bool LLMediaImplGStreamer::stop()
690 if (!mPlaybin || mState == GST_STATE_NULL) 710 if (!mPlaybin || mState == GST_STATE_NULL)
691 return true; 711 return true;
692 712
693 GstElement *pipeline = (GstElement *)gst_object_ref(GST_OBJECT(mPlaybin)); 713 GstStateChangeReturn state_change;
694 gst_object_unref(pipeline);
695
696 gst_element_set_state(pipeline, GST_STATE_READY);
697 714
698 if (mState == GST_STATE_PLAYING) 715 state_change = gst_element_set_state(mPlaybin, GST_STATE_READY);
699 mState = GST_STATE_VOID_PENDING;
700 else
701 mState = GST_STATE_READY;
702 716
703 GstStateChangeReturn state_change = gst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE); 717 LL_DEBUGS("MediaImpl") << gst_element_state_change_return_get_name(state_change) << LL_ENDL;
704 LL_DEBUGS("MediaImpl") << "get_state: " << gst_element_state_change_return_get_name(state_change) << LL_ENDL;
705 718
706 return true; 719 if (state_change == GST_STATE_CHANGE_FAILURE)
720 {
721 LL_WARNS("MediaImpl") << "could not stop stream!" << LL_ENDL;
722 return false;
723 }
724 else
725 {
726 // Going into pending after play keeps dead streams from looping
727 (mState == GST_STATE_PLAYING) ? (mState = GST_STATE_VOID_PENDING) : (mState = GST_STATE_READY);
728 return true;
729 }
707} 730}
708 731
709/////////////////////////////////////////////////////////////////////////////// 732///////////////////////////////////////////////////////////////////////////////
@@ -733,21 +756,27 @@ bool LLMediaImplGStreamer::play()
733 return true; 756 return true;
734} 757}
735 758
759
736void LLMediaImplGStreamer::startPlay() 760void LLMediaImplGStreamer::startPlay()
737{ 761{
738 GstElement *pipeline = (GstElement *)gst_object_ref(GST_OBJECT(mPlaybin)); 762 GstElement *pipeline = (GstElement *)gst_object_ref(GST_OBJECT(mPlaybin));
739 gst_object_unref(pipeline); 763 gst_object_unref(pipeline);
740 764
741 gst_element_set_state(pipeline, GST_STATE_PLAYING); 765 GstStateChangeReturn state_change;
766
767 state_change = gst_element_set_state(mPlaybin, GST_STATE_PLAYING);
742 mState = GST_STATE_PLAYING; 768 mState = GST_STATE_PLAYING;
743 769
744 GstStateChangeReturn state_change = gst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE); 770 LL_DEBUGS("MediaImpl") << gst_element_state_change_return_get_name(state_change) << LL_ENDL;
745 LL_DEBUGS("MediaImpl") << "get_state: " << gst_element_state_change_return_get_name(state_change) << LL_ENDL;
746 771
747 // Check to make sure playing was successful. If not, stop. 772 // Check to make sure playing was successful. If not, stop.
773 // NOTE: state_change is almost always GST_STATE_CHANGE_ASYNC
748 if (state_change == GST_STATE_CHANGE_FAILURE) 774 if (state_change == GST_STATE_CHANGE_FAILURE)
749 { 775 {
750 setStatus(LLMediaBase::STATUS_STOPPED); 776 // If failing from a bad stream, go into an unknown
777 // state to stop bus_callback from looping back.
778 // We also force a stop in case the operations don't sync
779 setStatus(LLMediaBase::STATUS_UNKNOWN);
751 stop(); 780 stop();
752 } 781 }
753} 782}
@@ -761,13 +790,22 @@ bool LLMediaImplGStreamer::pause()
761 if (!mPlaybin || mState == GST_STATE_NULL) 790 if (!mPlaybin || mState == GST_STATE_NULL)
762 return true; 791 return true;
763 792
764 gst_element_set_state(mPlaybin, GST_STATE_PAUSED); 793 GstStateChangeReturn state_change;
765 mState = GST_STATE_PAUSED;
766
767 GstStateChangeReturn state_change = gst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE);
768 LL_DEBUGS("MediaImpl") << "get_state: " << gst_element_state_change_return_get_name(state_change) << LL_ENDL;
769 794
770 return true; 795 state_change = gst_element_set_state(mPlaybin, GST_STATE_PAUSED);
796
797 LL_DEBUGS("MediaImpl") << gst_element_state_change_return_get_name(state_change) << LL_ENDL;
798
799 if (state_change == GST_STATE_CHANGE_FAILURE)
800 {
801 LL_WARNS("MediaImpl") << "could not pause stream!" << LL_ENDL;
802 return false;
803 }
804 else
805 {
806 mState = GST_STATE_PAUSED;
807 return true;
808 }
771}; 809};
772 810
773 811
diff --git a/linden/indra/llmedia/llmediamanager.cpp b/linden/indra/llmedia/llmediamanager.cpp
index 5394b62..7fe0df3 100644
--- a/linden/indra/llmedia/llmediamanager.cpp
+++ b/linden/indra/llmedia/llmediamanager.cpp
@@ -30,12 +30,24 @@
30 */ 30 */
31 31
32#include "llmediamanager.h" 32#include "llmediamanager.h"
33
34#if LL_WINDOWS
35 // GStreamer 0.10.22 - gstutils.h - conversion from 'guint64' to 'guint8'.
36 // This was an intentional change to make GStreamer more threadsafe, and
37 // is okay. Delete this bit if GStreamer ever gets more VS-friendly -- McCabe
38 #pragma warning(disable : 4244)
39#endif
40#include "llmediaimplgstreamer.h"
41#if LL_WINDOWS
42 #pragma warning(default : 4244)
43#endif
44
33#include "llmediaimplfactory.h" 45#include "llmediaimplfactory.h"
34 46
35#include "llmediaimplexample1.h" 47#include "llmediaimplexample1.h"
36#include "llmediaimplexample2.h" 48#include "llmediaimplexample2.h"
37#include "llmediaimplquicktime.h" 49#include "llmediaimplquicktime.h"
38#include "llmediaimplgstreamer.h" 50
39#if LL_LLMOZLIB_ENABLED 51#if LL_LLMOZLIB_ENABLED
40# include "llmediaimplllmozlib.h" 52# include "llmediaimplllmozlib.h"
41#endif 53#endif