简体   繁体   English

在C#中使用DirectShow AsyncReader

[英]Using DirectShow AsyncReader with C#

I am running an AsyncReader to open a shared MPG file that is being downloaded by another application (progressive download). 我正在运行AsyncReader来打开另一个应用程序正在下载的共享MPG文件(渐进式下载)。 The shared MPG file is created with FILE-SHARE-READ | FILE-SHARE-DELETE | FILE-SHARE-WRITE 使用FILE-SHARE-READ | FILE-SHARE-DELETE | FILE-SHARE-WRITE创建共享的MPG文件FILE-SHARE-READ | FILE-SHARE-DELETE | FILE-SHARE-WRITE FILE-SHARE-READ | FILE-SHARE-DELETE | FILE-SHARE-WRITE FILE-SHARE-READ | FILE-SHARE-DELETE | FILE-SHARE-WRITE shared permissions. FILE-SHARE-READ | FILE-SHARE-DELETE | FILE-SHARE-WRITE共享权限。 I have even tried every combination of those flags. 我什至尝试了这些标志的所有组合。

Here's the problem: within C# the AsyncReader.Load method returns a error: 这是问题所在:在C#中, AsyncReader.Load方法返回错误:

file in use 使用中的文件

Within C++ it does not. 在C ++中没有。 C++ opens the file just fine. C ++可以很好地打开文件。

Any idea why this is? 知道为什么会这样吗?

Any idea why this is? 知道为什么会这样吗?

This is because File Source (Async) Filter is opening file exclusively, without allowing others to progressively write to the file in the same time. 这是因为文件源(异步)过滤器将专门打开文件,而不允许其他人同时逐步写入文件。

Code for same/similar asynchronous reader from old SDK, where it was available as a sample, contains: 来自旧SDK的相同/相似异步阅读器的代码(包含在样本中)包含:

// Open the requested file
HANDLE hFile = CreateFile(lpszFileName,
                          GENERIC_READ,
                          FILE_SHARE_READ,
                          NULL,
                          OPEN_EXISTING,
                          0,
                          NULL);

Note FILE_SHARE_READ . 注意FILE_SHARE_READ Your options are: 您的选择是:

  1. Complete progressive download before opening for playback 在打开播放之前完成渐进式下载
  2. Build a custom reader from SDK sample and change the file opening mode to allow writing as you play it 通过SDK示例构建自定义阅读器,并更改文件打开模式以允许在播放时进行写入

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM