←Select platform

IsVideoEncoded Property

Summary

Queries whether the current capture configuration has pre-encoded video.

Syntax

C#
VB
C++
public bool IsVideoEncoded {get;} 
Public ReadOnly Property IsVideoEncoded As Boolean 
public: 
property bool IsVideoEncoded { 
   bool get(); 
} 

Property Value

True if UseDeviceEncoding is true and the video device has output-compatible encoding.

Remarks

determine whether the video will be recompressed or is pre-encoded. It can be used by the application designer to disable output video encoding options if the pre-encoded video is used by the stream. You must lock the capture devices with LockDevices before calling this function.

Example

C#
VB
using Leadtools; 
using Leadtools.MediaStreaming; 
 
public Server _server = null; 
public bool _result = false; 
LiveStreamDevConfig devconfig; 
 
public class DesktopWin : System.Windows.Forms.IWin32Window 
{ 
   public DesktopWin() 
   { 
   } 
 
   public IntPtr Handle 
   { 
      get { return IntPtr.Zero; } 
   } 
} 
 
public void CreateOrReplaceLiveStreamExample() 
{ 
   try 
   { 
      int StreamIndex = 0; 
      string strPath = "Live/Stream1"; // live stream's path to find 
      // video device's name on my system (LEAD RTSP Source) 
      string strVideoDevice = "@device:sw:{083863F1-70DE-11D0-BD40-00A0C911CE86}\\{E2B7DE48-38C5-11D5-91F6-00104BDB8FF9}"; 
      // audio device's name on my system (Microphone (HD Pro Webcam C920)) 
      string strAudioDevice = "@device:cm:{33D9A762-90C8-11D0-BD43-00A0C911CE86}\\wave:{9D2FBF73-D543-44DA-8846-AE780EE65484}"; 
 
      // create an instance of the server object 
      _server = new Leadtools.MediaStreaming.Server(); 
 
      // retrieve a copy of the Live Streams 
      LiveStreams Streams = _server.GetLiveStreams(); 
 
      LiveStream stream = null; 
 
      // search for existing stream with same path 
 
      for (StreamIndex = 0; StreamIndex < Streams.Count; StreamIndex++) 
      { 
         stream = Streams.GetLiveStream(StreamIndex); 
 
         if (stream.Path == strPath) 
            break; 
 
         stream.Dispose(); 
         stream = null; 
      } 
      if (stream == null) 
      { 
         // create a new stream 
         StreamIndex = -1; 
         stream = Streams.CreateLiveStream(); 
      } 
 
      // set the stream path 
      stream.Path = strPath; 
 
      // setup to recompress, change this to true if you want to use the device built-in compression 
      stream.UseDeviceEncoding = false; 
 
      // select video device 
      Leadtools.MediaStreaming.Devices videodevices; 
      videodevices = stream.VideoDevices; 
      int index = -1; 
      index = videodevices.IndexOf(strVideoDevice); 
      videodevices.Selection = index; 
 
      // select audio device 
      Leadtools.MediaStreaming.Devices audiodevices; 
      audiodevices = stream.AudioDevices; 
      index = -1; 
      index = audiodevices.IndexOf(strAudioDevice); 
      audiodevices.Selection = index; 
 
      /** alternative method of selection 
      if(index >= 0) 
      { 
         Leadtools.MediaStreaming.Device device; 
         device = audiodevices.[index]; 
         device.Selected = true; 
      } 
      else 
      { 
         audiodevices.Selection = -1; 
      } 
      **/ 
 
      // lock the devices so we can edit their properties 
      devconfig = stream.DeviceConfig; 
      devconfig.LockDevices(); 
 
      DesktopWin win = new DesktopWin(); 
 
      // show the main video device property page, if available 
      if (devconfig.HasDialog(LiveStreamDlg.VideoDevice)) 
      { 
         devconfig.ShowDialog(LiveStreamDlg.VideoDevice, win); 
      } 
 
      // show the main audio device property page, if available 
      if (devconfig.HasDialog(LiveStreamDlg.AudioDevice)) 
      { 
         devconfig.ShowDialog(LiveStreamDlg.AudioDevice, win); 
      } 
 
      // setup output video 
      if (devconfig.IsVideoEncoded) // the video is already encoded, the video output settings are ignored 
      { 
         stream.UseVideoInputSize = true; 
 
         // if UseVideoInputSize is true, then the width and height are ignored 
         stream.VideoWidth = 320; 
 
         stream.VideoHeight = 240; 
 
         stream.UseVideoInputFrameRate = true; 
 
         // if UseVideoInputFrameRate is true, then the frame rate is ignored 
         stream.VideoFrameRate = 29.97; 
 
         stream.VideoBitRate = 700000; 
 
         stream.QSVAcceleration = true; 
 
         stream.CUDAAcceleration = true; 
      } 
 
      // setup output audio 
      if (devconfig.IsAudioEncoded) // the audio is already encoded, the audio output settings are ignored 
      { 
         int nCount = 0; 
 
         Leadtools.MediaStreaming.AudioTypes audiotypes = null; 
 
         audiotypes = stream.AudioTypes; 
 
         nCount = audiotypes.Count; 
 
         for (index = 0; index < nCount; index++) 
         { 
            Leadtools.MediaStreaming.AudioType audiotype = audiotypes[index]; 
 
            if (audiotype.Channels == 2 && audiotype.BitRate == 192000 && audiotype.SampleRate == 44100) 
            { 
               audiotype.Selected = true; 
               // alternative method of selection 
               // audiotypes.Selection = index; 
               break; 
            } 
         } 
      } 
 
      // setup output fragment size 
      stream.MinimumFragmentDuration = 2.0; 
 
      // add or replace stream 
      if (StreamIndex < 0) 
         Streams.AddLiveStream(stream); 
      else 
         Streams.SetLiveStream(StreamIndex, stream); 
 
      _server.SetLiveStreams(Streams); 
 
      if (devconfig != null) 
         devconfig.UnlockDevices(); 
 
      _result = true; 
   } 
   catch (Exception) 
   { 
      if (devconfig != null) 
         devconfig.UnlockDevices(); 
 
      _result = false; 
   } 
} 
Imports Leadtools 
Imports Leadtools.MediaStreaming 
 
 
Public _server As Server = Nothing 
Public _result As Boolean = False 
Private devconfig As LiveStreamDevConfig 
 
Public Class DesktopWin 
   Implements System.Windows.Forms.IWin32Window 
   Public Sub New() 
   End Sub 
 
   Public ReadOnly Property Handle() As IntPtr Implements IWin32Window.Handle 
      Get 
         Return System.IntPtr.Zero 
      End Get 
   End Property 
End Class 
 
Public Sub CreateOrReplaceLiveStreamExample() 
   Try 
      Dim StreamCount As Integer = 0 
      Dim StreamIndex As Integer = 0 
      Dim strPath As String = "Live/Stream1" ' live stream's path to find 
      ' video device's name on my system (LEAD RTSP Source) 
      Dim strVideoDevice As String = "@device:sw:{083863F1-70DE-11D0-BD40-00A0C911CE86}\{E2B7DE48-38C5-11D5-91F6-00104BDB8FF9}" 
      ' audio device's name on my system (Microphone (HD Pro Webcam C920)) 
      Dim strAudioDevice As String = "@device:cm:{33D9A762-90C8-11D0-BD43-00A0C911CE86}\wave:{9D2FBF73-D543-44DA-8846-AE780EE65484}" 
 
      ' create an instance of the server object 
      _server = New Leadtools.MediaStreaming.Server() 
 
      ' retrieve a copy of the Live Streams 
      Dim Streams As LiveStreams = _server.GetLiveStreams() 
 
      Dim stream As LiveStream = Nothing 
 
      ' search for existing stream with same path 
 
      StreamCount = Streams.Count 
 
      StreamIndex = 0 
      Do While StreamIndex < StreamCount 
         stream = Streams.GetLiveStream(StreamIndex) 
 
         If stream.Path = strPath Then 
            Exit Do 
         End If 
 
         stream.Dispose() 
         stream = Nothing 
         StreamIndex += 1 
      Loop 
      If stream Is Nothing Then 
         ' create a new stream 
         StreamIndex = -1 
         stream = Streams.CreateLiveStream() 
      End If 
 
      ' set the stream path 
      stream.Path = strPath 
 
      ' setup to recompress, change this to true if you want to use the device built-in compression 
      stream.UseDeviceEncoding = False 
 
      ' select video device 
      Dim videodevices As Leadtools.MediaStreaming.Devices 
      videodevices = stream.VideoDevices 
      Dim index As Integer = -1 
      index = videodevices.IndexOf(strVideoDevice) 
      videodevices.Selection = index 
 
      ' select audio device 
      Dim audiodevices As Leadtools.MediaStreaming.Devices 
      audiodevices = stream.AudioDevices 
      index = -1 
      index = audiodevices.IndexOf(strAudioDevice) 
 
      audiodevices.Selection = index 
 
      '' alternative method of selection 
      'If index >= 0 Then 
      'Dim device As Leadtools.MediaStreaming.Device 
      'device = audiodevices(index) 
      'device.Selected = True 
      'Else 
      'audiodevices.Selection = -1 
      'End If 
 
      ' lock the devices so we can edit their properties 
      devconfig = stream.DeviceConfig 
      devconfig.LockDevices() 
 
      Dim win As DesktopWin = New DesktopWin() 
 
      ' show the main video device property page, if available 
      If devconfig.HasDialog(LiveStreamDlg.VideoDevice) Then 
         devconfig.ShowDialog(LiveStreamDlg.VideoDevice, win) 
      End If 
 
      ' show the main audio device property page, if available 
      If devconfig.HasDialog(LiveStreamDlg.AudioDevice) Then 
         devconfig.ShowDialog(LiveStreamDlg.AudioDevice, win) 
      End If 
 
      ' setup output video 
      If devconfig.IsVideoEncoded Then ' the video is already encoded, the video output settings are ignored 
         stream.UseVideoInputSize = True 
 
         ' if UseVideoInputSize is true, then the width and height are ignored 
         stream.VideoWidth = 320 
 
         stream.VideoHeight = 240 
 
         stream.UseVideoInputFrameRate = True 
 
         ' if UseVideoInputFrameRate is true, then the frame rate is ignored 
         stream.VideoFrameRate = 29.97 
 
         stream.VideoBitRate = 700000 
 
         stream.QSVAcceleration = True 
 
         stream.CUDAAcceleration = True 
      End If 
 
      ' setup output audio 
      If devconfig.IsAudioEncoded Then ' the audio is already encoded, the audio output settings are ignored 
         Dim nCount As Integer = 0 
 
         Dim audiotypes As Leadtools.MediaStreaming.AudioTypes = Nothing 
 
         audiotypes = stream.AudioTypes 
 
         nCount = audiotypes.Count 
 
         index = 0 
         Do While index < nCount 
            Dim audiotype As Leadtools.MediaStreaming.AudioType = audiotypes(index) 
 
            If audiotype.Channels = 2 AndAlso audiotype.BitRate = 192000 AndAlso audiotype.SampleRate = 44100 Then 
               audiotype.Selected = True 
               ' alternative method of selection 
               'audiotypes.Selection = index 
 
               Exit Do 
            End If 
            index += 1 
         Loop 
      End If 
 
      ' setup output fragment size 
      stream.MinimumFragmentDuration = 2.0 
 
      ' add or replace stream 
      If StreamIndex < 0 Then 
         Streams.AddLiveStream(stream) 
      Else 
         Streams.SetLiveStream(StreamIndex, stream) 
      End If 
 
      _server.SetLiveStreams(Streams) 
 
      If Not devconfig Is Nothing Then 
         devconfig.UnlockDevices() 
      End If 
 
      _result = True 
   Catch e1 As Exception 
      If Not devconfig Is Nothing Then 
         devconfig.UnlockDevices() 
      End If 
 
      _result = False 
   End Try 
End Sub 

Requirements

Target Platforms

Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
Leadtools.MediaStreaming Assembly
Click or drag to resize