我想从C#转换为C ++并再次将缓冲区返回给C# 如何将IBuffer转换为" const unsigned char * data"再次给IBuffer
Windows::Storage::Streams::IBuffer^ Decode(Windows::Storage::Streams::IBuffer^ buff, int len, int frame_size, int decode_fec);
Windows::Storage::Streams::IBuffer^ MyApi::Decode(Windows::Storage::Streams::IBuffer^ buff, int len, int frame_size, int decode_fec)
{
}
答案 0 :(得分:3)
您可以通过查询IBufferByteAccess接口然后访问IBufferByteAccess :: Buffer来获取IBuffer的内容,以便将其内容作为字节*
IUnknown* pUnk = reinterpret_cast<IUnknown*>(buff);
IBufferByteAccess* pBufferByteAccess = nullptr;
HRESULT hr = pUnk->QueryInterface(IID_PPV_ARGS(pBufferByteAccess);
byte *pbytes = nullptr;
hr = pBufferByteAccess->Buffer(&pbytes);