aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmedia
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llmedia')
-rw-r--r--linden/indra/llmedia/CMakeLists.txt20
-rw-r--r--linden/indra/llmedia/llmediaimplgstreamer.cpp365
-rw-r--r--linden/indra/llmedia/llmediaimplgstreamer.h15
-rw-r--r--linden/indra/llmedia/llmediaimplgstreamer_syms.cpp4
-rw-r--r--linden/indra/llmedia/llmediaimplgstreamer_syms.h4
-rw-r--r--linden/indra/llmedia/llmediaimplgstreamervidplug.cpp28
-rw-r--r--linden/indra/llmedia/llmediaimplgstreamervidplug.h5
-rw-r--r--linden/indra/llmedia/llmediamanager.cpp12
8 files changed, 236 insertions, 217 deletions
diff --git a/linden/indra/llmedia/CMakeLists.txt b/linden/indra/llmedia/CMakeLists.txt
index 8ef8006..026afc1 100644
--- a/linden/indra/llmedia/CMakeLists.txt
+++ b/linden/indra/llmedia/CMakeLists.txt
@@ -29,6 +29,9 @@ set(llmedia_SOURCE_FILES
29 llmediaimplexample2.cpp 29 llmediaimplexample2.cpp
30 llmediaimplfactory.cpp 30 llmediaimplfactory.cpp
31 llmediamanager.cpp 31 llmediamanager.cpp
32 llmediaimplgstreamer.cpp
33 llmediaimplgstreamer_syms.cpp
34 llmediaimplgstreamervidplug.cpp
32 ) 35 )
33 36
34set(llmedia_HEADER_FILES 37set(llmedia_HEADER_FILES
@@ -43,21 +46,11 @@ set(llmedia_HEADER_FILES
43 llmediaimplregister.h 46 llmediaimplregister.h
44 llmediamanager.h 47 llmediamanager.h
45 llmediaobserver.h 48 llmediaobserver.h
49 llmediaimplgstreamer.h
50 llmediaimplgstreamervidplug.h
51 llmediaimplgstreamer_syms.h
46 ) 52 )
47 53
48if (GSTREAMER)
49 list(APPEND llmedia_SOURCE_FILES
50 llmediaimplgstreamer.cpp
51 llmediaimplgstreamer_syms.cpp
52 llmediaimplgstreamervidplug.cpp
53 )
54
55 list(APPEND llmedia_HEADER_FILES
56 llmediaimplgstreamer.h
57 llmediaimplgstreamervidplug.h
58 llmediaimplgstreamer_syms.h
59 )
60
61 # Work around a bad interaction between broken gstreamer headers and 54 # Work around a bad interaction between broken gstreamer headers and
62 # g++ 4.3's increased strictness. 55 # g++ 4.3's increased strictness.
63 56
@@ -65,7 +58,6 @@ if (GSTREAMER)
65 set_source_files_properties(llmediaimplgstreamervidplug.cpp PROPERTIES 58 set_source_files_properties(llmediaimplgstreamervidplug.cpp PROPERTIES
66 COMPILE_FLAGS -Wno-error=write-strings) 59 COMPILE_FLAGS -Wno-error=write-strings)
67 endif (${CXX_VERSION} MATCHES "4.[23]") 60 endif (${CXX_VERSION} MATCHES "4.[23]")
68endif (GSTREAMER)
69 61
70if (MOZLIB) 62if (MOZLIB)
71 list(APPEND llmedia_SOURCE_FILES llmediaimplllmozlib.cpp) 63 list(APPEND llmedia_SOURCE_FILES llmediaimplllmozlib.cpp)
diff --git a/linden/indra/llmedia/llmediaimplgstreamer.cpp b/linden/indra/llmedia/llmediaimplgstreamer.cpp
index 5d6a648..d889f6f 100644
--- a/linden/indra/llmedia/llmediaimplgstreamer.cpp
+++ b/linden/indra/llmedia/llmediaimplgstreamer.cpp
@@ -32,7 +32,7 @@
32 32
33#include "llmediaimplgstreamer.h" 33#include "llmediaimplgstreamer.h"
34 34
35#if LL_GSTREAMER_ENABLED 35///#if LL_GSTREAMER_ENABLED
36 36
37extern "C" { 37extern "C" {
38#include <gst/gst.h> 38#include <gst/gst.h>
@@ -49,6 +49,8 @@ extern "C" {
49 49
50#include "llmediaimplgstreamer_syms.h" 50#include "llmediaimplgstreamer_syms.h"
51 51
52#include "llerror.h"
53
52// register this impl with media manager factory 54// register this impl with media manager factory
53static LLMediaImplRegister sLLMediaImplGStreamerReg( "LLMediaImplGStreamer", new LLMediaImplGStreamerMaker() ); 55static LLMediaImplRegister sLLMediaImplGStreamerReg( "LLMediaImplGStreamer", new LLMediaImplGStreamerMaker() );
54 56
@@ -73,12 +75,14 @@ LLMediaImplGStreamer () :
73 mTextureFormatType ( LL_MEDIA_UNSIGNED_INT_8_8_8_8_REV ), 75 mTextureFormatType ( LL_MEDIA_UNSIGNED_INT_8_8_8_8_REV ),
74 mPump ( NULL ), 76 mPump ( NULL ),
75 mPlaybin ( NULL ), 77 mPlaybin ( NULL ),
76 mVideoSink ( NULL ) 78 mVideoSink ( NULL ),
79 mState( GST_STATE_NULL )
77#ifdef LL_GST_SOUNDSINK 80#ifdef LL_GST_SOUNDSINK
78 ,mAudioSink ( NULL ) 81 ,mAudioSink ( NULL )
79#endif // LL_GST_SOUNDSINK 82#endif // LL_GST_SOUNDSINK
80{ 83{
81 DEBUGMSG("constructing media..."); 84 LL_DEBUGS("MediaManager") << "constructing media..." << LL_ENDL;
85 mVolume = -1.0; // XXX Hack to make the vould change happend first time
82 86
83 setMediaDepth(4); 87 setMediaDepth(4);
84 88
@@ -97,13 +101,15 @@ LLMediaImplGStreamer () :
97 return; // error 101 return; // error
98 } 102 }
99 103
100 if (NULL == getenv("LL_GSTREAMER_EXTERNAL")) { 104 if (NULL == getenv("LL_GSTREAMER_EXTERNAL"))
105 {
101 // instantiate and connect a custom video sink 106 // instantiate and connect a custom video sink
107 LL_DEBUGS("MediaManager") << "extrenal video sink..." << LL_ENDL;
102 mVideoSink = 108 mVideoSink =
103 GST_SLVIDEO(llgst_element_factory_make ("private-slvideo", "slvideo")); 109 GST_SLVIDEO(llgst_element_factory_make ("private-slvideo", "slvideo"));
104 if (!mVideoSink) 110 if (!mVideoSink)
105 { 111 {
106 WARNMSG("Could not instantiate private-slvideo element."); 112 LL_WARNS("MediaImpl") << "Could not instantiate private-slvideo element." << LL_ENDL;
107 // todo: cleanup. 113 // todo: cleanup.
108 return; // error 114 return; // error
109 } 115 }
@@ -111,12 +117,13 @@ LLMediaImplGStreamer () :
111 g_object_set(mPlaybin, "video-sink", mVideoSink, NULL); 117 g_object_set(mPlaybin, "video-sink", mVideoSink, NULL);
112 118
113#ifdef LL_GST_SOUNDSINK 119#ifdef LL_GST_SOUNDSINK
120 LL_DEBUGS("MediaManager") << "extrenal audio sink..." << LL_ENDL;
114 // instantiate and connect a custom audio sink 121 // instantiate and connect a custom audio sink
115 mAudioSink = 122 mAudioSink =
116 GST_SLSOUND(llgst_element_factory_make ("private-slsound", "slsound")); 123 GST_SLSOUND(llgst_element_factory_make ("private-slsound", "slsound"));
117 if (!mAudioSink) 124 if (!mAudioSink)
118 { 125 {
119 WARNMSG("Could not instantiate private-slsound element."); 126 LL_WARN("MediaImpl") << "Could not instantiate private-slsound element." << LL_ENDL;
120 // todo: cleanup. 127 // todo: cleanup.
121 return; // error 128 return; // error
122 } 129 }
@@ -149,7 +156,7 @@ int LLMediaImplGStreamer::getTextureFormatInternal() const
149LLMediaImplGStreamer:: 156LLMediaImplGStreamer::
150~LLMediaImplGStreamer () 157~LLMediaImplGStreamer ()
151{ 158{
152 DEBUGMSG("dtor of media..."); 159 LL_DEBUGS("MediaImpl") << ("dtor of media...") << LL_ENDL;
153 unload(); 160 unload();
154} 161}
155 162
@@ -161,36 +168,41 @@ std::string LLMediaImplGStreamer::getVersion()
161 rtn = "[" + sLLMediaImplGStreamerReg.getImplName() + "] - GStreamer 0.10.x"; 168 rtn = "[" + sLLMediaImplGStreamerReg.getImplName() + "] - GStreamer 0.10.x";
162 return rtn; 169 return rtn;
163} 170}
164 171//
172//THIS IS THE METHOD THAT'S BREAKING STUFF
165/////////////////////////////////////////////////////////////////////////////// 173///////////////////////////////////////////////////////////////////////////////
166// (static) super-initialization - called once at application startup 174// (static) super-initialization - called once at application startup
167bool 175bool LLMediaImplGStreamer::startup (LLMediaManagerData* init_data)
168LLMediaImplGStreamer::
169startup ( LLMediaManagerData* init_data )
170{ 176{
171 static bool done_init = false; 177 static bool done_init = false;
172 if (!done_init) 178 if (!done_init)
173 { 179 {
180 // Init the glib type system - we need it.
181 g_type_init();
182
174 // Get symbols! 183 // Get symbols!
175 if (! grab_gst_syms("libgstreamer-0.10.so.0", 184#if LL_WINDOWS
176 "libgstvideo-0.10.so.0", 185 if (! grab_gst_syms("libgstreamer-0.10.dll", "libgstvideo-0.10.dll", "libgstaudio-0.10.dll") )
177 "libgstaudio-0.10.so.0") ) 186#else
187 if (! grab_gst_syms("libgstreamer-0.10.so.0", "libgstvideo-0.10.so.0", "libgstaudio-0.10.so.0") )
178 { 188 {
179 WARNMSG("Couldn't find suitable GStreamer 0.10 support on this system - video playback disabled."); 189 LL_WARNS("MediaImpl") << "Couldn't find suitable GStreamer 0.10 support on this system - video playback disabled." << LL_ENDL;
180 return false; 190 return false;
181 } 191 }
182 192#endif
183 if (llgst_segtrap_set_enabled) 193 if (llgst_segtrap_set_enabled)
184 llgst_segtrap_set_enabled(FALSE); 194 llgst_segtrap_set_enabled(FALSE);
185 else 195 else
186 WARNMSG("gst_segtrap_set_enabled() is not available; Automated crash-reporter may cease to function until next restart."); 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 }
187 199
188 // Protect against GStreamer resetting the locale, yuck. 200 // Protect against GStreamer resetting the locale, yuck.
189 static std::string saved_locale; 201 static std::string saved_locale;
190 saved_locale = setlocale(LC_ALL, NULL); 202 saved_locale = setlocale(LC_ALL, NULL);
191 if (0 == llgst_init_check(NULL, NULL, NULL)) 203 if (0 == llgst_init_check(NULL, NULL, NULL))
192 { 204 {
193 WARNMSG("GST init failed for unspecified reason."); 205 LL_WARNS("MediaImpl") << "GST init failed for unspecified reason." << LL_ENDL;
194 setlocale(LC_ALL, saved_locale.c_str() ); 206 setlocale(LC_ALL, saved_locale.c_str() );
195 return false; 207 return false;
196 } 208 }
@@ -204,16 +216,13 @@ startup ( LLMediaManagerData* init_data )
204 216
205 done_init = true; 217 done_init = true;
206 } 218 }
207
208 return true; 219 return true;
209} 220}
210 221
211 222
212bool LLMediaImplGStreamer:: 223bool LLMediaImplGStreamer::closedown()
213closedown()
214{ 224{
215 ungrab_gst_syms(); 225 ungrab_gst_syms();
216
217 return true; 226 return true;
218} 227}
219 228
@@ -222,145 +231,164 @@ closedown()
222// 231//
223//#define LL_GST_REPORT_STATE_CHANGES 232//#define LL_GST_REPORT_STATE_CHANGES
224#ifdef LL_GST_REPORT_STATE_CHANGES 233#ifdef LL_GST_REPORT_STATE_CHANGES
225static char* get_gst_state_name(GstState state) 234static const char* get_gst_state_name(GstState state)
226{ 235{
227 switch (state) { 236 switch (state)
228 case GST_STATE_VOID_PENDING: return "VOID_PENDING"; 237 {
229 case GST_STATE_NULL: return "NULL"; 238 case GST_STATE_VOID_PENDING: return "VOID_PENDING";
230 case GST_STATE_READY: return "READY"; 239 case GST_STATE_NULL: return "NULL";
231 case GST_STATE_PAUSED: return "PAUSED"; 240 case GST_STATE_READY: return "READY";
232 case GST_STATE_PLAYING: return "PLAYING"; 241 case GST_STATE_PAUSED: return "PAUSED";
242 case GST_STATE_PLAYING: return "PLAYING";
233 } 243 }
234 return "(unknown)"; 244 return "(unknown)";
235} 245}
236#endif // LL_GST_REPORT_STATE_CHANGES 246#endif // LL_GST_REPORT_STATE_CHANGES
237 247
238//static 248//static
239gboolean 249gboolean LLMediaImplGStreamer::bus_callback(GstBus *bus, GstMessage *message, gpointer data)
240LLMediaImplGStreamer::bus_callback (GstBus *bus,
241 GstMessage *message,
242 gpointer data)
243{ 250{
244 if (GST_MESSAGE_TYPE(message) != GST_MESSAGE_STATE_CHANGED && 251 LL_DEBUGS("MediaCallback") << "Got GST message type: " << LLGST_MESSAGE_TYPE_NAME (message) << LL_ENDL;
245 GST_MESSAGE_TYPE(message) != GST_MESSAGE_BUFFERING)
246 {
247 DEBUGMSG("Got GST message type: %s",
248 LLGST_MESSAGE_TYPE_NAME (message));
249 }
250 else
251 {
252 DEBUGMSG("Got GST message type: %s",
253 LLGST_MESSAGE_TYPE_NAME (message));
254 }
255 252
256 LLMediaImplGStreamer *impl = (LLMediaImplGStreamer*)data; 253 LLMediaImplGStreamer *impl = (LLMediaImplGStreamer*)data;
257 254
258 switch (GST_MESSAGE_TYPE (message)) { 255 switch (GST_MESSAGE_TYPE (message))
259 case GST_MESSAGE_BUFFERING: { 256 {
260 // NEEDS GST 0.10.11+ 257 case GST_MESSAGE_BUFFERING:
261 if (llgst_message_parse_buffering)
262 { 258 {
263 gint percent = 0; 259 // NEEDS GST 0.10.11+
264 llgst_message_parse_buffering(message, &percent); 260 if (llgst_message_parse_buffering)
265 DEBUGMSG("GST buffering: %d%%", percent); 261 {
266 LLMediaEvent event( impl, percent ); 262 gint percent = 0;
267 impl->getEventEmitter().update( &LLMediaObserver::onUpdateProgress, event ); 263 llgst_message_parse_buffering(message, &percent);
268 264 LL_DEBUGS("MediaBuffering") << "GST buffering: " << percent << "%%" << LL_ENDL;
265 LLMediaEvent event( impl, percent );
266 impl->getEventEmitter().update( &LLMediaObserver::onUpdateProgress, event );
267 }
269 } 268 }
270 break; 269 break;
271 } 270 case GST_MESSAGE_STATE_CHANGED:
272 case GST_MESSAGE_STATE_CHANGED: { 271 {
273 GstState old_state; 272 GstState old_state;
274 GstState new_state; 273 GstState new_state;
275 GstState pending_state; 274 GstState pending_state;
276 llgst_message_parse_state_changed(message, 275 llgst_message_parse_state_changed(message,
277 &old_state, 276 &old_state,
278 &new_state, 277 &new_state,
279 &pending_state); 278 &pending_state);
280#ifdef LL_GST_REPORT_STATE_CHANGES 279#ifdef LL_GST_REPORT_STATE_CHANGES
281 // not generally very useful, and rather spammy. 280 // not generally very useful, and rather spammy.
282 DEBUGMSG("state change (old,<new>,pending): %s,<%s>,%s", 281 LL_DEBUGS("MediaState") << "GST state change (old,<new>,pending): "<< get_gst_state_name(old_state) << ",<" << get_gst_state_name(new_state) << ">," << get_gst_state_name(pending_state) << LL_ENDL;
283 get_gst_state_name(old_state),
284 get_gst_state_name(new_state),
285 get_gst_state_name(pending_state));
286#endif // LL_GST_REPORT_STATE_CHANGES 282#endif // LL_GST_REPORT_STATE_CHANGES
287 283
288 switch (new_state) { 284 switch (new_state)
289 case GST_STATE_VOID_PENDING: 285 {
290 break; 286 case GST_STATE_VOID_PENDING:
291 case GST_STATE_NULL: 287 break;
292 break; 288 case GST_STATE_NULL:
293 case GST_STATE_READY: 289 LL_DEBUGS("MediaImpl") << "State changed to NULL" << LL_ENDL;
294 break; 290 if (impl->getState() == GST_STATE_PLAYING)
295 case GST_STATE_PAUSED: 291 { // We got stoped by gstremer...
296 break; 292 impl->play();
297 case GST_STATE_PLAYING: 293 LL_DEBUGS("MediaImpl") << "Trying to restart." << LL_ENDL;
298 LLMediaEvent event( impl, 100 ); 294 }
299 impl->getEventEmitter().update( &LLMediaObserver::onUpdateProgress, event ); 295 break;
300 // emit an event to say that a media source was loaded 296 case GST_STATE_READY:
301 LLMediaEvent event2( impl ); 297 break;
302 impl->getEventEmitter().update( &LLMediaObserver::onMediaLoaded, event2 ); 298 case GST_STATE_PAUSED:
299 break;
300 case GST_STATE_PLAYING:
301 LLMediaEvent event( impl, 100 );
302 impl->getEventEmitter().update( &LLMediaObserver::onUpdateProgress, event );
303 // emit an event to say that a media source was loaded
304 LLMediaEvent event2( impl );
305 impl->getEventEmitter().update( &LLMediaObserver::onMediaLoaded, event2 );
306 break;
307 }
303 break; 308 break;
304 } 309 }
305 break; 310 case GST_MESSAGE_ERROR:
306 } 311 {
307 case GST_MESSAGE_ERROR: { 312 GError *err = NULL;
308 GError *err = NULL; 313 gchar *debug = NULL;
309 gchar *debug = NULL;
310 314
311 llgst_message_parse_error (message, &err, &debug); 315 llgst_message_parse_error (message, &err, &debug);
312 WARNMSG("GST error: %s", err->message); 316 LL_WARNS("MediaImpl") << "GST Error: " << err->message << LL_ENDL;
313 g_error_free (err); 317 g_error_free (err);
314 g_free (debug); 318 g_free (debug);
315 319
316 impl->addCommand(LLMediaBase::COMMAND_STOP); 320 impl->addCommand(LLMediaBase::COMMAND_STOP);
321 //impl->addCommand(LLMediaBase::COMMAND_START);
317 322
318 break; 323 break;
319 } 324 }
320 case GST_MESSAGE_INFO: { 325 case GST_MESSAGE_INFO:
321 if (llgst_message_parse_info) 326 {
327 if (llgst_message_parse_info)
328 {
329 GError *err = NULL;
330 gchar *debug = NULL;
331
332 llgst_message_parse_info (message, &err, &debug);
333 LL_INFOS("MediaImpl") << "GST info: " << err->message
334 << LL_ENDL;
335 g_error_free (err);
336 g_free (debug);
337 }
338 break;
339 }
340 case GST_MESSAGE_WARNING:
322 { 341 {
323 GError *err = NULL; 342 GError *err = NULL;
324 gchar *debug = NULL; 343 gchar *debug = NULL;
325 344
326 llgst_message_parse_info (message, &err, &debug); 345 llgst_message_parse_warning (message, &err, &debug);
327 INFOMSG("GST info: %s", err->message); 346 LL_WARNS("MediaImpl") << "GST warning: " << err->message
347 << LL_ENDL;
328 g_error_free (err); 348 g_error_free (err);
329 g_free (debug); 349 g_free (debug);
330 }
331 break;
332 }
333 case GST_MESSAGE_WARNING: {
334 GError *err = NULL;
335 gchar *debug = NULL;
336 350
337 llgst_message_parse_warning (message, &err, &debug); 351 break;
338 WARNMSG("GST warning: %s", err->message); 352 }
339 g_error_free (err); 353 case GST_MESSAGE_TAG:
340 g_free (debug);
341
342 break;
343 }
344 case GST_MESSAGE_EOS:
345 /* end-of-stream */
346 DEBUGMSG("GST end-of-stream.");
347 if (impl->isLooping())
348 { 354 {
349 DEBUGMSG("looping media..."); 355#if 0
350 impl->stop(); 356 GstTagList *tag_list;
351 impl->play(); 357 gchar *title;
358 gchar *artist;
359 llgst_message_parse_tag(message, &tag_list);
360 gboolean hazTitle = llgst_tag_list_get_string(tag_list,
361 GST_TAG_TITLE, &title);
362 gboolean hazArtist = llgst_tag_list_get_string(tag_list,
363 GST_TAG_ARTIST, &artist);
364 if(hazTitle)
365 LL_INFOS("MediaInfo") << "Title is " << title << LL_ENDL;
366 if(hazArtist)
367 LL_INFOS("MediaInfo") << "Artist is " << artist << LL_ENDL;
368#endif
369 break;
352 } 370 }
353 else 371 case GST_MESSAGE_EOS:
354 { 372 {
355 // inject a COMMAND_STOP 373 /* end-of-stream */
356 impl->addCommand(LLMediaBase::COMMAND_STOP); 374 LL_DEBUGS("MediaImpl") << "GST end-of-stream." << LL_ENDL;
375 if (impl->isLooping())
376 {
377 LL_DEBUGS("MediaImpl") << "looping media..." << LL_ENDL;
378 impl->stop();
379 impl->play();
380 }
381 else
382 {
383 // inject a COMMAND_STOP
384 impl->addCommand(LLMediaBase::COMMAND_STOP);
385 }
386 break;
387 default:
388 /* unhandled message */
389 break;
357 } 390 }
358 break;
359 default:
360 /* unhandled message */
361 break;
362 } 391 }
363
364 /* we want to be notified again the next time there is a message 392 /* we want to be notified again the next time there is a message
365 * on the bus, so return true (false means we want to stop watching 393 * on the bus, so return true (false means we want to stop watching
366 * for messages on the bus and our callback should not be called again) 394 * for messages on the bus and our callback should not be called again)
@@ -370,11 +398,10 @@ LLMediaImplGStreamer::bus_callback (GstBus *bus,
370 398
371/////////////////////////////////////////////////////////// 399///////////////////////////////////////////////////////////
372// virtual 400// virtual
373bool 401bool LLMediaImplGStreamer::navigateTo (const std::string urlIn)
374LLMediaImplGStreamer::
375navigateTo ( const std::string urlIn )
376{ 402{
377 DEBUGMSG("Setting media URI: %s", urlIn.c_str()); 403 LL_DEBUGS("MediaImpl") << "Setting media URI: " << urlIn.c_str()
404 << LL_ENDL;
378 405
379 if (NULL == mPump 406 if (NULL == mPump
380#ifdef LL_GST_SOUNDSINK 407#ifdef LL_GST_SOUNDSINK
@@ -408,14 +435,13 @@ navigateTo ( const std::string urlIn )
408 435
409/////////////////////////////////////////////////////////////////////////////// 436///////////////////////////////////////////////////////////////////////////////
410// 437//
411bool 438bool LLMediaImplGStreamer::unload()
412LLMediaImplGStreamer::
413unload ()
414{ 439{
415 DEBUGMSG("unloading media..."); 440 LL_DEBUGS("MediaImpl") << "unloading media..." << LL_ENDL;
416 if (mPlaybin) 441 if (mPlaybin)
417 { 442 {
418 llgst_element_set_state (mPlaybin, GST_STATE_NULL); 443 llgst_element_set_state (mPlaybin, GST_STATE_NULL);
444 mState = GST_STATE_NULL;
419 llgst_object_unref (GST_OBJECT (mPlaybin)); 445 llgst_object_unref (GST_OBJECT (mPlaybin));
420 mPlaybin = NULL; 446 mPlaybin = NULL;
421 } 447 }
@@ -439,11 +465,9 @@ unload ()
439 465
440/////////////////////////////////////////////////////////////////////////////// 466///////////////////////////////////////////////////////////////////////////////
441// virtual 467// virtual
442bool 468bool LLMediaImplGStreamer::updateMedia()
443LLMediaImplGStreamer::
444updateMedia ()
445{ 469{
446 DEBUGMSG("updating media..."); 470 //LL_DEBUGS("MediaImpl") << "updating media..." << LL_ENDL;
447 471
448 // sanity check 472 // sanity check
449 if (NULL == mPump 473 if (NULL == mPump
@@ -452,7 +476,7 @@ updateMedia ()
452#endif 476#endif
453 || NULL == mPlaybin) 477 || NULL == mPlaybin)
454 { 478 {
455 DEBUGMSG("dead media..."); 479 LL_DEBUGS("MediaImpl") << "dead media..." << LL_ENDL;
456 return false; 480 return false;
457 } 481 }
458 482
@@ -460,36 +484,33 @@ updateMedia ()
460 switch (nextCommand()) 484 switch (nextCommand())
461 { 485 {
462 case LLMediaBase::COMMAND_START: 486 case LLMediaBase::COMMAND_START:
463 DEBUGMSG("COMMAND_START"); 487 LL_DEBUGS("MediaImpl") << "COMMAND_START" << LL_ENDL;
464 if (getStatus() == LLMediaBase::STATUS_PAUSED || 488 if (getStatus() == LLMediaBase::STATUS_PAUSED ||
465 getStatus() == LLMediaBase::STATUS_NAVIGATING || 489 getStatus() == LLMediaBase::STATUS_NAVIGATING ||
466 getStatus() == LLMediaBase::STATUS_STOPPED) 490 getStatus() == LLMediaBase::STATUS_STOPPED)
467 { 491 {
468 DEBUGMSG("doing COMMAND_START");
469 play(); 492 play();
470 setStatus(LLMediaBase::STATUS_STARTED); 493 setStatus(LLMediaBase::STATUS_STARTED);
471 clearCommand(); 494 clearCommand();
472 } 495 }
473 break; 496 break;
474 case LLMediaBase::COMMAND_STOP: 497 case LLMediaBase::COMMAND_STOP:
475 DEBUGMSG("COMMAND_STOP"); 498 LL_DEBUGS("MediaImpl") << "COMMAND_STOP" << LL_ENDL;
476 DEBUGMSG("doing COMMAND_STOP");
477 stop(); 499 stop();
478 setStatus(LLMediaBase::STATUS_STOPPED); 500 setStatus(LLMediaBase::STATUS_STOPPED);
479 clearCommand(); 501 clearCommand();
480 break; 502 break;
481 case LLMediaBase::COMMAND_PAUSE: 503 case LLMediaBase::COMMAND_PAUSE:
482 DEBUGMSG("COMMAND_PAUSE"); 504 LL_DEBUGS("MediaImpl") << "COMMAND_PAUSE" << LL_ENDL;
483 if (getStatus() == LLMediaBase::STATUS_STARTED) 505 if (getStatus() == LLMediaBase::STATUS_STARTED)
484 { 506 {
485 DEBUGMSG("doing COMMAND_PAUSE");
486 pause(); 507 pause();
487 setStatus(LLMediaBase::STATUS_PAUSED); 508 setStatus(LLMediaBase::STATUS_PAUSED);
488 clearCommand(); 509 clearCommand();
489 } 510 }
490 break; 511 break;
491 default: 512 default:
492 DEBUGMSG("COMMAND_?"); 513 LL_INFOS("MediaImpl") << "Unknown command" << LL_ENDL;
493 clearCommand(); 514 clearCommand();
494 break; 515 break;
495 case LLMediaBase::COMMAND_NONE: 516 case LLMediaBase::COMMAND_NONE:
@@ -507,7 +528,7 @@ updateMedia ()
507 GST_OBJECT_LOCK(mVideoSink); 528 GST_OBJECT_LOCK(mVideoSink);
508 if (mVideoSink->retained_frame_ready) 529 if (mVideoSink->retained_frame_ready)
509 { 530 {
510 DEBUGMSG("NEW FRAME "); 531 LL_DEBUGS("MediaImpl") <<"NEW FRAME " << LL_ENDL;
511 if (mVideoSink->retained_frame_width != getMediaWidth() || 532 if (mVideoSink->retained_frame_width != getMediaWidth() ||
512 mVideoSink->retained_frame_height != getMediaHeight()) 533 mVideoSink->retained_frame_height != getMediaHeight())
513 // *TODO: also check for change in format 534 // *TODO: also check for change in format
@@ -527,8 +548,9 @@ updateMedia ()
527 mTextureFormatType = LL_MEDIA_UNSIGNED_INT_8_8_8_8_REV; 548 mTextureFormatType = LL_MEDIA_UNSIGNED_INT_8_8_8_8_REV;
528 } 549 }
529 mMediaRowbytes = neww * newd; 550 mMediaRowbytes = neww * newd;
530 DEBUGMSG("video container resized to %dx%d", 551 LL_DEBUGS("MediaImpl")
531 neww, newh); 552 << "video container resized to " <<
553 neww <<"x"<< newh << LL_ENDL;
532 554
533 delete[] mediaData; 555 delete[] mediaData;
534 mediaData = new unsigned char[mMediaRowbytes * 556 mediaData = new unsigned char[mMediaRowbytes *
@@ -564,46 +586,41 @@ updateMedia ()
564 586
565/////////////////////////////////////////////////////////////////////////////// 587///////////////////////////////////////////////////////////////////////////////
566// 588//
567bool 589bool LLMediaImplGStreamer::stop()
568LLMediaImplGStreamer::
569stop ()
570{ 590{
571 DEBUGMSG("stopping media..."); 591 LL_DEBUGS("MediaImpl") << "stopping media..." << LL_ENDL;
572 // todo: error-check this? 592 // todo: error-check this?
573 llgst_element_set_state(mPlaybin, GST_STATE_READY); 593 llgst_element_set_state(mPlaybin, GST_STATE_READY);
594 mState = GST_STATE_READY;
574 return true; 595 return true;
575} 596}
576 597
577/////////////////////////////////////////////////////////////////////////////// 598///////////////////////////////////////////////////////////////////////////////
578// 599//
579bool 600bool LLMediaImplGStreamer::play()
580LLMediaImplGStreamer::
581play ()
582{ 601{
583 DEBUGMSG("playing media..."); 602 LL_DEBUGS("MediaImpl") << "playing media..." << LL_ENDL;
584 // todo: error-check this? 603 // todo: error-check this?
585 llgst_element_set_state(mPlaybin, GST_STATE_PLAYING); 604 llgst_element_set_state(mPlaybin, GST_STATE_PLAYING);
605 mState = GST_STATE_PLAYING;
586 return true; 606 return true;
587} 607}
588 608
589/////////////////////////////////////////////////////////////////////////////// 609///////////////////////////////////////////////////////////////////////////////
590// 610//
591bool 611bool LLMediaImplGStreamer::pause()
592LLMediaImplGStreamer::
593pause ()
594{ 612{
595 DEBUGMSG("pausing media..."); 613 LL_DEBUGS("MediaImpl") <<"pausing media..." << LL_ENDL;
596 // todo: error-check this? 614 // todo: error-check this?
597 llgst_element_set_state(mPlaybin, GST_STATE_PAUSED); 615 llgst_element_set_state(mPlaybin, GST_STATE_PAUSED);
616 mState = GST_STATE_PAUSED;
598 return true; 617 return true;
599}; 618};
600 619
601 620
602/////////////////////////////////////////////////////////////////////////////// 621///////////////////////////////////////////////////////////////////////////////
603// virtual 622// virtual
604unsigned char* 623unsigned char* LLMediaImplGStreamer::getMediaData()
605LLMediaImplGStreamer::
606getMediaData ()
607{ 624{
608 return mediaData; 625 return mediaData;
609} 626}
@@ -611,9 +628,7 @@ getMediaData ()
611 628
612/////////////////////////////////////////////////////////////////////////////// 629///////////////////////////////////////////////////////////////////////////////
613// virtual 630// virtual
614bool 631bool LLMediaImplGStreamer::seek(double time)
615LLMediaImplGStreamer::
616seek( double time )
617{ 632{
618 bool success = false; 633 bool success = false;
619 if (mPlaybin) 634 if (mPlaybin)
@@ -624,18 +639,22 @@ seek( double time )
624 GST_SEEK_TYPE_SET, gint64(time*1000000000.0F), 639 GST_SEEK_TYPE_SET, gint64(time*1000000000.0F),
625 GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE); 640 GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE);
626 } 641 }
627 DEBUGMSG("MEDIA SEEK REQUEST to %fsec result was %d", 642 LL_DEBUGS("MediaImpl") << "MEDIA SEEK REQUEST to " << float(time)
628 float(time), int(success)); 643 << "sec result was " << int(success) << LL_ENDL;
629 return success; 644 return success;
630} 645}
631 646
632 647
633/////////////////////////////////////////////////////////////////////////////// 648///////////////////////////////////////////////////////////////////////////////
634// virtual 649// virtual
635bool 650bool LLMediaImplGStreamer::setVolume(float volume)
636LLMediaImplGStreamer::
637setVolume(float volume)
638{ 651{
652 // XXX hack to make volume volume changes less othen
653 // bug in gstreamer 0.10.21
654 if(mVolume == volume)
655 return true;
656
657 LL_DEBUGS("MediaImpl") << "setVolume(" << volume << ") : " << getpid() << LL_ENDL;
639 mVolume = volume; 658 mVolume = volume;
640 if (mPlaybin) 659 if (mPlaybin)
641 { 660 {
@@ -645,4 +664,6 @@ setVolume(float volume)
645 return false; 664 return false;
646} 665}
647 666
648#endif // LL_GSTREAMER_ENABLED 667
668
669///#endif // LL_GSTREAMER_ENABLED
diff --git a/linden/indra/llmedia/llmediaimplgstreamer.h b/linden/indra/llmedia/llmediaimplgstreamer.h
index 247b0ce..4b9353b 100644
--- a/linden/indra/llmedia/llmediaimplgstreamer.h
+++ b/linden/indra/llmedia/llmediaimplgstreamer.h
@@ -31,20 +31,19 @@
31 */ 31 */
32 32
33// header guard 33// header guard
34#ifndef llmediaimplgstreamer_h 34///#ifndef llmediaimplgstreamer_h
35#define llmediaimplgstreamer_h 35#define llmediaimplgstreamer_h
36 36
37#include "llmediaimplcommon.h" 37#include "llmediaimplcommon.h"
38#include "llmediaimplfactory.h" 38#include "llmediaimplfactory.h"
39 39
40#if LL_GSTREAMER_ENABLED 40///#if LL_GSTREAMER_ENABLED
41 41
42extern "C" { 42extern "C" {
43#include <stdio.h> 43#include <stdio.h>
44#include <gst/gst.h> 44#include <gst/gst.h>
45 45#include <apr_pools.h>
46#include "apr_pools.h" 46#include <apr_dso.h>
47#include "apr_dso.h"
48} 47}
49 48
50#include "llmediaimplgstreamervidplug.h" 49#include "llmediaimplgstreamervidplug.h"
@@ -100,9 +99,11 @@ class LLMediaImplGStreamer:
100 GMainLoop *mPump; // event pump for this media 99 GMainLoop *mPump; // event pump for this media
101 GstElement *mPlaybin; 100 GstElement *mPlaybin;
102 GstSLVideo *mVideoSink; 101 GstSLVideo *mVideoSink;
102 GstState mState;
103#ifdef LL_GST_SOUNDSINK 103#ifdef LL_GST_SOUNDSINK
104 GstSLSound *mAudioSink; 104 GstSLSound *mAudioSink;
105#endif // LL_GST_SOUNDSINK 105#endif // LL_GST_SOUNDSINK
106 GstState getState() const { return mState; }
106}; 107};
107 108
108class LLMediaImplGStreamerMaker : public LLMediaImplMaker 109class LLMediaImplGStreamerMaker : public LLMediaImplMaker
@@ -129,6 +130,6 @@ public:
129#define WARNMSG STDERRMSG 130#define WARNMSG STDERRMSG
130///////////////////////////////////////////////////////////////////////// 131/////////////////////////////////////////////////////////////////////////
131 132
132#endif // LL_GSTREAMER_ENABLED 133///#endif // LL_GSTREAMER_ENABLED
133 134
134#endif // llmediaimplgstreamer_h 135///#endif // llmediaimplgstreamer_h
diff --git a/linden/indra/llmedia/llmediaimplgstreamer_syms.cpp b/linden/indra/llmedia/llmediaimplgstreamer_syms.cpp
index e81d886..fb1949a 100644
--- a/linden/indra/llmedia/llmediaimplgstreamer_syms.cpp
+++ b/linden/indra/llmedia/llmediaimplgstreamer_syms.cpp
@@ -29,7 +29,7 @@
29 * $/LicenseInfo$ 29 * $/LicenseInfo$
30 */ 30 */
31 31
32#if LL_GSTREAMER_ENABLED 32///#if LL_GSTREAMER_ENABLED
33 33
34extern "C" { 34extern "C" {
35#include <gst/gst.h> 35#include <gst/gst.h>
@@ -185,4 +185,4 @@ void ungrab_gst_syms()
185} 185}
186 186
187 187
188#endif // LL_GSTREAMER_ENABLED 188///#endif // LL_GSTREAMER_ENABLED
diff --git a/linden/indra/llmedia/llmediaimplgstreamer_syms.h b/linden/indra/llmedia/llmediaimplgstreamer_syms.h
index 92d46b7..ebebd80 100644
--- a/linden/indra/llmedia/llmediaimplgstreamer_syms.h
+++ b/linden/indra/llmedia/llmediaimplgstreamer_syms.h
@@ -31,7 +31,7 @@
31 31
32#include "linden_common.h" 32#include "linden_common.h"
33 33
34#if LL_GSTREAMER_ENABLED 34///#if LL_GSTREAMER_ENABLED
35 35
36extern "C" { 36extern "C" {
37#include <gst/gst.h> 37#include <gst/gst.h>
@@ -75,4 +75,4 @@ void ungrab_gst_syms();
75// more hacks 75// more hacks
76#define LLGST_MESSAGE_TYPE_NAME(M) (llgst_message_type_get_name(GST_MESSAGE_TYPE(M))) 76#define LLGST_MESSAGE_TYPE_NAME(M) (llgst_message_type_get_name(GST_MESSAGE_TYPE(M)))
77 77
78#endif // LL_GSTREAMER_ENABLED 78///#endif // LL_GSTREAMER_ENABLED
diff --git a/linden/indra/llmedia/llmediaimplgstreamervidplug.cpp b/linden/indra/llmedia/llmediaimplgstreamervidplug.cpp
index f9c2f89..892c50d 100644
--- a/linden/indra/llmedia/llmediaimplgstreamervidplug.cpp
+++ b/linden/indra/llmedia/llmediaimplgstreamervidplug.cpp
@@ -29,7 +29,7 @@
29 * $/LicenseInfo$ 29 * $/LicenseInfo$
30 */ 30 */
31 31
32#if LL_GSTREAMER_ENABLED 32///#if LL_GSTREAMER_ENABLED
33 33
34#include "linden_common.h" 34#include "linden_common.h"
35 35
@@ -68,8 +68,10 @@ static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE (
68 GST_STATIC_CAPS (SLV_ALLCAPS) 68 GST_STATIC_CAPS (SLV_ALLCAPS)
69 ); 69 );
70 70
71GST_BOILERPLATE (GstSLVideo, gst_slvideo, GstVideoSink, 71GST_BOILERPLATE (GstSLVideo,
72 GST_TYPE_VIDEO_SINK); 72 gst_slvideo,
73 GstVideoSink,
74 GST_TYPE_VIDEO_SINK);
73 75
74static void gst_slvideo_set_property (GObject * object, guint prop_id, 76static void gst_slvideo_set_property (GObject * object, guint prop_id,
75 const GValue * value, 77 const GValue * value,
@@ -229,7 +231,8 @@ gst_slvideo_set_caps (GstBaseSink * bsink, GstCaps * caps)
229 } 231 }
230 llgst_caps_unref(intersection); 232 llgst_caps_unref(intersection);
231 233
232 int width, height; 234 int width = 0;
235 int height = 0;
233 gboolean ret; 236 gboolean ret;
234 const GValue *fps; 237 const GValue *fps;
235 const GValue *par; 238 const GValue *par;
@@ -402,10 +405,8 @@ gst_slvideo_set_property (GObject * object, guint prop_id,
402{ 405{
403 llg_return_if_fail (GST_IS_SLVIDEO (object)); 406 llg_return_if_fail (GST_IS_SLVIDEO (object));
404 407
405 switch (prop_id) { 408 if (prop_id) {
406 default:
407 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); 409 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
408 break;
409 } 410 }
410} 411}
411 412
@@ -415,10 +416,8 @@ gst_slvideo_get_property (GObject * object, guint prop_id,
415{ 416{
416 llg_return_if_fail (GST_IS_SLVIDEO (object)); 417 llg_return_if_fail (GST_IS_SLVIDEO (object));
417 418
418 switch (prop_id) { 419 if (prop_id) {
419 default:
420 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); 420 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
421 break;
422 } 421 }
423} 422}
424 423
@@ -446,10 +445,8 @@ plugin_init (GstPlugin * plugin)
446 some g++ versions buggily avoid __attribute__((constructor)) functions - 445 some g++ versions buggily avoid __attribute__((constructor)) functions -
447 so we provide an explicit plugin init function. 446 so we provide an explicit plugin init function.
448 */ 447 */
449void gst_slvideo_init_class (void)
450{
451#define PACKAGE "packagehack" 448#define PACKAGE "packagehack"
452 static GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, 449 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
453 GST_VERSION_MINOR, 450 GST_VERSION_MINOR,
454 "private-slvideoplugin", 451 "private-slvideoplugin",
455 "SL Video sink plugin", 452 "SL Video sink plugin",
@@ -457,8 +454,11 @@ void gst_slvideo_init_class (void)
457 "Second Life", 454 "Second Life",
458 "http://www.secondlife.com/"); 455 "http://www.secondlife.com/");
459#undef PACKAGE 456#undef PACKAGE
457
458void gst_slvideo_init_class (void)
459{
460 ll_gst_plugin_register_static (&gst_plugin_desc); 460 ll_gst_plugin_register_static (&gst_plugin_desc);
461 //fprintf(stderr, "\n\n\nCLASS INIT\n\n\n"); 461 //fprintf(stderr, "\n\n\nCLASS INIT\n\n\n");
462} 462}
463 463
464#endif // LL_GSTREAMER_ENABLED 464///#endif // LL_GSTREAMER_ENABLED
diff --git a/linden/indra/llmedia/llmediaimplgstreamervidplug.h b/linden/indra/llmedia/llmediaimplgstreamervidplug.h
index 27957db..026a52d 100644
--- a/linden/indra/llmedia/llmediaimplgstreamervidplug.h
+++ b/linden/indra/llmedia/llmediaimplgstreamervidplug.h
@@ -32,12 +32,13 @@
32#ifndef __GST_SLVIDEO_H__ 32#ifndef __GST_SLVIDEO_H__
33#define __GST_SLVIDEO_H__ 33#define __GST_SLVIDEO_H__
34 34
35#if LL_GSTREAMER_ENABLED 35///#if LL_GSTREAMER_ENABLED
36 36
37extern "C" { 37extern "C" {
38#include <gst/gst.h> 38#include <gst/gst.h>
39#include <gst/video/video.h> 39#include <gst/video/video.h>
40#include <gst/video/gstvideosink.h> 40#include <gst/video/gstvideosink.h>
41#include <gthread.h>
41} 42}
42 43
43G_BEGIN_DECLS 44G_BEGIN_DECLS
@@ -99,6 +100,6 @@ void gst_slvideo_init_class (void);
99 100
100G_END_DECLS 101G_END_DECLS
101 102
102#endif // LL_GSTREAMER_ENABLED 103///#endif // LL_GSTREAMER_ENABLED
103 104
104#endif /* __GST_SLVIDEO_H__ */ 105#endif /* __GST_SLVIDEO_H__ */
diff --git a/linden/indra/llmedia/llmediamanager.cpp b/linden/indra/llmedia/llmediamanager.cpp
index 16c731f..5394b62 100644
--- a/linden/indra/llmedia/llmediamanager.cpp
+++ b/linden/indra/llmedia/llmediamanager.cpp
@@ -40,6 +40,7 @@
40# include "llmediaimplllmozlib.h" 40# include "llmediaimplllmozlib.h"
41#endif 41#endif
42 42
43#include "llerror.h"
43LLMediaManager* LLMediaManager::sInstance = 0; 44LLMediaManager* LLMediaManager::sInstance = 0;
44 45
45 46
@@ -75,6 +76,7 @@ void LLMediaManager::initClass( LLMediaManagerData* init_data )
75 if ( ! sInstance ) 76 if ( ! sInstance )
76 sInstance = new LLMediaManager(); 77 sInstance = new LLMediaManager();
77 78
79 LL_DEBUGS("MediaManager") << "LLMediaManager::initClass" << LL_ENDL;
78 // Initialize impl classes here - this breaks the encapsulation model 80 // Initialize impl classes here - this breaks the encapsulation model
79 // but some of the initialization takes a long time and we only want to 81 // but some of the initialization takes a long time and we only want to
80 // do it once at app startup before any of the impls have been created 82 // do it once at app startup before any of the impls have been created
@@ -84,12 +86,14 @@ void LLMediaManager::initClass( LLMediaManagerData* init_data )
84 LLMediaImplExample2::startup( init_data ); 86 LLMediaImplExample2::startup( init_data );
85 87
86#if LL_QUICKTIME_ENABLED 88#if LL_QUICKTIME_ENABLED
89 LL_DEBUGS("MediaManager") << "LLMediaManager::initClass: starting quicktime." << LL_ENDL;
87 LLMediaImplQuickTime::startup( init_data ); 90 LLMediaImplQuickTime::startup( init_data );
88#endif // LL_QUICKTIME_ENABLED 91#endif // LL_QUICKTIME_ENABLED
89 92
90#if LL_GSTREAMER_ENABLED 93///#if LL_GSTREAMER_ENABLED
94 LL_DEBUGS("MediaManager") << "LLMediaManager::initClass: starting gstreamer" << LL_ENDL;
91 LLMediaImplGStreamer::startup( init_data ); 95 LLMediaImplGStreamer::startup( init_data );
92#endif // LL_GSTREAMER_ENABLED 96///#endif // LL_GSTREAMER_ENABLED
93} 97}
94 98
95//////////////////////////////////////////////////////////////////////////////// 99////////////////////////////////////////////////////////////////////////////////
@@ -129,9 +133,9 @@ void LLMediaManager::cleanupClass()
129 LLMediaImplQuickTime::closedown(); 133 LLMediaImplQuickTime::closedown();
130#endif // LL_QUICKTIME_ENABLED 134#endif // LL_QUICKTIME_ENABLED
131 135
132#if LL_GSTREAMER_ENABLED 136///#if LL_GSTREAMER_ENABLED
133 LLMediaImplGStreamer::closedown(); 137 LLMediaImplGStreamer::closedown();
134#endif // LL_QUICKTIME_ENABLED 138///#endif // LL_QUICKTIME_ENABLED
135 139
136 if ( sInstance ) 140 if ( sInstance )
137 delete sInstance; 141 delete sInstance;