bool get_functions_address_free_decoder(ISVCDecoder* pDecoder) { if(!g_at264Module) return false; LPDestroyWelsCSDecoder pfuncDestroySWDec = (LPDestroyWelsCSDecoder)GetProcessAddress(g_at264Module, "DestroySVCDecoder"); LPDestroyVHDController pfuncDestroyHWDec = (LPDestroyVHDController)GetProcessAddress(g_at264Module, "DestroySVCVHDController"); if(pfuncDestroySWDec != NULL) { pfuncDestroySWDec( pDecoder ); } else { return false; } if(pfuncDestroyHWDec != NULL) { pfuncDestroyHWDec(); } else { return false; } return true; }
bool get_functions_address_create_decoder(ISVCDecoder** ppDecoder) { if(!g_at264Module) return false; LPCreateWelsCSDecoder pfuncCreateSWDec = (LPCreateWelsCSDecoder)GetProcessAddress(g_at264Module, "CreateSVCDecoder"); LPCreateVHDController pfuncCreateHWDec = (LPCreateVHDController)GetProcessAddress(g_at264Module, "CreateSVCVHDController"); if(pfuncCreateSWDec != NULL) { pfuncCreateSWDec( ppDecoder ); } else { return false; } if(pfuncCreateHWDec != NULL) { pfuncCreateHWDec(); } else { return false; } return true; }
int32_t WelsEncBundleDestroyEncoder (ISVCEncoder* pEncoder) { if (!g_at264Module) return 1; LPDestroyWelsCSEncoder pfuncDestroyCSEnc = (LPDestroyWelsCSEncoder)GetProcessAddress (g_at264Module, "DestroySVCEncoder"); if (pfuncDestroyCSEnc != NULL) { pfuncDestroyCSEnc (pEncoder); return 0; } else return 1; }
int32_t WelsEncBundleCreateEncoder (ISVCEncoder** ppEncoder) { if (!g_at264Module) return 1; LPCreateWelsCSEncoder pfuncCreateCSEnc = (LPCreateWelsCSEncoder)GetProcessAddress (g_at264Module, "CreateSVCEncoder"); if (pfuncCreateCSEnc != NULL) { return (pfuncCreateCSEnc (ppEncoder)); } return 1; }
void* CWelsLib::QueryFunction (const str_t* pName) { void* pFunc = NULL; if (m_pVpLib) { #if defined(WIN32) HMODULE shModule = (HMODULE)m_pVpLib; pFunc = (void*)GetProcAddress (shModule, pName); #elif defined(MACOS) CFBundleRef shModule = (CFBundleRef)m_pVpLib; pFunc = (void*)GetProcessAddress (shModule, pName); #elif defined(__GNUC__) void* shModule = m_pVpLib; pFunc = (void*)dlsym (shModule, pName); if (pFunc == NULL) printf ("dlsym %s iRet=%p, err=%s\n", shModule, pFunc, dlerror()); #endif } return pFunc; }
int32_t CWelsCodecTrace::LoadWelsTraceModule() { #ifdef NO_DYNAMIC_VP m_fpDebugTrace = welsStderrTrace<WELS_LOG_DEBUG>; m_fpInfoTrace = welsStderrTrace<WELS_LOG_INFO>; m_fpWarnTrace = welsStderrTrace<WELS_LOG_WARNING>; m_fpErrorTrace = welsStderrTrace<WELS_LOG_ERROR>; #else #if defined WIN32 HMODULE hHandle = ::LoadLibrary("welstrace.dll"); // HMODULE handle = ::LoadLibrary("contrace.dll"); // for c7 trace if ( NULL == hHandle ) return -1; CHAR chPath[ _MAX_PATH]= {0}; GetModuleFileName( (HMODULE)hHandle, chPath, _MAX_PATH); m_hTraceHandle = ::LoadLibrary(chPath); OutputDebugStringA(chPath); if( m_hTraceHandle) { m_fpDebugTrace = ( CM_WELS_TRACE)::GetProcAddress( ( HMODULE)m_hTraceHandle, "WELSDEBUGA"); m_fpInfoTrace = ( CM_WELS_TRACE)::GetProcAddress( ( HMODULE)m_hTraceHandle, "WELSINFOA"); m_fpWarnTrace = ( CM_WELS_TRACE)::GetProcAddress( ( HMODULE)m_hTraceHandle, "WELSWARNA"); m_fpErrorTrace = ( CM_WELS_TRACE)::GetProcAddress( ( HMODULE)m_hTraceHandle, "WELSERRORA"); } // coverity scan uninitial if (hHandle != NULL) { ::FreeLibrary(hHandle); hHandle = NULL; } #elif defined MACOS m_hTraceHandle = LoadLibrary("welstrace.bundle"); if(m_hTraceHandle) { m_fpDebugTrace = ( CM_WELS_TRACE)GetProcessAddress( (CFBundleRef)m_hTraceHandle, "WELSDEBUG2"); m_fpInfoTrace = ( CM_WELS_TRACE)GetProcessAddress( (CFBundleRef)m_hTraceHandle, "WELSINFO2"); m_fpWarnTrace = ( CM_WELS_TRACE)GetProcessAddress( (CFBundleRef)m_hTraceHandle, "WELSWARN2"); m_fpErrorTrace = ( CM_WELS_TRACE)GetProcessAddress( (CFBundleRef)m_hTraceHandle, "WELSERROR2"); } #elif defined LINUX || defined SOLARIS || defined UNIX //#else // CCmString cmPath; str_t chPath[255]= {0}; Dl_info sDlInfo; static int iMmTPAddress; dladdr( &iMmTPAddress, &sDlInfo); if (NULL == sDlInfo.dli_fname) return -1; WelsStrncpy(chPath, 255, (const str_t*)sDlInfo.dli_fname, WelsStrnlen((const str_t*)sDlInfo.dli_fname, 255)); str_t* p = strrchr(chPath, '/');//confirmed_safe_unsafe_usage if ( NULL == p ) return -1; const int iLenTraceName = WelsStrnlen((const str_t*)"/libwelstrace.so", 15); const int iCurPos = p - chPath; if ( iCurPos + iLenTraceName < 255 ) WelsStrncpy(p, 254-iCurPos, (const str_t*)"/libwelstrace.so", iLenTraceName ); else return -1; m_hTraceHandle = dlopen( chPath, RTLD_LAZY); if (m_hTraceHandle == NULL) { WelsFileHandle* fp = WelsFopen((const str_t*)"/tmp/trace.txt", (const str_t*)"a"); if(fp) { fprintf(fp, "welsCodecTrace::welsCodecTrace ===> dlopen %s fail, %s\n", chPath, dlerror()); WelsFclose(fp); } return -1; } if (m_hTraceHandle) { m_fpDebugTrace = ( CM_WELS_TRACE)dlsym( m_hTraceHandle, "WELSDEBUG2"); m_fpInfoTrace = ( CM_WELS_TRACE)dlsym( m_hTraceHandle, "WELSINFO2"); m_fpWarnTrace = ( CM_WELS_TRACE)dlsym( m_hTraceHandle, "WELSWARN2"); m_fpErrorTrace = ( CM_WELS_TRACE)dlsym( m_hTraceHandle, "WELSERROR2"); if(m_fpDebugTrace == NULL) { WelsFileHandle* fp = WelsFopen((const str_t*)"/tmp/trace.txt", (const str_t*)"a"); if(fp) { printf("welsCodecTrace::welsCodecTrace ===> dlsym failed (WELSDEBUG2) , dlerror = %s\n", dlerror()); WelsFclose(fp); } return -1; } } #endif #endif // NO_DYNAMIC_VP return 0; }