LEADTOOLS Multimedia (Leadtools.Multimedia assembly) Send comments on this topic. | Back to Introduction | Help Version 17.0.3.22
LiveSource Property
See Also 
LMNetMux Namespace > ILMNetMux Interface : LiveSource Property



Gets or sets a value that indicates whether the media source is treated as a live source.

Syntax

Visual Basic (Declaration) 
<DispIdAttribute(3)>
Property LiveSource As Boolean
Visual Basic (Usage)Copy Code
Dim instance As ILMNetMux
Dim value As Boolean
 
instance.LiveSource = value
 
value = instance.LiveSource
C# 
[DispIdAttribute(3)]
bool LiveSource {get; set;}
C++/CLI 
[DispIdAttribute(3)]
property bool LiveSource {
   bool get();
   void set (    bool value);
}

Property Value

true if the source is treated as a live source; otherwise it is false if the source is not live.

Example

Visual BasicCopy Code
Public _result As Boolean = False
Public _form As CaptureCtrlForm = New CaptureCtrlForm()
Public _captureCtrl As CaptureCtrl
Private Const MaxBitRate As Integer = 128
Private Const TestBitRate As Integer = MaxBitRate + 1

Public Sub NetworkMultiplexerExample()
   ' reference the capture control
   _captureCtrl = _form.CaptureCtrl

   ' output file
   Dim outFile As String = "ltsf://127.0.0.1:27015"

   Try
      ' try to find a USB camera
      If _captureCtrl.VideoDevices("Logitech") Is Nothing Then
         Throw New Exception("No Logitech video device available")
      End If

      _captureCtrl.VideoDevices("Logitech").Selected = True

      ' select a video compressor
      _captureCtrl.VideoCompressors.Mpeg4.Selected = True

      ' set the target output file
      _captureCtrl.TargetFormat = TargetFormatType.NET
      _captureCtrl.TargetFile = outFile

      If _captureCtrl.IsModeAvailable(CaptureMode.Video) Then
         ' just 10 seconds of capture time
         _captureCtrl.TimeLimit = 10
         _captureCtrl.UseTimeLimit = True

         ' ready the capture graph in order to get the LNMetMux instance
         _captureCtrl.ReadyCapture(CaptureMode.Video)

         ' get the network multiplexer reference
         Dim pMux As LMNetMux = TryCast(_captureCtrl.GetSubObject(CaptureObject.TargetFilter), LMNetMux)

         If Not pMux Is Nothing Then
            ' set live source (dropping samples is allowed if the sink is not sending fast enough to keep up)
            pMux.LiveSource = True

            ' atleast 10 seconds for the netmux sample queue
            If pMux.MaxQueueDuration < 10 Then
               pMux.MaxQueueDuration = 10
            End If

            ' 128 kbps max
            pMux.BitRateLimit = MaxBitRate * 1024

            ' set the result to what we expect
            _result = True
         End If

         ' start capture
         _captureCtrl.StartCapture(CaptureMode.Video)

         ' we'll loop on the state and pump messages for this example.
         ' but you should not need to if running from a Windows Forms application.
         Do While _captureCtrl.State = CaptureState.Running
            If Not pMux Is Nothing Then
               ' confirm that the actual bitrate does not exceed our max specified above
               _result = _result And (pMux.BitRate / 1024 < TestBitRate)
            End If
            Application.DoEvents()
         Loop

         ' release the mux since its a COM object
         If Not pMux Is Nothing Then
            Marshal.ReleaseComObject(pMux)
         End If
      End If
   Catch e1 As Exception
      _result = False
   End Try
End Sub
C#Copy Code
public bool _result = false;
public CaptureCtrlForm _form = new CaptureCtrlForm();
public CaptureCtrl _captureCtrl;
const int MaxBitRate = 128;
const int TestBitRate = MaxBitRate+1;

public void NetworkMultiplexerExample()
{
   // reference the capture control
   _captureCtrl = _form.CaptureCtrl;

   // output file
   string outFile = @"ltsf://127.0.0.1:27015";

   try
   {
      // try to find a USB camera
      if (_captureCtrl.VideoDevices["Logitech"] == null)
         throw new Exception("No Logitech video device available");

      _captureCtrl.VideoDevices["Logitech"].Selected = true;

      // select a video compressor
      _captureCtrl.VideoCompressors.Mpeg4.Selected = true;

      // set the target output file
      _captureCtrl.TargetFormat = TargetFormatType.NET;
      _captureCtrl.TargetFile = outFile;

      if (_captureCtrl.IsModeAvailable(CaptureMode.Video))
      {
         // just 10 seconds of capture time
         _captureCtrl.TimeLimit = 10;     
         _captureCtrl.UseTimeLimit = true;

         // ready the capture graph in order to get the LNMetMux instance
         _captureCtrl.ReadyCapture(CaptureMode.Video);

         // get the network multiplexer reference
         LMNetMux pMux = _captureCtrl.GetSubObject(CaptureObject.TargetFilter) as LMNetMux;

         if (pMux != null)
         {
            // set live source (dropping samples is allowed if the sink is not sending fast enough to keep up)
            pMux.LiveSource = true;

            // atleast 10 seconds for the netmux sample queue
            if (pMux.MaxQueueDuration < 10)
               pMux.MaxQueueDuration = 10;

            // 128 kbps max
            pMux.BitRateLimit = MaxBitRate * 1024;

            // set the result to what we expect
            _result = true;
         }

         // start capture
         _captureCtrl.StartCapture(CaptureMode.Video);

         // we'll loop on the state and pump messages for this example.
         // but you should not need to if running from a Windows Forms application.
         while (_captureCtrl.State == CaptureState.Running)
         {
            if (pMux != null)
            {
               // confirm that the actual bitrate does not exceed our max specified above
               _result &= (pMux.BitRate/1024 < TestBitRate);
            }
            Application.DoEvents();
         }

         // release the mux since its a COM object
         if (pMux != null)
            Marshal.ReleaseComObject(pMux);
      }
   }
   catch (Exception)
   {
      _result = false;
   }
}

Remarks

If the media source is a live source, dropping samples is allowed if the output is lagging behind the source.

If the media source is NOT live, the multiplexer will buffer more samples to keep up with the source.

This uses the MaxQueueDuration value to determine when to drop samples. In a live capture situation the multiplexer will drop samples in attempt to prevent the video stream from halting before the MaxQueueDuration is reached. The Leadtools Multiplexer will start dropping samples at 2/3 * MaxQueueDuration.

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 2000, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7

See Also