我在使用Windows Media Encoder SDK编程时,使用如下代码: HRESULT hr;
IWMEncBroadcast* pBroadcast; USES_CONVERSION; //保存广播端口
short PortNum;
hr = pEncoder->get_Broadcast(&pBroadcast);
hr = pBroadcast->get_PortNumber(WMENC_PROTOCOL_HTTP,&PortNum);
g_VideoEncoderOutputInf[iIndex].iGbdk = (long) PortNum;但编译时却报告如下错误:D:\SLencoder\EncoderView.cpp(1514) : error C2664: 'get_PortNumber' : cannot convert parameter 2 from 'short *' to 'long *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast Error executing cl.exe.>>>>>>
>>>>>>为什么?请高手指点解决方法.......^_^
IWMEncBroadcast* pBroadcast; USES_CONVERSION; //保存广播端口
short PortNum;
hr = pEncoder->get_Broadcast(&pBroadcast);
hr = pBroadcast->get_PortNumber(WMENC_PROTOCOL_HTTP,&PortNum);
g_VideoEncoderOutputInf[iIndex].iGbdk = (long) PortNum;但编译时却报告如下错误:D:\SLencoder\EncoderView.cpp(1514) : error C2664: 'get_PortNumber' : cannot convert parameter 2 from 'short *' to 'long *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast Error executing cl.exe.>>>>>>
>>>>>>为什么?请高手指点解决方法.......^_^
传递LONG型的数据。
hr = pBroadcast->get_PortNumber(WMENC_PROTOCOL_HTTP,(long*)&PortNum);
IWMEncBroadcast::get_PortNumber
The get_PortNumber method retrieves the port number used for broadcasting encoded content.SyntaxHRESULT get_PortNumber(
WMENC_BROADCAST_PROTOCOL enumProtocol,
short* piPort
);
ParametersenumProtocol[in] short containing the protocol for transmitting encoded content. Currently, this must be the following value.Value Number Meaning
WMENC_PROTOCOL_HTTP 1 The transmission uses the HTTP protocol.
piPort[out] Pointer to a short containing the port number.Return ValuesIf the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.Return code Number Description
E_POINTER 0x80004003 The pointer to the port number is NULL.
E_INVALIDARG 0x80070057 The protocol is invalid.
ResOnly the HTTP protocol can be used. To specify a port number, use the IWMEncBroadcast::put_PortNumber method.Example// Include libraries.#include <windows.h>
#include "wmencode.h"// Declare variables.HRESULT hr;
IWMEncoder* pEncoder;
IWMEncBroadcast* pBrdcst;
short PortNum;// Initialize the COM library and retrieve a pointer to the
// IWMEncoder interface.
hr = CoInitialize(NULL);CoCreateInstance(CLSID_WMEncoder,
NULL,
CLSCTX_INPROC_SERVER,
IID_IWMEncoder,
(void**) &pEncoder);// Retrieve a pointer to the IWMEncBroadcast interface.
hr = pEncoder->get_Broadcast(&pBrdcst);// Retrieve the port number. The port number defaults to zero.
hr = pBrdcst->get_PortNumber(WMENC_PROTOCOL_HTTP, &PortNum);// Set the port number.
PortNum = 2356;
hr = pBrdcst->put_PortNumber(WMENC_PROTOCOL_HTTP, PortNum);