aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmedia/llmediaimplgstreamer.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/llmedia/llmediaimplgstreamer.cpp118
1 files changed, 44 insertions, 74 deletions
diff --git a/linden/indra/llmedia/llmediaimplgstreamer.cpp b/linden/indra/llmedia/llmediaimplgstreamer.cpp
index b37deac..98d6459 100644
--- a/linden/indra/llmedia/llmediaimplgstreamer.cpp
+++ b/linden/indra/llmedia/llmediaimplgstreamer.cpp
@@ -55,9 +55,8 @@ extern "C" {
55 55
56#include "llmediaimplgstreamervidplug.h" 56#include "llmediaimplgstreamervidplug.h"
57 57
58#include "llmediaimplgstreamer_syms.h"
59
60#include "llerror.h" 58#include "llerror.h"
59#include "linden_common.h"
61 60
62// register this impl with media manager factory 61// register this impl with media manager factory
63static LLMediaImplRegister sLLMediaImplGStreamerReg( "LLMediaImplGStreamer", new LLMediaImplGStreamerMaker() ); 62static LLMediaImplRegister sLLMediaImplGStreamerReg( "LLMediaImplGStreamer", new LLMediaImplGStreamerMaker() );
@@ -101,7 +100,7 @@ LLMediaImplGStreamer () :
101 } 100 }
102 101
103 // instantiate a playbin element to do the hard work 102 // instantiate a playbin element to do the hard work
104 mPlaybin = llgst_element_factory_make ("playbin", "play"); 103 mPlaybin = gst_element_factory_make ("playbin", "play");
105 if (!mPlaybin) 104 if (!mPlaybin)
106 { 105 {
107 // todo: cleanup pump 106 // todo: cleanup pump
@@ -115,7 +114,7 @@ LLMediaImplGStreamer () :
115 114
116 // Plays inworld instead of in external player 115 // Plays inworld instead of in external player
117 mVideoSink = 116 mVideoSink =
118 GST_SLVIDEO(llgst_element_factory_make ("private-slvideo", "slvideo")); 117 GST_SLVIDEO(gst_element_factory_make ("private-slvideo", "slvideo"));
119 if (!mVideoSink) 118 if (!mVideoSink)
120 { 119 {
121 LL_WARNS("MediaImpl") << "Could not instantiate private-slvideo element." << LL_ENDL; 120 LL_WARNS("MediaImpl") << "Could not instantiate private-slvideo element." << LL_ENDL;
@@ -159,7 +158,7 @@ LLMediaImplGStreamer::
159std::string LLMediaImplGStreamer::getVersion() 158std::string LLMediaImplGStreamer::getVersion()
160{ 159{
161 guint major, minor, micro, nano; 160 guint major, minor, micro, nano;
162 llgst_version(&major, &minor, &micro, &nano); 161 gst_version(&major, &minor, &micro, &nano);
163 std::string version = llformat("%d.%d.%d.%d",major,minor,micro,nano); 162 std::string version = llformat("%d.%d.%d.%d",major,minor,micro,nano);
164 return version; 163 return version;
165} 164}
@@ -176,31 +175,10 @@ bool LLMediaImplGStreamer::startup (LLMediaManagerData* init_data)
176 // Init the glib type system - we need it. 175 // Init the glib type system - we need it.
177 g_type_init(); 176 g_type_init();
178 177
179 // Get symbols!
180#if LL_WINDOWS
181 if (! grab_gst_syms("libgstreamer-0.10.dll", "libgstvideo-0.10.dll", "libgstaudio-0.10.dll") )
182 {
183 LL_WARNS("MediaImpl") << "Couldn't find suitable GStreamer 0.10 support on this system - video playback disabled." << LL_ENDL;
184 return false;
185 }
186#else
187 if (! grab_gst_syms("libgstreamer-0.10.so.0", "libgstvideo-0.10.so.0", "libgstaudio-0.10.so.0") )
188 {
189 LL_WARNS("MediaImpl") << "Couldn't find suitable GStreamer 0.10 support on this system - video playback disabled." << LL_ENDL;
190 return false;
191 }
192#endif
193 if (llgst_segtrap_set_enabled)
194 llgst_segtrap_set_enabled(FALSE);
195 else
196 {
197 LL_WARNS("MediaImpl") << "gst_segtrap_set_enabled() is not available; Automated crash-reporter may cease to function until next restart." << LL_ENDL;
198 }
199
200 // Protect against GStreamer resetting the locale, yuck. 178 // Protect against GStreamer resetting the locale, yuck.
201 static std::string saved_locale; 179 static std::string saved_locale;
202 saved_locale = setlocale(LC_ALL, NULL); 180 saved_locale = setlocale(LC_ALL, NULL);
203 if (0 == llgst_init_check(NULL, NULL, NULL)) 181 if (0 == gst_init_check(NULL, NULL, NULL))
204 { 182 {
205 LL_WARNS("MediaImpl") << "GStreamer library failed to initialize and load standard plugins." << LL_ENDL; 183 LL_WARNS("MediaImpl") << "GStreamer library failed to initialize and load standard plugins." << LL_ENDL;
206 setlocale(LC_ALL, saved_locale.c_str() ); 184 setlocale(LC_ALL, saved_locale.c_str() );
@@ -219,7 +197,6 @@ bool LLMediaImplGStreamer::startup (LLMediaManagerData* init_data)
219 197
220bool LLMediaImplGStreamer::closedown() 198bool LLMediaImplGStreamer::closedown()
221{ 199{
222 ungrab_gst_syms();
223 return true; 200 return true;
224} 201}
225 202
@@ -247,7 +224,7 @@ static const char* get_gst_state_name(GstState state)
247gboolean LLMediaImplGStreamer::bus_callback(GstBus *bus, GstMessage *message, gpointer data) 224gboolean LLMediaImplGStreamer::bus_callback(GstBus *bus, GstMessage *message, gpointer data)
248{ 225{
249#ifdef LL_GST_REPORT_STATE_CHANGES 226#ifdef LL_GST_REPORT_STATE_CHANGES
250 LL_DEBUGS("MediaCallback") << "Got GST message type: " << LLGST_MESSAGE_TYPE_NAME (message) << LL_ENDL; 227 LL_DEBUGS("MediaCallback") << "Got GST message type: " << GST_MESSAGE_TYPE_NAME (message) << LL_ENDL;
251#endif 228#endif
252 229
253 LLMediaImplGStreamer *impl = (LLMediaImplGStreamer*)data; 230 LLMediaImplGStreamer *impl = (LLMediaImplGStreamer*)data;
@@ -256,17 +233,13 @@ gboolean LLMediaImplGStreamer::bus_callback(GstBus *bus, GstMessage *message, gp
256 { 233 {
257 case GST_MESSAGE_BUFFERING: 234 case GST_MESSAGE_BUFFERING:
258 { 235 {
259 // NEEDS GST 0.10.11+ 236 gint percent = 0;
260 if (llgst_message_parse_buffering) 237 gst_message_parse_buffering(message, &percent);
261 {
262 gint percent = 0;
263 llgst_message_parse_buffering(message, &percent);
264#ifdef LL_GST_REPORT_STATE_CHANGES 238#ifdef LL_GST_REPORT_STATE_CHANGES
265 LL_DEBUGS("MediaBuffering") << "GST buffering: " << percent << "%%" << LL_ENDL; 239 LL_DEBUGS("MediaBuffering") << "GST buffering: " << percent << "%%" << LL_ENDL;
266#endif 240#endif
267 LLMediaEvent event( impl, percent ); 241 LLMediaEvent event( impl, percent );
268 impl->getEventEmitter().update( &LLMediaObserver::onUpdateProgress, event ); 242 impl->getEventEmitter().update( &LLMediaObserver::onUpdateProgress, event );
269 }
270 } 243 }
271 break; 244 break;
272 case GST_MESSAGE_STATE_CHANGED: 245 case GST_MESSAGE_STATE_CHANGED:
@@ -274,7 +247,7 @@ gboolean LLMediaImplGStreamer::bus_callback(GstBus *bus, GstMessage *message, gp
274 GstState old_state; 247 GstState old_state;
275 GstState new_state; 248 GstState new_state;
276 GstState pending_state; 249 GstState pending_state;
277 llgst_message_parse_state_changed(message, 250 gst_message_parse_state_changed(message,
278 &old_state, 251 &old_state,
279 &new_state, 252 &new_state,
280 &pending_state); 253 &pending_state);
@@ -319,7 +292,7 @@ gboolean LLMediaImplGStreamer::bus_callback(GstBus *bus, GstMessage *message, gp
319 GError *err = NULL; 292 GError *err = NULL;
320 gchar *debug = NULL; 293 gchar *debug = NULL;
321 294
322 llgst_message_parse_error (message, &err, &debug); 295 gst_message_parse_error (message, &err, &debug);
323 LL_WARNS("MediaImpl") << "GST Error: " << err->message << LL_ENDL; 296 LL_WARNS("MediaImpl") << "GST Error: " << err->message << LL_ENDL;
324 g_error_free (err); 297 g_error_free (err);
325 g_free (debug); 298 g_free (debug);
@@ -331,17 +304,14 @@ gboolean LLMediaImplGStreamer::bus_callback(GstBus *bus, GstMessage *message, gp
331 } 304 }
332 case GST_MESSAGE_INFO: 305 case GST_MESSAGE_INFO:
333 { 306 {
334 if (llgst_message_parse_info) 307 GError *err = NULL;
335 { 308 gchar *debug = NULL;
336 GError *err = NULL;
337 gchar *debug = NULL;
338 309
339 llgst_message_parse_info (message, &err, &debug); 310 gst_message_parse_info (message, &err, &debug);
340 LL_INFOS("MediaImpl") << "GST info: " << err->message 311 LL_INFOS("MediaImpl") << "GST info: " << err->message
341 << LL_ENDL; 312 << LL_ENDL;
342 g_error_free (err); 313 g_error_free (err);
343 g_free (debug); 314 g_free (debug);
344 }
345 break; 315 break;
346 } 316 }
347 case GST_MESSAGE_WARNING: 317 case GST_MESSAGE_WARNING:
@@ -349,7 +319,7 @@ gboolean LLMediaImplGStreamer::bus_callback(GstBus *bus, GstMessage *message, gp
349 GError *err = NULL; 319 GError *err = NULL;
350 gchar *debug = NULL; 320 gchar *debug = NULL;
351 321
352 llgst_message_parse_warning (message, &err, &debug); 322 gst_message_parse_warning (message, &err, &debug);
353 LL_WARNS("MediaImpl") << "GST warning: " << err->message 323 LL_WARNS("MediaImpl") << "GST warning: " << err->message
354 << LL_ENDL; 324 << LL_ENDL;
355 g_error_free (err); 325 g_error_free (err);
@@ -362,10 +332,10 @@ gboolean LLMediaImplGStreamer::bus_callback(GstBus *bus, GstMessage *message, gp
362 GstTagList *tag_list; 332 GstTagList *tag_list;
363 gchar *title; 333 gchar *title;
364 gchar *artist; 334 gchar *artist;
365 llgst_message_parse_tag(message, &tag_list); 335 gst_message_parse_tag(message, &tag_list);
366 gboolean hazTitle = llgst_tag_list_get_string(tag_list, 336 gboolean hazTitle = gst_tag_list_get_string(tag_list,
367 GST_TAG_TITLE, &title); 337 GST_TAG_TITLE, &title);
368 gboolean hazArtist = llgst_tag_list_get_string(tag_list, 338 gboolean hazArtist = gst_tag_list_get_string(tag_list,
369 GST_TAG_ARTIST, &artist); 339 GST_TAG_ARTIST, &artist);
370 if(hazTitle) 340 if(hazTitle)
371 LL_INFOS("MediaInfo") << "Title: " << title << LL_ENDL; 341 LL_INFOS("MediaInfo") << "Title: " << title << LL_ENDL;
@@ -419,13 +389,13 @@ bool LLMediaImplGStreamer::navigateTo (const std::string urlIn)
419 g_object_set (G_OBJECT (mPlaybin), "uri", urlIn.c_str(), NULL); 389 g_object_set (G_OBJECT (mPlaybin), "uri", urlIn.c_str(), NULL);
420 390
421 // get playbin's bus - perhaps this can/should be done in ctor 391 // get playbin's bus - perhaps this can/should be done in ctor
422 GstBus *bus = llgst_pipeline_get_bus (GST_PIPELINE (mPlaybin)); 392 GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (mPlaybin));
423 if (!bus) 393 if (!bus)
424 { 394 {
425 return false; 395 return false;
426 } 396 }
427 llgst_bus_add_watch (bus, bus_callback, this); 397 gst_bus_add_watch (bus, bus_callback, this);
428 llgst_object_unref (bus); 398 gst_object_unref (bus);
429 399
430 mState = GST_STATE_READY; 400 mState = GST_STATE_READY;
431 401
@@ -442,9 +412,9 @@ bool LLMediaImplGStreamer::unload()
442 LL_DEBUGS("MediaImpl") << "unloading media..." << LL_ENDL; 412 LL_DEBUGS("MediaImpl") << "unloading media..." << LL_ENDL;
443 if (mPlaybin) 413 if (mPlaybin)
444 { 414 {
445 llgst_element_set_state (mPlaybin, GST_STATE_NULL); 415 gst_element_set_state (mPlaybin, GST_STATE_NULL);
446 mState = GST_STATE_NULL; 416 mState = GST_STATE_NULL;
447 llgst_object_unref (GST_OBJECT (mPlaybin)); 417 gst_object_unref (GST_OBJECT (mPlaybin));
448 mPlaybin = NULL; 418 mPlaybin = NULL;
449 } 419 }
450 420
@@ -602,18 +572,18 @@ bool LLMediaImplGStreamer::stop()
602 if (!mPlaybin || mState == GST_STATE_NULL) 572 if (!mPlaybin || mState == GST_STATE_NULL)
603 return true; 573 return true;
604 574
605 GstElement *pipeline = (GstElement *)llgst_object_ref(GST_OBJECT(mPlaybin)); 575 GstElement *pipeline = (GstElement *)gst_object_ref(GST_OBJECT(mPlaybin));
606 llgst_object_unref(pipeline); 576 gst_object_unref(pipeline);
607 577
608 llgst_element_set_state(pipeline, GST_STATE_READY); 578 gst_element_set_state(pipeline, GST_STATE_READY);
609 579
610 if (mState == GST_STATE_PLAYING) 580 if (mState == GST_STATE_PLAYING)
611 mState = GST_STATE_VOID_PENDING; 581 mState = GST_STATE_VOID_PENDING;
612 else 582 else
613 mState = GST_STATE_READY; 583 mState = GST_STATE_READY;
614 584
615 GstStateChangeReturn state_change = llgst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE); 585 GstStateChangeReturn state_change = gst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE);
616 LL_DEBUGS("MediaImpl") << "get_state: " << llgst_element_state_change_return_get_name(state_change) << LL_ENDL; 586 LL_DEBUGS("MediaImpl") << "get_state: " << gst_element_state_change_return_get_name(state_change) << LL_ENDL;
617 587
618 return true; 588 return true;
619} 589}
@@ -627,16 +597,16 @@ bool LLMediaImplGStreamer::play()
627 if (!mPlaybin || mState == GST_STATE_NULL) 597 if (!mPlaybin || mState == GST_STATE_NULL)
628 return true; 598 return true;
629 599
630 GstElement *pipeline = (GstElement *)llgst_object_ref(GST_OBJECT(mPlaybin)); 600 GstElement *pipeline = (GstElement *)gst_object_ref(GST_OBJECT(mPlaybin));
631 llgst_object_unref(pipeline); 601 gst_object_unref(pipeline);
632 602
633 llgst_element_set_state(pipeline, GST_STATE_PLAYING); 603 gst_element_set_state(pipeline, GST_STATE_PLAYING);
634 mState = GST_STATE_PLAYING; 604 mState = GST_STATE_PLAYING;
635 /*llgst_element_set_state(mPlaybin, GST_STATE_PLAYING); 605 /*gst_element_set_state(mPlaybin, GST_STATE_PLAYING);
636 mState = GST_STATE_PLAYING;*/ 606 mState = GST_STATE_PLAYING;*/
637 607
638 GstStateChangeReturn state_change = llgst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE); 608 GstStateChangeReturn state_change = gst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE);
639 LL_DEBUGS("MediaImpl") << "get_state: " << llgst_element_state_change_return_get_name(state_change) << LL_ENDL; 609 LL_DEBUGS("MediaImpl") << "get_state: " << gst_element_state_change_return_get_name(state_change) << LL_ENDL;
640 610
641 // Check to make sure playing was successful. If not, stop. 611 // Check to make sure playing was successful. If not, stop.
642 if (state_change == GST_STATE_CHANGE_FAILURE) 612 if (state_change == GST_STATE_CHANGE_FAILURE)
@@ -657,11 +627,11 @@ bool LLMediaImplGStreamer::pause()
657 if (!mPlaybin || mState == GST_STATE_NULL) 627 if (!mPlaybin || mState == GST_STATE_NULL)
658 return true; 628 return true;
659 629
660 llgst_element_set_state(mPlaybin, GST_STATE_PAUSED); 630 gst_element_set_state(mPlaybin, GST_STATE_PAUSED);
661 mState = GST_STATE_PAUSED; 631 mState = GST_STATE_PAUSED;
662 632
663 GstStateChangeReturn state_change = llgst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE); 633 GstStateChangeReturn state_change = gst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE);
664 LL_DEBUGS("MediaImpl") << "get_state: " << llgst_element_state_change_return_get_name(state_change) << LL_ENDL; 634 LL_DEBUGS("MediaImpl") << "get_state: " << gst_element_state_change_return_get_name(state_change) << LL_ENDL;
665 635
666 return true; 636 return true;
667}; 637};
@@ -682,7 +652,7 @@ bool LLMediaImplGStreamer::seek(double time)
682 bool success = false; 652 bool success = false;
683 if (mPlaybin) 653 if (mPlaybin)
684 { 654 {
685 success = llgst_element_seek(mPlaybin, 1.0F, GST_FORMAT_TIME, 655 success = gst_element_seek(mPlaybin, 1.0F, GST_FORMAT_TIME,
686 GstSeekFlags(GST_SEEK_FLAG_FLUSH | 656 GstSeekFlags(GST_SEEK_FLAG_FLUSH |
687 GST_SEEK_FLAG_KEY_UNIT), 657 GST_SEEK_FLAG_KEY_UNIT),
688 GST_SEEK_TYPE_SET, gint64(time*1000000000.0F), 658 GST_SEEK_TYPE_SET, gint64(time*1000000000.0F),