Jiangsheng的CSDN Digest (Dec 2005)[3]

[入库:2006年2月23日] [更新:2007年3月24日]

本文简介:


Topic in microsoft.public.windowsmedia.sdk
how to use IWMWriterSink::OnDataUnit

Q:
I want to use IWMWriterSink::OnDataUnit() to get the
compressed sample. I modify the WMVNetWrite sample
application for test app, add the following:

IWMWriterNetSink->QurryInterfaceIID_IWMWriterSink,
m_pWriterSink)

m_pWriterSink->AllocateDataUnit();
m_pWriterSink->OnDataUnit();

then use the INSSBuffer::GetBufferAndLength(),but the
buffer content is null! I don't know how to use the
interface: If the OnDataUnit is a callback function, it
should be inherented by a class , otherwise , query
interface to get it, but where and how to call the
OnDataUnit function.
I am waiting for your help
regards
billy

A:
If you want to override OnDataUnit() method of a network sinker. You need to
do these steps:


1. Define a new class that inherits from IWMClientConnections2,
IWMRegisterCallback, IWMWriterNetworkSinkobject, and IWMAddressAccess2
interfaces.


For example:

class CMyWMNetSink : public IWMWriterNetworkSink,
public IWMClientConnections2,
public IWMRegisterCallback,
public IWMAddressAccess2

2. Besides declare the constructor and the destructor of this class,
you also need to declare all methods of the inherited interfaces.

For example:
virtual HRESULT STDMETHODCALLTYPE OnDataUnit(
/* [in] */ INSSBuffer __RPC_FAR *pDataUnit);
3. Implement the constructor of this class
a) Set the reference count to 1
b) Create an internal IWMWriterNetworkSink object m_pNetworkSink by
using WMCreateWriterNetworkSink() function.
4. Implement IUnknow interfaces.
a) Implement AddRef() and Release() method just like you implement
other COM interfaces.
b) Imlplement QueryInterface() method. Return "this" pointer when
querying the supported interfaces, such as IID_IWMWriterNetworkSink,
IID_IWMWriterSink and etc.
5. Implement all other interfaces this class supports. Pass the calls
to the internal IWMWriterNetworkSinker object. Add your own code before or
after the calls.
For example:
HRESULT STDMETHODCALLTYPE CMyWMNetSink::OnDataUnit(
/* [in] */ INSSBuffer __RPC_FAR *pDataUnit)
{
////////////////////////////////////////////
// You can add you code here
////////////////////////////////////////////
IWMWriterSink * pWriterSink = NULL;
HRESULT hr = S_OK;
hr = m_pNetworkSink->QueryInterface( IID_IWMWriterSink, (void
**)&pWriterSink ); if ( FAILED( hr ) ) {return hr;}
hr = pWriterSink->OnDataUnit( pDataUnit ); if ( FAILED( hr ) ) { pWriterSink->Release(); return hr;}
pWriterSink->Release();

/////////////////////////////////////////////////
// You can also add you code here
/////////////////////////////////////////////////
return hr;
}

6. Create an instance of this class in your program. Get the
IWMWriterNetworkSink interface from this instance.
For example:
IWMWriterNetworkSink * pNetworkSink = NULL;
CMyWMNetSink * pMySink = new CMyWMNetSink();
if ( pMySink == NULL ) { return E_OUTOFMEMORY; }
hr = pMySink->QueryInterface( IID_IWMWriterNetworkSink, (void
**)&pNetworkSink ); if ( FAILED( hr ) ) { return hr; }

7. Then you can use this IWMWriterNetworkSink interface in your
program.
--
Thanks!
Gangjiang Li
Microsoft Corp.
Windows Media Format SDK


如何用DirectShow实现将一批BMP图片和指定的MP3合成一个MPEG或AVI文件(VC/MFC 图形处理/算法 )


去看DirectShow示例里面那个desktop push的sample filter CPushSourceDesktop.
(SDK root)\Samples\C++\DirectShow\Filters\PushSource,在网上找一找曾经开源的软件CamStudio的源代码。


一种自定义的图形格式如何在windows的文件管理器里缩略图显示出来(VC/MFC ATL/ActiveX/COM )


就象photoshop和CorelDraw的文件一样, 这种格式按理说Windows是不认识的, 但我们在用缩略图方式查看文件时却可以显示这样的图片, 为什么?如果我们自己有一种格式需要写出自己的图形回显程序才能显示的, 如何通知WINDOWS呢?


http://www.codeproject.com/shell/thumbextract.asp


请问创建线程是用afxBeginThreaD还是应该用CREATETHREAD? (VC/MFC 进程/线程/DLL )


为什么我用调试工具调试时,总是提醒说不应该用AFXBEGINTHREAD而应该用CREATETHREAD?


both C runtime and MFC need some special initialization to function properly, so if you need MFC support, use AfxBeginThread. otherwise use _beginthreadex. DO NOT use CreateThread, since you are almost always using C runtime.


请问这个东西用脚本能实现么? (其他开发语言 脚本语言(Perl ,Python))

本文关键:Jiangsheng的CSDN Digest (Dec 2005)
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top