aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmedia/llmediaimplgstreamer_syms.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:04 -0500
committerJacek Antonelli2008-08-15 23:45:04 -0500
commit117e22047c5752352342d64e3fb7ce00a4eb8113 (patch)
treee32de2cfba0dda8705ae528fcd1fbe23ba075685 /linden/indra/llmedia/llmediaimplgstreamer_syms.cpp
parentSecond Life viewer sources 1.18.0.6 (diff)
downloadmeta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.zip
meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.tar.gz
meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.tar.bz2
meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.tar.xz
Second Life viewer sources 1.18.1.2
Diffstat (limited to 'linden/indra/llmedia/llmediaimplgstreamer_syms.cpp')
-rw-r--r--linden/indra/llmedia/llmediaimplgstreamer_syms.cpp189
1 files changed, 189 insertions, 0 deletions
diff --git a/linden/indra/llmedia/llmediaimplgstreamer_syms.cpp b/linden/indra/llmedia/llmediaimplgstreamer_syms.cpp
new file mode 100644
index 0000000..76f62e1
--- /dev/null
+++ b/linden/indra/llmedia/llmediaimplgstreamer_syms.cpp
@@ -0,0 +1,189 @@
1/**
2 * @file llmediaimplgstreamer_syms.cpp
3 * @brief dynamic GStreamer symbol-grabbing code
4 *
5 * Copyright (c) 2007-2007, Linden Research, Inc.
6 *
7 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement
11 * ("Other License"), formally executed by you and Linden Lab. Terms of
12 * the GPL can be found in doc/GPL-license.txt in this distribution, or
13 * online at http://secondlife.com/developers/opensource/gplv2
14 *
15 * There are special exceptions to the terms and conditions of the GPL as
16 * it is applied to this Source Code. View the full text of the exception
17 * in the file doc/FLOSS-exception.txt in this software distribution, or
18 * online at http://secondlife.com/developers/opensource/flossexception
19 *
20 * By copying, modifying or distributing this software, you acknowledge
21 * that you have read and understood your obligations described above,
22 * and agree to abide by those obligations.
23 *
24 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
25 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
26 * COMPLETENESS OR PERFORMANCE.
27 */
28
29#include "linden_common.h"
30
31#if LL_GSTREAMER_ENABLED
32
33extern "C" {
34#include <gst/gst.h>
35
36#include <apr-1/apr_pools.h>
37#include <apr-1/apr_dso.h>
38}
39
40#include "llmediaimplgstreamer.h"
41
42#define LL_GST_SYM(REQ, GSTSYM, RTN, ...) RTN (*ll##GSTSYM)(__VA_ARGS__) = NULL
43#include "llmediaimplgstreamer_syms_raw.inc"
44#include "llmediaimplgstreamer_syms_rawa.inc"
45#include "llmediaimplgstreamer_syms_rawv.inc"
46#undef LL_GST_SYM
47
48
49static bool sSymsGrabbed = false;
50static apr_pool_t *sSymGSTDSOMemoryPool = NULL;
51static apr_dso_handle_t *sSymGSTDSOHandleG = NULL;
52static apr_dso_handle_t *sSymGSTDSOHandleV = NULL;
53static apr_dso_handle_t *sSymGSTDSOHandleA = NULL;
54
55
56bool grab_gst_syms(std::string gst_dso_name,
57 std::string gst_dso_name_vid,
58 std::string gst_dso_name_aud)
59{
60 if (sSymsGrabbed)
61 {
62 // already have grabbed good syms
63 return TRUE;
64 }
65
66 bool sym_error = false;
67 bool rtn = false;
68 apr_status_t rv;
69 apr_dso_handle_t *sSymGSTDSOHandle = NULL;
70
71#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) {llwarns << "Failed to grab symbol: " << #GSTSYM << llendl; if (REQ) sym_error = true;} else llinfos << "grabbed symbol: " << #GSTSYM << " from " << (void*)ll##GSTSYM << llendl;}while(0)
72
73 //attempt to load the shared libraries
74 apr_pool_create(&sSymGSTDSOMemoryPool, NULL);
75
76 if ( APR_SUCCESS == (rv = apr_dso_load(&sSymGSTDSOHandle,
77 gst_dso_name.c_str(),
78 sSymGSTDSOMemoryPool) ))
79 {
80 llinfos << "Found DSO: " << gst_dso_name << llendl;
81#include "llmediaimplgstreamer_syms_raw.inc"
82
83 if ( sSymGSTDSOHandle )
84 {
85 sSymGSTDSOHandleG = sSymGSTDSOHandle;
86 sSymGSTDSOHandle = NULL;
87 }
88
89 if ( APR_SUCCESS == (rv = apr_dso_load(&sSymGSTDSOHandle,
90 gst_dso_name_aud.c_str(),
91 sSymGSTDSOMemoryPool) ))
92 {
93 llinfos << "Found DSO: " << gst_dso_name_aud << llendl;
94#include "llmediaimplgstreamer_syms_rawa.inc"
95
96 if ( sSymGSTDSOHandle )
97 {
98 sSymGSTDSOHandleA = sSymGSTDSOHandle;
99 sSymGSTDSOHandle = NULL;
100 }
101
102 if ( APR_SUCCESS ==
103 (rv = apr_dso_load(&sSymGSTDSOHandle,
104 gst_dso_name_vid.c_str(),
105 sSymGSTDSOMemoryPool) ))
106 {
107 llinfos << "Found DSO: " << gst_dso_name_vid << llendl;
108#include "llmediaimplgstreamer_syms_rawv.inc"
109 }
110 else
111 {
112 llwarns << "Couldn't load DSO: "
113 << gst_dso_name_vid << llendl;
114 rtn = false; // failure
115 }
116 }
117 else
118 {
119 llwarns << "Couldn't load DSO: "
120 << gst_dso_name_aud << llendl;
121 rtn = false; // failure
122 }
123
124 rtn = !sym_error;
125 }
126 else
127 {
128 llwarns << "Couldn't load DSO: " << gst_dso_name << llendl;
129 rtn = false; // failure
130 }
131
132 if (sym_error)
133 {
134 llwarns << "Failed to find necessary symbols in GStreamer libraries." << llendl;
135 }
136
137 if ( sSymGSTDSOHandle )
138 {
139 sSymGSTDSOHandleV = sSymGSTDSOHandle;
140 sSymGSTDSOHandle = NULL;
141 }
142#undef LL_GST_SYM
143
144 sSymsGrabbed = !!rtn;
145 return rtn;
146}
147
148
149void ungrab_gst_syms()
150{
151 // should be safe to call regardless of whether we've
152 // actually grabbed syms.
153
154 if ( sSymGSTDSOHandleG )
155 {
156 apr_dso_unload(sSymGSTDSOHandleG);
157 sSymGSTDSOHandleG = NULL;
158 }
159
160 if ( sSymGSTDSOHandleA )
161 {
162 apr_dso_unload(sSymGSTDSOHandleA);
163 sSymGSTDSOHandleA = NULL;
164 }
165
166 if ( sSymGSTDSOHandleV )
167 {
168 apr_dso_unload(sSymGSTDSOHandleV);
169 sSymGSTDSOHandleV = NULL;
170 }
171
172 if ( sSymGSTDSOMemoryPool )
173 {
174 apr_pool_destroy(sSymGSTDSOMemoryPool);
175 sSymGSTDSOMemoryPool = NULL;
176 }
177
178 // NULL-out all of the symbols we'd grabbed
179#define LL_GST_SYM(REQ, GSTSYM, RTN, ...) do{ll##GSTSYM = NULL;}while(0)
180#include "llmediaimplgstreamer_syms_raw.inc"
181#include "llmediaimplgstreamer_syms_rawa.inc"
182#include "llmediaimplgstreamer_syms_rawv.inc"
183#undef LL_GST_SYM
184
185 sSymsGrabbed = false;
186}
187
188
189#endif // LL_GSTREAMER_ENABLED