aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmedia
diff options
context:
space:
mode:
authorJacek Antonelli2009-04-06 01:51:38 -0500
committerJacek Antonelli2009-04-06 01:52:15 -0500
commitbcf93cd3a302fd4cc1f8cf82c47a5b863dc2d937 (patch)
tree7b2154384c2d1339c6c030e237e3ea6ba7e19e94 /linden/indra/llmedia
parentChanged the login splash screen URL. (diff)
parentMerge branch gst-thread into gst-revamp (diff)
downloadmeta-impy-bcf93cd3a302fd4cc1f8cf82c47a5b863dc2d937.zip
meta-impy-bcf93cd3a302fd4cc1f8cf82c47a5b863dc2d937.tar.gz
meta-impy-bcf93cd3a302fd4cc1f8cf82c47a5b863dc2d937.tar.bz2
meta-impy-bcf93cd3a302fd4cc1f8cf82c47a5b863dc2d937.tar.xz
Merge branch 'gst-revamp' into next
Diffstat (limited to '')
-rw-r--r--linden/indra/llmedia/CMakeLists.txt4
-rw-r--r--linden/indra/llmedia/llgstplaythread.cpp54
-rw-r--r--linden/indra/llmedia/llgstplaythread.h62
-rw-r--r--linden/indra/llmedia/llmediabase.h15
-rw-r--r--linden/indra/llmedia/llmediaimplcommon.cpp12
-rw-r--r--linden/indra/llmedia/llmediaimplcommon.h2
-rw-r--r--linden/indra/llmedia/llmediaimplgstreamer.cpp335
-rw-r--r--linden/indra/llmedia/llmediaimplgstreamer.h27
-rw-r--r--linden/indra/llmedia/llmediaimplgstreamer_syms.cpp188
-rw-r--r--linden/indra/llmedia/llmediaimplgstreamer_syms.h78
-rw-r--r--linden/indra/llmedia/llmediaimplgstreamer_syms_raw.inc50
-rw-r--r--linden/indra/llmedia/llmediaimplgstreamer_syms_rawa.inc5
-rw-r--r--linden/indra/llmedia/llmediaimplgstreamer_syms_rawv.inc5
-rw-r--r--linden/indra/llmedia/llmediaimplgstreamervidplug.cpp83
-rw-r--r--linden/indra/llmedia/llmediamanager.cpp14
15 files changed, 467 insertions, 467 deletions
diff --git a/linden/indra/llmedia/CMakeLists.txt b/linden/indra/llmedia/CMakeLists.txt
index 026afc1..0e5b261 100644
--- a/linden/indra/llmedia/CMakeLists.txt
+++ b/linden/indra/llmedia/CMakeLists.txt
@@ -30,8 +30,8 @@ set(llmedia_SOURCE_FILES
30 llmediaimplfactory.cpp 30 llmediaimplfactory.cpp
31 llmediamanager.cpp 31 llmediamanager.cpp
32 llmediaimplgstreamer.cpp 32 llmediaimplgstreamer.cpp
33 llmediaimplgstreamer_syms.cpp
34 llmediaimplgstreamervidplug.cpp 33 llmediaimplgstreamervidplug.cpp
34 llgstplaythread.cpp
35 ) 35 )
36 36
37set(llmedia_HEADER_FILES 37set(llmedia_HEADER_FILES
@@ -48,7 +48,7 @@ set(llmedia_HEADER_FILES
48 llmediaobserver.h 48 llmediaobserver.h
49 llmediaimplgstreamer.h 49 llmediaimplgstreamer.h
50 llmediaimplgstreamervidplug.h 50 llmediaimplgstreamervidplug.h
51 llmediaimplgstreamer_syms.h 51 llgstplaythread.h
52 ) 52 )
53 53
54 # Work around a bad interaction between broken gstreamer headers and 54 # Work around a bad interaction between broken gstreamer headers and
diff --git a/linden/indra/llmedia/llgstplaythread.cpp b/linden/indra/llmedia/llgstplaythread.cpp
new file mode 100644
index 0000000..152f9d9
--- /dev/null
+++ b/linden/indra/llmedia/llgstplaythread.cpp
@@ -0,0 +1,54 @@
1/**
2 * @file llgstplaythread.cpp
3 * @author Jacek Antonelli
4 * @brief GStreamer playback management thread class
5 *
6 * $LicenseInfo:firstyear=2009&license=viewergpl$
7 *
8 * Copyright (c) 2009, Jacek Antonelli
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of version 2 of the GNU General Public
12 * License as published by the Free Software Foundation. Terms of
13 * the GPL can be found in doc/GPL-license.txt in this distribution, or
14 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
15 *
16 * There are special exceptions to the terms and conditions of the GPL as
17 * it is applied to this Source Code. View the full text of the exception
18 * in the file doc/FLOSS-exception.txt in this software distribution, or
19 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License along
27 * with this program; if not, write to the Free Software Foundation, Inc.,
28 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 *
30 * $/LicenseInfo$
31 */
32
33#include "llgstplaythread.h"
34#include "llmediaimplgstreamer.h"
35
36LLGstPlayThread::
37LLGstPlayThread( LLMediaImplCommon *impl,
38 const std::string& name, apr_pool_t *poolp ):
39 LLThread( name, poolp ),
40 mMediaImpl( impl )
41{
42}
43
44
45LLGstPlayThread::~LLGstPlayThread()
46{
47}
48
49
50// virtual
51void LLGstPlayThread::run()
52{
53 ((LLMediaImplGStreamer *)mMediaImpl)->startPlay();
54}
diff --git a/linden/indra/llmedia/llgstplaythread.h b/linden/indra/llmedia/llgstplaythread.h
new file mode 100644
index 0000000..c3c36a7
--- /dev/null
+++ b/linden/indra/llmedia/llgstplaythread.h
@@ -0,0 +1,62 @@
1/**
2 * @file llgstplaythread.h
3 * @author Jacek Antonelli
4 * @brief GStreamer playback management thread class
5 *
6 * $LicenseInfo:firstyear=2009&license=viewergpl$
7 *
8 * Copyright (c) 2009, Jacek Antonelli
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of version 2 of the GNU General Public
12 * License as published by the Free Software Foundation. Terms of
13 * the GPL can be found in doc/GPL-license.txt in this distribution, or
14 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
15 *
16 * There are special exceptions to the terms and conditions of the GPL as
17 * it is applied to this Source Code. View the full text of the exception
18 * in the file doc/FLOSS-exception.txt in this software distribution, or
19 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License along
27 * with this program; if not, write to the Free Software Foundation, Inc.,
28 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 *
30 * $/LicenseInfo$
31 */
32
33
34#ifndef LL_LLGSTPLAYTHREAD_H
35#define LL_LLGSTPLAYTHREAD_H
36
37#include "linden_common.h"
38
39#include "llthread.h"
40#include "llmediaimplcommon.h"
41
42class LLGstPlayThread: public LLThread
43{
44 public:
45
46 LLGstPlayThread( LLMediaImplCommon *impl,
47 const std::string& name, apr_pool_t *poolp );
48
49 ~LLGstPlayThread();
50
51 virtual void run();
52
53 private:
54
55 // Actually, this will really only be an LLMediaImplGStreamer.
56 // But we have to jump through some hoops to mutual pointer-holding.
57 // There may be a better way, but I don't have the motivation to find it.
58 LLMediaImplCommon *mMediaImpl;
59};
60
61
62#endif // LL_LLGSTPLAYTHREAD_H
diff --git a/linden/indra/llmedia/llmediabase.h b/linden/indra/llmedia/llmediabase.h
index b5b9420..bf54a22 100644
--- a/linden/indra/llmedia/llmediabase.h
+++ b/linden/indra/llmedia/llmediabase.h
@@ -61,6 +61,21 @@ class LLMediaBase
61 // undoes everything init() didm called by the media manager when destroying a source 61 // undoes everything init() didm called by the media manager when destroying a source
62 virtual bool reset() = 0; 62 virtual bool reset() = 0;
63 63
64
65 /* Mirrors GStreamer debug levels. */
66 enum EDebugLevel {
67 DEBUG_LEVEL_NONE = 0,
68 DEBUG_LEVEL_ERROR,
69 DEBUG_LEVEL_WARNING,
70 DEBUG_LEVEL_INFO,
71 DEBUG_LEVEL_DEBUG,
72 DEBUG_LEVEL_LOG,
73 DEBUG_LEVEL_COUNT,
74 };
75
76 /* Set the debug verbosity level. Only implemented for GStreamer. */
77 virtual bool setDebugLevel( EDebugLevel level ) = 0;
78
64 // accessor for MIME type 79 // accessor for MIME type
65 virtual bool setMimeType( const std::string mime_type ) = 0; 80 virtual bool setMimeType( const std::string mime_type ) = 0;
66 virtual std::string getMimeType() const = 0; 81 virtual std::string getMimeType() const = 0;
diff --git a/linden/indra/llmedia/llmediaimplcommon.cpp b/linden/indra/llmedia/llmediaimplcommon.cpp
index abb61e1..48b3973 100644
--- a/linden/indra/llmedia/llmediaimplcommon.cpp
+++ b/linden/indra/llmedia/llmediaimplcommon.cpp
@@ -66,7 +66,8 @@ LLMediaImplCommon::LLMediaImplCommon() :
66 mCommand( LLMediaBase::COMMAND_NONE ), 66 mCommand( LLMediaBase::COMMAND_NONE ),
67 mStatus( LLMediaBase::STATUS_UNKNOWN ), 67 mStatus( LLMediaBase::STATUS_UNKNOWN ),
68 mVolume( 0 ), 68 mVolume( 0 ),
69 mLooping( false ) 69 mLooping( false ),
70 mDebugLevel( LLMediaBase::DEBUG_LEVEL_NONE )
70{ 71{
71} 72}
72 73
@@ -92,6 +93,15 @@ bool LLMediaImplCommon::reset()
92 93
93//////////////////////////////////////////////////////////////////////////////// 94////////////////////////////////////////////////////////////////////////////////
94// virtual (derives from LLMediaBase) 95// virtual (derives from LLMediaBase)
96bool LLMediaImplCommon::setDebugLevel( LLMediaBase::EDebugLevel level )
97{
98 mDebugLevel = level;
99
100 return true;
101}
102
103////////////////////////////////////////////////////////////////////////////////
104// virtual (derives from LLMediaBase)
95bool LLMediaImplCommon::setMimeType( const std::string mime_type ) 105bool LLMediaImplCommon::setMimeType( const std::string mime_type )
96{ 106{
97 mMimeType = mime_type; 107 mMimeType = mime_type;
diff --git a/linden/indra/llmedia/llmediaimplcommon.h b/linden/indra/llmedia/llmediaimplcommon.h
index aa6c4d5..8a726f1 100644
--- a/linden/indra/llmedia/llmediaimplcommon.h
+++ b/linden/indra/llmedia/llmediaimplcommon.h
@@ -54,6 +54,7 @@ class LLMediaImplCommon :
54 // housekeeping 54 // housekeeping
55 virtual bool init(); 55 virtual bool init();
56 virtual bool reset(); 56 virtual bool reset();
57 virtual bool setDebugLevel( LLMediaBase::EDebugLevel level );
57 virtual bool setMimeType( const std::string url ); 58 virtual bool setMimeType( const std::string url );
58 virtual std::string getMimeType() const; 59 virtual std::string getMimeType() const;
59 virtual std::string getMediaURL() const; 60 virtual std::string getMediaURL() const;
@@ -156,6 +157,7 @@ class LLMediaImplCommon :
156 LLMediaBase::ECommand mCommand; 157 LLMediaBase::ECommand mCommand;
157 LLMediaBase::EStatus mStatus; 158 LLMediaBase::EStatus mStatus;
158 bool mLooping; 159 bool mLooping;
160 LLMediaBase::EDebugLevel mDebugLevel;
159}; 161};
160 162
161#endif // LLMEDIAIMPLCOMMON_H 163#endif // LLMEDIAIMPLCOMMON_H
diff --git a/linden/indra/llmedia/llmediaimplgstreamer.cpp b/linden/indra/llmedia/llmediaimplgstreamer.cpp
index 30706f1..7ae6b02 100644
--- a/linden/indra/llmedia/llmediaimplgstreamer.cpp
+++ b/linden/indra/llmedia/llmediaimplgstreamer.cpp
@@ -30,23 +30,35 @@
30 * $/LicenseInfo$ 30 * $/LicenseInfo$
31 */ 31 */
32 32
33#include "llmediaimplgstreamer.h"
34
35///#if LL_GSTREAMER_ENABLED 33///#if LL_GSTREAMER_ENABLED
36 34
35#if LL_WINDOWS
36 // GStreamer 0.10.22 - gstutils.h - conversion from 'guint64' to 'guint8'.
37 // This was an intentional change to make GStreamer more threadsafe, and
38 // is okay. Delete this bit if GStreamer ever gets more VS-friendly -- McCabe
39 #pragma warning(disable : 4244)
40#endif
41
42#include "linden_common.h"
43#include "llmediaimplgstreamer.h"
44
37extern "C" { 45extern "C" {
38#include <gst/gst.h> 46#include <gst/gst.h>
39#include <gst/gstelement.h> 47#include <gst/gstelement.h>
40} 48}
41 49
50#if LL_WINDOWS
51 #pragma warning(default : 4244)
52#include <direct.h>
53#include <stdlib.h>
54#endif
55
42#include "llmediamanager.h" 56#include "llmediamanager.h"
43#include "llmediaimplregister.h" 57#include "llmediaimplregister.h"
44 58
45#include "llmediaimplgstreamervidplug.h" 59#include "llmediaimplgstreamervidplug.h"
60#include "llgstplaythread.h"
46 61
47#include "llmediaimplgstreamer_syms.h"
48
49#include "llerror.h"
50 62
51// register this impl with media manager factory 63// register this impl with media manager factory
52static LLMediaImplRegister sLLMediaImplGStreamerReg( "LLMediaImplGStreamer", new LLMediaImplGStreamerMaker() ); 64static LLMediaImplRegister sLLMediaImplGStreamerReg( "LLMediaImplGStreamer", new LLMediaImplGStreamerMaker() );
@@ -73,7 +85,8 @@ LLMediaImplGStreamer () :
73 mPump ( NULL ), 85 mPump ( NULL ),
74 mPlaybin ( NULL ), 86 mPlaybin ( NULL ),
75 mVideoSink ( NULL ), 87 mVideoSink ( NULL ),
76 mState( GST_STATE_NULL ) 88 mState( GST_STATE_NULL ),
89 mPlayThread ( NULL )
77{ 90{
78 startup( NULL ); // Startup gstreamer if it hasn't been already. 91 startup( NULL ); // Startup gstreamer if it hasn't been already.
79 92
@@ -90,7 +103,7 @@ LLMediaImplGStreamer () :
90 } 103 }
91 104
92 // instantiate a playbin element to do the hard work 105 // instantiate a playbin element to do the hard work
93 mPlaybin = llgst_element_factory_make ("playbin", "play"); 106 mPlaybin = gst_element_factory_make ("playbin", "play");
94 if (!mPlaybin) 107 if (!mPlaybin)
95 { 108 {
96 // todo: cleanup pump 109 // todo: cleanup pump
@@ -104,7 +117,7 @@ LLMediaImplGStreamer () :
104 117
105 // Plays inworld instead of in external player 118 // Plays inworld instead of in external player
106 mVideoSink = 119 mVideoSink =
107 GST_SLVIDEO(llgst_element_factory_make ("private-slvideo", "slvideo")); 120 GST_SLVIDEO(gst_element_factory_make ("private-slvideo", "slvideo"));
108 if (!mVideoSink) 121 if (!mVideoSink)
109 { 122 {
110 LL_WARNS("MediaImpl") << "Could not instantiate private-slvideo element." << LL_ENDL; 123 LL_WARNS("MediaImpl") << "Could not instantiate private-slvideo element." << LL_ENDL;
@@ -148,7 +161,7 @@ LLMediaImplGStreamer::
148std::string LLMediaImplGStreamer::getVersion() 161std::string LLMediaImplGStreamer::getVersion()
149{ 162{
150 guint major, minor, micro, nano; 163 guint major, minor, micro, nano;
151 llgst_version(&major, &minor, &micro, &nano); 164 gst_version(&major, &minor, &micro, &nano);
152 std::string version = llformat("%d.%d.%d.%d",major,minor,micro,nano); 165 std::string version = llformat("%d.%d.%d.%d",major,minor,micro,nano);
153 return version; 166 return version;
154} 167}
@@ -165,50 +178,163 @@ bool LLMediaImplGStreamer::startup (LLMediaManagerData* init_data)
165 // Init the glib type system - we need it. 178 // Init the glib type system - we need it.
166 g_type_init(); 179 g_type_init();
167 180
168 // Get symbols! 181 set_gst_plugin_path();
169#if LL_WINDOWS
170 if (! grab_gst_syms("libgstreamer-0.10.dll", "libgstvideo-0.10.dll", "libgstaudio-0.10.dll") )
171 {
172 LL_WARNS("MediaImpl") << "Couldn't find suitable GStreamer 0.10 support on this system - video playback disabled." << LL_ENDL;
173 return false;
174 }
175#else
176 if (! grab_gst_syms("libgstreamer-0.10.so.0", "libgstvideo-0.10.so.0", "libgstaudio-0.10.so.0") )
177 {
178 LL_WARNS("MediaImpl") << "Couldn't find suitable GStreamer 0.10 support on this system - video playback disabled." << LL_ENDL;
179 return false;
180 }
181#endif
182 if (llgst_segtrap_set_enabled)
183 llgst_segtrap_set_enabled(FALSE);
184 else
185 {
186 LL_WARNS("MediaImpl") << "gst_segtrap_set_enabled() is not available; Automated crash-reporter may cease to function until next restart." << LL_ENDL;
187 }
188 182
189 // Protect against GStreamer resetting the locale, yuck. 183 // Protect against GStreamer resetting the locale, yuck.
190 static std::string saved_locale; 184 static std::string saved_locale;
191 saved_locale = setlocale(LC_ALL, NULL); 185 saved_locale = setlocale(LC_ALL, NULL);
192 if (0 == llgst_init_check(NULL, NULL, NULL)) 186 if (0 == gst_init_check(NULL, NULL, NULL))
193 { 187 {
194 LL_WARNS("MediaImpl") << "GStreamer library failed to initialize and load standard plugins." << LL_ENDL; 188 LL_WARNS("MediaImpl") << "GStreamer library failed to initialize and load standard plugins." << LL_ENDL;
195 setlocale(LC_ALL, saved_locale.c_str() ); 189 setlocale(LC_ALL, saved_locale.c_str() );
196 return false; 190 return false;
197 } 191 }
198 setlocale(LC_ALL, saved_locale.c_str() ); 192 setlocale(LC_ALL, saved_locale.c_str() );
199 193
194 // Set up logging facilities
195 gst_debug_remove_log_function( gst_debug_log_default );
196 gst_debug_add_log_function( gstreamer_log, NULL );
197
200 // Init our custom plugins - only really need do this once. 198 // Init our custom plugins - only really need do this once.
201 gst_slvideo_init_class(); 199 gst_slvideo_init_class();
202 200
201
202 // List the plugins GStreamer can find
203 LL_DEBUGS("MediaImpl") << "Found GStreamer plugins:" << LL_ENDL;
204 GList *list;
205 GstRegistry *registry = gst_registry_get_default();
206 std::string loaded = "";
207 for (list = gst_registry_get_plugin_list(registry);
208 list != NULL;
209 list = g_list_next(list))
210 {
211 GstPlugin *list_plugin = (GstPlugin *)list->data;
212 (bool)gst_plugin_is_loaded(list_plugin) ? loaded = "Yes" : loaded = "No";
213 LL_DEBUGS("MediaImpl") << gst_plugin_get_name(list_plugin) << ", loaded? " << loaded << LL_ENDL;
214 }
215 gst_plugin_list_free(list);
216
217
203 done_init = true; 218 done_init = true;
204 } 219 }
205 return true; 220 return true;
206} 221}
207 222
208 223
224void LLMediaImplGStreamer::set_gst_plugin_path()
225{
226 // Only needed for Windows.
227 // Linux sets in wrapper.sh, Mac sets in Info-Imprudence.plist
228#ifdef LL_WINDOWS
229
230 char* imp_cwd;
231
232 // Get the current working directory:
233 imp_cwd = _getcwd(NULL,0);
234
235 if(imp_cwd == NULL)
236 {
237 LL_DEBUGS("MediaImpl") << "_getcwd failed, not setting GST_PLUGIN_PATH."
238 << LL_ENDL;
239 }
240 else
241 {
242 LL_DEBUGS("MediaImpl") << "Imprudence is installed at "
243 << imp_cwd << LL_ENDL;
244
245 // Grab the current path, if it's set.
246 std::string old_plugin_path = "";
247 char *old_path = getenv("GST_PLUGIN_PATH");
248 if(old_path == NULL)
249 {
250 LL_DEBUGS("MediaImpl") << "Did not find user-set GST_PLUGIN_PATH."
251 << LL_ENDL;
252 }
253 else
254 {
255 old_plugin_path = ";" + std::string( old_path );
256 }
257
258
259 // Search both Imprudence and Imprudence\lib\gstreamer-plugins.
260 // If those fail, search the path the user has set, if any.
261 std::string plugin_path =
262 "GST_PLUGIN_PATH=" +
263 std::string(imp_cwd) + "\\lib\\gstreamer-plugins;" +
264 std::string(imp_cwd) +
265 old_plugin_path;
266
267 // Place GST_PLUGIN_PATH in the environment settings for imprudence.exe
268 // Returns 0 on success
269 if(_putenv( (char*)plugin_path.c_str() ))
270 {
271 LL_WARNS("MediaImpl") << "Setting environment variable failed!" << LL_ENDL;
272 }
273 else
274 {
275 LL_DEBUGS("MediaImpl") << "GST_PLUGIN_PATH set to "
276 << getenv("GST_PLUGIN_PATH") << LL_ENDL;
277 }
278 }
279
280#endif //LL_WINDOWS
281}
282
283
284void LLMediaImplGStreamer::gstreamer_log(GstDebugCategory *category,
285 GstDebugLevel level,
286 const gchar *file,
287 const gchar *function,
288 gint line,
289 GObject *object,
290 GstDebugMessage *message,
291 gpointer data)
292{
293 std::stringstream log(std::stringstream::out);
294
295 // Log format example:
296 //
297 // GST_ELEMENT_PADS: removing pad 'sink' (in gstelement.c:757:gst_element_remove_pad)
298 //
299 log << gst_debug_category_get_name( category ) << ": "
300 << gst_debug_message_get(message) << " "
301 << "(in " << file << ":" << line << ":" << function << ")";
302
303 switch( level )
304 {
305 case GST_LEVEL_ERROR:
306 LL_ERRS("MediaImpl") << log.str() << LL_ENDL;
307 break;
308 case GST_LEVEL_WARNING:
309 LL_WARNS("MediaImpl") << log.str() << LL_ENDL;
310 break;
311 case GST_LEVEL_DEBUG:
312 LL_DEBUGS("MediaImpl") << log.str() << LL_ENDL;
313 break;
314 case GST_LEVEL_INFO:
315 LL_INFOS("MediaImpl") << log.str() << LL_ENDL;
316 break;
317 default:
318 // Do nothing.
319 break;
320 }
321}
322
323
209bool LLMediaImplGStreamer::closedown() 324bool LLMediaImplGStreamer::closedown()
210{ 325{
211 ungrab_gst_syms(); 326 return true;
327}
328
329
330bool LLMediaImplGStreamer::setDebugLevel( LLMediaBase::EDebugLevel level )
331{
332 // Do parent class stuff.
333 LLMediaImplCommon::setDebugLevel(level);
334
335 // Set GStreamer verbosity.
336 gst_debug_set_default_threshold( (GstDebugLevel)level );
337
212 return true; 338 return true;
213} 339}
214 340
@@ -236,7 +362,7 @@ static const char* get_gst_state_name(GstState state)
236gboolean LLMediaImplGStreamer::bus_callback(GstBus *bus, GstMessage *message, gpointer data) 362gboolean LLMediaImplGStreamer::bus_callback(GstBus *bus, GstMessage *message, gpointer data)
237{ 363{
238#ifdef LL_GST_REPORT_STATE_CHANGES 364#ifdef LL_GST_REPORT_STATE_CHANGES
239 LL_DEBUGS("MediaCallback") << "Got GST message type: " << LLGST_MESSAGE_TYPE_NAME (message) << LL_ENDL; 365 LL_DEBUGS("MediaCallback") << "Got GST message type: " << GST_MESSAGE_TYPE_NAME (message) << LL_ENDL;
240#endif 366#endif
241 367
242 LLMediaImplGStreamer *impl = (LLMediaImplGStreamer*)data; 368 LLMediaImplGStreamer *impl = (LLMediaImplGStreamer*)data;
@@ -245,17 +371,13 @@ gboolean LLMediaImplGStreamer::bus_callback(GstBus *bus, GstMessage *message, gp
245 { 371 {
246 case GST_MESSAGE_BUFFERING: 372 case GST_MESSAGE_BUFFERING:
247 { 373 {
248 // NEEDS GST 0.10.11+ 374 gint percent = 0;
249 if (llgst_message_parse_buffering) 375 gst_message_parse_buffering(message, &percent);
250 {
251 gint percent = 0;
252 llgst_message_parse_buffering(message, &percent);
253#ifdef LL_GST_REPORT_STATE_CHANGES 376#ifdef LL_GST_REPORT_STATE_CHANGES
254 LL_DEBUGS("MediaBuffering") << "GST buffering: " << percent << "%%" << LL_ENDL; 377 LL_DEBUGS("MediaBuffering") << "GST buffering: " << percent << "%%" << LL_ENDL;
255#endif 378#endif
256 LLMediaEvent event( impl, percent ); 379 LLMediaEvent event( impl, percent );
257 impl->getEventEmitter().update( &LLMediaObserver::onUpdateProgress, event ); 380 impl->getEventEmitter().update( &LLMediaObserver::onUpdateProgress, event );
258 }
259 } 381 }
260 break; 382 break;
261 case GST_MESSAGE_STATE_CHANGED: 383 case GST_MESSAGE_STATE_CHANGED:
@@ -263,7 +385,7 @@ gboolean LLMediaImplGStreamer::bus_callback(GstBus *bus, GstMessage *message, gp
263 GstState old_state; 385 GstState old_state;
264 GstState new_state; 386 GstState new_state;
265 GstState pending_state; 387 GstState pending_state;
266 llgst_message_parse_state_changed(message, 388 gst_message_parse_state_changed(message,
267 &old_state, 389 &old_state,
268 &new_state, 390 &new_state,
269 &pending_state); 391 &pending_state);
@@ -308,7 +430,7 @@ gboolean LLMediaImplGStreamer::bus_callback(GstBus *bus, GstMessage *message, gp
308 GError *err = NULL; 430 GError *err = NULL;
309 gchar *debug = NULL; 431 gchar *debug = NULL;
310 432
311 llgst_message_parse_error (message, &err, &debug); 433 gst_message_parse_error (message, &err, &debug);
312 LL_WARNS("MediaImpl") << "GST Error: " << err->message << LL_ENDL; 434 LL_WARNS("MediaImpl") << "GST Error: " << err->message << LL_ENDL;
313 g_error_free (err); 435 g_error_free (err);
314 g_free (debug); 436 g_free (debug);
@@ -320,17 +442,14 @@ gboolean LLMediaImplGStreamer::bus_callback(GstBus *bus, GstMessage *message, gp
320 } 442 }
321 case GST_MESSAGE_INFO: 443 case GST_MESSAGE_INFO:
322 { 444 {
323 if (llgst_message_parse_info) 445 GError *err = NULL;
324 { 446 gchar *debug = NULL;
325 GError *err = NULL;
326 gchar *debug = NULL;
327 447
328 llgst_message_parse_info (message, &err, &debug); 448 gst_message_parse_info (message, &err, &debug);
329 LL_INFOS("MediaImpl") << "GST info: " << err->message 449 LL_INFOS("MediaImpl") << "GST info: " << err->message
330 << LL_ENDL; 450 << LL_ENDL;
331 g_error_free (err); 451 g_error_free (err);
332 g_free (debug); 452 g_free (debug);
333 }
334 break; 453 break;
335 } 454 }
336 case GST_MESSAGE_WARNING: 455 case GST_MESSAGE_WARNING:
@@ -338,7 +457,7 @@ gboolean LLMediaImplGStreamer::bus_callback(GstBus *bus, GstMessage *message, gp
338 GError *err = NULL; 457 GError *err = NULL;
339 gchar *debug = NULL; 458 gchar *debug = NULL;
340 459
341 llgst_message_parse_warning (message, &err, &debug); 460 gst_message_parse_warning (message, &err, &debug);
342 LL_WARNS("MediaImpl") << "GST warning: " << err->message 461 LL_WARNS("MediaImpl") << "GST warning: " << err->message
343 << LL_ENDL; 462 << LL_ENDL;
344 g_error_free (err); 463 g_error_free (err);
@@ -351,10 +470,10 @@ gboolean LLMediaImplGStreamer::bus_callback(GstBus *bus, GstMessage *message, gp
351 GstTagList *tag_list; 470 GstTagList *tag_list;
352 gchar *title; 471 gchar *title;
353 gchar *artist; 472 gchar *artist;
354 llgst_message_parse_tag(message, &tag_list); 473 gst_message_parse_tag(message, &tag_list);
355 gboolean hazTitle = llgst_tag_list_get_string(tag_list, 474 gboolean hazTitle = gst_tag_list_get_string(tag_list,
356 GST_TAG_TITLE, &title); 475 GST_TAG_TITLE, &title);
357 gboolean hazArtist = llgst_tag_list_get_string(tag_list, 476 gboolean hazArtist = gst_tag_list_get_string(tag_list,
358 GST_TAG_ARTIST, &artist); 477 GST_TAG_ARTIST, &artist);
359 if(hazTitle) 478 if(hazTitle)
360 LL_INFOS("MediaInfo") << "Title: " << title << LL_ENDL; 479 LL_INFOS("MediaInfo") << "Title: " << title << LL_ENDL;
@@ -408,13 +527,13 @@ bool LLMediaImplGStreamer::navigateTo (const std::string urlIn)
408 g_object_set (G_OBJECT (mPlaybin), "uri", urlIn.c_str(), NULL); 527 g_object_set (G_OBJECT (mPlaybin), "uri", urlIn.c_str(), NULL);
409 528
410 // get playbin's bus - perhaps this can/should be done in ctor 529 // get playbin's bus - perhaps this can/should be done in ctor
411 GstBus *bus = llgst_pipeline_get_bus (GST_PIPELINE (mPlaybin)); 530 GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (mPlaybin));
412 if (!bus) 531 if (!bus)
413 { 532 {
414 return false; 533 return false;
415 } 534 }
416 llgst_bus_add_watch (bus, bus_callback, this); 535 gst_bus_add_watch (bus, bus_callback, this);
417 llgst_object_unref (bus); 536 gst_object_unref (bus);
418 537
419 mState = GST_STATE_READY; 538 mState = GST_STATE_READY;
420 539
@@ -431,9 +550,9 @@ bool LLMediaImplGStreamer::unload()
431 LL_DEBUGS("MediaImpl") << "unloading media..." << LL_ENDL; 550 LL_DEBUGS("MediaImpl") << "unloading media..." << LL_ENDL;
432 if (mPlaybin) 551 if (mPlaybin)
433 { 552 {
434 llgst_element_set_state (mPlaybin, GST_STATE_NULL); 553 gst_element_set_state (mPlaybin, GST_STATE_NULL);
435 mState = GST_STATE_NULL; 554 mState = GST_STATE_NULL;
436 llgst_object_unref (GST_OBJECT (mPlaybin)); 555 gst_object_unref (GST_OBJECT (mPlaybin));
437 mPlaybin = NULL; 556 mPlaybin = NULL;
438 } 557 }
439 558
@@ -591,20 +710,23 @@ bool LLMediaImplGStreamer::stop()
591 if (!mPlaybin || mState == GST_STATE_NULL) 710 if (!mPlaybin || mState == GST_STATE_NULL)
592 return true; 711 return true;
593 712
594 GstElement *pipeline = (GstElement *)llgst_object_ref(GST_OBJECT(mPlaybin)); 713 GstStateChangeReturn state_change;
595 llgst_object_unref(pipeline);
596
597 llgst_element_set_state(pipeline, GST_STATE_READY);
598 714
599 if (mState == GST_STATE_PLAYING) 715 state_change = gst_element_set_state(mPlaybin, GST_STATE_READY);
600 mState = GST_STATE_VOID_PENDING;
601 else
602 mState = GST_STATE_READY;
603 716
604 GstStateChangeReturn state_change = llgst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE); 717 LL_DEBUGS("MediaImpl") << gst_element_state_change_return_get_name(state_change) << LL_ENDL;
605 LL_DEBUGS("MediaImpl") << "get_state: " << llgst_element_state_change_return_get_name(state_change) << LL_ENDL;
606 718
607 return true; 719 if (state_change == GST_STATE_CHANGE_FAILURE)
720 {
721 LL_WARNS("MediaImpl") << "could not stop stream!" << LL_ENDL;
722 return false;
723 }
724 else
725 {
726 // Going into pending after play keeps dead streams from looping
727 (mState == GST_STATE_PLAYING) ? (mState = GST_STATE_VOID_PENDING) : (mState = GST_STATE_READY);
728 return true;
729 }
608} 730}
609 731
610/////////////////////////////////////////////////////////////////////////////// 732///////////////////////////////////////////////////////////////////////////////
@@ -616,25 +738,47 @@ bool LLMediaImplGStreamer::play()
616 if (!mPlaybin || mState == GST_STATE_NULL) 738 if (!mPlaybin || mState == GST_STATE_NULL)
617 return true; 739 return true;
618 740
619 GstElement *pipeline = (GstElement *)llgst_object_ref(GST_OBJECT(mPlaybin)); 741 // Clean up the existing thread, if any.
620 llgst_object_unref(pipeline); 742 if( mPlayThread != NULL && mPlayThread->isStopped())
743 {
744 delete mPlayThread;
745 mPlayThread = NULL;
746 }
747
748 if( mPlayThread == NULL )
749 {
750 // Make a new thread to start playing. This keeps the viewer
751 // responsive while the stream is resolved and buffered.
752 mPlayThread = new LLGstPlayThread( (LLMediaImplCommon *)this, "GstPlayThread", NULL);
753 mPlayThread->start();
754 }
755
756 return true;
757}
758
759
760void LLMediaImplGStreamer::startPlay()
761{
762 GstElement *pipeline = (GstElement *)gst_object_ref(GST_OBJECT(mPlaybin));
763 gst_object_unref(pipeline);
621 764
622 llgst_element_set_state(pipeline, GST_STATE_PLAYING); 765 GstStateChangeReturn state_change;
766
767 state_change = gst_element_set_state(mPlaybin, GST_STATE_PLAYING);
623 mState = GST_STATE_PLAYING; 768 mState = GST_STATE_PLAYING;
624 /*llgst_element_set_state(mPlaybin, GST_STATE_PLAYING);
625 mState = GST_STATE_PLAYING;*/
626 769
627 GstStateChangeReturn state_change = llgst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE); 770 LL_DEBUGS("MediaImpl") << gst_element_state_change_return_get_name(state_change) << LL_ENDL;
628 LL_DEBUGS("MediaImpl") << "get_state: " << llgst_element_state_change_return_get_name(state_change) << LL_ENDL;
629 771
630 // Check to make sure playing was successful. If not, stop. 772 // Check to make sure playing was successful. If not, stop.
773 // NOTE: state_change is almost always GST_STATE_CHANGE_ASYNC
631 if (state_change == GST_STATE_CHANGE_FAILURE) 774 if (state_change == GST_STATE_CHANGE_FAILURE)
632 { 775 {
633 setStatus(LLMediaBase::STATUS_STOPPED); 776 // If failing from a bad stream, go into an unknown
777 // state to stop bus_callback from looping back.
778 // We also force a stop in case the operations don't sync
779 setStatus(LLMediaBase::STATUS_UNKNOWN);
634 stop(); 780 stop();
635 } 781 }
636
637 return true;
638} 782}
639 783
640/////////////////////////////////////////////////////////////////////////////// 784///////////////////////////////////////////////////////////////////////////////
@@ -646,13 +790,22 @@ bool LLMediaImplGStreamer::pause()
646 if (!mPlaybin || mState == GST_STATE_NULL) 790 if (!mPlaybin || mState == GST_STATE_NULL)
647 return true; 791 return true;
648 792
649 llgst_element_set_state(mPlaybin, GST_STATE_PAUSED); 793 GstStateChangeReturn state_change;
650 mState = GST_STATE_PAUSED;
651
652 GstStateChangeReturn state_change = llgst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE);
653 LL_DEBUGS("MediaImpl") << "get_state: " << llgst_element_state_change_return_get_name(state_change) << LL_ENDL;
654 794
655 return true; 795 state_change = gst_element_set_state(mPlaybin, GST_STATE_PAUSED);
796
797 LL_DEBUGS("MediaImpl") << gst_element_state_change_return_get_name(state_change) << LL_ENDL;
798
799 if (state_change == GST_STATE_CHANGE_FAILURE)
800 {
801 LL_WARNS("MediaImpl") << "could not pause stream!" << LL_ENDL;
802 return false;
803 }
804 else
805 {
806 mState = GST_STATE_PAUSED;
807 return true;
808 }
656}; 809};
657 810
658 811
@@ -671,7 +824,7 @@ bool LLMediaImplGStreamer::seek(double time)
671 bool success = false; 824 bool success = false;
672 if (mPlaybin) 825 if (mPlaybin)
673 { 826 {
674 success = llgst_element_seek(mPlaybin, 1.0F, GST_FORMAT_TIME, 827 success = gst_element_seek(mPlaybin, 1.0F, GST_FORMAT_TIME,
675 GstSeekFlags(GST_SEEK_FLAG_FLUSH | 828 GstSeekFlags(GST_SEEK_FLAG_FLUSH |
676 GST_SEEK_FLAG_KEY_UNIT), 829 GST_SEEK_FLAG_KEY_UNIT),
677 GST_SEEK_TYPE_SET, gint64(time*1000000000.0F), 830 GST_SEEK_TYPE_SET, gint64(time*1000000000.0F),
diff --git a/linden/indra/llmedia/llmediaimplgstreamer.h b/linden/indra/llmedia/llmediaimplgstreamer.h
index dec970a..32e6bd1 100644
--- a/linden/indra/llmedia/llmediaimplgstreamer.h
+++ b/linden/indra/llmedia/llmediaimplgstreamer.h
@@ -48,6 +48,7 @@ extern "C" {
48} 48}
49 49
50#include "llmediaimplgstreamervidplug.h" 50#include "llmediaimplgstreamervidplug.h"
51#include "llgstplaythread.h"
51 52
52class LLMediaManagerData; 53class LLMediaManagerData;
53class LLMediaImplMaker; 54class LLMediaImplMaker;
@@ -66,6 +67,26 @@ class LLMediaImplGStreamer:
66 static bool startup( LLMediaManagerData* init_data ); 67 static bool startup( LLMediaManagerData* init_data );
67 static bool closedown(); 68 static bool closedown();
68 69
70 // Sets GST_PLUGIN_PATH env var for GStreamer.
71 static void set_gst_plugin_path();
72
73 /* virtual */ bool setDebugLevel( LLMediaBase::EDebugLevel level );
74
75 // Function given to GStreamer for handling debug messages
76 static void gstreamer_log(GstDebugCategory *category,
77 GstDebugLevel level,
78 const gchar *file,
79 const gchar *function,
80 gint line,
81 GObject *object,
82 GstDebugMessage *message,
83 gpointer data)
84#if __GNUC__
85 // recommended by the gstreamer docs
86 G_GNUC_NO_INSTRUMENT
87#endif
88 ;
89
69 /* virtual */ std::string getVersion(); 90 /* virtual */ std::string getVersion();
70 /* virtual */ bool navigateTo( const std::string url ); 91 /* virtual */ bool navigateTo( const std::string url );
71 /* virtual */ bool updateMedia(); 92 /* virtual */ bool updateMedia();
@@ -76,9 +97,13 @@ class LLMediaImplGStreamer:
76 /* virtual */ bool seek( double time ); 97 /* virtual */ bool seek( double time );
77 /* virtual */ bool setVolume( float volume ); 98 /* virtual */ bool setVolume( float volume );
78 99
100 void startPlay();
101
102
79 LLMediaEmitter< LLMediaObserver > getEventEmitter() const {return mEventEmitter;}; 103 LLMediaEmitter< LLMediaObserver > getEventEmitter() const {return mEventEmitter;};
80 104
81 private: 105 private:
106
82 // misc 107 // misc
83 bool unload(); 108 bool unload();
84 bool pause(); 109 bool pause();
@@ -100,6 +125,8 @@ class LLMediaImplGStreamer:
100 GstSLVideo *mVideoSink; 125 GstSLVideo *mVideoSink;
101 GstState mState; 126 GstState mState;
102 GstState getState() const { return mState; } 127 GstState getState() const { return mState; }
128
129 LLGstPlayThread *mPlayThread;
103}; 130};
104 131
105class LLMediaImplGStreamerMaker : public LLMediaImplMaker 132class LLMediaImplGStreamerMaker : public LLMediaImplMaker
diff --git a/linden/indra/llmedia/llmediaimplgstreamer_syms.cpp b/linden/indra/llmedia/llmediaimplgstreamer_syms.cpp
deleted file mode 100644
index fb1949a..0000000
--- a/linden/indra/llmedia/llmediaimplgstreamer_syms.cpp
+++ /dev/null
@@ -1,188 +0,0 @@
1/**
2 * @file llmediaimplgstreamer_syms.cpp
3 * @brief dynamic GStreamer symbol-grabbing code
4 *
5 * $LicenseInfo:firstyear=2007&license=viewergpl$
6 *
7 * Copyright (c) 2007-2008, Linden Research, Inc.
8 *
9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab
11 * to you under the terms of the GNU General Public License, version 2.0
12 * ("GPL"), unless you have obtained a separate licensing agreement
13 * ("Other License"), formally executed by you and Linden Lab. Terms of
14 * the GPL can be found in doc/GPL-license.txt in this distribution, or
15 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
16 *
17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
30 */
31
32///#if LL_GSTREAMER_ENABLED
33
34extern "C" {
35#include <gst/gst.h>
36
37#include "apr_pools.h"
38#include "apr_dso.h"
39}
40
41#include "llmediaimplgstreamer.h"
42
43#define LL_GST_SYM(REQ, GSTSYM, RTN, ...) RTN (*ll##GSTSYM)(__VA_ARGS__) = NULL
44#include "llmediaimplgstreamer_syms_raw.inc"
45#include "llmediaimplgstreamer_syms_rawa.inc"
46#include "llmediaimplgstreamer_syms_rawv.inc"
47#undef LL_GST_SYM
48
49
50static bool sSymsGrabbed = false;
51static apr_pool_t *sSymGSTDSOMemoryPool = NULL;
52static apr_dso_handle_t *sSymGSTDSOHandleG = NULL;
53static apr_dso_handle_t *sSymGSTDSOHandleV = NULL;
54static apr_dso_handle_t *sSymGSTDSOHandleA = NULL;
55
56
57bool grab_gst_syms(std::string gst_dso_name,
58 std::string gst_dso_name_vid,
59 std::string gst_dso_name_aud)
60{
61 if (sSymsGrabbed)
62 {
63 // already have grabbed good syms
64 return TRUE;
65 }
66
67 bool sym_error = false;
68 bool rtn = false;
69 apr_status_t rv;
70 apr_dso_handle_t *sSymGSTDSOHandle = NULL;
71
72#define LL_GST_SYM(REQ, GSTSYM, RTN, ...) do{rv = apr_dso_sym((apr_dso_handle_sym_t*)&ll##GSTSYM, sSymGSTDSOHandle, #GSTSYM); if (rv != APR_SUCCESS) {INFOMSG("Failed to grab symbol: %s", #GSTSYM); if (REQ) sym_error = true;} else DEBUGMSG("grabbed symbol: %s from %p", #GSTSYM, (void*)ll##GSTSYM);}while(0)
73
74 //attempt to load the shared libraries
75 apr_pool_create(&sSymGSTDSOMemoryPool, NULL);
76
77 if ( APR_SUCCESS == (rv = apr_dso_load(&sSymGSTDSOHandle,
78 gst_dso_name.c_str(),
79 sSymGSTDSOMemoryPool) ))
80 {
81 INFOMSG("Found DSO: %s", gst_dso_name.c_str());
82#include "llmediaimplgstreamer_syms_raw.inc"
83
84 if ( sSymGSTDSOHandle )
85 {
86 sSymGSTDSOHandleG = sSymGSTDSOHandle;
87 sSymGSTDSOHandle = NULL;
88 }
89
90 if ( APR_SUCCESS == (rv = apr_dso_load(&sSymGSTDSOHandle,
91 gst_dso_name_aud.c_str(),
92 sSymGSTDSOMemoryPool) ))
93 {
94 INFOMSG("Found DSO: %s", gst_dso_name_aud.c_str());
95#include "llmediaimplgstreamer_syms_rawa.inc"
96
97 if ( sSymGSTDSOHandle )
98 {
99 sSymGSTDSOHandleA = sSymGSTDSOHandle;
100 sSymGSTDSOHandle = NULL;
101 }
102
103 if ( APR_SUCCESS ==
104 (rv = apr_dso_load(&sSymGSTDSOHandle,
105 gst_dso_name_vid.c_str(),
106 sSymGSTDSOMemoryPool) ))
107 {
108 INFOMSG("Found DSO: %s", gst_dso_name_vid.c_str());
109#include "llmediaimplgstreamer_syms_rawv.inc"
110 }
111 else
112 {
113 INFOMSG("Couldn't load DSO: %s", gst_dso_name_vid.c_str());
114 rtn = false; // failure
115 }
116 }
117 else
118 {
119 INFOMSG("Couldn't load DSO: %s", gst_dso_name_aud.c_str());
120 rtn = false; // failure
121 }
122
123 rtn = !sym_error;
124 }
125 else
126 {
127 INFOMSG("Couldn't load DSO: %s", gst_dso_name.c_str());
128 rtn = false; // failure
129 }
130
131 if (sym_error)
132 {
133 WARNMSG("Failed to find necessary symbols in GStreamer libraries.");
134 }
135
136 if ( sSymGSTDSOHandle )
137 {
138 sSymGSTDSOHandleV = sSymGSTDSOHandle;
139 sSymGSTDSOHandle = NULL;
140 }
141#undef LL_GST_SYM
142
143 sSymsGrabbed = !!rtn;
144 return rtn;
145}
146
147
148void ungrab_gst_syms()
149{
150 // should be safe to call regardless of whether we've
151 // actually grabbed syms.
152
153 if ( sSymGSTDSOHandleG )
154 {
155 apr_dso_unload(sSymGSTDSOHandleG);
156 sSymGSTDSOHandleG = NULL;
157 }
158
159 if ( sSymGSTDSOHandleA )
160 {
161 apr_dso_unload(sSymGSTDSOHandleA);
162 sSymGSTDSOHandleA = NULL;
163 }
164
165 if ( sSymGSTDSOHandleV )
166 {
167 apr_dso_unload(sSymGSTDSOHandleV);
168 sSymGSTDSOHandleV = NULL;
169 }
170
171 if ( sSymGSTDSOMemoryPool )
172 {
173 apr_pool_destroy(sSymGSTDSOMemoryPool);
174 sSymGSTDSOMemoryPool = NULL;
175 }
176
177 // NULL-out all of the symbols we'd grabbed
178#define LL_GST_SYM(REQ, GSTSYM, RTN, ...) do{ll##GSTSYM = NULL;}while(0)
179#include "llmediaimplgstreamer_syms_raw.inc"
180#include "llmediaimplgstreamer_syms_rawa.inc"
181#include "llmediaimplgstreamer_syms_rawv.inc"
182#undef LL_GST_SYM
183
184 sSymsGrabbed = false;
185}
186
187
188///#endif // LL_GSTREAMER_ENABLED
diff --git a/linden/indra/llmedia/llmediaimplgstreamer_syms.h b/linden/indra/llmedia/llmediaimplgstreamer_syms.h
deleted file mode 100644
index ebebd80..0000000
--- a/linden/indra/llmedia/llmediaimplgstreamer_syms.h
+++ /dev/null
@@ -1,78 +0,0 @@
1/**
2 * @file llmediaimplgstreamer_syms.h
3 * @brief dynamic GStreamer symbol-grabbing code
4 *
5 * $LicenseInfo:firstyear=2007&license=viewergpl$
6 *
7 * Copyright (c) 2007-2008, Linden Research, Inc.
8 *
9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab
11 * to you under the terms of the GNU General Public License, version 2.0
12 * ("GPL"), unless you have obtained a separate licensing agreement
13 * ("Other License"), formally executed by you and Linden Lab. Terms of
14 * the GPL can be found in doc/GPL-license.txt in this distribution, or
15 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
16 *
17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
30 */
31
32#include "linden_common.h"
33
34///#if LL_GSTREAMER_ENABLED
35
36extern "C" {
37#include <gst/gst.h>
38}
39
40bool grab_gst_syms(std::string gst_dso_name,
41 std::string gst_dso_name_vid,
42 std::string gst_dso_name_aud);
43void ungrab_gst_syms();
44
45#define LL_GST_SYM(REQ, GSTSYM, RTN, ...) extern RTN (*ll##GSTSYM)(__VA_ARGS__)
46#include "llmediaimplgstreamer_syms_raw.inc"
47#include "llmediaimplgstreamer_syms_rawa.inc"
48#include "llmediaimplgstreamer_syms_rawv.inc"
49#undef LL_GST_SYM
50
51// regrettable hacks to give us better runtime compatibility with older systems
52#define llg_return_if_fail(COND) do{if (!(COND)) return;}while(0)
53#define llg_return_val_if_fail(COND,V) do{if (!(COND)) return V;}while(0)
54
55// regrettable hacks because GStreamer was not designed for runtime loading
56#undef GST_TYPE_MESSAGE
57#define GST_TYPE_MESSAGE (llgst_message_get_type())
58#undef GST_TYPE_OBJECT
59#define GST_TYPE_OBJECT (llgst_object_get_type())
60#undef GST_TYPE_PIPELINE
61#define GST_TYPE_PIPELINE (llgst_pipeline_get_type())
62#undef GST_TYPE_ELEMENT
63#define GST_TYPE_ELEMENT (llgst_element_get_type())
64#undef GST_TYPE_AUDIO_SINK
65#define GST_TYPE_AUDIO_SINK (llgst_audio_sink_get_type())
66#undef GST_TYPE_VIDEO_SINK
67#define GST_TYPE_VIDEO_SINK (llgst_video_sink_get_type())
68#undef _gst_debug_register_funcptr
69#define _gst_debug_register_funcptr ll_gst_debug_register_funcptr
70#undef _gst_debug_category_new
71#define _gst_debug_category_new ll_gst_debug_category_new
72#undef __gst_debug_enabled
73#define __gst_debug_enabled (0)
74
75// more hacks
76#define LLGST_MESSAGE_TYPE_NAME(M) (llgst_message_type_get_name(GST_MESSAGE_TYPE(M)))
77
78///#endif // LL_GSTREAMER_ENABLED
diff --git a/linden/indra/llmedia/llmediaimplgstreamer_syms_raw.inc b/linden/indra/llmedia/llmediaimplgstreamer_syms_raw.inc
deleted file mode 100644
index 0d0d764..0000000
--- a/linden/indra/llmedia/llmediaimplgstreamer_syms_raw.inc
+++ /dev/null
@@ -1,50 +0,0 @@
1
2// required symbols to grab
3LL_GST_SYM(true, gst_init_check, gboolean, int *argc, char **argv[], GError ** err);
4LL_GST_SYM(true, gst_message_get_type, GType, void);
5LL_GST_SYM(true, gst_message_type_get_name, const gchar*, GstMessageType type);
6LL_GST_SYM(true, gst_message_parse_error, 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);
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);
11LL_GST_SYM(true, gst_object_unref, void, gpointer object);
12LL_GST_SYM(true, gst_object_ref, gpointer, gpointer object);
13LL_GST_SYM(true, gst_object_get_type, GType, void);
14LL_GST_SYM(true, gst_pipeline_get_type, GType, void);
15LL_GST_SYM(true, gst_pipeline_get_bus, GstBus*, GstPipeline *pipeline);
16LL_GST_SYM(true, gst_bus_add_watch, guint, GstBus * bus, GstBusFunc func, gpointer user_data);
17LL_GST_SYM(true, gst_element_factory_make, GstElement*, const gchar *factoryname, const gchar *name);
18LL_GST_SYM(true, gst_element_get_type, GType, void);
19LL_GST_SYM(true, gst_static_pad_template_get, GstPadTemplate*, GstStaticPadTemplate *pad_template);
20LL_GST_SYM(true, gst_element_class_add_pad_template, void, GstElementClass *klass, GstPadTemplate *temp);
21LL_GST_SYM(true, gst_element_class_set_details, void, GstElementClass *klass, const GstElementDetails *details);
22LL_GST_SYM(true, gst_caps_unref, void, GstCaps* caps);
23LL_GST_SYM(true, gst_caps_ref, GstCaps *, GstCaps* caps);
24LL_GST_SYM(true, _gst_debug_register_funcptr, void, GstDebugFuncPtr func, gchar* ptrname);
25LL_GST_SYM(true, _gst_debug_category_new, GstDebugCategory *, gchar *name, guint color, gchar *description);
26LL_GST_SYM(true, gst_caps_is_empty, gboolean, const GstCaps *caps);
27LL_GST_SYM(true, gst_caps_from_string, GstCaps *, const gchar *string);
28LL_GST_SYM(true, gst_caps_replace, void, GstCaps **caps, GstCaps *newcaps);
29LL_GST_SYM(true, gst_caps_get_structure, GstStructure *, const GstCaps *caps, guint index);
30LL_GST_SYM(true, gst_caps_copy, GstCaps *, const GstCaps * caps);
31LL_GST_SYM(true, gst_caps_intersect, GstCaps *, const GstCaps *caps1, const GstCaps *caps2);
32LL_GST_SYM(true, gst_element_register, gboolean, GstPlugin *plugin, const gchar *name, guint rank, GType type);
33LL_GST_SYM(true, _gst_plugin_register_static, void, GstPluginDesc *desc);
34LL_GST_SYM(true, gst_structure_get_int, gboolean, const GstStructure *structure, const gchar *fieldname, gint *value);
35LL_GST_SYM(true, gst_structure_get_value, G_CONST_RETURN GValue *, const GstStructure *structure, const gchar *fieldname);
36LL_GST_SYM(true, gst_value_get_fraction_numerator, gint, const GValue *value);
37LL_GST_SYM(true, gst_value_get_fraction_denominator, gint, const GValue *value);
38LL_GST_SYM(true, gst_structure_get_name, G_CONST_RETURN gchar *, const GstStructure *structure);
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);
42
43// optional symbols to grab
44LL_GST_SYM(false, gst_segtrap_set_enabled, void, gboolean enabled);
45LL_GST_SYM(false, gst_message_parse_buffering, void, GstMessage *message, gint *percent);
46LL_GST_SYM(false, gst_message_parse_info, void, GstMessage *message, GError **gerror, gchar **debug);
47
48//aw tag infos (Artist, Title, ...tbc...)
49LL_GST_SYM(true, gst_message_parse_tag, void, GstMessage *message, GstTagList **tag_list);
50LL_GST_SYM(true, gst_tag_list_get_string, gboolean, const GstTagList *list, const gchar *tag, gchar **value);
diff --git a/linden/indra/llmedia/llmediaimplgstreamer_syms_rawa.inc b/linden/indra/llmedia/llmediaimplgstreamer_syms_rawa.inc
deleted file mode 100644
index 0be99b5..0000000
--- a/linden/indra/llmedia/llmediaimplgstreamer_syms_rawa.inc
+++ /dev/null
@@ -1,5 +0,0 @@
1
2// required symbols to grab
3LL_GST_SYM(true, gst_audio_sink_get_type, GType, void);
4
5// optional symbols to grab
diff --git a/linden/indra/llmedia/llmediaimplgstreamer_syms_rawv.inc b/linden/indra/llmedia/llmediaimplgstreamer_syms_rawv.inc
deleted file mode 100644
index 14fbcb4..0000000
--- a/linden/indra/llmedia/llmediaimplgstreamer_syms_rawv.inc
+++ /dev/null
@@ -1,5 +0,0 @@
1
2// required symbols to grab
3LL_GST_SYM(true, gst_video_sink_get_type, GType, void);
4
5// optional symbols to grab
diff --git a/linden/indra/llmedia/llmediaimplgstreamervidplug.cpp b/linden/indra/llmedia/llmediaimplgstreamervidplug.cpp
index c95ef36..eaf2c84 100644
--- a/linden/indra/llmedia/llmediaimplgstreamervidplug.cpp
+++ b/linden/indra/llmedia/llmediaimplgstreamervidplug.cpp
@@ -37,8 +37,6 @@
37#include <gst/video/video.h> 37#include <gst/video/video.h>
38#include <gst/video/gstvideosink.h> 38#include <gst/video/gstvideosink.h>
39 39
40#include "llmediaimplgstreamer_syms.h"
41
42#include "llthread.h" 40#include "llthread.h"
43 41
44#include "llmediaimplgstreamervidplug.h" 42#include "llmediaimplgstreamervidplug.h"
@@ -88,9 +86,9 @@ gst_slvideo_base_init (gpointer gclass)
88 }; 86 };
89 GstElementClass *element_class = GST_ELEMENT_CLASS (gclass); 87 GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
90 88
91 llgst_element_class_add_pad_template (element_class, 89 gst_element_class_add_pad_template (element_class,
92 llgst_static_pad_template_get (&sink_factory)); 90 gst_static_pad_template_get (&sink_factory));
93 llgst_element_class_set_details (element_class, &element_details); 91 gst_element_class_set_details (element_class, &element_details);
94} 92}
95 93
96 94
@@ -101,7 +99,7 @@ gst_slvideo_finalize (GObject * object)
101 slvideo = GST_SLVIDEO (object); 99 slvideo = GST_SLVIDEO (object);
102 if (slvideo->caps) 100 if (slvideo->caps)
103 { 101 {
104 llgst_caps_unref(slvideo->caps); 102 gst_caps_unref(slvideo->caps);
105 } 103 }
106 104
107 G_OBJECT_CLASS(parent_class)->finalize (object); 105 G_OBJECT_CLASS(parent_class)->finalize (object);
@@ -112,7 +110,7 @@ static GstFlowReturn
112gst_slvideo_show_frame (GstBaseSink * bsink, GstBuffer * buf) 110gst_slvideo_show_frame (GstBaseSink * bsink, GstBuffer * buf)
113{ 111{
114 GstSLVideo *slvideo; 112 GstSLVideo *slvideo;
115 llg_return_val_if_fail (buf != NULL, GST_FLOW_ERROR); 113 g_return_val_if_fail (buf != NULL, GST_FLOW_ERROR);
116 114
117 slvideo = GST_SLVIDEO(bsink); 115 slvideo = GST_SLVIDEO(bsink);
118 116
@@ -205,7 +203,7 @@ gst_slvideo_get_caps (GstBaseSink * bsink)
205 GstSLVideo *slvideo; 203 GstSLVideo *slvideo;
206 slvideo = GST_SLVIDEO(bsink); 204 slvideo = GST_SLVIDEO(bsink);
207 205
208 return llgst_caps_ref (slvideo->caps); 206 return gst_caps_ref (slvideo->caps);
209} 207}
210 208
211 209
@@ -221,36 +219,36 @@ gst_slvideo_set_caps (GstBaseSink * bsink, GstCaps * caps)
221 219
222 filter = GST_SLVIDEO(bsink); 220 filter = GST_SLVIDEO(bsink);
223 221
224 intersection = llgst_caps_intersect (filter->caps, caps); 222 intersection = gst_caps_intersect (filter->caps, caps);
225 if (llgst_caps_is_empty (intersection)) 223 if (gst_caps_is_empty (intersection))
226 { 224 {
227 // no overlap between our caps and requested caps 225 // no overlap between our caps and requested caps
228 return FALSE; 226 return FALSE;
229 } 227 }
230 llgst_caps_unref(intersection); 228 gst_caps_unref(intersection);
231 229
232 int width = 0; 230 int width = 0;
233 int height = 0; 231 int height = 0;
234 gboolean ret; 232 gboolean ret;
235 const GValue *fps; 233 const GValue *fps;
236 const GValue *par; 234 const GValue *par;
237 structure = llgst_caps_get_structure (caps, 0); 235 structure = gst_caps_get_structure (caps, 0);
238 ret = llgst_structure_get_int (structure, "width", &width); 236 ret = gst_structure_get_int (structure, "width", &width);
239 ret = ret && llgst_structure_get_int (structure, "height", &height); 237 ret = ret && gst_structure_get_int (structure, "height", &height);
240 fps = llgst_structure_get_value (structure, "framerate"); 238 fps = gst_structure_get_value (structure, "framerate");
241 ret = ret && (fps != NULL); 239 ret = ret && (fps != NULL);
242 par = llgst_structure_get_value (structure, "pixel-aspect-ratio"); 240 par = gst_structure_get_value (structure, "pixel-aspect-ratio");
243 if (!ret) 241 if (!ret)
244 return FALSE; 242 return FALSE;
245 243
246 filter->width = width; 244 filter->width = width;
247 filter->height = height; 245 filter->height = height;
248 filter->fps_n = llgst_value_get_fraction_numerator(fps); 246 filter->fps_n = gst_value_get_fraction_numerator(fps);
249 filter->fps_d = llgst_value_get_fraction_denominator(fps); 247 filter->fps_d = gst_value_get_fraction_denominator(fps);
250 if (par) 248 if (par)
251 { 249 {
252 filter->par_n = llgst_value_get_fraction_numerator(par); 250 filter->par_n = gst_value_get_fraction_numerator(par);
253 filter->par_d = llgst_value_get_fraction_denominator(par); 251 filter->par_d = gst_value_get_fraction_denominator(par);
254 } 252 }
255 else 253 else
256 { 254 {
@@ -261,15 +259,15 @@ gst_slvideo_set_caps (GstBaseSink * bsink, GstCaps * caps)
261 GST_VIDEO_SINK_HEIGHT(filter) = height; 259 GST_VIDEO_SINK_HEIGHT(filter) = height;
262 260
263 filter->format = SLV_PF_UNKNOWN; 261 filter->format = SLV_PF_UNKNOWN;
264 if (0 == strcmp(llgst_structure_get_name(structure), 262 if (0 == strcmp(gst_structure_get_name(structure),
265 "video/x-raw-rgb")) 263 "video/x-raw-rgb"))
266 { 264 {
267 int red_mask; 265 int red_mask;
268 int green_mask; 266 int green_mask;
269 int blue_mask; 267 int blue_mask;
270 llgst_structure_get_int(structure, "red_mask", &red_mask); 268 gst_structure_get_int(structure, "red_mask", &red_mask);
271 llgst_structure_get_int(structure, "green_mask", &green_mask); 269 gst_structure_get_int(structure, "green_mask", &green_mask);
272 llgst_structure_get_int(structure, "blue_mask", &blue_mask); 270 gst_structure_get_int(structure, "blue_mask", &blue_mask);
273 if ((unsigned int)red_mask == 0xFF000000 && 271 if ((unsigned int)red_mask == 0xFF000000 &&
274 (unsigned int)green_mask == 0x00FF0000 && 272 (unsigned int)green_mask == 0x00FF0000 &&
275 (unsigned int)blue_mask == 0x0000FF00) 273 (unsigned int)blue_mask == 0x0000FF00)
@@ -366,9 +364,9 @@ gst_slvideo_update_caps (GstSLVideo * slvideo)
366 // GStreamer will automatically convert colourspace if necessary. 364 // GStreamer will automatically convert colourspace if necessary.
367 // GStreamer will automatically resize media to one of these enumerated 365 // GStreamer will automatically resize media to one of these enumerated
368 // powers-of-two that we ask for (yay GStreamer!) 366 // powers-of-two that we ask for (yay GStreamer!)
369 caps = llgst_caps_from_string (SLV_ALLCAPS); 367 caps = gst_caps_from_string (SLV_ALLCAPS);
370 368
371 llgst_caps_replace (&slvideo->caps, caps); 369 gst_caps_replace (&slvideo->caps, caps);
372} 370}
373 371
374 372
@@ -401,7 +399,7 @@ static void
401gst_slvideo_set_property (GObject * object, guint prop_id, 399gst_slvideo_set_property (GObject * object, guint prop_id,
402 const GValue * value, GParamSpec * pspec) 400 const GValue * value, GParamSpec * pspec)
403{ 401{
404 llg_return_if_fail (GST_IS_SLVIDEO (object)); 402 g_return_if_fail (GST_IS_SLVIDEO (object));
405 403
406 if (prop_id) { 404 if (prop_id) {
407 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); 405 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -412,7 +410,7 @@ static void
412gst_slvideo_get_property (GObject * object, guint prop_id, 410gst_slvideo_get_property (GObject * object, guint prop_id,
413 GValue * value, GParamSpec * pspec) 411 GValue * value, GParamSpec * pspec)
414{ 412{
415 llg_return_if_fail (GST_IS_SLVIDEO (object)); 413 g_return_if_fail (GST_IS_SLVIDEO (object));
416 414
417 if (prop_id) { 415 if (prop_id) {
418 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); 416 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -433,30 +431,23 @@ plugin_init (GstPlugin * plugin)
433 GST_DEBUG_CATEGORY_INIT (gst_slvideo_debug, "private-slvideo-plugin", 431 GST_DEBUG_CATEGORY_INIT (gst_slvideo_debug, "private-slvideo-plugin",
434 0, "Second Life Video Sink"); 432 0, "Second Life Video Sink");
435 433
436 return llgst_element_register (plugin, "private-slvideo", 434 return gst_element_register (plugin, "private-slvideo",
437 GST_RANK_NONE, GST_TYPE_SLVIDEO); 435 GST_RANK_NONE, GST_TYPE_SLVIDEO);
438} 436}
439 437
440/* this is the structure that gstreamer looks for to register plugins
441 */
442/* NOTE: Can't rely upon GST_PLUGIN_DEFINE_STATIC to self-register, since
443 some g++ versions buggily avoid __attribute__((constructor)) functions -
444 so we provide an explicit plugin init function.
445 */
446#define PACKAGE "packagehack"
447 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
448 GST_VERSION_MINOR,
449 "private-slvideoplugin",
450 "SL Video sink plugin",
451 plugin_init, "0.1", GST_LICENSE_UNKNOWN,
452 "Second Life",
453 "http://www.secondlife.com/");
454#undef PACKAGE
455 438
456void gst_slvideo_init_class (void) 439void gst_slvideo_init_class (void)
457{ 440{
458 ll_gst_plugin_register_static (&gst_plugin_desc); 441 gst_plugin_register_static( GST_VERSION_MAJOR,
459 //fprintf(stderr, "\n\n\nCLASS INIT\n\n\n"); 442 GST_VERSION_MINOR,
443 "private-slvideoplugin",
444 "SL Video sink plugin",
445 plugin_init,
446 "0.1",
447 GST_LICENSE_UNKNOWN,
448 "Second Life",
449 "Second Life",
450 "http://www.secondlife.com/" );
460} 451}
461 452
462///#endif // LL_GSTREAMER_ENABLED 453///#endif // LL_GSTREAMER_ENABLED
diff --git a/linden/indra/llmedia/llmediamanager.cpp b/linden/indra/llmedia/llmediamanager.cpp
index 5394b62..7fe0df3 100644
--- a/linden/indra/llmedia/llmediamanager.cpp
+++ b/linden/indra/llmedia/llmediamanager.cpp
@@ -30,12 +30,24 @@
30 */ 30 */
31 31
32#include "llmediamanager.h" 32#include "llmediamanager.h"
33
34#if LL_WINDOWS
35 // GStreamer 0.10.22 - gstutils.h - conversion from 'guint64' to 'guint8'.
36 // This was an intentional change to make GStreamer more threadsafe, and
37 // is okay. Delete this bit if GStreamer ever gets more VS-friendly -- McCabe
38 #pragma warning(disable : 4244)
39#endif
40#include "llmediaimplgstreamer.h"
41#if LL_WINDOWS
42 #pragma warning(default : 4244)
43#endif
44
33#include "llmediaimplfactory.h" 45#include "llmediaimplfactory.h"
34 46
35#include "llmediaimplexample1.h" 47#include "llmediaimplexample1.h"
36#include "llmediaimplexample2.h" 48#include "llmediaimplexample2.h"
37#include "llmediaimplquicktime.h" 49#include "llmediaimplquicktime.h"
38#include "llmediaimplgstreamer.h" 50
39#if LL_LLMOZLIB_ENABLED 51#if LL_LLMOZLIB_ENABLED
40# include "llmediaimplllmozlib.h" 52# include "llmediaimplllmozlib.h"
41#endif 53#endif