00001
00032 #include "linden_common.h"
00033
00034 #if LL_GSTREAMER_ENABLED
00035
00036 extern "C" {
00037 #include <gst/gst.h>
00038
00039 #include <apr-1/apr_pools.h>
00040 #include <apr-1/apr_dso.h>
00041 }
00042
00043 #include "llmediaimplgstreamer.h"
00044
00045 #define LL_GST_SYM(REQ, GSTSYM, RTN, ...) RTN (*ll##GSTSYM)(__VA_ARGS__) = NULL
00046 #include "llmediaimplgstreamer_syms_raw.inc"
00047 #include "llmediaimplgstreamer_syms_rawa.inc"
00048 #include "llmediaimplgstreamer_syms_rawv.inc"
00049 #undef LL_GST_SYM
00050
00051
00052 static bool sSymsGrabbed = false;
00053 static apr_pool_t *sSymGSTDSOMemoryPool = NULL;
00054 static apr_dso_handle_t *sSymGSTDSOHandleG = NULL;
00055 static apr_dso_handle_t *sSymGSTDSOHandleV = NULL;
00056 static apr_dso_handle_t *sSymGSTDSOHandleA = NULL;
00057
00058
00059 bool grab_gst_syms(std::string gst_dso_name,
00060 std::string gst_dso_name_vid,
00061 std::string gst_dso_name_aud)
00062 {
00063 if (sSymsGrabbed)
00064 {
00065
00066 return TRUE;
00067 }
00068
00069 bool sym_error = false;
00070 bool rtn = false;
00071 apr_status_t rv;
00072 apr_dso_handle_t *sSymGSTDSOHandle = NULL;
00073
00074 #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)
00075
00076
00077 apr_pool_create(&sSymGSTDSOMemoryPool, NULL);
00078
00079 if ( APR_SUCCESS == (rv = apr_dso_load(&sSymGSTDSOHandle,
00080 gst_dso_name.c_str(),
00081 sSymGSTDSOMemoryPool) ))
00082 {
00083 llinfos << "Found DSO: " << gst_dso_name << llendl;
00084 #include "llmediaimplgstreamer_syms_raw.inc"
00085
00086 if ( sSymGSTDSOHandle )
00087 {
00088 sSymGSTDSOHandleG = sSymGSTDSOHandle;
00089 sSymGSTDSOHandle = NULL;
00090 }
00091
00092 if ( APR_SUCCESS == (rv = apr_dso_load(&sSymGSTDSOHandle,
00093 gst_dso_name_aud.c_str(),
00094 sSymGSTDSOMemoryPool) ))
00095 {
00096 llinfos << "Found DSO: " << gst_dso_name_aud << llendl;
00097 #include "llmediaimplgstreamer_syms_rawa.inc"
00098
00099 if ( sSymGSTDSOHandle )
00100 {
00101 sSymGSTDSOHandleA = sSymGSTDSOHandle;
00102 sSymGSTDSOHandle = NULL;
00103 }
00104
00105 if ( APR_SUCCESS ==
00106 (rv = apr_dso_load(&sSymGSTDSOHandle,
00107 gst_dso_name_vid.c_str(),
00108 sSymGSTDSOMemoryPool) ))
00109 {
00110 llinfos << "Found DSO: " << gst_dso_name_vid << llendl;
00111 #include "llmediaimplgstreamer_syms_rawv.inc"
00112 }
00113 else
00114 {
00115 llwarns << "Couldn't load DSO: "
00116 << gst_dso_name_vid << llendl;
00117 rtn = false;
00118 }
00119 }
00120 else
00121 {
00122 llwarns << "Couldn't load DSO: "
00123 << gst_dso_name_aud << llendl;
00124 rtn = false;
00125 }
00126
00127 rtn = !sym_error;
00128 }
00129 else
00130 {
00131 llwarns << "Couldn't load DSO: " << gst_dso_name << llendl;
00132 rtn = false;
00133 }
00134
00135 if (sym_error)
00136 {
00137 llwarns << "Failed to find necessary symbols in GStreamer libraries." << llendl;
00138 }
00139
00140 if ( sSymGSTDSOHandle )
00141 {
00142 sSymGSTDSOHandleV = sSymGSTDSOHandle;
00143 sSymGSTDSOHandle = NULL;
00144 }
00145 #undef LL_GST_SYM
00146
00147 sSymsGrabbed = !!rtn;
00148 return rtn;
00149 }
00150
00151
00152 void ungrab_gst_syms()
00153 {
00154
00155
00156
00157 if ( sSymGSTDSOHandleG )
00158 {
00159 apr_dso_unload(sSymGSTDSOHandleG);
00160 sSymGSTDSOHandleG = NULL;
00161 }
00162
00163 if ( sSymGSTDSOHandleA )
00164 {
00165 apr_dso_unload(sSymGSTDSOHandleA);
00166 sSymGSTDSOHandleA = NULL;
00167 }
00168
00169 if ( sSymGSTDSOHandleV )
00170 {
00171 apr_dso_unload(sSymGSTDSOHandleV);
00172 sSymGSTDSOHandleV = NULL;
00173 }
00174
00175 if ( sSymGSTDSOMemoryPool )
00176 {
00177 apr_pool_destroy(sSymGSTDSOMemoryPool);
00178 sSymGSTDSOMemoryPool = NULL;
00179 }
00180
00181
00182 #define LL_GST_SYM(REQ, GSTSYM, RTN, ...) do{ll##GSTSYM = NULL;}while(0)
00183 #include "llmediaimplgstreamer_syms_raw.inc"
00184 #include "llmediaimplgstreamer_syms_rawa.inc"
00185 #include "llmediaimplgstreamer_syms_rawv.inc"
00186 #undef LL_GST_SYM
00187
00188 sSymsGrabbed = false;
00189 }
00190
00191
00192 #endif // LL_GSTREAMER_ENABLED