Resets the network demultiplexer to default values.
[DispIdAttribute(4)]void ResetToDefaults()
<DispIdAttribute(4)>Sub ResetToDefaults()
[DispIdAttribute(4)]void ResetToDefaults();
Resets the network demultiplexer to default values from the previous version of the filter.
using Leadtools;using Leadtools.Multimedia;using LeadtoolsMultimediaExamples.Fixtures;public bool _result = false;public CaptureAndPlayCtrlForm _serverAndClient = new CaptureAndPlayCtrlForm();bool _msgSent = false;CaptureCtrl _captureCtrl;PlayCtrl _playCtrl;LMNetMux _pMux;LMNetDmx _pDemux;const string _networkUrl = @"ltsf://127.0.0.1:27015"; // network stream urlconst string _testMessage = "LEAD NETWORK";string _recordedVideoFile = Path.Combine(LEAD_VARS.MediaDir, "LMNetDmx_ReadMessageExample.mp4");public void NetworkDemultiplexerExample(){// reference the capture control_captureCtrl = _serverAndClient.CaptureCtrl;// reference the play control_playCtrl = _serverAndClient.PlayCtrl;try{// try to find a video cameraif (_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 = _networkUrl;if (_captureCtrl.IsModeAvailable(CaptureMode.Video)){// just 10 seconds of capture time_captureCtrl.TimeLimit = 10;_captureCtrl.UseTimeLimit = true;_captureCtrl.FrameRate = 30;_captureCtrl.UseFrameRate = true;_captureCtrl.Preview = true;// subscribe to the started and progress events for this example// we will connect a client after the capture starts// and send a test message after 5 seconds._captureCtrl.Started += new EventHandler(CaptureCtrl_Started);_captureCtrl.Progress += new ProgressEventHandler(CaptureCtrl_Progress);// ready the capture graph in order to get the LNMetMux instance_captureCtrl.ReadyCapture(CaptureMode.Video);// get the network multiplexer reference_pMux = _captureCtrl.GetSubObject(CaptureObject.TargetFilter) as LMNetMux;if (_pMux != null){// set some mux settings_pMux.LiveSource = 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|| _playCtrl.State == PlayState.Running){Application.DoEvents();}// verify we have a recording file too_result &= File.Exists(_recordedVideoFile);// release the mux and demux COM objectsif (_pMux != null)Marshal.ReleaseComObject(_pMux);if (_pDemux != null)Marshal.ReleaseComObject(_pDemux);}}catch (Exception){_result = false;}}void CaptureCtrl_Progress(object sender, ProgressEventArgs e){// for this test we will send a message after// 5 secs of capture timeif (e.time > 5000 && !_msgSent){_pMux.WriteMessage(_testMessage);Console.WriteLine("Server sent message");_msgSent = true;}}void CaptureCtrl_Started(object sender, EventArgs e){StartClient();}private void StartClient(){try{LMNetSrc netSrc = new LMNetSrc();netSrc.CheckConnection(_networkUrl, 0, 5000);Marshal.ReleaseComObject(netSrc);}catch (COMException){// could not connectreturn;}_playCtrl.SourceFile = _networkUrl;_pDemux = _playCtrl.GetSubObject(PlayObject.Splitter) as LMNetDmx;if (_pDemux != null && _pDemux.AutoLiveTolerance < 5){// reset the demux settings to defaults_pDemux.ResetToDefaults();// set the live tolerance setting to 5 seconds// this will cause the playback to be smoother on jittery// network connections -- although, the playback may lag// behing the live stream when using a tolerance value > 0_pDemux.AutoLiveTolerance = 5;// set the output filename for recorded video_pDemux.OutputFileName = _recordedVideoFile;}_serverAndClient.TestTimer.Interval = 100;_serverAndClient.TestTimer.Tick += new EventHandler(PlayTimer_Tick);_serverAndClient.TestTimer.Start();}void PlayTimer_Tick(object sender, EventArgs e){_serverAndClient.TestTimer.Enabled = false;if (_pDemux != null){// read any messages herestring msg = _pDemux.ReadMessage();// set the result to what we expectif (msg == _testMessage){_result = true;Console.WriteLine("Client received message");}// get the bitrateint bitRate = _pDemux.BitRate;Console.WriteLine("Client bitrate = {0}", bitRate);}_serverAndClient.TestTimer.Enabled = true;}static class LEAD_VARS{public const string MediaDir = @"C:\Program Files (x86)\LEAD Technologies\LEADTOOLS 20\Media";}
Imports LeadtoolsImports Leadtools.MultimediaImports LeadtoolsMultimediaExamples.FixturesPublic _result As Boolean = FalsePublic _serverAndClient As CaptureAndPlayCtrlForm = New CaptureAndPlayCtrlForm()Private _msgSent As Boolean = FalsePrivate _captureCtrl As CaptureCtrlPrivate _playCtrl As PlayCtrlPrivate _pMux As LMNetMuxPrivate _pDemux As LMNetDmxPrivate Const _networkUrl As String = "ltsf://127.0.0.1:27015" ' network stream urlPrivate Const _testMessage As String = "LEAD NETWORK"Dim _recordedVideoFile As String = Path.Combine(LEAD_VARS.MediaDir, "mediafiles/output/LMNetDmx_ReadMessageExample.mp4")Public Sub NetworkDemultiplexerExample()' reference the capture control_captureCtrl = _serverAndClient.CaptureCtrl' reference the play control_playCtrl = _serverAndClient.PlayCtrlTry' try to find a video cameraIf _captureCtrl.VideoDevices("Logitech") Is Nothing ThenThrow 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 = _networkUrlIf _captureCtrl.IsModeAvailable(CaptureMode.Video) Then' just 10 seconds of capture time_captureCtrl.TimeLimit = 10_captureCtrl.UseTimeLimit = True_captureCtrl.FrameRate = 30_captureCtrl.UseFrameRate = True_captureCtrl.Preview = True' subscribe to the started and progress events for this example' we will connect a client after the capture starts' and send a test message after 5 seconds.AddHandler _captureCtrl.Started, AddressOf CaptureCtrl_StartedAddHandler _captureCtrl.Progress, AddressOf CaptureCtrl_Progress' ready the capture graph in order to get the LNMetMux instance_captureCtrl.ReadyCapture(CaptureMode.Video)' get the network multiplexer reference_pMux = TryCast(_captureCtrl.GetSubObject(CaptureObject.TargetFilter), LMNetMux)If Not _pMux Is Nothing Then' set some mux settings_pMux.LiveSource = TrueEnd 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 OrElse _playCtrl.State = PlayState.RunningApplication.DoEvents()Loop' verify we have a recording file too_result = _result And File.Exists(_recordedVideoFile)' release the mux and demux COM objectsIf Not _pMux Is Nothing ThenMarshal.ReleaseComObject(_pMux)End IfIf Not _pDemux Is Nothing ThenMarshal.ReleaseComObject(_pDemux)End IfEnd IfCatch e1 As Exception_result = FalseEnd TryEnd SubPrivate Sub CaptureCtrl_Progress(ByVal sender As Object, ByVal e As ProgressEventArgs)' for this test we will send a message after' 5 secs of capture timeIf e.time > 5000 AndAlso (Not _msgSent) Then_pMux.WriteMessage(_testMessage)Console.WriteLine("Server sent message")_msgSent = TrueEnd IfEnd SubPrivate Sub CaptureCtrl_Started(ByVal sender As Object, ByVal e As EventArgs)StartClient()End SubPrivate Sub StartClient()TryDim netSrc As LMNetSrc = New LMNetSrc()netSrc.CheckConnection(_networkUrl, 0, 5000)Marshal.ReleaseComObject(netSrc)Catch cex As COMException' could not connectReturnEnd Try_playCtrl.SourceFile = _networkUrl_pDemux = TryCast(_playCtrl.GetSubObject(PlayObject.Splitter), LMNetDmx)If Not _pDemux Is Nothing AndAlso _pDemux.AutoLiveTolerance < 5 Then' reset the demux settings to defaults_pDemux.ResetToDefaults()' set the live tolerance setting to 5 seconds' this will cause the playback to be smoother on jittery' network connections -- although, the playback may lag' behing the live stream when using a tolerance value > 0_pDemux.AutoLiveTolerance = 5' set the output filename for recorded video_pDemux.OutputFileName = _recordedVideoFileEnd If_serverAndClient.TestTimer.Interval = 100AddHandler _serverAndClient.TestTimer.Tick, AddressOf PlayTimer_Tick_serverAndClient.TestTimer.Start()End SubPrivate Sub PlayTimer_Tick(ByVal sender As Object, ByVal e As EventArgs)_serverAndClient.TestTimer.Enabled = FalseIf Not _pDemux Is Nothing Then' read any messages hereDim msg As String = _pDemux.ReadMessage()' set the result to what we expectIf msg = _testMessage Then_result = TrueConsole.WriteLine("Client received message")End If' get the bitrateDim bitRate As Integer = _pDemux.BitRateConsole.WriteLine("Client bitrate = {0}", bitRate)End If_serverAndClient.TestTimer.Enabled = TrueEnd SubPublic NotInheritable Class LEAD_VARSPublic Const MediaDir As String = "C:\Program Files (x86)\LEAD Technologies\LEADTOOLS 20\Media"End Class
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
