Microsoft TV Technologies and the Video Control COM object

 Around XP and possibly a little bit earlier, the WDM device driver model for Windows device drivers became popular. 

 And the COM object method of  writing programs, with a whole raft of common services that could be accessed and programmed abstractly without knowing the details of the devices or their drivers.

Windows 2000, XP and up until very recently had a COM object group of library code for implementing and using Analog and Digital TV signal media, called Microsoft TV Technologies.

It was hard to understand after learning upwards from missing device drivers, then Directshow Filters and the Graph Edit method of graphically constructing abstract visual Graphs linking filters into running prototypes for understanding how video capture devices worked.. that they related to Microsoft TV Technologies.

Originally the BDA - Broadcast Driver Architecture, defined "How" to "Tune" an Analog or Digital source by firing off a Graph Build process that created a Filter Graph in program memory.

Usually this was expected to be an Analog TV tuner card, or a Digital Video Broadcast (DVB) TV tuner card. But to accommodate, legacy "analog input only" cards with simply s-video or composite they also included an AuxIn type of "Tuning" which treated a Video Capture card as if it were a complete Analog TV tuner.

Once a handle for a COM Object of the Tuner type was obtained, a tuner request object was created by the COM object and then used as a template to "fill out" or complete a Tuning request.. which when executed or "Run" by calling a Video Control method.. caused the Video Control Object to assemble and run the Directshow Graph constructed of filters to accomplish the task.. which included "Rendering" the output to a video window.

The Streaming Buffer Component could also be used with the Video Control to Pause, Rewind and Record the currently viewed stream.

The Video Control COM object could be used by VBscript, Jscript automation scripting via HTML or Windows Shell Host.. or used via Visual C/C++ or Visual Basic. Which offered finer degrees of control.

Or Directshow could be used directly via its GraphBuilder object to build up a custom Graph either partially automatic or manually.

This appeared to be the foundation of Windows Media Center in Windows XP and later.. but I'm not entirely sure how Graph Build automation succeeded with some hardware compression cards.. I suspect the WMC compatible brand label required some sort of WMC helper agent to establish or assist the automation process of completing a graph that had hardware encoders and or decoders for MPEG2.

Although I could see how it might work with plain frame grabber YUV frames that required only a minimal Directshow Graph Filter.

Using the Video Control

The dual nature of Playback versus Record, also led to the separation of Graphs in memory and priority when using a program like Windows Media Center or other Capture software.

When using GraphEdit to view a Playback graph of WMC or Capture software only the Playback graph could be seen in the RunTime Object Table (ROT) if the operating system didn't block access due to different administative priority levels.. like ordinary user versus a system service.

GraphEdit could be "tricked" into "seeing" other spaces, by starting both in the same user space, or running GraphEdit with administrator rights.. or launching GraphEdit with an "at" command to proxy access to the system level space "services" are run launching a command window and then launching GraphEdit from a C:\ prompt

All of which was much easier in XP or 32 bit days, before strict enforcement of user memory spaces were enforced and hid much of the access to the memory space of other programs due to security and malware concerns.

This is a snippet of  VBScript that illustrates how the Video Control "MsVidCtl" is grasped and instantiated, then Objects are created from the Control and used to accomplish automation tasks upon the control.

The "simplified" world view of the Video Control is that there are only three things; Input Devices, Features and Output Devices. Where the word "Devices" is over used in this situation to represent something other than just a Filter in a Graph. Essentially the Video Control does whatever is necessary in the background to "enable" the COM object "controls" to do their function. The "exposed" controls being a set of objects that "look like" a Tuning Source, some minimal closed caption decoding, and finally a Video window.



    This sample requires an analog TV tuner card compatible with the Windows Driver Model.

<OBJECT ID="MSVidCtl" CLASSID="CLSID:B0EDF163-910A-11D2-B632-00C04F79498E"></OBJECT>

<SCRIPT language=vbscript>
option explicit

dim tscontainer 'tuning space collection
dim ts 'Analog TV tuning space
dim tr 'Analog TV tune request

sub window_onload
    MSVidCtl.Width = 800
    MSVidCtl.Height = 600
    set tscontainer = CreateObject("BDATuner.SystemTuningSpaces")

    'Get the tuning space with the word "Cable" in its name. 
    'This tuning space works with North American NTSC Cable
    'You can use the tuning space "Antenna" if you are using NTSC terrestrial analog broadcast
    'For other types of analog broadcast, you will need to create your own tuning space
        set ts = tscontainer("Cable")

        set tr = ts.CreateTuneRequest
    'By default we will start on channel 5
    tr.Channel = 5
    'Pass the tune request to the View() method and then build the graph
    MSVidCtl.View tr

    'This will alpha blend the image mstv.jpg over the video
    dim pict
    dim alpha
    dim tempvidrend
    dim myrect

    dim CurrentPath
    CurrentPath = location.href
    CurrentPath = Replace(CurrentPath,"%20"," ")
    CurrentPath = Replace(CurrentPath,"/","\")
    CurrentPath = Mid(CurrentPath,6,InstrRev(CurrentPath,"\")-6)
    if Mid(CurrentPath, 5, 1) = ":" then CurrentPath = Mid(CurrentPath, 4, Len(CurrentPath)-3)
    dim fileLoc
    fileLoc = CurrentPath & "\mstv.jpg"
    set pict = LoadPicture(fileLoc)

    alpha = 35
    set tempvidrend = MSVidCtl.VideoRendererActive
    tempvidrend.MixerBitmapOpacity = alpha
    set myrect = tempvidrend.MixerBitmapPositionRect
    myrect.Top = 20
    myrect.Left = 20
    myrect.Width = 50
    myrect.Height = 20
    tempvidrend.MixerBitmapPositionRect = myrect
    tempvidrend.MixerBitmap = pict

    'Display the channel information
    dl.innertext = MSVidCtl.InputActive.Tune.Channel
    currentchannel.value = MSVidCtl.InputActive.Tune.Channel
end sub

sub startbutton_onclick
    'This starts the graph and begins displaying audio and video
end sub

sub stopbutton_onclick
    'This stops the graph, but does not destroy it
end sub

sub chanup_onclick
    'Tune to the next channel up
    tr.Channel = tr.Channel + 1
        MSVidCtl.View tr

        dl.innertext = MSVidCtl.InputActive.Tune.Channel
    currentchannel.value = MSVidCtl.InputActive.Tune.Channel
end sub

sub chandown_onclick
    'Tune to the next channel down
    tr.Channel = tr.Channel - 1
        MSVidCtl.View tr

        dl.innertext = MSVidCtl.InputActive.Tune.Channel
    currentchannel.value = MSVidCtl.InputActive.Tune.Channel
end sub

sub enter_onclick
    'Tune to the channel the user entered in the textbox
    tr.channel = currentchannel.value
        MSVidCtl.View tr

        dl.innertext = MSVidCtl.InputActive.Tune.Channel
    currentchannel.value = MSVidCtl.InputActive.Tune.Channel
end sub