using DirectShowLib;\r
+using NLog;\r
using System;\r
using System.IO;\r
using System.Reflection;\r
Codec_VCR1,\r
Codec_Snow,\r
Codec_FFV1,\r
- Codec_v210,\r
+ Codec_v210//,\r
//Codec_NB // Number of entrys (do not use when dynamically linking)\r
};\r
\r
/// </summary>\r
public static object threadSync = new object();\r
\r
+ private static readonly Logger logger = LogManager.GetCurrentClassLogger();\r
+\r
/// <summary>\r
/// Gets the IBaseFilter interface for the LAVVideo filter - you must release this when finished using it with Marshal.ReleaseComObject\r
/// </summary>\r
object oSettings = null;\r
IBaseFilter filter = null;\r
string currentDir = Directory.GetCurrentDirectory();\r
+\r
// we have the filters in the subdirectory 'codecs' of the running app\r
string path = Path.Combine(Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath), subDir);\r
\r
- try {\r
- // we need to be in the filter directory since it will load a bunch \r
- // of other dlls that are there, and they won't resolve otherwise\r
- Directory.SetCurrentDirectory(path);\r
+ if (Directory.Exists(path)) { \r
+ try {\r
+ // we need to be in the filter directory since it will load a bunch \r
+ // of other dlls that are there, and they won't resolve otherwise\r
+ Directory.SetCurrentDirectory(path);\r
\r
- path = Path.Combine(path, "LAVVideo.ax");\r
+ path = Path.Combine(path, "LAVVideo.ax");\r
\r
- IntPtr lavVideoDll = LoadLibrary(path);\r
- IntPtr proc = GetProcAddress(lavVideoDll, "DllGetClassObject");\r
+ IntPtr lavVideoDll = LoadLibrary(path);\r
+ IntPtr proc = GetProcAddress(lavVideoDll, "DllGetClassObject");\r
\r
- var getClassObject = (LavVideoDllGetClassObject)Marshal.GetDelegateForFunctionPointer(proc, typeof(LavVideoDllGetClassObject));\r
+ var getClassObject = (LavVideoDllGetClassObject)Marshal.GetDelegateForFunctionPointer(proc, typeof(LavVideoDllGetClassObject));\r
\r
- int hr = getClassObject(ILAVVIDEO_GUID, IUNKNOWN_GUID, out oFactory);\r
+ int hr = getClassObject(ILAVVIDEO_GUID, IUNKNOWN_GUID, out oFactory);\r
\r
- IClassFactory factory = oFactory as IClassFactory;\r
+ IClassFactory factory = oFactory as IClassFactory;\r
\r
- if (factory == null) {\r
- if (oFactory != null) Marshal.ReleaseComObject(oFactory);\r
- throw new Exception("Could not QueryInterface for the IClassFactory interface");\r
- }\r
+ if (factory == null) {\r
+ if (oFactory != null) Marshal.ReleaseComObject(oFactory);\r
+ throw new Exception("Could not QueryInterface for the IClassFactory interface");\r
+ }\r
\r
- Guid baseFilterGUID = typeof(IBaseFilter).GUID;\r
- hr = factory.CreateInstance(null, baseFilterGUID, out oFilter);\r
+ Guid baseFilterGUID = typeof(IBaseFilter).GUID;\r
+ hr = factory.CreateInstance(null, baseFilterGUID, out oFilter);\r
\r
- filter = oFilter as IBaseFilter;\r
- if (filter == null) {\r
- if (oFilter != null) Marshal.ReleaseComObject(oFilter);\r
- throw new Exception("Could not QueryInterface for the IBaseFilter interface");\r
- }\r
+ filter = oFilter as IBaseFilter;\r
+ if (filter == null) {\r
+ if (oFilter != null) Marshal.ReleaseComObject(oFilter);\r
+ throw new Exception("Could not QueryInterface for the IBaseFilter interface");\r
+ }\r
\r
- Guid videoSettingsGUID = new Guid("{FA40D6E9-4D38-4761-ADD2-71A9EC5FD32F}");\r
- hr = factory.CreateInstance(null, videoSettingsGUID, out oSettings);\r
+ Guid videoSettingsGUID = new Guid("{FA40D6E9-4D38-4761-ADD2-71A9EC5FD32F}");\r
+ hr = factory.CreateInstance(null, videoSettingsGUID, out oSettings);\r
\r
- settings = oSettings as ILAVVideoSettings;\r
- if (filter == null) {\r
- if (oSettings != null) Marshal.ReleaseComObject(oSettings);\r
- throw new Exception("Could not QueryInterface for the ILAVVideoSettings interface");\r
- }\r
+ settings = oSettings as ILAVVideoSettings;\r
+ if (filter == null) {\r
+ if (oSettings != null) Marshal.ReleaseComObject(oSettings);\r
+ throw new Exception("Could not QueryInterface for the ILAVVideoSettings interface");\r
+ }\r
\r
- }\r
- catch {\r
- // if somehting bad happens give back the path since we will rethrow the exception ater cleanup\r
- Directory.SetCurrentDirectory(currentDir);\r
+ }\r
+ catch {\r
+ // if somehting bad happens give back the path since we will rethrow the exception ater cleanup\r
+ Directory.SetCurrentDirectory(currentDir);\r
\r
- if (oFactory != null)\r
- Marshal.FinalReleaseComObject(oFactory);\r
+ if (oFactory != null)\r
+ Marshal.FinalReleaseComObject(oFactory);\r
\r
- if (oFilter != null)\r
- Marshal.FinalReleaseComObject(oFilter);\r
+ if (oFilter != null)\r
+ Marshal.FinalReleaseComObject(oFilter);\r
\r
- if (oSettings != null)\r
- Marshal.FinalReleaseComObject(oSettings);\r
- }\r
- finally {\r
- // even if nothing bad happens we need to clenup and give back to the original path\r
- Directory.SetCurrentDirectory(currentDir);\r
+ if (oSettings != null)\r
+ Marshal.FinalReleaseComObject(oSettings);\r
+ }\r
+ finally {\r
+ // even if nothing bad happens we need to clenup and give back to the original path\r
+ Directory.SetCurrentDirectory(currentDir);\r
\r
- if (oFactory != null)\r
- Marshal.FinalReleaseComObject(oFactory);\r
+ if (oFactory != null)\r
+ Marshal.FinalReleaseComObject(oFactory);\r
\r
+ }\r
+ }\r
+ else\r
+ {\r
+ logger.Debug("Path does not exists: " + path);\r
}\r
\r
return filter;\r
string currentDir = Directory.GetCurrentDirectory();\r
// we have the filters in the subdirectory 'codecs' of the running app\r
string path = Path.Combine(Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath), subDir);\r
-\r
- try {\r
- // we need to be in the filter directory since it will load a bunch \r
- // of other dlls that are there, and they won't resolve otherwise\r
- Directory.SetCurrentDirectory(path);\r
-\r
- path = Path.Combine(path, "LAVAudio.ax");\r
-\r
- IntPtr lavVideoDll = LoadLibrary(path);\r
- IntPtr proc = GetProcAddress(lavVideoDll, "DllGetClassObject");\r
-\r
- var getClassObject = (LavVideoDllGetClassObject)Marshal.GetDelegateForFunctionPointer(proc, typeof(LavVideoDllGetClassObject));\r
-\r
- int hr = getClassObject(ILAVAUDIO_GUID, IUNKNOWN_GUID, out oFactory);\r
-\r
- IClassFactory factory = oFactory as IClassFactory;\r
-\r
- if (factory == null) {\r
- if (oFactory != null) Marshal.ReleaseComObject(oFactory);\r
- throw new Exception("Could not QueryInterface for the IClassFactory interface");\r
+ if (Directory.Exists(path))\r
+ {\r
+ try\r
+ {\r
+ // we need to be in the filter directory since it will load a bunch \r
+ // of other dlls that are there, and they won't resolve otherwise\r
+ Directory.SetCurrentDirectory(path);\r
+\r
+ path = Path.Combine(path, "LAVAudio.ax");\r
+\r
+ IntPtr lavVideoDll = LoadLibrary(path);\r
+ IntPtr proc = GetProcAddress(lavVideoDll, "DllGetClassObject");\r
+\r
+ var getClassObject = (LavVideoDllGetClassObject)Marshal.GetDelegateForFunctionPointer(proc, typeof(LavVideoDllGetClassObject));\r
+\r
+ int hr = getClassObject(ILAVAUDIO_GUID, IUNKNOWN_GUID, out oFactory);\r
+\r
+ IClassFactory factory = oFactory as IClassFactory;\r
+\r
+ if (factory == null)\r
+ {\r
+ if (oFactory != null) Marshal.ReleaseComObject(oFactory);\r
+ throw new Exception("Could not QueryInterface for the IClassFactory interface");\r
+ }\r
+\r
+ Guid baseFilterGUID = typeof(IBaseFilter).GUID;\r
+ hr = factory.CreateInstance(null, baseFilterGUID, out oFilter);\r
+\r
+ filter = oFilter as IBaseFilter;\r
+ if (filter == null)\r
+ {\r
+ if (oFilter != null) Marshal.ReleaseComObject(oFilter);\r
+ throw new Exception("Could not QueryInterface for the IBaseFilter interface");\r
+ }\r
+\r
+ Guid audioSettingsGUID = typeof(ILAVAudioSettings).GUID;\r
+ hr = factory.CreateInstance(null, audioSettingsGUID, out oSettings);\r
+\r
+ settings = oSettings as ILAVAudioSettings;\r
+ if (filter == null)\r
+ {\r
+ if (oSettings != null) Marshal.ReleaseComObject(oSettings);\r
+ throw new Exception("Could not QueryInterface for the ILAVAudioSettings interface");\r
+ }\r
+\r
+ Guid audioStatusGUID = typeof(ILAVAudioStatus).GUID;\r
+ hr = factory.CreateInstance(null, audioStatusGUID, out oStatus);\r
+\r
+ status = oStatus as ILAVAudioStatus;\r
+ if (filter == null)\r
+ {\r
+ if (oStatus != null) Marshal.ReleaseComObject(oStatus);\r
+ throw new Exception("Could not QueryInterface for the ILAVAudioStatus interface");\r
+ }\r
}\r
+ catch\r
+ {\r
+ // if somehting bad happens give back the path since we will rethrow the exception ater cleanup\r
+ Directory.SetCurrentDirectory(currentDir);\r
\r
- Guid baseFilterGUID = typeof(IBaseFilter).GUID;\r
- hr = factory.CreateInstance(null, baseFilterGUID, out oFilter);\r
+ if (oFactory != null)\r
+ Marshal.FinalReleaseComObject(oFactory);\r
\r
- filter = oFilter as IBaseFilter;\r
- if (filter == null) {\r
- if (oFilter != null) Marshal.ReleaseComObject(oFilter);\r
- throw new Exception("Could not QueryInterface for the IBaseFilter interface");\r
- }\r
+ if (oFilter != null)\r
+ Marshal.FinalReleaseComObject(oFilter);\r
\r
- Guid audioSettingsGUID = typeof(ILAVAudioSettings).GUID;\r
- hr = factory.CreateInstance(null, audioSettingsGUID, out oSettings);\r
+ if (oStatus != null)\r
+ Marshal.FinalReleaseComObject(oStatus);\r
\r
- settings = oSettings as ILAVAudioSettings;\r
- if (filter == null) {\r
- if (oSettings != null) Marshal.ReleaseComObject(oSettings);\r
- throw new Exception("Could not QueryInterface for the ILAVAudioSettings interface");\r
+ if (oSettings != null)\r
+ Marshal.FinalReleaseComObject(oSettings);\r
}\r
+ finally\r
+ {\r
+ // even if nothing bad happens we need to clenup and give back to the original path\r
+ Directory.SetCurrentDirectory(currentDir);\r
\r
- Guid audioStatusGUID = typeof(ILAVAudioStatus).GUID;\r
- hr = factory.CreateInstance(null, audioStatusGUID, out oStatus);\r
+ if (oFactory != null)\r
+ Marshal.FinalReleaseComObject(oFactory);\r
\r
- status = oStatus as ILAVAudioStatus;\r
- if (filter == null) {\r
- if (oStatus != null) Marshal.ReleaseComObject(oStatus);\r
- throw new Exception("Could not QueryInterface for the ILAVAudioStatus interface");\r
}\r
}\r
- catch {\r
- // if somehting bad happens give back the path since we will rethrow the exception ater cleanup\r
- Directory.SetCurrentDirectory(currentDir);\r
-\r
- if (oFactory != null)\r
- Marshal.FinalReleaseComObject(oFactory);\r
-\r
- if (oFilter != null)\r
- Marshal.FinalReleaseComObject(oFilter);\r
-\r
- if (oStatus != null)\r
- Marshal.FinalReleaseComObject(oStatus);\r
-\r
- if (oSettings != null)\r
- Marshal.FinalReleaseComObject(oSettings);\r
- }\r
- finally {\r
- // even if nothing bad happens we need to clenup and give back to the original path\r
- Directory.SetCurrentDirectory(currentDir);\r
-\r
- if (oFactory != null)\r
- Marshal.FinalReleaseComObject(oFactory);\r
-\r
+ else\r
+ {\r
+ logger.Debug("Path does not exists: " + path);\r
}\r
\r
return filter;\r
// we have the filters in the subdirectory 'codecs' of the running app\r
string path = Path.Combine(Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath), subDir);\r
MessageBox.Show(path);\r
- try {\r
- // we need to be in the filter directory since it will load a bunch \r
- // of other dlls that are there, and they won't resolve otherwise\r
- Directory.SetCurrentDirectory(path);\r
+ if (Directory.Exists(path))\r
+ {\r
+ try\r
+ {\r
+ // we need to be in the filter directory since it will load a bunch \r
+ // of other dlls that are there, and they won't resolve otherwise\r
+ Directory.SetCurrentDirectory(path);\r
\r
- path = Path.Combine(path, "LAVSplitter.ax");\r
+ path = Path.Combine(path, "LAVSplitter.ax");\r
\r
- IntPtr lavVideoDll = LoadLibrary(path);\r
- IntPtr proc = GetProcAddress(lavVideoDll, "DllGetClassObject");\r
+ IntPtr lavVideoDll = LoadLibrary(path);\r
+ IntPtr proc = GetProcAddress(lavVideoDll, "DllGetClassObject");\r
\r
- var getClassObject = (LavVideoDllGetClassObject)Marshal.GetDelegateForFunctionPointer(proc, typeof(LavVideoDllGetClassObject));\r
+ var getClassObject = (LavVideoDllGetClassObject)Marshal.GetDelegateForFunctionPointer(proc, typeof(LavVideoDllGetClassObject));\r
\r
- int hr = getClassObject(ILAVSPLITTERSOURCE_GUID, IUNKNOWN_GUID, out oFactory);\r
+ int hr = getClassObject(ILAVSPLITTERSOURCE_GUID, IUNKNOWN_GUID, out oFactory);\r
\r
- IClassFactory factory = oFactory as IClassFactory;\r
+ IClassFactory factory = oFactory as IClassFactory;\r
\r
- if (factory == null) {\r
- if (oFactory != null) Marshal.ReleaseComObject(oFactory);\r
- throw new Exception("Could not QueryInterface for the IClassFactory interface");\r
- }\r
+ if (factory == null)\r
+ {\r
+ if (oFactory != null) Marshal.ReleaseComObject(oFactory);\r
+ throw new Exception("Could not QueryInterface for the IClassFactory interface");\r
+ }\r
\r
- Guid baseFilterGUID = typeof(IFileSourceFilter).GUID;\r
- hr = factory.CreateInstance(null, baseFilterGUID, out oFilter);\r
+ Guid baseFilterGUID = typeof(IFileSourceFilter).GUID;\r
+ hr = factory.CreateInstance(null, baseFilterGUID, out oFilter);\r
\r
- filter = oFilter as IFileSourceFilter;\r
- if (filter == null) {\r
- if (oFilter != null) Marshal.ReleaseComObject(oFilter);\r
- throw new Exception("Could not QueryInterface for the IFileSourceFilter interface");\r
- }\r
+ filter = oFilter as IFileSourceFilter;\r
+ if (filter == null)\r
+ {\r
+ if (oFilter != null) Marshal.ReleaseComObject(oFilter);\r
+ throw new Exception("Could not QueryInterface for the IFileSourceFilter interface");\r
+ }\r
\r
- Guid splitterSettingsGUID = typeof(ILAVSplitterSettings).GUID;\r
- hr = factory.CreateInstance(null, splitterSettingsGUID, out oSettings);\r
+ Guid splitterSettingsGUID = typeof(ILAVSplitterSettings).GUID;\r
+ hr = factory.CreateInstance(null, splitterSettingsGUID, out oSettings);\r
\r
- settings = oSettings as ILAVSplitterSettings;\r
- if (filter == null) {\r
- if (oSettings != null) Marshal.ReleaseComObject(oSettings);\r
- throw new Exception("Could not QueryInterface for the ILAVSplitterSettings interface");\r
- }\r
+ settings = oSettings as ILAVSplitterSettings;\r
+ if (filter == null)\r
+ {\r
+ if (oSettings != null) Marshal.ReleaseComObject(oSettings);\r
+ throw new Exception("Could not QueryInterface for the ILAVSplitterSettings interface");\r
+ }\r
\r
- }\r
- catch {\r
- // if somehting bad happens give back the path since we will rethrow the exception ater cleanup\r
- Directory.SetCurrentDirectory(currentDir);\r
+ }\r
+ catch\r
+ {\r
+ // if somehting bad happens give back the path since we will rethrow the exception ater cleanup\r
+ Directory.SetCurrentDirectory(currentDir);\r
\r
- if (oFactory != null)\r
- Marshal.FinalReleaseComObject(oFactory);\r
+ if (oFactory != null)\r
+ Marshal.FinalReleaseComObject(oFactory);\r
\r
- if (oFilter != null)\r
- Marshal.FinalReleaseComObject(oFilter);\r
+ if (oFilter != null)\r
+ Marshal.FinalReleaseComObject(oFilter);\r
\r
- if (oSettings != null)\r
- Marshal.FinalReleaseComObject(oSettings);\r
+ if (oSettings != null)\r
+ Marshal.FinalReleaseComObject(oSettings);\r
\r
- throw;\r
- }\r
- finally {\r
- // even if nothing bad happens we need to clenup and give back to the original path\r
- Directory.SetCurrentDirectory(currentDir);\r
+ throw;\r
+ }\r
+ finally\r
+ {\r
+ // even if nothing bad happens we need to clenup and give back to the original path\r
+ Directory.SetCurrentDirectory(currentDir);\r
\r
- if (oFactory != null)\r
- Marshal.FinalReleaseComObject(oFactory);\r
+ if (oFactory != null)\r
+ Marshal.FinalReleaseComObject(oFactory);\r
\r
+ }\r
+ }\r
+ else\r
+ {\r
+ logger.Debug("Path does not exists: " + path);\r
}\r
\r
return filter;\r
// we have the filters in the subdirectory 'codecs' of the running app\r
string path = Path.Combine(Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath), subDir);\r
\r
- try {\r
- // we need to be in the filter directory since it will load a bunch \r
- // of other dlls that are there, and they won't resolve otherwise\r
- Directory.SetCurrentDirectory(path);\r
+ if (Directory.Exists(path))\r
+ {\r
+ try\r
+ {\r
+ // we need to be in the filter directory since it will load a bunch \r
+ // of other dlls that are there, and they won't resolve otherwise\r
+ Directory.SetCurrentDirectory(path);\r
\r
- path = Path.Combine(path, "LAVSplitter.ax");\r
+ path = Path.Combine(path, "LAVSplitter.ax");\r
\r
- IntPtr lavVideoDll = LoadLibrary(path);\r
- IntPtr proc = GetProcAddress(lavVideoDll, "DllGetClassObject");\r
+ IntPtr lavVideoDll = LoadLibrary(path);\r
+ IntPtr proc = GetProcAddress(lavVideoDll, "DllGetClassObject");\r
\r
- var getClassObject = (LavVideoDllGetClassObject)Marshal.GetDelegateForFunctionPointer(proc, typeof(LavVideoDllGetClassObject));\r
+ var getClassObject = (LavVideoDllGetClassObject)Marshal.GetDelegateForFunctionPointer(proc, typeof(LavVideoDllGetClassObject));\r
\r
- int hr = getClassObject(ILAVSPLITTER_GUID, IUNKNOWN_GUID, out oFactory);\r
+ int hr = getClassObject(ILAVSPLITTER_GUID, IUNKNOWN_GUID, out oFactory);\r
\r
- IClassFactory factory = oFactory as IClassFactory;\r
+ IClassFactory factory = oFactory as IClassFactory;\r
\r
- if (factory == null) {\r
- if (oFactory != null) Marshal.ReleaseComObject(oFactory);\r
- throw new Exception("Could not QueryInterface for the IClassFactory interface");\r
- }\r
+ if (factory == null)\r
+ {\r
+ if (oFactory != null) Marshal.ReleaseComObject(oFactory);\r
+ throw new Exception("Could not QueryInterface for the IClassFactory interface");\r
+ }\r
\r
- Guid baseFilterGUID = typeof(IBaseFilter).GUID;\r
- hr = factory.CreateInstance(null, baseFilterGUID, out oFilter);\r
+ Guid baseFilterGUID = typeof(IBaseFilter).GUID;\r
+ hr = factory.CreateInstance(null, baseFilterGUID, out oFilter);\r
\r
- filter = oFilter as IBaseFilter;\r
- if (filter == null) {\r
- if (oFilter != null) Marshal.ReleaseComObject(oFilter);\r
- throw new Exception("Could not QueryInterface for the IBaseFilter interface");\r
- }\r
+ filter = oFilter as IBaseFilter;\r
+ if (filter == null)\r
+ {\r
+ if (oFilter != null) Marshal.ReleaseComObject(oFilter);\r
+ throw new Exception("Could not QueryInterface for the IBaseFilter interface");\r
+ }\r
\r
- Guid splitterSettingsGUID = typeof(ILAVSplitterSettings).GUID;\r
- hr = factory.CreateInstance(null, splitterSettingsGUID, out oSettings);\r
+ Guid splitterSettingsGUID = typeof(ILAVSplitterSettings).GUID;\r
+ hr = factory.CreateInstance(null, splitterSettingsGUID, out oSettings);\r
\r
- settings = oSettings as ILAVSplitterSettings;\r
- if (filter == null) {\r
- if (oSettings != null) Marshal.ReleaseComObject(oSettings);\r
- throw new Exception("Could not QueryInterface for the ILAVSplitterSettings interface");\r
- }\r
+ settings = oSettings as ILAVSplitterSettings;\r
+ if (filter == null)\r
+ {\r
+ if (oSettings != null) Marshal.ReleaseComObject(oSettings);\r
+ throw new Exception("Could not QueryInterface for the ILAVSplitterSettings interface");\r
+ }\r
\r
- }\r
- catch {\r
- // if somehting bad happens give back the path since we will rethrow the exception ater cleanup\r
- Directory.SetCurrentDirectory(currentDir);\r
+ }\r
+ catch\r
+ {\r
+ // if somehting bad happens give back the path since we will rethrow the exception ater cleanup\r
+ Directory.SetCurrentDirectory(currentDir);\r
\r
- if (oFactory != null)\r
- Marshal.FinalReleaseComObject(oFactory);\r
+ if (oFactory != null)\r
+ Marshal.FinalReleaseComObject(oFactory);\r
\r
- if (oFilter != null)\r
- Marshal.FinalReleaseComObject(oFilter);\r
+ if (oFilter != null)\r
+ Marshal.FinalReleaseComObject(oFilter);\r
\r
- if (oSettings != null)\r
- Marshal.FinalReleaseComObject(oSettings);\r
- }\r
- finally {\r
- // even if nothing bad happens we need to clenup and give back to the original path\r
- Directory.SetCurrentDirectory(currentDir);\r
+ if (oSettings != null)\r
+ Marshal.FinalReleaseComObject(oSettings);\r
+ }\r
+ finally\r
+ {\r
+ // even if nothing bad happens we need to clenup and give back to the original path\r
+ Directory.SetCurrentDirectory(currentDir);\r
\r
- if (oFactory != null)\r
- Marshal.FinalReleaseComObject(oFactory);\r
+ if (oFactory != null)\r
+ Marshal.FinalReleaseComObject(oFactory);\r
\r
+ }\r
}\r
-\r
+ else {\r
+ logger.Debug("Path does not exists: "+path);\r
+ }\r
+ \r
return filter;\r
}\r
}\r