public void AddLiveStream(LiveStream stream)
Public Sub AddLiveStream( _ByVal stream As LiveStream _)
public:void AddLiveStream(LiveStream^ stream)
stream
The new LiveStream to copy and append to the collection.
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 StreamsLiveStreams Streams = _server.GetLiveStreams();LiveStream stream = null;// search for existing stream with same pathfor (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 streamStreamIndex = -1;stream = Streams.CreateLiveStream();}// set the stream pathstream.Path = strPath;// setup to recompress, change this to true if you want to use the device built-in compressionstream.UseDeviceEncoding = false;// select video deviceLeadtools.MediaStreaming.Devices videodevices;videodevices = stream.VideoDevices;int index = -1;index = videodevices.IndexOf(strVideoDevice);videodevices.Selection = index;// select audio deviceLeadtools.MediaStreaming.Devices audiodevices;audiodevices = stream.AudioDevices;index = -1;index = audiodevices.IndexOf(strAudioDevice);audiodevices.Selection = index;/** alternative method of selectionif(index >= 0){Leadtools.MediaStreaming.Device device;device = audiodevices.[index];device.Selected = true;}else{audiodevices.Selection = -1;}**/// lock the devices so we can edit their propertiesdevconfig = stream.DeviceConfig;devconfig.LockDevices();DesktopWin win = new DesktopWin();// show the main video device property page, if availableif (devconfig.HasDialog(LiveStreamDlg.VideoDevice)){devconfig.ShowDialog(LiveStreamDlg.VideoDevice, win);}// show the main audio device property page, if availableif (devconfig.HasDialog(LiveStreamDlg.AudioDevice)){devconfig.ShowDialog(LiveStreamDlg.AudioDevice, win);}// setup output videoif (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 ignoredstream.VideoWidth = 320;stream.VideoHeight = 240;stream.UseVideoInputFrameRate = true;// if UseVideoInputFrameRate is true, then the frame rate is ignoredstream.VideoFrameRate = 29.97;stream.VideoBitRate = 700000;stream.QSVAcceleration = true;stream.CUDAAcceleration = true;}// setup output audioif (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 sizestream.MinimumFragmentDuration = 2.0;// add or replace streamif (StreamIndex < 0)Streams.AddLiveStream(stream);elseStreams.SetLiveStream(StreamIndex, stream);_server.SetLiveStreams(Streams);if (devconfig != null)devconfig.UnlockDevices();_result = true;}catch (Exception){if (devconfig != null)devconfig.UnlockDevices();_result = false;}}
Imports LeadtoolsImports Leadtools.MediaStreamingPublic _server As Server = NothingPublic _result As Boolean = FalsePrivate devconfig As LiveStreamDevConfigPublic Class DesktopWinImplements System.Windows.Forms.IWin32WindowPublic Sub New()End SubPublic ReadOnly Property Handle() As IntPtr Implements IWin32Window.HandleGetReturn System.IntPtr.ZeroEnd GetEnd PropertyEnd ClassPublic Sub CreateOrReplaceLiveStreamExample()TryDim StreamCount As Integer = 0Dim StreamIndex As Integer = 0Dim 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 StreamsDim Streams As LiveStreams = _server.GetLiveStreams()Dim stream As LiveStream = Nothing' search for existing stream with same pathStreamCount = Streams.CountStreamIndex = 0Do While StreamIndex < StreamCountstream = Streams.GetLiveStream(StreamIndex)If stream.Path = strPath ThenExit DoEnd Ifstream.Dispose()stream = NothingStreamIndex += 1LoopIf stream Is Nothing Then' create a new streamStreamIndex = -1stream = Streams.CreateLiveStream()End If' set the stream pathstream.Path = strPath' setup to recompress, change this to true if you want to use the device built-in compressionstream.UseDeviceEncoding = False' select video deviceDim videodevices As Leadtools.MediaStreaming.Devicesvideodevices = stream.VideoDevicesDim index As Integer = -1index = videodevices.IndexOf(strVideoDevice)videodevices.Selection = index' select audio deviceDim audiodevices As Leadtools.MediaStreaming.Devicesaudiodevices = stream.AudioDevicesindex = -1index = 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 propertiesdevconfig = stream.DeviceConfigdevconfig.LockDevices()Dim win As DesktopWin = New DesktopWin()' show the main video device property page, if availableIf devconfig.HasDialog(LiveStreamDlg.VideoDevice) Thendevconfig.ShowDialog(LiveStreamDlg.VideoDevice, win)End If' show the main audio device property page, if availableIf devconfig.HasDialog(LiveStreamDlg.AudioDevice) Thendevconfig.ShowDialog(LiveStreamDlg.AudioDevice, win)End If' setup output videoIf devconfig.IsVideoEncoded Then ' the video is already encoded, the video output settings are ignoredstream.UseVideoInputSize = True' if UseVideoInputSize is true, then the width and height are ignoredstream.VideoWidth = 320stream.VideoHeight = 240stream.UseVideoInputFrameRate = True' if UseVideoInputFrameRate is true, then the frame rate is ignoredstream.VideoFrameRate = 29.97stream.VideoBitRate = 700000stream.QSVAcceleration = Truestream.CUDAAcceleration = TrueEnd If' setup output audioIf devconfig.IsAudioEncoded Then ' the audio is already encoded, the audio output settings are ignoredDim nCount As Integer = 0Dim audiotypes As Leadtools.MediaStreaming.AudioTypes = Nothingaudiotypes = stream.AudioTypesnCount = audiotypes.Countindex = 0Do While index < nCountDim audiotype As Leadtools.MediaStreaming.AudioType = audiotypes(index)If audiotype.Channels = 2 AndAlso audiotype.BitRate = 192000 AndAlso audiotype.SampleRate = 44100 Thenaudiotype.Selected = True' alternative method of selection'audiotypes.Selection = indexExit DoEnd Ifindex += 1LoopEnd If' setup output fragment sizestream.MinimumFragmentDuration = 2.0' add or replace streamIf StreamIndex < 0 ThenStreams.AddLiveStream(stream)ElseStreams.SetLiveStream(StreamIndex, stream)End If_server.SetLiveStreams(Streams)If Not devconfig Is Nothing Thendevconfig.UnlockDevices()End If_result = TrueCatch e1 As ExceptionIf Not devconfig Is Nothing Thendevconfig.UnlockDevices()End If_result = FalseEnd TryEnd Sub
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
