aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmedia/llmediaimplgstreamer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llmedia/llmediaimplgstreamer.cpp')
-rw-r--r--linden/indra/llmedia/llmediaimplgstreamer.cpp125
1 files changed, 44 insertions, 81 deletions
diff --git a/linden/indra/llmedia/llmediaimplgstreamer.cpp b/linden/indra/llmedia/llmediaimplgstreamer.cpp
index cd6c91b..5d4d553 100644
--- a/linden/indra/llmedia/llmediaimplgstreamer.cpp
+++ b/linden/indra/llmedia/llmediaimplgstreamer.cpp
@@ -44,9 +44,8 @@ extern "C" {
44 44
45#include "llmediaimplgstreamervidplug.h" 45#include "llmediaimplgstreamervidplug.h"
46 46
47#include "llmediaimplgstreamer_syms.h"
48
49#include "llerror.h" 47#include "llerror.h"
48#include "linden_common.h"
50 49
51// register this impl with media manager factory 50// register this impl with media manager factory
52static LLMediaImplRegister sLLMediaImplGStreamerReg( "LLMediaImplGStreamer", new LLMediaImplGStreamerMaker() ); 51static LLMediaImplRegister sLLMediaImplGStreamerReg( "LLMediaImplGStreamer", new LLMediaImplGStreamerMaker() );
@@ -90,7 +89,7 @@ LLMediaImplGStreamer () :
90 } 89 }
91 90
92 // instantiate a playbin element to do the hard work 91 // instantiate a playbin element to do the hard work
93 mPlaybin = llgst_element_factory_make ("playbin", "play"); 92 mPlaybin = gst_element_factory_make ("playbin", "play");
94 if (!mPlaybin) 93 if (!mPlaybin)
95 { 94 {
96 // todo: cleanup pump 95 // todo: cleanup pump
@@ -104,7 +103,7 @@ LLMediaImplGStreamer () :
104 103
105 // Plays inworld instead of in external player 104 // Plays inworld instead of in external player
106 mVideoSink = 105 mVideoSink =
107 GST_SLVIDEO(llgst_element_factory_make ("private-slvideo", "slvideo")); 106 GST_SLVIDEO(gst_element_factory_make ("private-slvideo", "slvideo"));
108 if (!mVideoSink) 107 if (!mVideoSink)
109 { 108 {
110 LL_WARNS("MediaImpl") << "Could not instantiate private-slvideo element." << LL_ENDL; 109 LL_WARNS("MediaImpl") << "Could not instantiate private-slvideo element." << LL_ENDL;
@@ -148,7 +147,7 @@ LLMediaImplGStreamer::
148std::string LLMediaImplGStreamer::getVersion() 147std::string LLMediaImplGStreamer::getVersion()
149{ 148{
150 guint major, minor, micro, nano; 149 guint major, minor, micro, nano;
151 llgst_version(&major, &minor, &micro, &nano); 150 gst_version(&major, &minor, &micro, &nano);
152 std::string version = llformat("%d.%d.%d.%d",major,minor,micro,nano); 151 std::string version = llformat("%d.%d.%d.%d",major,minor,micro,nano);
153 return version; 152 return version;
154} 153}
@@ -165,38 +164,10 @@ bool LLMediaImplGStreamer::startup (LLMediaManagerData* init_data)
165 // Init the glib type system - we need it. 164 // Init the glib type system - we need it.
166 g_type_init(); 165 g_type_init();
167 166
168 // Get symbols!
169 if (
170#if LL_WINDOWS
171 ! grab_gst_syms("libgstreamer-0.10.dll",
172 "libgstvideo-0.10.dll",
173 "libgstaudio-0.10.dll")
174#elif LL_DARWIN
175 ! grab_gst_syms("libgstreamer-0.10.dylib",
176 "libgstvideo-0.10.dylib",
177 "libgstaudio-0.10.dylib")
178#else
179 ! grab_gst_syms("libgstreamer-0.10.so.0",
180 "libgstvideo-0.10.so.0",
181 "libgstaudio-0.10.so.0")
182#endif
183 )
184 {
185 LL_WARNS("MediaImpl") << "Couldn't find suitable GStreamer 0.10 support on this system - video playback disabled." << LL_ENDL;
186 return false;
187 }
188
189 if (llgst_segtrap_set_enabled)
190 llgst_segtrap_set_enabled(FALSE);
191 else
192 {
193 LL_WARNS("MediaImpl") << "gst_segtrap_set_enabled() is not available; Automated crash-reporter may cease to function until next restart." << LL_ENDL;
194 }
195
196 // Protect against GStreamer resetting the locale, yuck. 167 // Protect against GStreamer resetting the locale, yuck.
197 static std::string saved_locale; 168 static std::string saved_locale;
198 saved_locale = setlocale(LC_ALL, NULL); 169 saved_locale = setlocale(LC_ALL, NULL);
199 if (0 == llgst_init_check(NULL, NULL, NULL)) 170 if (0 == gst_init_check(NULL, NULL, NULL))
200 { 171 {
201 LL_WARNS("MediaImpl") << "GStreamer library failed to initialize and load standard plugins." << LL_ENDL; 172 LL_WARNS("MediaImpl") << "GStreamer library failed to initialize and load standard plugins." << LL_ENDL;
202 setlocale(LC_ALL, saved_locale.c_str() ); 173 setlocale(LC_ALL, saved_locale.c_str() );
@@ -215,7 +186,6 @@ bool LLMediaImplGStreamer::startup (LLMediaManagerData* init_data)
215 186
216bool LLMediaImplGStreamer::closedown() 187bool LLMediaImplGStreamer::closedown()
217{ 188{
218 ungrab_gst_syms();
219 return true; 189 return true;
220} 190}
221 191
@@ -243,7 +213,7 @@ static const char* get_gst_state_name(GstState state)
243gboolean LLMediaImplGStreamer::bus_callback(GstBus *bus, GstMessage *message, gpointer data) 213gboolean LLMediaImplGStreamer::bus_callback(GstBus *bus, GstMessage *message, gpointer data)
244{ 214{
245#ifdef LL_GST_REPORT_STATE_CHANGES 215#ifdef LL_GST_REPORT_STATE_CHANGES
246 LL_DEBUGS("MediaCallback") << "Got GST message type: " << LLGST_MESSAGE_TYPE_NAME (message) << LL_ENDL; 216 LL_DEBUGS("MediaCallback") << "Got GST message type: " << GST_MESSAGE_TYPE_NAME (message) << LL_ENDL;
247#endif 217#endif
248 218
249 LLMediaImplGStreamer *impl = (LLMediaImplGStreamer*)data; 219 LLMediaImplGStreamer *impl = (LLMediaImplGStreamer*)data;
@@ -252,17 +222,13 @@ gboolean LLMediaImplGStreamer::bus_callback(GstBus *bus, GstMessage *message, gp
252 { 222 {
253 case GST_MESSAGE_BUFFERING: 223 case GST_MESSAGE_BUFFERING:
254 { 224 {
255 // NEEDS GST 0.10.11+ 225 gint percent = 0;
256 if (llgst_message_parse_buffering) 226 gst_message_parse_buffering(message, &percent);
257 {
258 gint percent = 0;
259 llgst_message_parse_buffering(message, &percent);
260#ifdef LL_GST_REPORT_STATE_CHANGES 227#ifdef LL_GST_REPORT_STATE_CHANGES
261 LL_DEBUGS("MediaBuffering") << "GST buffering: " << percent << "%%" << LL_ENDL; 228 LL_DEBUGS("MediaBuffering") << "GST buffering: " << percent << "%%" << LL_ENDL;
262#endif 229#endif
263 LLMediaEvent event( impl, percent ); 230 LLMediaEvent event( impl, percent );
264 impl->getEventEmitter().update( &LLMediaObserver::onUpdateProgress, event ); 231 impl->getEventEmitter().update( &LLMediaObserver::onUpdateProgress, event );
265 }
266 } 232 }
267 break; 233 break;
268 case GST_MESSAGE_STATE_CHANGED: 234 case GST_MESSAGE_STATE_CHANGED:
@@ -270,7 +236,7 @@ gboolean LLMediaImplGStreamer::bus_callback(GstBus *bus, GstMessage *message, gp
270 GstState old_state; 236 GstState old_state;
271 GstState new_state; 237 GstState new_state;
272 GstState pending_state; 238 GstState pending_state;
273 llgst_message_parse_state_changed(message, 239 gst_message_parse_state_changed(message,
274 &old_state, 240 &old_state,
275 &new_state, 241 &new_state,
276 &pending_state); 242 &pending_state);
@@ -315,7 +281,7 @@ gboolean LLMediaImplGStreamer::bus_callback(GstBus *bus, GstMessage *message, gp
315 GError *err = NULL; 281 GError *err = NULL;
316 gchar *debug = NULL; 282 gchar *debug = NULL;
317 283
318 llgst_message_parse_error (message, &err, &debug); 284 gst_message_parse_error (message, &err, &debug);
319 LL_WARNS("MediaImpl") << "GST Error: " << err->message << LL_ENDL; 285 LL_WARNS("MediaImpl") << "GST Error: " << err->message << LL_ENDL;
320 g_error_free (err); 286 g_error_free (err);
321 g_free (debug); 287 g_free (debug);
@@ -327,17 +293,14 @@ gboolean LLMediaImplGStreamer::bus_callback(GstBus *bus, GstMessage *message, gp
327 } 293 }
328 case GST_MESSAGE_INFO: 294 case GST_MESSAGE_INFO:
329 { 295 {
330 if (llgst_message_parse_info) 296 GError *err = NULL;
331 { 297 gchar *debug = NULL;
332 GError *err = NULL;
333 gchar *debug = NULL;
334 298
335 llgst_message_parse_info (message, &err, &debug); 299 gst_message_parse_info (message, &err, &debug);
336 LL_INFOS("MediaImpl") << "GST info: " << err->message 300 LL_INFOS("MediaImpl") << "GST info: " << err->message
337 << LL_ENDL; 301 << LL_ENDL;
338 g_error_free (err); 302 g_error_free (err);
339 g_free (debug); 303 g_free (debug);
340 }
341 break; 304 break;
342 } 305 }
343 case GST_MESSAGE_WARNING: 306 case GST_MESSAGE_WARNING:
@@ -345,7 +308,7 @@ gboolean LLMediaImplGStreamer::bus_callback(GstBus *bus, GstMessage *message, gp
345 GError *err = NULL; 308 GError *err = NULL;
346 gchar *debug = NULL; 309 gchar *debug = NULL;
347 310
348 llgst_message_parse_warning (message, &err, &debug); 311 gst_message_parse_warning (message, &err, &debug);
349 LL_WARNS("MediaImpl") << "GST warning: " << err->message 312 LL_WARNS("MediaImpl") << "GST warning: " << err->message
350 << LL_ENDL; 313 << LL_ENDL;
351 g_error_free (err); 314 g_error_free (err);
@@ -358,10 +321,10 @@ gboolean LLMediaImplGStreamer::bus_callback(GstBus *bus, GstMessage *message, gp
358 GstTagList *tag_list; 321 GstTagList *tag_list;
359 gchar *title; 322 gchar *title;
360 gchar *artist; 323 gchar *artist;
361 llgst_message_parse_tag(message, &tag_list); 324 gst_message_parse_tag(message, &tag_list);
362 gboolean hazTitle = llgst_tag_list_get_string(tag_list, 325 gboolean hazTitle = gst_tag_list_get_string(tag_list,
363 GST_TAG_TITLE, &title); 326 GST_TAG_TITLE, &title);
364 gboolean hazArtist = llgst_tag_list_get_string(tag_list, 327 gboolean hazArtist = gst_tag_list_get_string(tag_list,
365 GST_TAG_ARTIST, &artist); 328 GST_TAG_ARTIST, &artist);
366 if(hazTitle) 329 if(hazTitle)
367 LL_INFOS("MediaInfo") << "Title: " << title << LL_ENDL; 330 LL_INFOS("MediaInfo") << "Title: " << title << LL_ENDL;
@@ -415,13 +378,13 @@ bool LLMediaImplGStreamer::navigateTo (const std::string urlIn)
415 g_object_set (G_OBJECT (mPlaybin), "uri", urlIn.c_str(), NULL); 378 g_object_set (G_OBJECT (mPlaybin), "uri", urlIn.c_str(), NULL);
416 379
417 // get playbin's bus - perhaps this can/should be done in ctor 380 // get playbin's bus - perhaps this can/should be done in ctor
418 GstBus *bus = llgst_pipeline_get_bus (GST_PIPELINE (mPlaybin)); 381 GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (mPlaybin));
419 if (!bus) 382 if (!bus)
420 { 383 {
421 return false; 384 return false;
422 } 385 }
423 llgst_bus_add_watch (bus, bus_callback, this); 386 gst_bus_add_watch (bus, bus_callback, this);
424 llgst_object_unref (bus); 387 gst_object_unref (bus);
425 388
426 mState = GST_STATE_READY; 389 mState = GST_STATE_READY;
427 390
@@ -438,9 +401,9 @@ bool LLMediaImplGStreamer::unload()
438 LL_DEBUGS("MediaImpl") << "unloading media..." << LL_ENDL; 401 LL_DEBUGS("MediaImpl") << "unloading media..." << LL_ENDL;
439 if (mPlaybin) 402 if (mPlaybin)
440 { 403 {
441 llgst_element_set_state (mPlaybin, GST_STATE_NULL); 404 gst_element_set_state (mPlaybin, GST_STATE_NULL);
442 mState = GST_STATE_NULL; 405 mState = GST_STATE_NULL;
443 llgst_object_unref (GST_OBJECT (mPlaybin)); 406 gst_object_unref (GST_OBJECT (mPlaybin));
444 mPlaybin = NULL; 407 mPlaybin = NULL;
445 } 408 }
446 409
@@ -598,18 +561,18 @@ bool LLMediaImplGStreamer::stop()
598 if (!mPlaybin || mState == GST_STATE_NULL) 561 if (!mPlaybin || mState == GST_STATE_NULL)
599 return true; 562 return true;
600 563
601 GstElement *pipeline = (GstElement *)llgst_object_ref(GST_OBJECT(mPlaybin)); 564 GstElement *pipeline = (GstElement *)gst_object_ref(GST_OBJECT(mPlaybin));
602 llgst_object_unref(pipeline); 565 gst_object_unref(pipeline);
603 566
604 llgst_element_set_state(pipeline, GST_STATE_READY); 567 gst_element_set_state(pipeline, GST_STATE_READY);
605 568
606 if (mState == GST_STATE_PLAYING) 569 if (mState == GST_STATE_PLAYING)
607 mState = GST_STATE_VOID_PENDING; 570 mState = GST_STATE_VOID_PENDING;
608 else 571 else
609 mState = GST_STATE_READY; 572 mState = GST_STATE_READY;
610 573
611 GstStateChangeReturn state_change = llgst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE); 574 GstStateChangeReturn state_change = gst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE);
612 LL_DEBUGS("MediaImpl") << "get_state: " << llgst_element_state_change_return_get_name(state_change) << LL_ENDL; 575 LL_DEBUGS("MediaImpl") << "get_state: " << gst_element_state_change_return_get_name(state_change) << LL_ENDL;
613 576
614 return true; 577 return true;
615} 578}
@@ -623,16 +586,16 @@ bool LLMediaImplGStreamer::play()
623 if (!mPlaybin || mState == GST_STATE_NULL) 586 if (!mPlaybin || mState == GST_STATE_NULL)
624 return true; 587 return true;
625 588
626 GstElement *pipeline = (GstElement *)llgst_object_ref(GST_OBJECT(mPlaybin)); 589 GstElement *pipeline = (GstElement *)gst_object_ref(GST_OBJECT(mPlaybin));
627 llgst_object_unref(pipeline); 590 gst_object_unref(pipeline);
628 591
629 llgst_element_set_state(pipeline, GST_STATE_PLAYING); 592 gst_element_set_state(pipeline, GST_STATE_PLAYING);
630 mState = GST_STATE_PLAYING; 593 mState = GST_STATE_PLAYING;
631 /*llgst_element_set_state(mPlaybin, GST_STATE_PLAYING); 594 /*gst_element_set_state(mPlaybin, GST_STATE_PLAYING);
632 mState = GST_STATE_PLAYING;*/ 595 mState = GST_STATE_PLAYING;*/
633 596
634 GstStateChangeReturn state_change = llgst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE); 597 GstStateChangeReturn state_change = gst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE);
635 LL_DEBUGS("MediaImpl") << "get_state: " << llgst_element_state_change_return_get_name(state_change) << LL_ENDL; 598 LL_DEBUGS("MediaImpl") << "get_state: " << gst_element_state_change_return_get_name(state_change) << LL_ENDL;
636 599
637 // Check to make sure playing was successful. If not, stop. 600 // Check to make sure playing was successful. If not, stop.
638 if (state_change == GST_STATE_CHANGE_FAILURE) 601 if (state_change == GST_STATE_CHANGE_FAILURE)
@@ -653,11 +616,11 @@ bool LLMediaImplGStreamer::pause()
653 if (!mPlaybin || mState == GST_STATE_NULL) 616 if (!mPlaybin || mState == GST_STATE_NULL)
654 return true; 617 return true;
655 618
656 llgst_element_set_state(mPlaybin, GST_STATE_PAUSED); 619 gst_element_set_state(mPlaybin, GST_STATE_PAUSED);
657 mState = GST_STATE_PAUSED; 620 mState = GST_STATE_PAUSED;
658 621
659 GstStateChangeReturn state_change = llgst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE); 622 GstStateChangeReturn state_change = gst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE);
660 LL_DEBUGS("MediaImpl") << "get_state: " << llgst_element_state_change_return_get_name(state_change) << LL_ENDL; 623 LL_DEBUGS("MediaImpl") << "get_state: " << gst_element_state_change_return_get_name(state_change) << LL_ENDL;
661 624
662 return true; 625 return true;
663}; 626};
@@ -678,7 +641,7 @@ bool LLMediaImplGStreamer::seek(double time)
678 bool success = false; 641 bool success = false;
679 if (mPlaybin) 642 if (mPlaybin)
680 { 643 {
681 success = llgst_element_seek(mPlaybin, 1.0F, GST_FORMAT_TIME, 644 success = gst_element_seek(mPlaybin, 1.0F, GST_FORMAT_TIME,
682 GstSeekFlags(GST_SEEK_FLAG_FLUSH | 645 GstSeekFlags(GST_SEEK_FLAG_FLUSH |
683 GST_SEEK_FLAG_KEY_UNIT), 646 GST_SEEK_FLAG_KEY_UNIT),
684 GST_SEEK_TYPE_SET, gint64(time*1000000000.0F), 647 GST_SEEK_TYPE_SET, gint64(time*1000000000.0F),