-1

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.

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).

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. 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.

Anybody knows how to create a URL stream, and then get notified when the stream wants data?

Im using Visual C++ MFC/Win32.

Thanks

user5199516
  • 27
  • 3
  • 9
  • Possible [XY Problem](http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem). What is the end result? Are you trying to make a player for this type of encrypted music? Are you trying to set up windows media player (or other players on the system) to play this type of file? Did you look at any of the [other](https://msdn.microsoft.com/en-us/library/windows/desktop/aa369729.aspx) [options](https://msdn.microsoft.com/en-us/library/windows/desktop/ms700168.aspx) [available](https://msdn.microsoft.com/en-us/library/windows/desktop/hh828986.aspx)? – theB May 31 '16 at 16:48
  • I have embedded the windows media player activeX control in my Visual C++ application dialog box, but it seems it can only play from a URL, but I only have a decrypted data stream of the mp3 file. I cant write the file to disk because then someone can steal it, so have to play the file as a stream only, and if I read the whole file into memory it takes up to 15 seconds to read and decrypt the whole file so instead its better to decrypt and play at the same time so user dont have to wait for while file to play. So I need to know how to play using a stream from memory – user5199516 May 31 '16 at 22:21
  • @user5199516 there were similar topics, look e.g. http://stackoverflow.com/questions/18353278/video-encryption-for-local-software and http://stackoverflow.com/questions/30940230/how-to-play-encrypted-video-file-using-windowsmediaplayer/32026471 and http://stackoverflow.com/questions/12405635/play-videos-from-memory-stream – Artem Razin Jun 01 '16 at 11:29

1 Answers1

0

The WMP requires an URL, which can be the name of a file or a HTTP(S) URL that delivers the file data. In your case, the HTTP option would seem a good choice so you get notified when data is needed. For this to work you have to implement your own tiny HTTP server, preferably on an ephemeral port. So, you have your music file in memory and set up a HTTP server to deliver the file data. The URL for example will be something like http://127.0.0.1:5432/MusicFile.mp3, which you specify to WMP. Your web server will then receive a request for the file and you can start sending it.

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.

Ton Plooij
  • 2,583
  • 12
  • 15