April 23,2008
從C#中取得Filter中的IMediaSample
HRESULT GetIMediaSample(IMediaSample ** pSample)
{
*pSample = [your IMediaSample address]
return S_OK;
}
C#:
[PreserveSig]
int GetIMediaSample(out IMediaSample pSample)
兩邊有一邊宣告錯誤就會拿到NULL
C# 中使用範例:
IMediaSample sample = null;
if (GetIMediaSample(out sample)==0)
{
// do something with the sample you got
}
March 28,2008
Direct Show SDK安裝
由於實在不想灌多灌一個Platform SDK,選擇使用 DirectX SDK 9.0b裡面附的
由於使用VS2005,所以必需做一些修正。這邊順手把修正記錄一下
- 關於c:\program files\microsoft visual studio 8\vc\platformsdk\include\winnt.h(222) : error C2146: syntax error : missing ';' before identifier 'PVOID64' 錯誤訊息:
在 winnt.h 中加入 #define POINTER_64 __ptr64
- c:\program files\microsoft visual studio 8\vc\platformsdk\include\winnt.h(222) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
在project setting->C++項目下的command line裡加上 /wd4430 忽略之
- 修正Count及iDone兩個變數找不到的問題(重新宣告即可)
補充,DXSDK9裡附的filter的sample在編譯時需在 library 中增加 strmiids.lib 方可順利編譯
October 23,2006
Remove reference clock from Graph for full speed transcoding & preview
一般DirectShow Graph在運行的時候,會選定一個reference clock做為撥放的基準(一般會在render上)。但是同時要轉檔(transcoding)以及預覽(preview)轉換後的結果時,會變成transcoding的速度會被render限制住,這時候就需要把reference clock取消,讓transcoding全速執行。
// C# // use IMediaFilter::SetSyncSource |
July 21,2005
Debug directshow filter 的方法
In Visual Studio
- [F5] (Start Debug)
- Choose excutable: graphedit.exe
- Generate your filter in graphedit, and do something.
- Debug ....:P
July 19,2005
Filter 收不到 sample 的問題解決了
今天請了 leader 來幫忙看,算是解決了
不是我的 filter 有問題,是Windows內建的某 filter 有問題 ORZ
接上那個問題 filter ,接在它後面的 filter 完全收不到訊號
不過後來發現那邊比較像是接錯了,手動換成正確的 filter 就沒問題了
July 14,2005
IPin::ConnectionMediaType
If the pin is connected, this method copies the media type into the AM_MEDIA_TYPE structure specified by pmt. The caller must free the media type's format block. You can use the MicrosoftR Win32R CoTaskMemFree function, or the FreeMediaType helper function.
If the pin is not connected, this method clears the media type specified by pmt and returns an error code.
July 8,2005
DirectShow filter 寫作
- DirectShow filter is a win32 DLL.
- Use regsvr32.exe to register filter, then u can find it in GraphEdit.
- For building a DirectShow filter
- First, build base classes of DirectShow in the "DXSDK/Sample/DirectShow/BaseClasses".
- Include <streams.h> in BaseClasses dir.
- Use __stdcall in "calling convention" of VC++ project setting.
- Use multithread rulltime library.
- Add a xxx.def file into your project dir. The fomat should like below:
LIBRARY xxx.ax
EXPORTS
DllMain PRIVATE
DllGetClassObject PRIVATE
DllCanUnloadNow PRIVATE
DllRegisterServer PRIVATE
DllUnregisterServer PRIVATE - Link these libraries to project.
Debug:
Strmbasd.lib, Msvcrtd.lib, Winmm.lib
Release:
Strmbas.lib, Msvcrtd.lib, Winmm.lib
- Choose "ignore default library" in linker options of project setting.
- Declear a DLL Entry as follow
extern "C" BOOL WINAPI DllEntryPoint(HINSTANCE, ULONG, LPVOID);
BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
{
return DllEntryPoint((HINSTANCE)(hModule), dwReason, lpReserved);
}