Microsoft DirectX 9.0

Using the Stream Buffer Engine in Script

This topic applies to Windows XP Service Pack 1 only.

The Video Control can pause a live video stream using the Stream Buffer Engine. Place two separate instances of the Video Control in your Web page. The first instance will receive the tune request and record the content, using the MSVidStreamBufferSink (sink) object. The second instance will play back the content, using the MSVidStreamBufferSource (source) object.

In the following example, MSVidCtl_Sink is for the sink and MSVidCtl_Src is for the source:

    <!-- Stream Buffer Sink instance of the Video Control -->
        CLASSID="CLSID:B0EDF163-910A-11D2-B632-00C04F79498E" > 
    <!-- Stream Buffer Source instance of the Video Control -->
        CLASSID="CLSID:B0EDF163-910A-11D2-B632-00C04F79498E" > 

Initialize the Stream Buffer Sink

First, create a tune request and pass it stream buffer sink instance of the Video Control. For details, see Creating a Tune Request (Script). Next, add the Encoder feature (CLSID_MSVidEncoder) to the active features collection:

ENC_CLSID = "{BB530C63-D9DF-4B49-9439-63453962E598}"
' Create an empty Features collection
Set MyFeatures = CreateObject("MSVidCtl.MSVidFeatures")

' Enumerate the available features
For Each feature In MSVidCtl.FeaturesAvailable
   ' Look for the MSVidEncoder feature
    If (feature.ClassID = ENC_CLSID) Then
        MyFeatures.Add feature
    End If
    ' Optionally, add other features (not shown).

' Use this as the active features collection.
MSVidCtl_Sink.FeaturesActive = MyFeatures

Enumerate the available output devices in the GUID_NULL category, and set the MSVidStreamBufferSink object as the active output device:

GUID_NULL = "{00000000-0000-0000-0000-000000000000}"
SINK_CLSID = "{9E77AAC4-35E5-42A1-BDC2-8F3FF399847C}"

' Create an empty output device collection.
Set MyOutputs = CreateObject("MSVidCtl.MSVidOutputDevices")

' Enumerate the available output devices.
Dim objStreamBufferSink
For Each output In MSVidCtl.OutputsAvailable(GUID_NULL)
    If output.ClassID = SINK_CLSID Then
        ' This is the one we want.
        MyOutputs.add output 
        Set objStreamBufferSink = output  ' Store this for later use.
    End If

' Set the active outputs collection.
MSVidCtl_Sink.OutputsActive = outs

Specify a file name for the output device:

strFilename = "C:\Example.wmv
objStreamBufferSink.SinkName = strFilename

Disable video and audio rendering in the Video Control for the stream buffer sink. Rendering will be performed by the stream buffer source instance.


Initialize the Stream Buffer Source

Using the other instance of the Video Control, enumerate the available input devices in the GUID_NULL category. Set the MSVidStreamBufferSource device as the active input device.

DVR_CLSID = "{AD8E510D-217F-409B-8076-29C5E73B98E8}"
Dim objStreamBufferSource
' Enumerate the available inputs
For Each input in MSVidCtl_Src.InputsAvailable(GUID_NULL)
    If input.ClassID = DVR_CLSID Then
        ' This is the one we want.
        MSVidCtl_Src.InputActive = input
        Set objStreamBufferSource = input  ' Store this for later use.
    End If

Specify the same file name used previously:

objStreamBufferSource.FileName = strFilename

Run both Video Control instances: