A Complete Example: Server and Client
The following code assumes you are already familiar with using the capture object of the toolkit. It is provided to show the major steps for achieving client-server communication. For a complete code listing, refer to the LEAD NetServer and LEAD NetClient demos.
The server side:
Dim sServer As String
Dim NetMux as LMNetMux
'set the target format The format to be used for the converted file. This includes the file format, any special settings used by that format, and which audio and/or video codec A COmpressor combined with a DECompressor, or encoder and a decoder, which allows you to both compress and decompress that same data. is to be used for the conversion, and any special settings used by the codecs.:
ltmmCaptureCtrl.TargetFormat = ltmmCapture_TargetFormat_NET
' after selecting video and/or audio devices (both assumed)
' and compressors:
' set the server address as a target file
sServer =”ltsf://10.1.1.200” ' use the default port, 27015
ltmmCaptureCtrl.TargetFile = sServer
' call ReadyCapture to build the graph:
ltmmCaptureCtrl.ReadyCapture ltmmCapture_Mode_VideoOrAudio
' change the NET Mux settings if needed:
' get the mux object and query for the interface
Set NetMux = ltmmCaptureCtrl.GetSubObject(ltmmCapture_Object_TargetFilter)
' this is a live source
NetMux.LiveSource = True;
' I can afford 128 kbps only
NetMux.BitRateLimit = 128*1024
Set NetMux = Nothing
' start the server:
ltmmCaptureCtrl.StartCapture ltmmCapture_Mode_VideoOrAudio
' you can monitor the achieved bit rate by continuously checking
' the BitRate property of the NET mux, use: get_BitRate(…)
' to send text messages, use the WriteMessage method of the
mux:
' first, get the mux object again (you might want to keep it for the
' life time of the communication session:
' write the message:
NetMux.WriteMessage("Hello")
The client side:
' set the player source:
Dim sServer As String
sServer = ”ltsf://10.1.1.200”
Dim pns As New LMNetSrc
On Error Resume Next
pns.CheckConnection sServer, 0, 5000
' set the player source:
ltmmPlayCtrl.SourceFile = sServer
' if the AutoStart property is not TRUE, you need to run the player:
ltmmPlayCtrl.Run
' you can monitor the incoming bit rate by checking the BitRate property
of
' the demultiplexer object:
Dim NetDmx As LMNetDmx
Dim bitrate As Long
Set NetDmx = ltmmPlayCtrl.GetSubObject(ltmmPlay_Object_Splitter)
bitrate = NetDmx.BitRate ' you
may display the value
Set NetDmx = Nothing
' to receive a text message sent by the server, use the ReadMessage method:
' first, get the demux object again (you might want to keep it for the
life of
' the communication session:
' read the message:
Dim Message As String;
Message = NetDmx.ReadMessage
' do something with the message.
' Call ReadMessage continuously to check for new messages.