LEADTOOLS Multimedia (Leadtools.Multimedia assembly)
LEAD Technologies, Inc

CheckConnection Method

Example 





A System.String that contains the server address to be checked.
Value that indicates whether the method should negotiate the user name and password. Possible values are:
Value Meaning
0 Do not negotiate the user name and password.
NetSrc_CC_ForceConnection Negotiate the user name and password.
Value that represents the amount of time, in milliseconds, to wait for the connection check before failing.
Determines whether the server exists without making a connection.
Syntax
[DispIdAttribute(1)]
void CheckConnection( 
   string URL,
   int Flags,
   int Timeout
)
'Declaration
 
<DispIdAttribute(1)>
Sub CheckConnection( _
   ByVal URL As String, _
   ByVal Flags As Integer, _
   ByVal Timeout As Integer _
) 
'Usage
 
Dim instance As ILMNetSrc
Dim URL As String
Dim Flags As Integer
Dim Timeout As Integer
 
instance.CheckConnection(URL, Flags, Timeout)
[DispIdAttribute(1)]
void CheckConnection( 
   string URL,
   int Flags,
   int Timeout
)
DispIdAttribute(1)
function LMNetSrc.ILMNetSrc.CheckConnection( 
   URL ,
   Flags ,
   Timeout 
)
[DispIdAttribute(1)]
void CheckConnection( 
   String^ URL,
   int Flags,
   int Timeout
) 

Parameters

URL
A System.String that contains the server address to be checked.
Flags
Value that indicates whether the method should negotiate the user name and password. Possible values are:
Value Meaning
0 Do not negotiate the user name and password.
NetSrc_CC_ForceConnection Negotiate the user name and password.
Timeout
Value that represents the amount of time, in milliseconds, to wait for the connection check before failing.

Return Value

S_OK if the function was successful.

<>S_OK if an error occurred. Refer to the Error Codes or the HRESULT error codes in the DirectShow documentation.

Example
Copy CodeCopy Code  
Public _result As Boolean = False
Public _serverAndClient As CaptureAndPlayCtrlForm = New CaptureAndPlayCtrlForm()
Private _msgSent As Boolean = False
Private _captureCtrl As CaptureCtrl
Private _playCtrl As PlayCtrl

Private Const _networkUrl As String = "ltsf://127.0.0.1:27015" ' network stream url
Private Const _testMessage As String = "LEAD NETWORK"

Public Sub NetworkSourceExample()
  ' reference the capture control
  _captureCtrl = _serverAndClient.CaptureCtrl

  ' reference the play control
  _playCtrl = _serverAndClient.PlayCtrl

  Try
     ' try to find a video 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 = _networkUrl

     If _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
       AddHandler _captureCtrl.Started, AddressOf CaptureCtrl_Started

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

       ' 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.Running
         Application.DoEvents()
       Loop
     End If
  Catch e1 As Exception
     _result = False
  End Try
End Sub

Private Sub CaptureCtrl_Started(ByVal sender As Object, ByVal e As EventArgs)
  StartClient()
End Sub

Private Sub StartClient()
  Try
     Dim netSrc As LMNetSrc = New LMNetSrc()
     netSrc.CheckConnection(_networkUrl, 0, 5000)
     _result = True
     Marshal.ReleaseComObject(netSrc)
  Catch cex As COMException
     ' could not connect
     _result = False
     Return
  End Try

  ' connects the client player
  _playCtrl.SourceFile = _networkUrl
End Sub
public bool _result = false;
public CaptureAndPlayCtrlForm _serverAndClient = new CaptureAndPlayCtrlForm();
CaptureCtrl _captureCtrl;
PlayCtrl _playCtrl;

const string _networkUrl = @"ltsf://127.0.0.1:27015"; // network stream url
const string _testMessage = "LEAD NETWORK";

public void NetworkSourceExample()
{
   // reference the capture control
   _captureCtrl = _serverAndClient.CaptureCtrl;

   // reference the play control
   _playCtrl = _serverAndClient.PlayCtrl;

   try
   {
      // try to find a video 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 = _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
         _captureCtrl.Started += new EventHandler(CaptureCtrl_Started);

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

         // 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();
         }
      }
   }
   catch (Exception)
   {
      _result = false;
   }
}

void CaptureCtrl_Started(object sender, EventArgs e)
{
   StartClient();
}

private void StartClient()
{
   try
   {
      LMNetSrc netSrc = new LMNetSrc();
      netSrc.CheckConnection(_networkUrl, 0, 5000);
      _result = true;
      Marshal.ReleaseComObject(netSrc);
   }
   catch (COMException)
   {
      // could not connect
      _result = false;
      return;
   }

   // connects the client player
   _playCtrl.SourceFile = _networkUrl;
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

ILMNetSrc Interface
ILMNetSrc Members

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.