使用 IMFSourceResolver::CreateObjectFromByteStream

发布于 2024-09-10 03:58:02 字数 1104 浏览 1 评论 0原文

我正在尝试使用 IMFSourceResolver::CreateObjectFromByteStream 方法为受 DRM 保护的 WMA 文件创建 IMFMediaSource 实例。我正在将 Windows SDK 中的 ProtectedPlayback 示例改编为游乐场。我希望实现的最终目标是让播放过程由我将编写的 IMFByteStream 自定义实现提供支持。

但是,我无法使简单的 IMFByteStream 实现或 MFCreateFile 函数返回的实现正常工作。当传递给 CreateObjectFromByteStream 时,每个都返回 MF_E_UNSUPPORTED_BYTESTREAM_TYPE 的 HRESULT。

我在默认状态下使用受 DRM 保护的 WMA 文件测试了示例项目(在文件上使用 CreateObjectFromUrl),并且运行良好。文件未损坏并且许可证有效。我不明白为什么用 CreateObjectFromByteStream( MFCreateFile() ) 替换这段代码不起作用。我已经能够找到很少的文档来介绍如何使用自定义字节流或解析器对字节流实例的期望。

如果有人对这些东西有任何经验或知道我做错了什么,我将不胜感激。

我正在使用的代码在这里:

IMFByteStream* stream = NULL;

HRESULT hr2 = MFCreateFile(
    MF_ACCESSMODE_READ,
    MF_OPENMODE_FAIL_IF_NOT_EXIST,
    MF_FILEFLAGS_NONE,
    L"C:\\IFB.wma",
    &stream);


CHECK_HR(hr = pSourceResolver->CreateObjectFromByteStream(
                stream,
                NULL,
                MF_RESOLUTION_MEDIASOURCE,
                NULL,
                &ObjectType,
                &pSource));

我没有包含整个内容,因为它与示例基本相同,我只更改了这部分。

谢谢,

史蒂夫

I am trying to use the IMFSourceResolver::CreateObjectFromByteStream method to create a IMFMediaSource instance for a DRM protected WMA file. I am adapting the ProtectedPlayback sample from the Windows SDK as a playground. The end goal I wish to achieve is to have the playback process fed by a custom implementation if IMFByteStream that I will write.

However, I cannot get either my simple IMFByteStream implementation or the implementations returned by the MFCreateFile function to work. Each returns a HRESULT of MF_E_UNSUPPORTED_BYTESTREAM_TYPE when passed to CreateObjectFromByteStream.

I tested the sample project in its default state (using CreateObjectFromUrl on a file) with a DRM protected WMA file and it worked fine. The file is not corrupt and the license is valid. I don't understand why substituting this bit of code with CreateObjectFromByteStream( MFCreateFile() ) does not work. I have been able to find little documentation that covers using custom byte streams or what the resolver expects from a byte stream instance.

If anybody has any experience with this stuff or any idea what I am doing wrong, some pointers would be appreciated.

The code I am using is here:

IMFByteStream* stream = NULL;

HRESULT hr2 = MFCreateFile(
    MF_ACCESSMODE_READ,
    MF_OPENMODE_FAIL_IF_NOT_EXIST,
    MF_FILEFLAGS_NONE,
    L"C:\\IFB.wma",
    &stream);


CHECK_HR(hr = pSourceResolver->CreateObjectFromByteStream(
                stream,
                NULL,
                MF_RESOLUTION_MEDIASOURCE,
                NULL,
                &ObjectType,
                &pSource));

I've not included the whole thing because its basically the same as the sample, I've only changed this part.

Thanks,

Steve

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小猫一只 2024-09-17 03:58:02

@pisomojado

感谢您的回复,我完全忘记了我已经发布了这个问题。

问题是,如果我没记错的话,CreateObjectFromByteStream 需要一种方法来识别内容类型。您可以通过传入 URL 以及字节流实例(pwszURL 参数)或通过使字节流类实现 IMFAttributes 并处理对要求内容类型的 GetAllocationString 的调用来完成此操作。由于我没有做这些事情,所以解析器只是拒绝流。

我本以为解析器会尝试通过前几个字节来识别流内容类型,就像您在答案中建议的那样,但对我来说,它似乎没有这样做。不知道为什么会这样,但没关系。

史蒂夫

@pisomojado

Thanks for the response, I totally forgot I had posted this question.

The problem was, if I remember correctly, that CreateObjectFromByteStream needs a way to identify the content type. You can either do this by passing in a URL as well as the byte stream instance (pwszURL parameter) or by making the byte stream class implement IMFAttributes and handle the call to GetAllocatedString that asks for the content type. Since I was doing neither of these things, the resolver was just rejecting the stream.

I would have thought that the resolver would attempt to recognize the stream content type via the first few bytes like you suggested in your answer, but for me it did not appear to do so. Not sure why this is, but nevermind.

Steve

作妖 2024-09-17 03:58:02

调试此处发生的情况的一些想法:

首先,在 c:\ifb.wma 文件上执行 IMFSourceResolver::CreateObjectFromUrl ;确保那是快乐的。

假设是这样,那么就可以在 CreateObjectFromByteStream 调用中查看 IMFByteStream 中发生的情况。通常,CreateObjectFromByteStream 将尝试从 IMFByteStream 的开头读取几个字节,因为那里通常有某种识别字节序列。设置一些断点或从 IMFByteStream::[Begin]Read 进行一些日志记录,以查看所要求的内容以及是否忠实地传递了正确的字节。

FWIW,所有 WMA 文件(以及 WMV 和 ASF)都是这样开始的(它是 ASF 标头 GUID)。

30 26 b2 75 8e 66 cf 11 a6 d9 00 aa 00 62 ce 6c

Some ideas for debugging what's going on here:

First off, do an IMFSourceResolver::CreateObjectFromUrl on your c:\ifb.wma file; make sure that's happy.

Assuming it is, then it's on to looking at what happens in your IMFByteStream while inside the CreateObjectFromByteStream call. Typically, CreateObjectFromByteStream will try to read a couple bytes off the beginning of the IMFByteStream, since there's usually some kind of identifying byte sequence there. Set some breakpoints or do some logging from your IMFByteStream::[Begin]Read to see what you're being asked for, and whether you're faithfully delivering the right bytes.

FWIW, all WMA files (and WMV, and ASF) start like this (it's the ASF header GUID).

30 26 b2 75 8e 66 cf 11 a6 d9 00 aa 00 62 ce 6c
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文