Capture to Play Control Interfacing Example for Visual Basic

The following code demonstrates grabbing samples from the capture control and feeding them to the play control. It is intended to demonstrate the basic function set that would be required to remote the playback of media samples.

Dim SampleSource As ltmmSampleSource
Dim SampleTarget As ltmmSampleTarget


Private Sub cmdAbort_Click()
    ' stop processing samples
    timer.Enabled = False
    ' stop the capture control
    ltmmCaptureCtrl1.StopCapture
    ' stop the play control
    SampleSource.DeliverEndOfStream 1000
    ltmmPlayCtrl1.Stop
    ' exit
    Unload Me
End Sub

Private Sub Form_Load()
    Dim varProtableType As Variant
    Dim MediaType As ltmmMediaType
    Dim MediaSample As ltmmMediaSample
    
    ' create the play sample source object
    Set SampleSource = New ltmmSampleSource
    
    ' create the capture sample target object
    Set SampleTarget = New ltmmSampleTarget
   
    ' assign the target to the capture control
    ltmmCaptureCtrl1.TargetObject = SampleTarget
    ' not using preview for this example
    ltmmCaptureCtrl1.Preview = False
    ' select first video device
    ltmmCaptureCtrl1.VideoDevices.Selection = 0
    ' select the LEAD compressor
    ltmmCaptureCtrl1.VideoCompressors.Selection = ltmmCaptureCtrl1.VideoCompressors.Find("@device:sw:{33D9A760-90C8-11D0-BD43-00A0C911CE86}\LEAD MCMP/MJPEG Codec A COmpressor Also known as an encoder, this is a module or algorithm to compress data. Playing that data back requires a decompressor, or decoder. combined with a DECompressor, or encoder Also known as compressor, this is a module or algorithm to compress data. Playing that data back requires a decompressor, or decoder. and a decoder Also known as a decompressor, this is a module or algorithm to decompress data., which allows you to both compress and decompress that same data. (2.0)")
    ' run the capture graph
    ltmmCaptureCtrl1.StartCapture ltmmCapture_Mode_Video
    
    ' could just assign the media type from target to source
    ' however, let's use the portable type to simulate
    ' the needed steps for remote playback
    varPortableType = SampleTarget.GetConnectedMediaType ()GetPortableType
    
    ' initialize a media type object with the portable type
    Set MediaType = New ltmmMediaType
    MediaType.SetPortableType varPortableType
    ' assign it to the source
    SampleSource.SetMediaType MediaType
    ' assignment of the source object will start playback
    ltmmPlayCtrl1.SourceObject = SampleSource
    ' start processing samples
    timer.Enabled = True

End Sub


Private Sub timer_Timer()
    ' get a sample and pass it along
   SampleSource.DeliverSample 1000, SampleTarget.GetSample(1000) 
End Sub