Can DirectShow be called from a windows service
-
27 Februari 2012 16:32
Can I call DirectShow from a service or is a session / login necessary? I've seen several posts that say a session is required for DirectX and MCI and that those will not work in a service when logged out.
Here's some background about what I am doing. We have a legacy C++ service that among other things, uses waveOutOpen to play wave files. I need to change the service so mp3 files can be played too. waveOutOpen will not play mp3 files. I am pretty sure I could use the ACM api to decompress / convert the mp3 data then continue to use waveOutOpen but my manager would rather me find a way to play mp3 directly and natively without converting it first. I have been asked to avoid the use of third party libraries such as LAME if possible. That is why I am starting to look at DirectShow.
Kevin Jones
Semua Balasan
-
27 Februari 2012 21:56You don't need an interactive session for DirectShow. Running your DirectShow-enabled application as a service is fine.
-
28 Februari 2012 5:20TC Kevin wrote:>>Can I call DirectShow from a service or is a session / login necessary?Are you familiar with the Windows Media Center application? The part thatrecords television shows is a DirectShow graph in a service that starts atboot whether or not there is a login.>I've seen several posts that say a session is required for DirectX and>MCI and that those will not work in a service when logged out.DirectX requires a desktop, but DirectShow (despite the name) is not partof DirectX. As long as you're not rendering to the screen, it works fine.--Tim Roberts, timr@probo.comProvidenza & Boekelheide, Inc.
Tim Roberts, VC++ MVP Providenza & Boekelheide, Inc. -
01 Maret 2012 23:22
DirectShow in general does not need a session or desktop or display. Of course, the renderers instead do (they use DirectSound, DirectDraw and Direct3D). However, as long as you do not use those filters, you're fine. Notice that the default audio renderer uses DirectSound, so you may want to explicitly select the one that uses waveOut instead (jn case DirectSound does not work in a service, since it requires a window as messape port).
Since the default MP3 reader is not very good (e.g. it does not properly support ID3 tags), you should build your graph manually anyway, in order to use the WMAsfReader source filter (which supports MP3 as well and fully supports those MP3 extensions).
Just create the WMAsfReader filter and add it to the graph, then call its IFileSourceFilter::Load() method. Use the system device enumerator to find the default waveOut renderer's moniker, use it to create the filter and add the filter to the graph. Then use IGraphBuilder::Connect() to connect the audio output pin of the WMAsfReader to the input pin of the audio renderer. You can use the ICaptureGraphBuilder2 helper object instead to make the last connection easier (otherwise it's an annoying multi-step procedure).
<http://www.riseoftheants.com/mmx/faq.htm>
- Disarankan sebagai Jawaban oleh Alessandro Angeli 01 Juni 2012 22:12