aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmedia
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llmedia')
-rw-r--r--linden/indra/llmedia/llmediabase.h3
-rw-r--r--linden/indra/llmedia/llmediaimplgstreamer.cpp107
-rw-r--r--linden/indra/llmedia/llmediaimplgstreamer.h3
-rw-r--r--linden/indra/llmedia/llmediaimplgstreamer_syms_raw.inc4
4 files changed, 90 insertions, 27 deletions
diff --git a/linden/indra/llmedia/llmediabase.h b/linden/indra/llmedia/llmediabase.h
index dad02ca..b5b9420 100644
--- a/linden/indra/llmedia/llmediabase.h
+++ b/linden/indra/llmedia/llmediabase.h
@@ -153,7 +153,8 @@ class LLMediaBase
153 STATUS_STARTED = 3, 153 STATUS_STARTED = 3,
154 STATUS_STOPPED = 4, 154 STATUS_STOPPED = 4,
155 STATUS_PAUSED = 6, 155 STATUS_PAUSED = 6,
156 STATUS_RESETTING = 7 156 STATUS_RESETTING = 7,
157 STATUS_DEAD = 8
157 }; 158 };
158 virtual bool addCommand( ECommand cmd ) = 0; 159 virtual bool addCommand( ECommand cmd ) = 0;
159 virtual bool clearCommand() = 0; 160 virtual bool clearCommand() = 0;
diff --git a/linden/indra/llmedia/llmediaimplgstreamer.cpp b/linden/indra/llmedia/llmediaimplgstreamer.cpp
index bae8ad9..af089bc 100644
--- a/linden/indra/llmedia/llmediaimplgstreamer.cpp
+++ b/linden/indra/llmedia/llmediaimplgstreamer.cpp
@@ -36,6 +36,7 @@
36 36
37extern "C" { 37extern "C" {
38#include <gst/gst.h> 38#include <gst/gst.h>
39#include <gst/gstelement.h>
39} 40}
40 41
41#include "llmediamanager.h" 42#include "llmediamanager.h"
@@ -72,7 +73,7 @@ LLMediaImplGStreamer () :
72 mPump ( NULL ), 73 mPump ( NULL ),
73 mPlaybin ( NULL ), 74 mPlaybin ( NULL ),
74 mVideoSink ( NULL ), 75 mVideoSink ( NULL ),
75 mState( GST_STATE_NULL ) 76 mState( GST_STATE_NULL )
76{ 77{
77 LL_DEBUGS("MediaManager") << "constructing media..." << LL_ENDL; 78 LL_DEBUGS("MediaManager") << "constructing media..." << LL_ENDL;
78 mVolume = -1.0; // XXX Hack to make the vould change happend first time 79 mVolume = -1.0; // XXX Hack to make the vould change happend first time
@@ -94,12 +95,14 @@ LLMediaImplGStreamer () :
94 return; // error 95 return; // error
95 } 96 }
96 97
97 if (NULL == getenv("LL_GSTREAMER_EXTERNAL")) 98 if (NULL == getenv("LL_GSTREAMER_EXTERNAL"))
98 { 99 {
99 // instantiate and connect a custom video sink 100 // instantiate and connect a custom video sink
100 LL_DEBUGS("MediaManager") << "extrenal video sink..." << LL_ENDL; 101 LL_DEBUGS("MediaManager") << "extrenal video sink..." << LL_ENDL;
102
103 // Plays inworld instead of in external player
101 mVideoSink = 104 mVideoSink =
102 GST_SLVIDEO(llgst_element_factory_make ("private-slvideo", "slvideo")); 105 GST_SLVIDEO(llgst_element_factory_make ("private-slvideo", "slvideo"));
103 if (!mVideoSink) 106 if (!mVideoSink)
104 { 107 {
105 LL_WARNS("MediaImpl") << "Could not instantiate private-slvideo element." << LL_ENDL; 108 LL_WARNS("MediaImpl") << "Could not instantiate private-slvideo element." << LL_ENDL;
@@ -142,12 +145,14 @@ LLMediaImplGStreamer::
142// virtual 145// virtual
143std::string LLMediaImplGStreamer::getVersion() 146std::string LLMediaImplGStreamer::getVersion()
144{ 147{
145 std::string rtn; 148 guint major, minor, micro, nano;
146 rtn = "[" + sLLMediaImplGStreamerReg.getImplName() + "] - GStreamer 0.10.x"; 149 llgst_version(&major, &minor, &micro, &nano);
147 return rtn; 150 std::string version = llformat("%d.%d.%d.%d",major,minor,micro,nano);
151 return version;
148} 152}
153
149// 154//
150//THIS IS THE METHOD THAT'S BREAKING STUFF 155// STARTUP
151/////////////////////////////////////////////////////////////////////////////// 156///////////////////////////////////////////////////////////////////////////////
152// (static) super-initialization - called once at application startup 157// (static) super-initialization - called once at application startup
153bool LLMediaImplGStreamer::startup (LLMediaManagerData* init_data) 158bool LLMediaImplGStreamer::startup (LLMediaManagerData* init_data)
@@ -161,6 +166,10 @@ bool LLMediaImplGStreamer::startup (LLMediaManagerData* init_data)
161 // Get symbols! 166 // Get symbols!
162#if LL_WINDOWS 167#if LL_WINDOWS
163 if (! grab_gst_syms("libgstreamer-0.10.dll", "libgstvideo-0.10.dll", "libgstaudio-0.10.dll") ) 168 if (! grab_gst_syms("libgstreamer-0.10.dll", "libgstvideo-0.10.dll", "libgstaudio-0.10.dll") )
169 {
170 LL_WARNS("MediaImpl") << "Couldn't find suitable GStreamer 0.10 support on this system - video playback disabled." << LL_ENDL;
171 return false;
172 }
164#else 173#else
165 if (! grab_gst_syms("libgstreamer-0.10.so.0", "libgstvideo-0.10.so.0", "libgstaudio-0.10.so.0") ) 174 if (! grab_gst_syms("libgstreamer-0.10.so.0", "libgstvideo-0.10.so.0", "libgstaudio-0.10.so.0") )
166 { 175 {
@@ -180,7 +189,7 @@ bool LLMediaImplGStreamer::startup (LLMediaManagerData* init_data)
180 saved_locale = setlocale(LC_ALL, NULL); 189 saved_locale = setlocale(LC_ALL, NULL);
181 if (0 == llgst_init_check(NULL, NULL, NULL)) 190 if (0 == llgst_init_check(NULL, NULL, NULL))
182 { 191 {
183 LL_WARNS("MediaImpl") << "GST init failed for unspecified reason." << LL_ENDL; 192 LL_WARNS("MediaImpl") << "GStreamer library failed to initialize and load standard plugins." << LL_ENDL;
184 setlocale(LC_ALL, saved_locale.c_str() ); 193 setlocale(LC_ALL, saved_locale.c_str() );
185 return false; 194 return false;
186 } 195 }
@@ -204,6 +213,7 @@ bool LLMediaImplGStreamer::closedown()
204 213
205/////////////////////////////////////////////////////////////////////////////// 214///////////////////////////////////////////////////////////////////////////////
206// 215//
216// Uncomment the line below to enable spammy debug data.
207//#define LL_GST_REPORT_STATE_CHANGES 217//#define LL_GST_REPORT_STATE_CHANGES
208#ifdef LL_GST_REPORT_STATE_CHANGES 218#ifdef LL_GST_REPORT_STATE_CHANGES
209static const char* get_gst_state_name(GstState state) 219static const char* get_gst_state_name(GstState state)
@@ -269,7 +279,8 @@ gboolean LLMediaImplGStreamer::bus_callback(GstBus *bus, GstMessage *message, gp
269 LL_DEBUGS("MediaImpl") << "State changed to NULL" << LL_ENDL; 279 LL_DEBUGS("MediaImpl") << "State changed to NULL" << LL_ENDL;
270#endif 280#endif
271 if (impl->getState() == GST_STATE_PLAYING) 281 if (impl->getState() == GST_STATE_PLAYING)
272 { // We got stoped by gstremer... 282 {
283 // Stream was probably dropped, trying to restart
273 impl->play(); 284 impl->play();
274#ifdef LL_GST_REPORT_STATE_CHANGES 285#ifdef LL_GST_REPORT_STATE_CHANGES
275 LL_DEBUGS("MediaImpl") << "Trying to restart." << LL_ENDL; 286 LL_DEBUGS("MediaImpl") << "Trying to restart." << LL_ENDL;
@@ -384,8 +395,7 @@ bool LLMediaImplGStreamer::navigateTo (const std::string urlIn)
384 LL_DEBUGS("MediaImpl") << "Setting media URI: " << urlIn.c_str() 395 LL_DEBUGS("MediaImpl") << "Setting media URI: " << urlIn.c_str()
385 << LL_ENDL; 396 << LL_ENDL;
386 397
387 if (NULL == mPump 398 if (mPump == NULL || mPlaybin == NULL)
388 || NULL == mPlaybin)
389 { 399 {
390 return false; 400 return false;
391 } 401 }
@@ -394,7 +404,6 @@ bool LLMediaImplGStreamer::navigateTo (const std::string urlIn)
394 404
395 // set URI 405 // set URI
396 g_object_set (G_OBJECT (mPlaybin), "uri", urlIn.c_str(), NULL); 406 g_object_set (G_OBJECT (mPlaybin), "uri", urlIn.c_str(), NULL);
397 //g_object_set (G_OBJECT (mPlaybin), "uri", "file:///tmp/movie", NULL);
398 407
399 // get playbin's bus - perhaps this can/should be done in ctor 408 // get playbin's bus - perhaps this can/should be done in ctor
400 GstBus *bus = llgst_pipeline_get_bus (GST_PIPELINE (mPlaybin)); 409 GstBus *bus = llgst_pipeline_get_bus (GST_PIPELINE (mPlaybin));
@@ -405,6 +414,8 @@ bool LLMediaImplGStreamer::navigateTo (const std::string urlIn)
405 llgst_bus_add_watch (bus, bus_callback, this); 414 llgst_bus_add_watch (bus, bus_callback, this);
406 llgst_object_unref (bus); 415 llgst_object_unref (bus);
407 416
417 mState = GST_STATE_READY;
418
408 // navigateTo implicitly plays, too. 419 // navigateTo implicitly plays, too.
409 play(); 420 play();
410 421
@@ -437,6 +448,8 @@ bool LLMediaImplGStreamer::unload()
437 } 448 }
438 449
439 mVideoSink = NULL; 450 mVideoSink = NULL;
451 mState = GST_STATE_NULL;
452 setStatus(LLMediaBase::STATUS_UNKNOWN);
440 453
441 return true; 454 return true;
442} 455}
@@ -448,15 +461,19 @@ bool LLMediaImplGStreamer::updateMedia()
448 //LL_DEBUGS("MediaImpl") << "updating media..." << LL_ENDL; 461 //LL_DEBUGS("MediaImpl") << "updating media..." << LL_ENDL;
449 462
450 // sanity check 463 // sanity check
451 if (NULL == mPump 464 if (mPump == NULL || mPlaybin == NULL)
452 || NULL == mPlaybin)
453 { 465 {
454#ifdef LL_GST_REPORT_STATE_CHANGES 466#ifdef LL_GST_REPORT_STATE_CHANGES
455 LL_DEBUGS("MediaImpl") << "dead media..." << LL_ENDL; 467 LL_DEBUGS("MediaImpl") << "dead media..." << LL_ENDL;
456#endif 468#endif
469 mState = GST_STATE_NULL;
470 setStatus(LLMediaBase::STATUS_DEAD);
457 return false; 471 return false;
458 } 472 }
459 473
474 if (mState == GST_STATE_VOID_PENDING || mState == GST_STATE_NULL)
475 return false;
476
460 // process next outstanding command 477 // process next outstanding command
461 switch (nextCommand()) 478 switch (nextCommand())
462 { 479 {
@@ -567,10 +584,24 @@ bool LLMediaImplGStreamer::updateMedia()
567// 584//
568bool LLMediaImplGStreamer::stop() 585bool LLMediaImplGStreamer::stop()
569{ 586{
570 LL_DEBUGS("MediaImpl") << "stopping media..." << LL_ENDL; 587 LL_DEBUGS("MediaImpl") << "attempting to stop..." << LL_ENDL;
571 // todo: error-check this? 588
572 llgst_element_set_state(mPlaybin, GST_STATE_READY); 589 if (!mPlaybin || mState == GST_STATE_NULL)
573 mState = GST_STATE_READY; 590 return true;
591
592 GstElement *pipeline = (GstElement *)llgst_object_ref(GST_OBJECT(mPlaybin));
593 llgst_object_unref(pipeline);
594
595 llgst_element_set_state(pipeline, GST_STATE_READY);
596
597 if (mState == GST_STATE_PLAYING)
598 mState = GST_STATE_VOID_PENDING;
599 else
600 mState = GST_STATE_READY;
601
602 GstStateChangeReturn state_change = llgst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE);
603 LL_DEBUGS("MediaImpl") << "get_state: " << llgst_element_state_change_return_get_name(state_change) << LL_ENDL;
604
574 return true; 605 return true;
575} 606}
576 607
@@ -578,10 +609,29 @@ bool LLMediaImplGStreamer::stop()
578// 609//
579bool LLMediaImplGStreamer::play() 610bool LLMediaImplGStreamer::play()
580{ 611{
581 LL_DEBUGS("MediaImpl") << "playing media..." << LL_ENDL; 612 LL_DEBUGS("MediaImpl") << "attempting to play..." << LL_ENDL;
582 // todo: error-check this? 613
583 llgst_element_set_state(mPlaybin, GST_STATE_PLAYING); 614 if (!mPlaybin || mState == GST_STATE_NULL)
615 return true;
616
617 GstElement *pipeline = (GstElement *)llgst_object_ref(GST_OBJECT(mPlaybin));
618 llgst_object_unref(pipeline);
619
620 llgst_element_set_state(pipeline, GST_STATE_PLAYING);
584 mState = GST_STATE_PLAYING; 621 mState = GST_STATE_PLAYING;
622 /*llgst_element_set_state(mPlaybin, GST_STATE_PLAYING);
623 mState = GST_STATE_PLAYING;*/
624
625 GstStateChangeReturn state_change = llgst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE);
626 LL_DEBUGS("MediaImpl") << "get_state: " << llgst_element_state_change_return_get_name(state_change) << LL_ENDL;
627
628 // Check to make sure playing was successful. If not, stop.
629 if (state_change == GST_STATE_CHANGE_FAILURE)
630 {
631 setStatus(LLMediaBase::STATUS_STOPPED);
632 stop();
633 }
634
585 return true; 635 return true;
586} 636}
587 637
@@ -589,10 +639,17 @@ bool LLMediaImplGStreamer::play()
589// 639//
590bool LLMediaImplGStreamer::pause() 640bool LLMediaImplGStreamer::pause()
591{ 641{
592 LL_DEBUGS("MediaImpl") <<"pausing media..." << LL_ENDL; 642 LL_DEBUGS("MediaImpl") << "attempting to pause..." << LL_ENDL;
593 // todo: error-check this? 643
644 if (!mPlaybin || mState == GST_STATE_NULL)
645 return true;
646
594 llgst_element_set_state(mPlaybin, GST_STATE_PAUSED); 647 llgst_element_set_state(mPlaybin, GST_STATE_PAUSED);
595 mState = GST_STATE_PAUSED; 648 mState = GST_STATE_PAUSED;
649
650 GstStateChangeReturn state_change = llgst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE);
651 LL_DEBUGS("MediaImpl") << "get_state: " << llgst_element_state_change_return_get_name(state_change) << LL_ENDL;
652
596 return true; 653 return true;
597}; 654};
598 655
@@ -628,12 +685,12 @@ bool LLMediaImplGStreamer::seek(double time)
628// virtual 685// virtual
629bool LLMediaImplGStreamer::setVolume(float volume) 686bool LLMediaImplGStreamer::setVolume(float volume)
630{ 687{
631 // XXX hack to make volume volume changes less othen 688 // XXX hack to make volume volume changes less othen
632 // bug in gstreamer 0.10.21 689 // bug in gstreamer 0.10.21
633 if(mVolume == volume) 690 if(mVolume == volume)
634 return true; 691 return true;
635 692
636 LL_DEBUGS("MediaImpl") << "setVolume(" << volume << ") : " << getpid() << LL_ENDL; 693 LL_DEBUGS("MediaImpl") << "setVolume(" << volume << ") : " << getpid() << LL_ENDL;
637 mVolume = volume; 694 mVolume = volume;
638 if (mPlaybin) 695 if (mPlaybin)
639 { 696 {
diff --git a/linden/indra/llmedia/llmediaimplgstreamer.h b/linden/indra/llmedia/llmediaimplgstreamer.h
index 5b493ad..dec970a 100644
--- a/linden/indra/llmedia/llmediaimplgstreamer.h
+++ b/linden/indra/llmedia/llmediaimplgstreamer.h
@@ -74,7 +74,7 @@ class LLMediaImplGStreamer:
74 /* virtual */ int getTextureFormatType() const; 74 /* virtual */ int getTextureFormatType() const;
75 /* virtual */ int getTextureFormatInternal() const; 75 /* virtual */ int getTextureFormatInternal() const;
76 /* virtual */ bool seek( double time ); 76 /* virtual */ bool seek( double time );
77 /* virtual */ bool setVolume( float volume ); 77 /* virtual */ bool setVolume( float volume );
78 78
79 LLMediaEmitter< LLMediaObserver > getEventEmitter() const {return mEventEmitter;}; 79 LLMediaEmitter< LLMediaObserver > getEventEmitter() const {return mEventEmitter;};
80 80
@@ -84,6 +84,7 @@ class LLMediaImplGStreamer:
84 bool pause(); 84 bool pause();
85 bool stop(); 85 bool stop();
86 bool play(); 86 bool play();
87
87 static gboolean bus_callback (GstBus *bus, 88 static gboolean bus_callback (GstBus *bus,
88 GstMessage *message, 89 GstMessage *message,
89 gpointer data); 90 gpointer data);
diff --git a/linden/indra/llmedia/llmediaimplgstreamer_syms_raw.inc b/linden/indra/llmedia/llmediaimplgstreamer_syms_raw.inc
index e17a7a0..0d0d764 100644
--- a/linden/indra/llmedia/llmediaimplgstreamer_syms_raw.inc
+++ b/linden/indra/llmedia/llmediaimplgstreamer_syms_raw.inc
@@ -7,7 +7,9 @@ LL_GST_SYM(true, gst_message_parse_error, void, GstMessage *message, GError **ge
7LL_GST_SYM(true, gst_message_parse_warning, void, GstMessage *message, GError **gerror, gchar **debug); 7LL_GST_SYM(true, gst_message_parse_warning, void, GstMessage *message, GError **gerror, gchar **debug);
8LL_GST_SYM(true, gst_message_parse_state_changed, void, GstMessage *message, GstState *oldstate, GstState *newstate, GstState *pending); 8LL_GST_SYM(true, gst_message_parse_state_changed, void, GstMessage *message, GstState *oldstate, GstState *newstate, GstState *pending);
9LL_GST_SYM(true, gst_element_set_state, GstStateChangeReturn, GstElement *element, GstState state); 9LL_GST_SYM(true, gst_element_set_state, GstStateChangeReturn, GstElement *element, GstState state);
10LL_GST_SYM(true, gst_element_get_state, GstStateChangeReturn, GstElement *element, GstState *state, GstState *pending, GstClockTime timeout);
10LL_GST_SYM(true, gst_object_unref, void, gpointer object); 11LL_GST_SYM(true, gst_object_unref, void, gpointer object);
12LL_GST_SYM(true, gst_object_ref, gpointer, gpointer object);
11LL_GST_SYM(true, gst_object_get_type, GType, void); 13LL_GST_SYM(true, gst_object_get_type, GType, void);
12LL_GST_SYM(true, gst_pipeline_get_type, GType, void); 14LL_GST_SYM(true, gst_pipeline_get_type, GType, void);
13LL_GST_SYM(true, gst_pipeline_get_bus, GstBus*, GstPipeline *pipeline); 15LL_GST_SYM(true, gst_pipeline_get_bus, GstBus*, GstPipeline *pipeline);
@@ -35,6 +37,8 @@ LL_GST_SYM(true, gst_value_get_fraction_numerator, gint, const GValue *value);
35LL_GST_SYM(true, gst_value_get_fraction_denominator, gint, const GValue *value); 37LL_GST_SYM(true, gst_value_get_fraction_denominator, gint, const GValue *value);
36LL_GST_SYM(true, gst_structure_get_name, G_CONST_RETURN gchar *, const GstStructure *structure); 38LL_GST_SYM(true, gst_structure_get_name, G_CONST_RETURN gchar *, const GstStructure *structure);
37LL_GST_SYM(true, gst_element_seek, bool, GstElement *, gdouble, GstFormat, GstSeekFlags, GstSeekType, gint64, GstSeekType, gint64); 39LL_GST_SYM(true, gst_element_seek, bool, GstElement *, gdouble, GstFormat, GstSeekFlags, GstSeekType, gint64, GstSeekType, gint64);
40LL_GST_SYM(true, gst_version, void, guint *major, guint *minor, guint *micro, guint *nano);
41LL_GST_SYM(true, gst_element_state_change_return_get_name, const gchar *, GstStateChangeReturn state_ret);
38 42
39// optional symbols to grab 43// optional symbols to grab
40LL_GST_SYM(false, gst_segtrap_set_enabled, void, gboolean enabled); 44LL_GST_SYM(false, gst_segtrap_set_enabled, void, gboolean enabled);