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