Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. HTTP Streaming MP3 to DirectSound

HTTP Streaming MP3 to DirectSound

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsgame-devsysadmindata-structuresquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Janovetz
    wrote on last edited by
    #1

    Hello- I've been investigating DirectSound for an app for a couple days and still a bit confused. What I would like to do is stream an MP3 from an Icecast/Shoutcast server to my machine and run that through DirectSound. To me, this would be done by writing the code to connect to the server, start streaming the MP3, then shovel that data into a DirectSound buffer which is configured to connect (via a filter graph) to an MP3 decoder. There are streaming examples with the DirectX SDK, but they don't talk about MP3s -- they're just for PCM. Am I approaching this correctly? Are there better examples for me to look at? I also want to incorporate my own FIR filter into the DirectSound stream -- I'm assuming this will be possible. Cheers, Jake

    A 1 Reply Last reply
    0
    • J Janovetz

      Hello- I've been investigating DirectSound for an app for a couple days and still a bit confused. What I would like to do is stream an MP3 from an Icecast/Shoutcast server to my machine and run that through DirectSound. To me, this would be done by writing the code to connect to the server, start streaming the MP3, then shovel that data into a DirectSound buffer which is configured to connect (via a filter graph) to an MP3 decoder. There are streaming examples with the DirectX SDK, but they don't talk about MP3s -- they're just for PCM. Am I approaching this correctly? Are there better examples for me to look at? I also want to incorporate my own FIR filter into the DirectSound stream -- I'm assuming this will be possible. Cheers, Jake

      A Offline
      A Offline
      Antti Keskinen
      wrote on last edited by
      #2

      After a few hours of work, I've done some prelimenary research for you. If you use a stream from the Internet, take the following steps into consideration: 1. Connecting to the stream and requesting for a stream (HTTP commands) 2. Receiving data from the stream 3. Running the stream through a DirectShow filter chain that decodes it 4. Shoveling from the final filter in the chain into the DirectSound buffer 5. Playing back the buffer There are at least some SHOUTCast DirectShow filters available, but I have no knowledge on how/if they work. A better way, I would feel, is to directly connect to the SHOUTCast server and request for a stream. The entire process bases itself around the IMediaObject interface, that represents a block of media data. First, you should create the necessary filter object, in MP3 case, it could be MPEG-1 Stream Splitter Filter, that can receive MEDIATYPE_STREAM with MEDIATYPE_MPEG1Audio. To continue from here, you can use ACM Wrapper filter, that supports conversion from MP3 to PCM format, if you have any MP3 decoders installed (installing WinAmp will install a decoder as well). The ACM Wrapper outputs PCM data that can be directed into a DirectSound Renderer filter, or if required, you can use IMemAllocator interface to get the decoded IMediaSample objects out from the chain. In order to utilize the received data, you can create an instance of a IMediaSample interface (and the object), set it up to represent the data you have received (MEDIATYPE_STREAM with MEDIATYPE_MPEG1Audio subtype, for example, if you use the MPEG-1 Stream Splitter). Then get a pointer into the sample's data area, copy data from the download buffer, and call IMemInputPin::Receive on the input pin. To get the input pin, get a pointer to the IBaseFilter interface on the MPEG-1 Stream Splitter interface, and query through the pins using EnumPins. When you find the suitable IPin, query for the IMemInputPin interface on it. This isn't a complete example on how to do it, but it should help you get started. Alternatively, if you already have a working application that connects to a SHOUTCast source, receives data and fills a temporary buffer (raw data buffer, non-DirectSound), then I could consider joining up to write the logic to decode and playback it. -Antti Keskinen ---------------------------------------------- The definition of impossible is strictly dependant on what we think is possible.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups