diff options
author | McCabe Maxsted | 2009-03-30 02:55:33 -0700 |
---|---|---|
committer | McCabe Maxsted | 2009-03-30 02:55:33 -0700 |
commit | 8ad8d0bac5e0305e2f71d05cc9d1c22e71b217af (patch) | |
tree | 377f08b13ac8d0f3ba267a5cff91ebd7ae23431d /linden/indra/llmedia | |
parent | Merge branch 'gst-revamp' into next (diff) | |
parent | Added flag for multi-core compiling in VS2005 (diff) | |
download | meta-impy-8ad8d0bac5e0305e2f71d05cc9d1c22e71b217af.zip meta-impy-8ad8d0bac5e0305e2f71d05cc9d1c22e71b217af.tar.gz meta-impy-8ad8d0bac5e0305e2f71d05cc9d1c22e71b217af.tar.bz2 meta-impy-8ad8d0bac5e0305e2f71d05cc9d1c22e71b217af.tar.xz |
Merge commit 'edadcfadf71ac23d301a1b6fb186883d' into next
Diffstat (limited to '')
-rw-r--r-- | linden/indra/llmedia/llmediaimplgstreamer.cpp | 155 | ||||
-rw-r--r-- | linden/indra/llmedia/llmediaimplgstreamer.h | 4 |
2 files changed, 130 insertions, 29 deletions
diff --git a/linden/indra/llmedia/llmediaimplgstreamer.cpp b/linden/indra/llmedia/llmediaimplgstreamer.cpp index e38dc29..952e22f 100644 --- a/linden/indra/llmedia/llmediaimplgstreamer.cpp +++ b/linden/indra/llmedia/llmediaimplgstreamer.cpp | |||
@@ -48,6 +48,8 @@ extern "C" { | |||
48 | 48 | ||
49 | #if LL_WINDOWS | 49 | #if LL_WINDOWS |
50 | #pragma warning(default : 4244) | 50 | #pragma warning(default : 4244) |
51 | #include <direct.h> | ||
52 | #include <stdlib.h> | ||
51 | #endif | 53 | #endif |
52 | 54 | ||
53 | #include "llmediamanager.h" | 55 | #include "llmediamanager.h" |
@@ -175,6 +177,8 @@ bool LLMediaImplGStreamer::startup (LLMediaManagerData* init_data) | |||
175 | // Init the glib type system - we need it. | 177 | // Init the glib type system - we need it. |
176 | g_type_init(); | 178 | g_type_init(); |
177 | 179 | ||
180 | set_gst_plugin_path(); | ||
181 | |||
178 | // Protect against GStreamer resetting the locale, yuck. | 182 | // Protect against GStreamer resetting the locale, yuck. |
179 | static std::string saved_locale; | 183 | static std::string saved_locale; |
180 | saved_locale = setlocale(LC_ALL, NULL); | 184 | saved_locale = setlocale(LC_ALL, NULL); |
@@ -189,12 +193,89 @@ bool LLMediaImplGStreamer::startup (LLMediaManagerData* init_data) | |||
189 | // Init our custom plugins - only really need do this once. | 193 | // Init our custom plugins - only really need do this once. |
190 | gst_slvideo_init_class(); | 194 | gst_slvideo_init_class(); |
191 | 195 | ||
196 | |||
197 | // List the plugins GStreamer can find | ||
198 | LL_DEBUGS("MediaImpl") << "Found GStreamer plugins:" << LL_ENDL; | ||
199 | GList *list; | ||
200 | GstRegistry *registry = gst_registry_get_default(); | ||
201 | std::string loaded = ""; | ||
202 | for (list = gst_registry_get_plugin_list(registry); | ||
203 | list != NULL; | ||
204 | list = g_list_next(list)) | ||
205 | { | ||
206 | GstPlugin *list_plugin = (GstPlugin *)list->data; | ||
207 | (bool)gst_plugin_is_loaded(list_plugin) ? loaded = "Yes" : loaded = "No"; | ||
208 | LL_DEBUGS("MediaImpl") << gst_plugin_get_name(list_plugin) << ", loaded? " << loaded << LL_ENDL; | ||
209 | } | ||
210 | gst_plugin_list_free(list); | ||
211 | |||
212 | |||
192 | done_init = true; | 213 | done_init = true; |
193 | } | 214 | } |
194 | return true; | 215 | return true; |
195 | } | 216 | } |
196 | 217 | ||
197 | 218 | ||
219 | void LLMediaImplGStreamer::set_gst_plugin_path() | ||
220 | { | ||
221 | // Only needed for Windows. | ||
222 | // Linux sets in wrapper.sh, Mac sets in Info-Imprudence.plist | ||
223 | #ifdef LL_WINDOWS | ||
224 | |||
225 | char* imp_cwd; | ||
226 | |||
227 | // Get the current working directory: | ||
228 | imp_cwd = _getcwd(NULL,0); | ||
229 | |||
230 | if(imp_cwd == NULL) | ||
231 | { | ||
232 | LL_DEBUGS("MediaImpl") << "_getcwd failed, not setting GST_PLUGIN_PATH." | ||
233 | << LL_ENDL; | ||
234 | } | ||
235 | else | ||
236 | { | ||
237 | LL_DEBUGS("MediaImpl") << "Imprudence is installed at " | ||
238 | << imp_cwd << LL_ENDL; | ||
239 | |||
240 | // Grab the current path, if it's set. | ||
241 | std::string old_plugin_path = ""; | ||
242 | char *old_path = getenv("GST_PLUGIN_PATH"); | ||
243 | if(old_path == NULL) | ||
244 | { | ||
245 | LL_DEBUGS("MediaImpl") << "Did not find user-set GST_PLUGIN_PATH." | ||
246 | << LL_ENDL; | ||
247 | } | ||
248 | else | ||
249 | { | ||
250 | old_plugin_path = ";" + std::string( old_path ); | ||
251 | } | ||
252 | |||
253 | |||
254 | // Search both Imprudence and Imprudence\lib\gstreamer-plugins. | ||
255 | // If those fail, search the path the user has set, if any. | ||
256 | std::string plugin_path = | ||
257 | "GST_PLUGIN_PATH=" + | ||
258 | std::string(imp_cwd) + "\\lib\\gstreamer-plugins;" + | ||
259 | std::string(imp_cwd) + | ||
260 | old_plugin_path; | ||
261 | |||
262 | // Place GST_PLUGIN_PATH in the environment settings for imprudence.exe | ||
263 | // Returns 0 on success | ||
264 | if(_putenv( (char*)plugin_path.c_str() )) | ||
265 | { | ||
266 | LL_WARNS("MediaImpl") << "Setting environment variable failed!" << LL_ENDL; | ||
267 | } | ||
268 | else | ||
269 | { | ||
270 | LL_DEBUGS("MediaImpl") << "GST_PLUGIN_PATH set to " | ||
271 | << getenv("GST_PLUGIN_PATH") << LL_ENDL; | ||
272 | } | ||
273 | } | ||
274 | |||
275 | #endif //LL_WINDOWS | ||
276 | } | ||
277 | |||
278 | |||
198 | bool LLMediaImplGStreamer::closedown() | 279 | bool LLMediaImplGStreamer::closedown() |
199 | { | 280 | { |
200 | return true; | 281 | return true; |
@@ -572,20 +653,23 @@ bool LLMediaImplGStreamer::stop() | |||
572 | if (!mPlaybin || mState == GST_STATE_NULL) | 653 | if (!mPlaybin || mState == GST_STATE_NULL) |
573 | return true; | 654 | return true; |
574 | 655 | ||
575 | GstElement *pipeline = (GstElement *)gst_object_ref(GST_OBJECT(mPlaybin)); | 656 | GstStateChangeReturn state_change; |
576 | gst_object_unref(pipeline); | ||
577 | |||
578 | gst_element_set_state(pipeline, GST_STATE_READY); | ||
579 | 657 | ||
580 | if (mState == GST_STATE_PLAYING) | 658 | state_change = gst_element_set_state(mPlaybin, GST_STATE_READY); |
581 | mState = GST_STATE_VOID_PENDING; | ||
582 | else | ||
583 | mState = GST_STATE_READY; | ||
584 | 659 | ||
585 | GstStateChangeReturn state_change = gst_element_get_state(mPlaybin, NULL, NULL, GST_MSECOND*5); | 660 | LL_DEBUGS("MediaImpl") << "result: " |
586 | LL_DEBUGS("MediaImpl") << "get_state: " << gst_element_state_change_return_get_name(state_change) << LL_ENDL; | 661 | << gst_element_state_change_return_get_name(state_change) << LL_ENDL; |
587 | 662 | ||
588 | return true; | 663 | if (state_change == GST_STATE_CHANGE_FAILURE) |
664 | { | ||
665 | LL_WARNS("MediaImpl") << "could not stop stream!" << LL_ENDL; | ||
666 | return false; | ||
667 | } | ||
668 | else | ||
669 | { | ||
670 | mState = GST_STATE_READY; | ||
671 | return true; | ||
672 | } | ||
589 | } | 673 | } |
590 | 674 | ||
591 | /////////////////////////////////////////////////////////////////////////////// | 675 | /////////////////////////////////////////////////////////////////////////////// |
@@ -597,25 +681,28 @@ bool LLMediaImplGStreamer::play() | |||
597 | if (!mPlaybin || mState == GST_STATE_NULL) | 681 | if (!mPlaybin || mState == GST_STATE_NULL) |
598 | return true; | 682 | return true; |
599 | 683 | ||
600 | GstElement *pipeline = (GstElement *)gst_object_ref(GST_OBJECT(mPlaybin)); | 684 | GstStateChangeReturn state_change; |
601 | gst_object_unref(pipeline); | ||
602 | |||
603 | gst_element_set_state(pipeline, GST_STATE_PLAYING); | ||
604 | mState = GST_STATE_PLAYING; | ||
605 | /*gst_element_set_state(mPlaybin, GST_STATE_PLAYING); | ||
606 | mState = GST_STATE_PLAYING;*/ | ||
607 | 685 | ||
608 | GstStateChangeReturn state_change = gst_element_get_state(mPlaybin, NULL, NULL, GST_MSECOND*5); | 686 | state_change = gst_element_set_state(mPlaybin, GST_STATE_PLAYING); |
609 | LL_DEBUGS("MediaImpl") << "get_state: " << gst_element_state_change_return_get_name(state_change) << LL_ENDL; | 687 | |
688 | LL_DEBUGS("MediaImpl") << "result: " | ||
689 | << gst_element_state_change_return_get_name(state_change) << LL_ENDL; | ||
610 | 690 | ||
611 | // Check to make sure playing was successful. If not, stop. | 691 | // Check to make sure playing was successful. If not, stop. |
692 | // NOTE: state_change is almost always GST_STATE_CHANGE_ASYNC | ||
612 | if (state_change == GST_STATE_CHANGE_FAILURE) | 693 | if (state_change == GST_STATE_CHANGE_FAILURE) |
613 | { | 694 | { |
614 | setStatus(LLMediaBase::STATUS_STOPPED); | 695 | // If failing from a bad stream, go into pending state |
696 | // (this is stopped at the callback) | ||
697 | mState = GST_STATE_VOID_PENDING; | ||
615 | stop(); | 698 | stop(); |
699 | return false; | ||
700 | } | ||
701 | else | ||
702 | { | ||
703 | mState = GST_STATE_PLAYING; | ||
704 | return true; | ||
616 | } | 705 | } |
617 | |||
618 | return true; | ||
619 | } | 706 | } |
620 | 707 | ||
621 | /////////////////////////////////////////////////////////////////////////////// | 708 | /////////////////////////////////////////////////////////////////////////////// |
@@ -627,13 +714,23 @@ bool LLMediaImplGStreamer::pause() | |||
627 | if (!mPlaybin || mState == GST_STATE_NULL) | 714 | if (!mPlaybin || mState == GST_STATE_NULL) |
628 | return true; | 715 | return true; |
629 | 716 | ||
630 | gst_element_set_state(mPlaybin, GST_STATE_PAUSED); | 717 | GstStateChangeReturn state_change; |
631 | mState = GST_STATE_PAUSED; | ||
632 | |||
633 | GstStateChangeReturn state_change = gst_element_get_state(mPlaybin, NULL, NULL, GST_MSECOND*5); | ||
634 | LL_DEBUGS("MediaImpl") << "get_state: " << gst_element_state_change_return_get_name(state_change) << LL_ENDL; | ||
635 | 718 | ||
636 | return true; | 719 | state_change = gst_element_set_state(mPlaybin, GST_STATE_PAUSED); |
720 | |||
721 | LL_DEBUGS("MediaImpl") << "result: " | ||
722 | << gst_element_state_change_return_get_name(state_change) << LL_ENDL; | ||
723 | |||
724 | if (state_change == GST_STATE_CHANGE_FAILURE) | ||
725 | { | ||
726 | LL_WARNS("MediaImpl") << "could not pause stream!" << LL_ENDL; | ||
727 | return false; | ||
728 | } | ||
729 | else | ||
730 | { | ||
731 | mState = GST_STATE_PAUSED; | ||
732 | return true; | ||
733 | } | ||
637 | }; | 734 | }; |
638 | 735 | ||
639 | 736 | ||
diff --git a/linden/indra/llmedia/llmediaimplgstreamer.h b/linden/indra/llmedia/llmediaimplgstreamer.h index dec970a..2918416 100644 --- a/linden/indra/llmedia/llmediaimplgstreamer.h +++ b/linden/indra/llmedia/llmediaimplgstreamer.h | |||
@@ -66,6 +66,9 @@ class LLMediaImplGStreamer: | |||
66 | static bool startup( LLMediaManagerData* init_data ); | 66 | static bool startup( LLMediaManagerData* init_data ); |
67 | static bool closedown(); | 67 | static bool closedown(); |
68 | 68 | ||
69 | // Sets GST_PLUGIN_PATH env var for GStreamer. | ||
70 | static void set_gst_plugin_path(); | ||
71 | |||
69 | /* virtual */ std::string getVersion(); | 72 | /* virtual */ std::string getVersion(); |
70 | /* virtual */ bool navigateTo( const std::string url ); | 73 | /* virtual */ bool navigateTo( const std::string url ); |
71 | /* virtual */ bool updateMedia(); | 74 | /* virtual */ bool updateMedia(); |
@@ -79,6 +82,7 @@ class LLMediaImplGStreamer: | |||
79 | LLMediaEmitter< LLMediaObserver > getEventEmitter() const {return mEventEmitter;}; | 82 | LLMediaEmitter< LLMediaObserver > getEventEmitter() const {return mEventEmitter;}; |
80 | 83 | ||
81 | private: | 84 | private: |
85 | |||
82 | // misc | 86 | // misc |
83 | bool unload(); | 87 | bool unload(); |
84 | bool pause(); | 88 | bool pause(); |