共用方式為


ASF Web Stream Playback in DirectShow

 
Microsoft DirectShow 9.0

ASF Web Stream Playback in DirectShow

Microsoft DirectShow supports Web streamsin file playback scenarios through the WM ASF Reader filter, but you must write your own DirectShow filter to capture and persist the stream.

  • **Note   **To play back Web streams in content that is being streamed from a server running Windows Media Services, use the Windows Media Player 9 Series ActiveX® control embedded in a Web page.

When given a file containing streams of type WMMEDIATYPE_FileTransfer, the WM ASF Reader will create an output pin for it. The format block will be a WMT_WEBSTREAM_FORMAT structure. (This structure is documented in the Windows Media Format SDK documentation.) If no downstream filter is available that can handle that media type, then the pin will remain unconnected, but the file will still play the audio and/or video streams.

Each media sample in a Web stream contains a WMT_WEBSTREAM_SAMPLE_HEADER structure, which is documented in the Windows Media Format SDK documentation. The structure has a variable length depending on the length of its wszURL member. The pointer to the sample data initially points to this structure, and you must advance the pointer past the structure in order to access the actual data in the stream.

Your Web stream handler filter should be based on the CBaseRenderer class. In the CBaseRenderer::DoRenderSample method, the filter will need to parse the structure for information about the Web stream, and then perform the appropriate action. Typically, this will involve saving the file to disk, and then calling the CommitUrlCacheEntry and CreateUrlCacheEntry functions to place the files into the Internet Explorer cache. The filter must handle multipart files, that is, files that are larger than one sample, and also must handle render commands, which are specified by the WMT_WEBSTREAM_SAMPLE_HEADER.wSampleType member. The filter sends an EC_OLE_EVENT event to the application, along with the text of the WMT_WEBSTREAM_SAMPLE_HEADER.wszURL string which contains the name of the file to be rendered. The application then causes the browser to display the specified page. If the Web stream has been authored correctly, the file should already be in the cache.

For more information on WMT_WEBSTREAM_FORMAT and WMT_WEBSTREAM_SAMPLE_HEADER, see the Windows Media Format SDK documentation.

See Also