00001
00002
00003
00004
00005
00006 #include "stdafx.h"
00007 #include "FdmApp.h"
00008 #include "vmsMediaConverter.h"
00009
00010 #ifdef _DEBUG
00011 #undef THIS_FILE
00012 static char THIS_FILE[]=__FILE__;
00013 #define new DEBUG_NEW
00014 #endif
00015
00016 vmsDLL vmsMediaConverter::m_dll;
00017 long vmsMediaConverter::m_cDllRefs = 0;
00018
00019 vmsMediaConverter::vmsMediaConverter()
00020 {
00021
00022 }
00023
00024 vmsMediaConverter::~vmsMediaConverter()
00025 {
00026
00027 }
00028
00029 BOOL vmsMediaConverter::ConvertMedia(LPCSTR pszSrcFile, LPCSTR pszDstFile, LPCSTR pszDstFormat,
00030 LPCSTR pszAudioCodec, int nAudioChannels, int nAudioBitrate,
00031 int nAudioRate,
00032 LPCSTR pszVideoCodec, int nVideoBitrate, int nVideoFrameRate,
00033 int nVideoFrameWidth, int nVideoFrameHeight,
00034 int* pnProgress, BOOL *pbCancel)
00035 {
00036 Initialize ();
00037
00038 typedef BOOL (*FNCM)(LPCSTR pszSrcFile, LPCSTR pszDstFile, LPCSTR pszDstFormat,
00039 LPCSTR pszAudioCodec, int nAudioChannels, int nAudioBitrate,
00040 int nAudioRate,
00041 LPCSTR pszVideoCodec, int nVideoBitrate, int nVideoFrameRate,
00042 int nVideoFrameWidth, int nVideoFrameHeight,
00043 int* pnProgress, BOOL *pbCancel);
00044
00045 FNCM pfn = (FNCM) m_dll.GetProcAddress ("ConvertMediaFile");
00046
00047 BOOL bRes = FALSE;
00048
00049 if (pfn)
00050 {
00051 bRes = pfn (pszSrcFile, pszDstFile, pszDstFormat, pszAudioCodec, nAudioChannels,
00052 nAudioBitrate, nAudioRate, pszVideoCodec, nVideoBitrate, nVideoFrameRate,
00053 nVideoFrameWidth, nVideoFrameHeight, pnProgress, pbCancel);
00054 }
00055
00056 Shutdown ();
00057
00058 return bRes;
00059 }
00060
00061 void vmsMediaConverter::Initialize()
00062 {
00063 InterlockedIncrement (&m_cDllRefs);
00064
00065 if (m_dll.is_Loaded () == false)
00066 {
00067 m_dll.Load ("mediaconverter.dll");
00068 typedef void (*FNI)();
00069 FNI pfn = (FNI) m_dll.GetProcAddress ("Initialize");
00070 if (pfn)
00071 pfn ();
00072 }
00073 }
00074
00075 void vmsMediaConverter::Shutdown()
00076 {
00077 InterlockedDecrement (&m_cDllRefs);
00078
00079 if (m_cDllRefs == 0)
00080 {
00081 typedef void (*FNS)();
00082 FNS pfn = (FNS) m_dll.GetProcAddress ("Shutdown");
00083 if (pfn)
00084 pfn ();
00085 m_dll.Free ();
00086 }
00087 }