public int SampleRate { get; }
Integer that represents the audio type's sample rate.
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;}}