简体   繁体   English

使用 C++ 流式传输到 Windows Media Player

[英]Stream to Windows Media Player with c++

I have to read encrypted music or video from USB drive, decrypt it on the fly as a stream, and send it to mp3 player.我必须从 USB 驱动器读取加密的音乐或视频,将其作为流即时解密,然后将其发送到 mp3 播放器。

I can already read the file from the USB and decrypt it on the fly in chunks, but now I need to send the chunked data somewhere to play it, for example windows media player (WMP).我已经可以从 USB 读取文件并以块的形式动态解密它,但现在我需要将分块数据发送到某个地方来播放它,例如 windows 媒体播放器 (WMP)。

WMP requires a URL to the music/video source, so I figure I would create a stream in memory and give that to WMP as the URL. WMP 需要一个指向音乐/视频源的 URL,所以我想我会在内存中创建一个流并将其作为 URL 提供给 WMP。 Then when WMP starts reading from the stream, it would somehow call my function which would then read a chunk of data from the USB, decrypt it, and put it to the stream to be played by WMP.然后,当 WMP 开始从流中读取时,它会以某种方式调用我的函数,然后该函数将从 USB 读取一大块数据,对其进行解密,然后将其放入 WMP 播放的流中。

Anybody knows how to create a URL stream, and then get notified when the stream wants data?有人知道如何创建 URL 流,然后在流需要数据时得到通知吗?

Im using Visual C++ MFC/Win32.我使用的是 Visual C++ MFC/Win32。

Thanks谢谢

The WMP requires an URL, which can be the name of a file or a HTTP(S) URL that delivers the file data. WMP 需要一个 URL,该 URL 可以是文件名或提供文件数据的 HTTP(S) URL。 In your case, the HTTP option would seem a good choice so you get notified when data is needed.在您的情况下,HTTP 选项似乎是一个不错的选择,因此您会在需要数据时收到通知。 For this to work you have to implement your own tiny HTTP server, preferably on an ephemeral port.为此,您必须实现自己的小型 HTTP 服务器,最好是在临时端口上。 So, you have your music file in memory and set up a HTTP server to deliver the file data.因此,您将音乐文件保存在内存中,并设置了一个 HTTP 服务器来传送文件数据。 The URL for example will be something like http://127.0.0.1:5432/MusicFile.mp3 , which you specify to WMP.例如,URL 将类似于http://127.0.0.1:5432/MusicFile.mp3 ,您指定给 WMP。 Your web server will then receive a request for the file and you can start sending it.然后,您的 Web 服务器将收到对该文件的请求,您可以开始发送它。

As a note, using a (non-persisted) memory-mapped file should also work.请注意,使用(非持久化)内存映射文件也应该有效。 However, you indicate that you want to be notified and it's not clear if that's just to be able to deliver data.但是,您表示希望收到通知,并且不清楚这是否只是为了能够提供数据。

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

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