Werbung: SecurityConsole.de verwaltet Ihre Computer mit Security Essentails aus der Cloud!
30 Tage kostenfrei testen und 20% Rabatt für Ihre Bestellung mit Promocode: WBF2685582
(Promocode gültig bis 31.12.2011)

Group:  English: Entertainment » microsoft.public.windowsmedia.sdk
Thread: developing my own windows media server for live devices

HTVi
TV Discussion Newsgroups

developing my own windows media server for live devices
Lehel <lehelkovach[ at ]gmail.com> 11/21/2008 1:47:47 AM
I basically want to develop a server to host my web cam and mic. I'm
guessing the best route for this is to develop my own server code and
then use DirectShow for my webcam and mic and then use Windows Media
Format SDK to create an encoded stream.

My question is, what are the programmatic steps i need to have an
encoded stream with a buffer i can read from and submit to connected
clients? Which interfaces do i need and do i need a file at the end
or can i just give econded data to TCP packets? the last part gets me
confused.

if someone can show me a flowchart or some pseudocode on how to
achieve my goal or point me to a more appropriate group, i'd be much
obliged.

lehel kovach
Re: developing my own windows media server for live devices
"Alessandro Angeli" <nobody[ at ]nowhere.in.the.net> 11/21/2008 2:12:47 AM
From: "Lehel"

[Quoted Text]
> My question is, what are the programmatic steps i need to
> have an encoded stream with a buffer i can read from and
> submit to connected clients? Which interfaces do i need
> and do i need a file at the end or can i just give
> econded data to TCP packets? the last part gets me
> confused.

capture -> compress -> mux -> send/write

If WindowsMedia is OK, the WMWriter (or the WMASFWriter
filter in DirectShow) will perform compression, muxing,
network sending and/or file writing. The supported network
protocol is MMS-over-HTTP and (I think) the maximum number
of clients is 50. If you want a better streaming protocol or
unlimited clients, you will need to reflect the stream with
WindowsMediaServices on Windows Server or write your own
protocol implementation.


--
// Alessandro Angeli
// MVP :: DirectShow / MediaFoundation
// mvpnews at riseoftheants dot com
// http://www.riseoftheants.com/mmx/faq.htm


Re: developing my own windows media server for live devices
Lehel <lehelkovach[ at ]gmail.com> 11/21/2008 2:27:19 AM
On Nov 20, 6:12 pm, "Alessandro Angeli" <nob...[ at ]nowhere.in.the.net>
wrote:
[Quoted Text]
> From: "Lehel"
>
> > My question is, what are the programmatic steps i need to
> > have an encoded stream with a buffer i can read from and
> > submit to connected clients?  Which interfaces do i need
> > and do i need a file at the end or can i just give
> > econded data to TCP packets?  the last part gets me
> > confused.
>
> capture -> compress -> mux -> send/write
>
> If WindowsMedia is OK, the WMWriter (or the WMASFWriter
> filter in DirectShow) will perform compression, muxing,
> network sending and/or file writing. The supported network
> protocol is MMS-over-HTTP and (I think) the maximum number
> of clients is 50. If you want a better streaming protocol or
> unlimited clients, you will need to reflect the stream with
> WindowsMediaServices on Windows Server or write your own
> protocol implementation.
>
> --
> // Alessandro Angeli
> // MVP :: DirectShow / MediaFoundation
> // mvpnews at riseoftheants dot com
> //http://www.riseoftheants.com/mmx/faq.htm

thanks for your speedy reply. the only question i have left is if i
need some metadata file like an asx file to point to my stream
server? i'm assuming if i want a windows media player to connect to
it, i'd need some file like that. if that's the case, how would i
specify the metadata?
Re: developing my own windows media server for live devices
"Alessandro Angeli" <nobody[ at ]nowhere.in.the.net> 11/21/2008 4:57:09 PM
From: "Lehel"

[Quoted Text]
> left is if i need some metadata file like an asx file to
> point to my stream server? i'm assuming if i want a
> windows media player to connect to it, i'd need some file
> like that.

No, you don't. WMP connects to the URL that corresponds to
the streaming server. You can either give WMP the URL
directly or you can (but don't have to) put it in an ASX
file and tell WMP to read the URL from there.

> if that's the case, how would i specify the
> metadata?

An ASX file is just a text file with an XML-like syntax that
you can easily write yourself. The syntax is documented in
the WMP SDK (also included in the Windows SDK and the
on-line and off-line MSDN Library):

http://msdn.microsoft.com/en-us/library/bb248407(VS.85).aspx

MS also provides an unsupported library to create ASX files:

http://support.microsoft.com/kb/933491


--
// Alessandro Angeli
// MVP :: DirectShow / MediaFoundation
// mvpnews at riseoftheants dot com
// http://www.riseoftheants.com/mmx/faq.htm


Re: developing my own windows media server for live devices
Lehel <lehelkovach[ at ]gmail.com> 11/21/2008 9:29:34 PM
On Nov 21, 8:57 am, "Alessandro Angeli" <nob...[ at ]nowhere.in.the.net>
wrote:
[Quoted Text]
> From: "Lehel"
>
> > left is if i need some metadata file like an asx file to
> > point to my stream server?  i'm assuming if i want a
> > windows media player to connect to it, i'd need some file
> > like that.
>
> No, you don't. WMP connects to the URL that corresponds to
> the streaming server. You can either give WMP the URL
> directly or you can (but don't have to) put it in an ASX
> file and tell WMP to read the URL from there.
>
> > if that's the case, how would i specify the
> > metadata?
>
> An ASX file is just a text file with an XML-like syntax that
> you can easily write yourself. The syntax is documented in
> the WMP SDK (also included in the Windows SDK and the
> on-line and off-line MSDN Library):
>
> http://msdn.microsoft.com/en-us/library/bb248407(VS.85).aspx
>
> MS also provides an unsupported library to create ASX files:
>
> http://support.microsoft.com/kb/933491
>
> --
> // Alessandro Angeli
> // MVP :: DirectShow / MediaFoundation
> // mvpnews at riseoftheants dot com
> //http://www.riseoftheants.com/mmx/faq.htm

Thank you so much for your help, Alessandro. If I may, I have some
follow-up questions.

First, I experimented with GraphEdit to test out the ASFWriter filter
for DirectShow. The writer creates an ASF file and then starts
appending data to it. This isn't what I really want because I dont
want to occupy any disk space and I want to be able to have clients
connect to a live feed rather than just opening the ASF file via HTTP
and reading from the beginning. What amendments would I use to
basically get a pointer to a buffer of the live compressed, muxed ASF
stream so I can begin to do my tcp send()s? Secondly, if I'm opting
not to use an ASF file, can I simply just write stream data to
connected wmp clients or do I need to learn the MMS-over-HTTP protocol
to accomplish this (i would assume that there has to be some
negotiation with the wmp client for it to know what exactly im
streaming to it)?

My last question has to do with the filters in GraphEdit. I tried
simply to make a graph using my video and audio capture filters and
connecting them directly to the ASFWriter which failed. I then tried
adding a video and audio compressor filters, respectively, but when I
did this, graphedit inserted a decoder right after my decoder and then
into the asf writer. is the capture->encoder->decoder->asf_writer
really necessary?
Re: developing my own windows media server for live devices
"Alessandro Angeli" <nobody[ at ]nowhere.in.the.net> 11/21/2008 9:51:28 PM
From: "Lehel"

[Quoted Text]
> First, I experimented with GraphEdit to test out the
> ASFWriter filter for DirectShow. The writer creates an
[...]

The WMASFWriter filter is not designed to work in GraphEdit,
because you can not configure it.

You might want to read this older thread for details that
shouls answer all of your previous questions:

http://groups.google.com/group/microsoft.public.win32.programmer.directx.video/browse_frm/thread/4c4cb1dd81a35d94

As an alternative to the stock WMASFWriter, you can also use
my own ASF sink (Q20 in my FAQ, link at the bottom). You
will have to remove some of the code that forces the
WMWriter object to work as a muxer only.

> My last question has to do with the filters in GraphEdit.
> I tried simply to make a graph using my video and audio
> capture filters and connecting them directly to the
> ASFWriter which failed. I then tried adding a video and
> audio compressor filters, respectively, but when I did
> this, graphedit inserted a decoder right after my decoder
> and then into the asf writer. is the
> capture->encoder->decoder->asf_writer really necessary?

No, it's not. As I said, the WMASFWriter can not be used in
GraphEdit because you can not configure it and you need to
configure it with the right profile to successfully connect
to it.

http://msdn.microsoft.com/en-us/library/aa384809(VS.85).aspx


--
// Alessandro Angeli
// MVP :: DirectShow / MediaFoundation
// mvpnews at riseoftheants dot com
// http://www.riseoftheants.com/mmx/faq.htm


Re: developing my own windows media server for live devices
Lehel <lehelkovach[ at ]gmail.com> 11/23/2008 7:10:56 AM
btw, would you know offhand why I get an E_FAIL when i query for the
advanced writer from the IServiceProvider?

here is my test code:

HRESULT hr = 0;
hr = ::CoInitialize(NULL);
// Create the graph builder and the filtergraph
hr = pCaptureGraphBuilder.CoCreateInstance
( CLSID_CaptureGraphBuilder2 );
hr = pGraph.CoCreateInstance( CLSID_FilterGraph );
hr = pCaptureGraphBuilder->SetFiltergraph( pGraph );
hr = pDevEnum.CoCreateInstance(CLSID_SystemDeviceEnum);

// Query all the interfaces needed later
hr = pGraph.QueryInterface( &pMediaControl );
hr = pGraph.QueryInterface( &pMediaEvent );
hr = pGraph.QueryInterface( &pMediaSeeking );

// Initialize the video capture filter
pVideoCap.Attach( GetFirstInputDriver(Video));
hr = pGraph->AddFilter( pVideoCap, L"Video capture source" );

// Initialize the audio capture filter
pAudioCaptureFilter.Attach(GetFirstInputDriver(Audio));
hr = pGraph->AddFilter( pAudioCaptureFilter, L"Audio Capture
Filter" );

// Initialize the Video DMO Wrapper
hr = pVideoEncoder.CoCreateInstance( CLSID_DMOWrapperFilter );
hr = pVideoEncoder.QueryInterface( &pVideoWrapperFilter );

// Load the WMV9 encoder in the DMO Wrapper.
// To encode in MPEG, replace CLSID_CWMV9EncMediaObject with the
// CLSID of your DMOCLSID_CWMV9EncMediaObject

hr = pVideoWrapperFilter->Init(__uuidof(CWMV9EncMediaObject), //
CLSID_CWMV9EncMediaObject,
DMOCATEGORY_VIDEO_ENCODER );
hr = pGraph->AddFilter( pVideoEncoder, L"WMV9 DMO Encoder" );

// Load ASF multiplexer.
// To create a MPEG file, change the CLSID_ASFWriter into the GUID
// of your multiplexer
hr = pAsfWriter.CoCreateInstance( CLSID_WMAsfWriter );
IFileSinkFilter* fileSink;
hr = pAsfWriter->QueryInterface( IID_IFileSinkFilter, (void**)
&fileSink );
pFileSinkFilter.Attach(fileSink);
hr = pFileSinkFilter->SetFileName(L"C:\\test0.asf", NULL);


IWMWriterNetworkSink* pNetSink = NULL;
hr = ::WMCreateWriterNetworkSink(&pNetSink);
pNetworkSink.Attach(pNetSink);
DWORD port = 2727;
hr = pNetworkSink->Open(&port);


IServiceProvider* prov = NULL;
hr = pAsfWriter->QueryInterface(IID_IServiceProvider, (void**)&prov);
pProvider.Attach(prov);
IWMWriterAdvanced2* writer = NULL;

//THIS RETURNS E_FAIL
hr = pProvider->QueryService
(IID_IWMWriterAdvanced2,IID_IWMWriterAdvanced2, (void**)&writer);
pWriterAdvanced.Attach(writer);

On Nov 21, 1:51 pm, "Alessandro Angeli" <nob...[ at ]nowhere.in.the.net>
wrote:
[Quoted Text]
> From: "Lehel"
>
> > First, I experimented with GraphEdit to test out the
> > ASFWriter filter for DirectShow.  The writer creates an
>
> [...]
>
> The WMASFWriter filter is not designed to work in GraphEdit,
> because you can not configure it.
>
> You might want to read this older thread for details that
> shouls answer all of your previous questions:
>
> http://groups.google.com/group/microsoft.public.win32.programmer.dire...
>
> As an alternative to the stock WMASFWriter, you can also use
> my own ASF sink (Q20 in my FAQ, link at the bottom). You
> will have to remove some of the code that forces the
> WMWriter object to work as a muxer only.
>
> > My last question has to do with the filters in GraphEdit.
> > I tried simply to make a graph using my video and audio
> > capture filters and connecting them directly to the
> > ASFWriter which failed.  I then tried adding a video and
> > audio compressor filters, respectively, but when I did
> > this, graphedit inserted a decoder right after my decoder
> > and then into the asf writer.  is the
> > capture->encoder->decoder->asf_writer really necessary?
>
> No, it's not. As I said, the WMASFWriter can not be used in
> GraphEdit because you can not configure it and you need to
> configure it with the right profile to successfully connect
> to it.
>
> http://msdn.microsoft.com/en-us/library/aa384809(VS.85).aspx
>
> --
> // Alessandro Angeli
> // MVP :: DirectShow / MediaFoundation
> // mvpnews at riseoftheants dot com
> //http://www.riseoftheants.com/mmx/faq.htm

Re: developing my own windows media server for live devices
Lehel <lehelkovach[ at ]gmail.com> 11/23/2008 10:48:03 AM
nm, i didn't add the asf writer to the filter. lol

On Nov 22, 11:10 pm, Lehel <lehelkov...[ at ]gmail.com> wrote:
[Quoted Text]
> btw,  would you know offhand why I get an E_FAIL when i query for the
> advanced writer from the IServiceProvider?
>
> here is my test code:
>
> HRESULT hr = 0;
>         hr = ::CoInitialize(NULL);
>         // Create the graph builder and the filtergraph
>         hr = pCaptureGraphBuilder.CoCreateInstance
> ( CLSID_CaptureGraphBuilder2 );
>         hr = pGraph.CoCreateInstance( CLSID_FilterGraph );
>         hr = pCaptureGraphBuilder->SetFiltergraph( pGraph );
>         hr = pDevEnum.CoCreateInstance(CLSID_SystemDeviceEnum);
>
>         // Query all the interfaces needed later
>         hr = pGraph.QueryInterface( &pMediaControl );
>         hr = pGraph.QueryInterface( &pMediaEvent );
>         hr = pGraph.QueryInterface( &pMediaSeeking );
>
>         // Initialize the video capture filter
>         pVideoCap.Attach( GetFirstInputDriver(Video));
>         hr = pGraph->AddFilter( pVideoCap, L"Video capture source" );
>
>         // Initialize the audio capture filter
>         pAudioCaptureFilter.Attach(GetFirstInputDriver(Audio));
>         hr = pGraph->AddFilter( pAudioCaptureFilter, L"Audio Capture
> Filter" );
>
>         // Initialize the Video DMO Wrapper
>         hr = pVideoEncoder.CoCreateInstance( CLSID_DMOWrapperFilter );
>         hr = pVideoEncoder.QueryInterface( &pVideoWrapperFilter );
>
>         // Load the WMV9 encoder in the DMO Wrapper.
>         // To encode in MPEG, replace CLSID_CWMV9EncMediaObject with the
>         // CLSID of your DMOCLSID_CWMV9EncMediaObject
>
>         hr = pVideoWrapperFilter->Init(__uuidof(CWMV9EncMediaObject), //
> CLSID_CWMV9EncMediaObject,
>                                                            DMOCATEGORY_VIDEO_ENCODER );
>         hr = pGraph->AddFilter( pVideoEncoder, L"WMV9 DMO Encoder" );
>
>         // Load ASF multiplexer.
>         // To create a MPEG file, change the CLSID_ASFWriter into the GUID
>         // of your multiplexer
>         hr = pAsfWriter.CoCreateInstance( CLSID_WMAsfWriter );
>         IFileSinkFilter* fileSink;
>         hr = pAsfWriter->QueryInterface( IID_IFileSinkFilter, (void**)
> &fileSink );
>         pFileSinkFilter.Attach(fileSink);
>         hr = pFileSinkFilter->SetFileName(L"C:\\test0.asf", NULL);
>
>         IWMWriterNetworkSink* pNetSink = NULL;
>         hr = ::WMCreateWriterNetworkSink(&pNetSink);
>         pNetworkSink.Attach(pNetSink);
>         DWORD port = 2727;
>         hr = pNetworkSink->Open(&port);
>
>         IServiceProvider* prov = NULL;
>         hr = pAsfWriter->QueryInterface(IID_IServiceProvider, (void**)&prov);
>         pProvider.Attach(prov);
>         IWMWriterAdvanced2* writer = NULL;
>
>        //THIS RETURNS E_FAIL
>         hr = pProvider->QueryService
> (IID_IWMWriterAdvanced2,IID_IWMWriterAdvanced2, (void**)&writer);
>         pWriterAdvanced.Attach(writer);
>
> On Nov 21, 1:51 pm, "Alessandro Angeli" <nob...[ at ]nowhere.in.the.net>
> wrote:
>
> > From: "Lehel"
>
> > > First, I experimented with GraphEdit to test out the
> > > ASFWriter filter for DirectShow.  The writer creates an
>
> > [...]
>
> > The WMASFWriter filter is not designed to work in GraphEdit,
> > because you can not configure it.
>
> > You might want to read this older thread for details that
> > shouls answer all of your previous questions:
>
> >http://groups.google.com/group/microsoft.public.win32.programmer.dire...
>
> > As an alternative to the stock WMASFWriter, you can also use
> > my own ASF sink (Q20 in my FAQ, link at the bottom). You
> > will have to remove some of the code that forces the
> > WMWriter object to work as a muxer only.
>
> > > My last question has to do with the filters in GraphEdit.
> > > I tried simply to make a graph using my video and audio
> > > capture filters and connecting them directly to the
> > > ASFWriter which failed.  I then tried adding a video and
> > > audio compressor filters, respectively, but when I did
> > > this, graphedit inserted a decoder right after my decoder
> > > and then into the asf writer.  is the
> > > capture->encoder->decoder->asf_writer really necessary?
>
> > No, it's not. As I said, the WMASFWriter can not be used in
> > GraphEdit because you can not configure it and you need to
> > configure it with the right profile to successfully connect
> > to it.
>
> >http://msdn.microsoft.com/en-us/library/aa384809(VS.85).aspx
>
> > --
> > // Alessandro Angeli
> > // MVP :: DirectShow / MediaFoundation
> > // mvpnews at riseoftheants dot com
> > //http://www.riseoftheants.com/mmx/faq.htm

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net
Suche nach Orten, Städten, Postleitzahlen, Vorwahlen, Kfz-Kennzeichen