SVClientSDK2

From Servision wiki
Jump to: navigation, search

Contents

Introduction

SerVision Client SDK2 is a COM-based client development kit allowing the user to unleash the full capabilities of SerVision Gateways. The SDK privides the user with the following core functionality (implemented in SVClientSDK2.dll):


Additionaly, the SDK provides the following GUI extensions (implemented in SVVideoPlayer.dll):

Download locations

The SDK2 is available in the following packages:

Unzip this archive and register the DLLs with regsvr32.exe, prior to using them in your development environment. Please note: to register the SDK on Vista or Win7 the user must have elevated permissions; to gain them, launch cmd.exe "as Administrator", then invoke regsvr32. If the above doesn't help, please disable UAC temporarily.

This package is automatically handled by Internet Explorer.

(see Revision History for details).

The following sample applications are available to download:

Revision history

See revision history

Entities overview

See entities overview


Reference

See full reference


Tutorial

In order to use most of examples from this tutorial, just copy the whole code of the appropriate example to an empty source-file.

Some examples require the SDK Window to be put on a Form. To compile them, it is crucial to import Window control from SVVideoPlayer.dll and ensure that AxSVVideoPlayer gets added to your project! Note that these examples have putWindowOnForm() placeholder function to allow errorless compilation. However to make them useful, it's recommended to do the following steps:

1) Create an empty WinForm application.

2) Import Window control from SVVideoPlayer.dll so that AxSVVideoPlayer reference will be added to your project.

3) Put SDK Window onto a Form.

4) Copy the appropriate example functions to the Form.

5) Modify these functions in the following way: remove "static" keywords; instead of "window_" use the Window instance you've just put in (3).


Connecting to a Gateway

Establishing connection to a gateway synchronously and acquiring its cameras and sensors

C#:

using System;
using System.Diagnostics;
using System.Windows.Forms; // for Application object
using ClientCoreCOMLib;
 
static class Demo
{
  static void connectToServer()
  {
    // If server object is disposed, it's disconnected from the Gateway,
    // so in a real application it's usually a member variable
    server server = new server();
 
    // subsribe to server events
    server.connectResponded += (sender, error) => { Debug.WriteLine("The result of an attempt to connect gateway: " + error.message); };
    server.loginResponded += (sender, error) => { Debug.WriteLine("The result of an attempt to login: " + error.message); };
 
    // connect to the gateway;
    // the function blocks until the connection is established or an error occures, or an implementation-defined time-out is reached
    var err = server.connect(Encryption.enNone, "demo01.svgateway.com", 9980);
    Debug.WriteLine(err.message);
    server.login("guest", "guest");
 
    // streaming services are the Cameras, Eventer, GPS, Recorders and some other services, which are able of producing a stream of data
    server.requestStreamingServices();
    foreach (camera cam in server.cameras)
      Debug.WriteLine(cam.name);
 
    // non-streaming services are the sensors (including activators and motion-detection sensors)
    server.requestNonstreamingServices();
    foreach (sensor sens in server.sensors)
      Debug.WriteLine(sens.name);
  }
 
  [STAThread]
  static void Main()
  {
    connectToServer();
    Application.Run();
  }
}

Establishing connection to a gateway asynchronously and acquiring its cameras and sensors

C#:

using System;
using System.Diagnostics;
using ClientCoreCOMLib;
using System.Windows.Forms; // for Application object
 
static class Demo
{
  static server server_ = new server();
 
  static void asyncConnectToGateway()
  {
    var asyncServer = server_ as IAsyncServer;
    // connect to the gateway; the function returns immediately
    // (also see CompletionCondition in the Reference)
    asyncServer.connect(Encryption.enNone, "demo01.svgateway.com", 9980, null, condOnSuccess);
    // we can issue next asynchronous action, without waiting for completion of the previous one
    asyncServer.login("guest", "guest", null, condOnSuccess);
    // subscirbe to the relevant events
    server_.streamingServicesResponded += streamingServicesResponded;
    server_.nonstreamingServicesResponded += nonstreamingServicesResponded;
    // request services
    asyncServer.requestStreamingServices(null, condOnSuccess);
    asyncServer.requestNonstreamingServices(null, condOnSuccess);
  }
 
 
  static void streamingServicesResponded(IServer sender, IErrorCode error)
  {
    if (error.value == 0)
      foreach(camera cam in sender.cameras)
        Debug.WriteLine(cam.name);
    else
      Debug.WriteLine(error.message);
  }
 
  static void nonstreamingServicesResponded(IServer sender, IErrorCode error)
  {
    if (error.value == 0)
      foreach(sensor sens in sender.sensors)
        Debug.WriteLine(sens.name);
    else
      Debug.WriteLine(error.message);
  }
 
  [STAThread]
  static void Main()
  {
    asyncConnectToGateway();
    Application.Run();
  }
}

Automatic reconnection

C#

using System;
using System.Diagnostics;
using ClientCoreCOMLib;
using System.Windows.Forms; // for Application object
 
static class Demo
{
  static server server_ = new server();
  // member object; should be alive as long as the connection monitoring is necessary
  static Reconnector reconnector_ = new Reconnector(); 
  static void asyncConnectWithReconnection()
  {
    // single Reconnector can server multiple servers
    reconnector_.beginScenario(server_); 
    try
    {
      // when the connection is lost, reconnector_ will wait 30 seconds before re-trying to connect
      reconnector_.set_delay(server_, 30);
 
      // on each reconnection the following procedures will be invoked;
      // NOTE: if reconnection is successful, 
      // all the services and streams, previously hold by the client, are valid and usable again, 
      // and all the streams are re-started automatically
      (server_ as IAsyncServer).connect(Encryption.enNone, "demo01.svgateway.com", 9980, null, condAlways);
      (server_ as IAsyncServer).login("guest", "guest", null, condAlways);
      (server_ as IAsyncServer).requestStreamingServices(null, condAlways);
      (server_ as IAsyncServer).requestNonstreamingServices(null, condAlways);
    }
    finally
    {
      reconnector_.endScenario(server_);
    }
    // application-level "ping" will be sent to the Gateway every 20 seconds, to ensure it's alive
    // NOTE: it's unnecessary to set keepAliveInterval explicitly, as it has a default value, which is optimal for most applications
    (server_ as IControlSession).keepAliveInterval = 20;
  }
 
  [STAThread]
  static void Main()
  {
    asyncConnectWithReconnection();
    Application.Run();
  }
}

Playing live and recorded video and audio

Starting live video-stream and stopping it

C#

using System;
using System.Diagnostics;
using ClientCoreCOMLib;
using System.Windows.Forms; // for Application object
 
static class Demo
{
  // the ActiveX should be imported from SVVideoPlayer.dll
  static AxSVVideoPlayerLib.AxWindow window_ = new AxSVVideoPlayerLib.AxWindow();
 
  static void putWindowOnForm(AxSVVideoPlayerLib.AxWindow window)
  {
    // implement it
  }
 
  static server server_ = new server();
  static void startLiveVideoFrom1stCamera()
  {
    server_.connect(Encryption.enNone, "demo01.svgateway.com", 9980);
    server_.login("guest", "guest");
    var err = server_.requestStreamingServices();
    if (err.value == 0)
    {
      var stream = server_.cameras[1].createStream(Type.Missing);
      (stream as _IStream_Events_Event).started += (sender) => { Debug.WriteLine("Started video from camera: " + (sender as ILiveCameraStream).camera.name); };
      putWindowOnForm(window_);
      (stream as ICameraStream).player = (IBitmapWindow)window_.GetOcx();
      // if the stream fails (eg., because of a network disconnection), the SDK will attempt to "rebind" it every 20 seconds
      // NOTE: it's unnecessary to set autoRebindInterval explicitly, as it has a default value, which is optimal for most applications
      stream.autoRebindInterval = 20;
      stream.start(PictureSize.sizSmall, StreamQuality.qualHigh, false, false, false);
 
      // Instead of using pre-defined "quality" parameter, you can start stream with custom parameters;
      // CAUTION: using arbitraty custom parameter might significantly affect server performance!
      // Please, consult with the tech. support before doing this
      // stream.startEx(PictureSize.sizSmall, 128000, 10, 30, false, false, false);
 
      // when stream object is destroyed, the live stream is stopped
      // so keep it from being garbage-collected
      window_.Tag = stream;
    }
  }
 
  static void closeVideo()
  {
    IStream_ stream = (IStream_)window_.Tag;
 
    // stops the stream, but doesn't free the resources associated with it;
    // the stream can be restarted later
    stream.stop();
 
    // frees the resources;
    // the same effect is achieved when all the references to a live stream go out of scope and get garbage-collected
    // NOTE: close() always stops the stream, so it's unnecessary to call stop() prior to close()
    stream.close();
  }
 
  [STAThread]
  static void Main()
  {
    startLiveVideoFrom1stCamera();
    Application.Run();
  }
}


Starting recorded video-stream

C#

using System;
using System.Diagnostics;
using ClientCoreCOMLib;
using System.Windows.Forms; // for Application object
 
static class Demo
{
  static server server_ = new server();
  // the ActiveX should be imported from SVVideoPlayer.dll
  static AxSVVideoPlayerLib.AxWindow window_ = new AxSVVideoPlayerLib.AxWindow();
 
  static void putWindowOnForm(AxSVVideoPlayerLib.AxWindow window)
  {
    // implement it
  }
 
  static void startRecodedVideoFrom1stCamera()
  {
    server_.connect(Encryption.enNone, "demo01.svgateway.com", 9980);
    server_.login("guest", "guest");
    var err = server_.requestStreamingServices();
    if (err.value != 0)
      return;
    // create recorded stream for the 1st camera
    var stream = server_.cameraRecorder.createStream(server_.cameras[1], Type.Missing);
    putWindowOnForm(window_);
    (stream as ICameraStream).player = (IBitmapWindow)window_.GetOcx();
    (stream as _IStream_Events_Event).changed += (sender, error) => { Debug.WriteLine("Change of a recorded video-stream failed; camera: " + (sender as IRecordedCameraStream).camera.name); };
    (stream as _IProgressEvents_Event).progress += progress;
 
    // play the segment: [now-30min. -- now-25min.)
    var begin = DateTime.Now - TimeSpan.FromMinutes(30);
    stream.play(PictureSize.sizMedium, StreamQuality.qualHigh, false, begin, begin + TimeSpan.FromMinutes(5), false, false);
  }
 
  static void progress(object sender, DateTime time, long bytes, int percent)
  {
    Debug.WriteLine("Playing time: " + time.ToString());
    Debug.WriteLine("Played " + bytes.ToString() + " so far, which is " + percent.ToString() + " percent of the whole segment");
  }
 
  [STAThread]
  static void Main()
  {
    startRecodedVideoFrom1stCamera();
    Application.Run();
  }
}

Receiving stream frames

Starting live video-stream, receiving its frames, and saving them in bitmap and jpeg formats

C#

using System;
using System.Diagnostics;
using ClientCoreCOMLib;
using System.Windows.Forms; // for Application & Timer objects
 
static class Demo
{
  static server server_ = new server();
  static LiveCameraStream stream_ = null;
 
  static void startStream()
  {
    server_.connect(Encryption.enNone, "demo01.svgateway.com", 9980);
    server_.login("guest", "guest");
    var err = server_.requestStreamingServices();
    if (err.value == 0)
    {
      stream_ = server_.cameras[1].createStream(Type.Missing);
      (stream_ as ICameraStream).ownerPlay = true;
      stream_.frameReceived += frameReceived;
      stream_.start(PictureSize.sizSmall, StreamQuality.qualHigh, false, false, false);
    }
  }
 
  private static int index_ = 0;
  static void frameReceived(ICameraStream sender, IVideoFrame frame, bool decodeOnly)
  {
    Trace.WriteLine("Frame received: " + frame.time);
    System.Drawing.Image.FromHbitmap((IntPtr)(frame.bitmap)).Save("c:/frame" + index_ + ".bmp");
 
    byte[] bytes = (byte[])frame.getJPEG(100);
    var f = System.IO.File.Create("c:/frame" + index_ + ".jpg");
    f.Write(bytes, 0, bytes.Length);
    f.Close();
 
    ++index_;
  }
 
  static void closeStream()
  {
    stream_.close();
  }
 
  static Timer timer_ = new Timer();
  [STAThread]
  static void Main()
  {
    startStream();
    // wait for 10 seconds, then close the stream
    timer_.Interval = 10000;
    timer_.Tick += (a1, a2) => { closeStream(); timer_.Stop(); };
    timer_.Enabled = true;
    Application.Run();
  }
}

Getting recordings information

C#

using System;
using System.Diagnostics;
using ClientCoreCOMLib;
using System.Windows.Forms; // for Application object
 
static class Demo
{
  public static void getRecordings()
  {
    server server = new server();
    server.connect(Encryption.enNone, "demo01.svgateway.com", 9980);
    server.login("guest", "guest");
    var err = server.requestStreamingServices();
    var begin = DateTime.Now - TimeSpan.FromMinutes(30);
    var end = begin + TimeSpan.FromMinutes(30);
    if (err.value != 0)
    {
      Debug.WriteLine(err.message);
      return;
    }
    var recorder = server.cameraRecorder;
    if (recorder == null)
    {
      // This may happen if Recorder feature is unavailable on your SerVision Video Gateway
      // or if a network failure occurred, so that the server object is disconnected now
      Debug.WriteLine("Recorder is unavailable");
      return;
    }
    server.cameraRecorder.requestRecordingsForCamera(server.cameras[3], begin, end);
    foreach (ICameraRecording recording in server.cameraRecorder.recordings)
    {
      Debug.WriteLine("===Recording:===");
      Debug.WriteLine(recording.begin.ToString() + ".." + recording.end.ToString());
      Debug.WriteLine(recording.available ? "is available" : "is not available");
      Debug.WriteLine("bitrate: " + recording.settings.bitrate);
      Debug.WriteLine("framerate: " + recording.settings.framerate);
      var extents = recording.settings.extents;
      if (extents != null)
        Debug.WriteLine("size: " + extents.size.ToString());
      Debug.WriteLine("interval: " + recording.settings.interval);
      Debug.WriteLine("format: " + recording.settings.codec.ToString());
      Debug.WriteLine("monochrome: " + recording.settings.monochrome.ToString());
      Debug.WriteLine("================");
    }
  }
 
  [STAThread]
  static void Main()
  {
    getRecordings();
    Application.Run();
  }
}

Acquiring live and recorded Gateway events

Using Event Cache to listen to the live events and to request the recorded ones

C#

using System;
using System.Diagnostics;
using ClientCoreCOMLib;
using System.Windows.Forms; // for Application object
 
 
static class Demo
{
  static server server_ = new server();
  static EventCache eventCache_ = new EventCache();
 
  static void listenToEvents()
  {
    server_.connect(Encryption.enNone, "demo01.svgateway.com", 9980);
    server_.login("guest", "guest");
    server_.requestStreamingServices();
    var err = server_.requestNonstreamingServices();
    if (err.value != 0)
      return;
    // the user can request events from EventCache;
    // handle responses to such requests
    eventCache_.response += (sender, requestID, events) => { addEvents(events); };
 
    // on new events, eventsReceived is invoked
    eventCache_.eventsReceived += (sender, events) => { addEvents(events); };
 
    // when events are updated, eventsUpdated is invoked;
    // eg., when MotionEnd comes after MotionBegin, EventCache updates the previous MotionBegin event, setting its duration
    eventCache_.eventsUpdated += (sender, events) => { updateEvents(events); };
 
    // tell the EventCach what eventer it should listen to;
    eventCache_.listen(server_.eventer);
  } 
 
  static void addEvents(IEventCollection events)
  {
    foreach (IEvent_ ev in events)
      if (ev.sensor is IVMD)
        Debug.WriteLine("Motion-detection for camera: " + (ev.sensor as IVMD).camera.name);
      else
        Debug.WriteLine("Event from sensor: " + ev.sensor.name);
  }
 
  static void updateEvents(IEventCollection events)
  {
    foreach (IEvent_ ev in events)
    {
      Debug.WriteLine("Updated: " + ev.time);
      // if an event has some view, this is the place to update it
    }
  }
 
  static void requestMotionEventsForLast24Hours()
  {
    // perform filtering request
    eventCache_.request(server_.cameras[1], DateTime.Now - TimeSpan.FromHours(12), DateTime.Now, EventType.evMotionBegin);
  }
 
  [STAThread]
  static void Main()
  {
    listenToEvents();
    requestMotionEventsForLast24Hours();
    Application.Run();
  }
}

Monitoring a Gateway activity

Getting encoded and readable statistics

C#:

using System;
using System.Diagnostics;
using ClientCoreCOMLib;
using System.Windows.Forms;
 
static class Demo
{
  static server server_ = new server();
  static EncodedStatisticsStream encoded_;
  static ReadableStatisticsStream readable_;
  public static void runStatistics()
  {
    server_.connect(Encryption.enNone, "demo01.svgateway.com", 9980);
    var err = server_.login("guest", "guest");
    if (err.value == 0)
    {
      encoded_ = server_.monitor.createEncodedStatisticsStream();
      encoded_.received += encodedStatsReceived;
      // poll every 10 seconds
      encoded_.start(10);
 
      readable_ = server_.monitor.createReadableStatisticsStream();
      readable_.received += readableStatsReceived;
      // poll every 15 seconds
      readable_.start(15);
    }
  }
 
  private static void readableStatsReceived(IServer sender, string stats)
  {
    Debug.WriteLine(stats);
  }
 
  private static void encodedStatsReceived(IServer sender, IEncodedStatistics stats)
  {
    var decoded = stats.decode(stats.rawData);
    var time = decoded.time;
    var rows = decoded.rows;
    Debug.WriteLine(stats.rawData);
    Debug.WriteLine("Decoding: ======================");
    Debug.WriteLine("Time: " + time);
    Debug.Indent();
    foreach (IDecodedRow row in rows)
    {
      Debug.WriteLine(row.name);
      Debug.Indent();
      foreach (IDecodedField field in row.fields)
        Debug.WriteLine(field.index + ":" + (string)field.value);
 
      var f2 = row.getField(2);
      Debug.WriteLine("2-nd field: " + (string)f2);
      Debug.Unindent();
    }
    Debug.Unindent();
    Debug.WriteLine("======================================");
  }
 
  [STAThread]
  static void Main()
  {
    runStatistics();
    Application.Run();
  }
}

Controlling PTZ-enabled camera and switching Night Mode

C#:

using System;
using System.Diagnostics;
using ClientCoreCOMLib;
using System.Windows.Forms;
 
static class Demo
{
  public static void controlPTZ()
  {
    server server = new server();
    server.connect(Encryption.enNone, "demo01.svgateway.com", 9980);
    server.login("guest", "guest");
    var err = server.requestStreamingServices();
    if (err.value != 0)
      return;
    foreach (ICamera camera in server.cameras)
    {
      bool capable = camera.move(CameraMove.cmLeft, 1, 5, false);
      Debug.WriteLine(capable ? "Camera could move left" : "Camera could not move left");
      // NOTE: diagonal moving requires special support on server-side
      capable = camera.move(CameraMove.cmUpleft, 1, 5, false);
      Debug.WriteLine(capable ? "Camera could move up-left" : "Camera could not move up-left");
      capable = camera.zoom(CameraZoom.czIn, 1, 2, false);
      Debug.WriteLine(capable ? "Camera could zoom-in" : "Camera could not zoom-in");
      capable = camera.focus(CameraFocus.cfNear, 2, 2, false);
      Debug.WriteLine(capable ? "Camera could focus nearer" : "Camera could not focus nearer");
      capable = camera.focus(CameraFocus.cfNear, 2, 2, false);
      Debug.WriteLine(capable ? "Camera could focus nearer" : "Camera could not focus nearer");
 
      // Now try continuous moving;
      // NOTE: continuous moving requires special support on server-side
      capable = camera.continuousPTZ(true, false);
      if (capable)
        capable = camera.move(CameraMove.cmLeft, 1, 5, false);
      System.Threading.Thread.Sleep(5000);
      camera.stop();      
      Debug.WriteLine(capable ? "Camera could move continuously" : "Camera could not move continuously");
      // NOTE: night mode requires special support on server-side
      capable = camera.nightMode(true, false);
      Debug.WriteLine(capable ? "Camera could switch to night mode" : "Camera could not switch to night mode");
      // switch back to day mode
      camera.nightMode(false, false);
    }
  }
 
  [STAThread]
  static void Main()
  {
    controlPTZ();
    Application.Run();
  }
}

Enabling an Activator

C#

using System;
using System.Diagnostics;
using ClientCoreCOMLib;
using System.Windows.Forms;
 
static class Demo
{
  static server server_ = new server();
  static EventerStream eventerStream_ = null;
 
  static void connect()
  {
    server_.connect(Encryption.enNone, "demo01.svgateway.com", 9980);
    server_.login("guest", "guest");
    server_.requestStreamingServices();
    var err = server_.requestNonstreamingServices();
    if (err.value != 0)
      return;
    eventerStream_ = server_.eventer.createStream();
    eventerStream_.eventsReceived += eventsReceived;
  }
 
  static void printState()
  {
    foreach (sensor s in server_.sensors)
      Trace.WriteLine("Is sensor on? " + s.isOn);
  }
 
  static void enableActivators(bool value)
  {
    foreach (sensor sens in server_.sensors)
    {
      if (sens is IActivatable)
      {
        if (value)
          (sens as IActivatable).activate();
        else
          (sens as IActivatable).deactivate();
      }
    }
  }
 
  static void eventsReceived(IStream_ sender, IEventCollection events)
  {
    foreach (IEvent_ ev in events)
      if (ev.sensor != null)
        if (ev.sensor is IActivatable)
          Debug.WriteLine(ev.type.ToString() + " from Activator: " + ev.sensor.name);
        else
          Debug.WriteLine("Some other event from " + ev.sensor.name);
  }
 
  [STAThread]
  static void Main()
  {
    connect();
    printState();
    enableActivators(true);
    System.Threading.Thread.Sleep(3000);
    printState();
    enableActivators(false);
    System.Threading.Thread.Sleep(3000);
    printState();
    Application.Run();
  }
}

Joint control of multiple streams

Setting-up a Stream Group and controlling groupped streams

C#:

using System;
using System.Diagnostics;
using ClientCoreCOMLib;
using System.Windows.Forms;
 
static class Demo
{
  static IServer server_ = new server();
  static StreamGroup group_ = new StreamGroup();
  static AxSVVideoPlayerLib.AxWindow window_ = new AxSVVideoPlayerLib.AxWindow();
 
  static void putWindowOnForm(AxSVVideoPlayerLib.AxWindow window)
  {
    // implement it
  }
 
  public static void startStreamGroup()
  {
    putWindowOnForm(window_);
    server_.connect(Encryption.enNone, "demo01.svgateway.com", 9980);
    server_.login("guest", "guest");
    var err = server_.requestStreamingServices();
    if (err.value != 0)
      return;
    bool firstMic = true;
 
    // create live stream from each camera, and start it paused
    // also create live stream from the 1st microphone, and start it paused
    foreach (ICamera camera in server_.cameras)
    {
      var stream = camera.createStream(Type.Missing);
      (stream as ICameraStream).player = (IBitmapWindow)window_.GetOcx();
      stream.start(PictureSize.sizSmall, StreamQuality.qualHigh, false, true, false);
 
      // NOTE: the underlaying stream object will be "used" by the group,
      // so it will not get disposed, even though c# object is local;
      // HOWEVER, the c# local object (i.e. exclusivepapers.Com is the company which first and main priority was, is and will be customers� satisfaction with the [http://exclusivepapers.com essays online]. If you still have no idea where to buy your writing tasks, this company is the best option for you. The [http://primewritings.com custom essay] accomplished by professionals, could bring students success in their education. Are you busy as a bee? Do not even have time for fun? Do your friends advise you to buy [http://bestwritingservice.com essay writing example]? Do not hesitate! Come after the advice of clever men and make a correct choice! I want to tell that I have got great experience of compare and contrast essays purchasing. I state that the [http://exclusivepapers.com essay writing service] can be the best helper in the research papers completing situation.   I did hear about [http://primewritings.com writing services], nevertheless, I did not decide to purchase essay papers there. Thus I pushed a link, which moved myself to custom essays writing company and I ordered essay and was happy with that.   Are you willing to try yourself in writing? See main principles of paper writing. In fact, I do not like to study a lot and I buy [http://exclusivepapers.com Online Essays].  It is a hard task to find proper  writing service, there is always a risk to be cheated or at least to get unsatisfactory grade for passing low quality paper. I have tried tons of them, and, to my mind, this is the best [http://exclusivepapers.com essay writing service]. Please take it into consideration because I think that it�s better to try it once than waste your time and money on unprofessional writing companies.   EssaysExperts.Com is the company which first and main priority was, is and will be customers� satisfaction with the [http://www.essaysexperts.com essays online]. If you still have no idea where to buy your writing tasks, this company is the best option for you. RCW) *will* be disposed,
      // so do not subscribe to particular stream events - you won't get them here.
      // If you have to listen to particular stream events, prevent it from being garbage-collected
      group_.addStream(stream);
 
      // take 1st gateway micriphone, start a stream and add it to the Group
      if (camera.microphone != null && firstMic)
      {
        firstMic = false;
        var micStream = camera.microphone.createStream(Type.Missing);
        micStream.start(StreamQuality.qualHigh, true, false);
        group_.addStream(micStream);
      }
    }
    // resume all the streams,
    // now they will play synchronously
    (group_ as IPlaybackControl).resume(false);
  }
 
  [STAThread]
  static void Main()
  {
    startStreamGroup();
    Application.Run();
  }
}

Taking a snapshot

Requesting a snapshot from the Gateway

C#:

using System;
using System.Diagnostics;
using System.IO;
using ClientCoreCOMLib;
using System.Windows.Forms; // for Application object
 
static class Demo
{
  static IServer server_ = new server();
  public static void requestSnapshotFromGateway()
  {
    server_.connect(Encryption.enNone, "demo01.svgateway.com", 9980);
    server_.login("guest", "guest");
    var err = server_.requestStreamingServices();
    if (err.value != 0)
    {
      Debug.WriteLine(err.message);
      return;
    }
 
    // request snapshot for each camera
    foreach (ICamera cam in server_.cameras)
    {
      (cam as _ICameraEvents_Event).snapshotReceived += snapshotGot;
      cam.requestSnapshot(DateTime.Now, 60, 10);
    }
  }
 
  private static void snapshotGot(ICamera sender, IErrorCode error, DateTime time, object snapshot)
  {
    if (error.value != 0)
    {
      Debug.WriteLine(sender.id);
      Debug.WriteLine(error.message);
      return;
    }
    // save the snapshot to a file
    byte[] bytes = (byte[])snapshot;
    var f = System.IO.File.Create(String.Format("c:/snapshot{0}.jpeg", sender.id));
    f.Write(bytes, 0, bytes.Length);
    f.Close();
  }
 
  [STAThread]
  static void Main()
  {
    requestSnapshotFromGateway();
    Application.Run();
  }
}

Taking a snapshot from Video Player

C#:

 

Acquiring live and recorded GPS information

C#:

using System;
using System.Diagnostics;
using System.IO;
using ClientCoreCOMLib;
using System.Windows.Forms; // for Application object
 
static class Demo
{
  static IServer server_ = new server();
  static LiveGPSStream liveGPSStream_;
  static RecordedGPSStream recordedGPSStream_;
  public static void streamingGPS()
  {
    server_.connect(Encryption.enNone, "demo01.svgateway.com", 9980);
    server_.login("guest", "guest");
    var err = server_.requestStreamingServices();
    if (err.value != 0)
    {
      Debug.WriteLine(err.message);
      return;
    }
 
    // if GPS device exists
    if (server_.gps != null)
    {
      liveGPSStream_ = server_.gps.createStream();
      liveGPSStream_.frameReceived += gpsGot;
      // The Gateway will send GPS data every 5 second
      liveGPSStream_.start(5, false);
    }
 
    // if GPS recorder exists
    if (server_.gpsRecorder != null)
    {
      recordedGPSStream_ = server_.gpsRecorder.createStream(Type.Missing);
      recordedGPSStream_.frameReceived += gpsGot;
      // play recorded GPS for time interval [Now-10min..Now)
      recordedGPSStream_.play(DateTime.Now - TimeSpan.FromMinutes(10), DateTime.Now, false);
    }
  }
 
  private static void gpsGot(IStream_ sender, IGPSFrame frame)
  {
    // if this is not status-data, status property will be null
    if (frame.status != null)
    {
      Debug.WriteLine("Status");
      Debug.WriteLine(frame.status.general.ToString());
    }
    // if this is not position-data, status property will be null
    else if (frame.position != null)
    {
      Debug.WriteLine("Speed");
      Debug.WriteLine(frame.position.gpsTime);
      Debug.WriteLine(frame.position.speed.value);
    }
  }
 
  [STAThread]
  static void Main()
  {
    streamingGPS();
    Application.Run();
  }
}

Sending an audio from the Client to a Gateway

C#:

using System;
using System.Diagnostics;
using System.Windows.Forms;
using ClientCoreCOMLib;
 
static class Demo
{
  static IServer server_ = new server();
  static LiveSpeakerStream speakerStream_;
  static System.Threading.Timer timer_ = null;
 
  public static void sendAudio()
  {
    server_.connect(Encryption.enNone, "demo01.svgateway.com", 9980);
    server_.login("guest", "guest");
    var err = server_.requestStreamingServices();
    if (err.value != 0)
    {
      Debug.WriteLine(err.message);
      return;
    }
 
    // typically, there's zero or one speaker at Gateway
    if (server_.speakers.Count > 0)
    {
      speakerStream_ = server_.speakers[1].createStream(Type.Missing);
      speakerStream_.start(StreamQuality.qualHigh, false);
      // Now speak to the microphone attached to the Client
 
      // stop it in 15 seconds
      timer_ = new System.Threading.Timer((s) => 
      { speakerStream_.stop(); }, speakerStream_, 15000, System.Threading.Timeout.Infinite);
 
    }  
  }
 
  [STAThread]
  static void Main()
  {
    sendAudio();
    Application.Run();
  }
}

Downloading Recorded Streams to file(s)

C#:

using System;
using System.Diagnostics;
using ClientCoreCOMLib;
using System.Windows.Forms; // for Application object
 
static class Demo
{
  static IServer server_ = new server();
  static SVXFile file_ = new SVXFile();
 
  public static void downloadVideoAndAudioFrom1stCamera()
  {
    server_.connect(Encryption.enNone, "demo01.svgateway.com", 9980);
    server_.login("guest", "guest");
    var err = server_.requestStreamingServices();
    if (err.value != 0)
    {
      Debug.WriteLine(err.message);
      return;
    }
 
    ICamera cameraToDownload = server_.cameras[1];
    // try to find a camera with associated microphone
    foreach (ICamera cam in server_.cameras)
    {
      if (cam.microphone != null)
      {
        cameraToDownload = cam;
        break;
      }
    }
 
    file_.name = "c:/Try1.svx";
 
    DownloadCameraStream video = server_.cameraRecorder.createDownloadStream(cameraToDownload, Type.Missing);
    // Download last 30 minutes
    DateTime begin = DateTime.Now - TimeSpan.FromMinutes(30);
    DateTime end = DateTime.Now;
    // file_.saver is a Stream Collector, add the stream to it
    // NOTE: a stream can be added to several Collectors (demonstrated in another example)
    file_.saver.addStream(video, begin, end);
 
    // if there's a microphone attached to this camera, download the audio as well
    if (cameraToDownload.microphone != null)
    {
      DownloadMicrophoneStream audio = server_.microphoneRecorder.createDownloadStream(cameraToDownload.microphone, Type.Missing);
      file_.saver.addStream(audio, begin, end);
 
      // start the download
      audio.download(begin, end);
    }
 
    // start the download
    video.download(begin, end);
  }
 
  [STAThread]
  static void Main()
  {
    downloadVideoAndAudioFrom1stCamera();
    Application.Run();
  }
}


Downloading Recorded Streams to a self-playable file (EXE)

C#:

using System;
using System.Diagnostics;
using ClientCoreCOMLib;
using System.Windows.Forms; // for Application object
 
static class Demo
{
  static IServer server_ = new server();
  static SVXFile file_ = new SVXFile();
 
  public static void downloadToEXE()
  {
    server_.connect(Encryption.enNone, "demo01.svgateway.com", 9980);
    server_.login("guest", "guest");
    var err = server_.requestStreamingServices();
    if (err.value != 0)
    {
      Debug.WriteLine(err.message);
      return;
    }
 
    ICamera cameraToDownload = server_.cameras[1];
    // try to find a camera with associated microphone
    foreach (ICamera cam in server_.cameras)
    {
      if (cam.microphone != null)
      {
        cameraToDownload = cam;
        break;
      }
    }
 
    // the only difference from downloading to svx - "exe" file extension
    file_.name = "c:/Try1.exe";
 
    DownloadCameraStream video = server_.cameraRecorder.createDownloadStream(cameraToDownload, Type.Missing);
    // Download last 30 minutes
    DateTime begin = DateTime.Now - TimeSpan.FromMinutes(30);
    DateTime end = DateTime.Now;
    // file_.saver is a Stream Collector, add the stream to it
    // NOTE: a stream can be added to several Collectors (demonstrated in another example)
    file_.saver.addStream(video, begin, end);
 
    // if there's a microphone attached to this camera, download the audio as well
    if (cameraToDownload.microphone != null)
    {
      DownloadMicrophoneStream audio = server_.microphoneRecorder.createDownloadStream(cameraToDownload.microphone, Type.Missing);
      file_.saver.addStream(audio, begin, end);
 
      // start the download
      audio.download(begin, end);
    }
 
    // start the download
    video.download(begin, end);
  }
 
  [STAThread]
  static void Main()
  {
    downloadToEXE();
    Application.Run();
  }
}

Storing Live Stream to file(s) and to database

C#:

using System;
using System.Diagnostics;
using System.Threading;
using ClientCoreCOMLib;
 
static class Demo
{
  static IServer server_ = new server();
  static SVXFile file_ = new SVXFile();
  static StandardFile stdFile_ = new StandardFile();
  static SVXDatabase db_ = new SVXDatabase();
 
  public static void storeLiveVideoAndAudio()
  {
    server_.connect(Encryption.enNone, "demo01.svgateway.com", 9980);
    server_.login("guest", "guest");
    var err = server_.requestStreamingServices();
    if (err.value != 0)
    {
      Debug.WriteLine(err.message);
      return;
    }
 
    ICamera cameraToPlay = server_.cameras[1];
    // try to find a camera with associated microphone
    foreach (ICamera cam in server_.cameras)
    {
      if (cam.microphone != null)
      {
        cameraToPlay = cam;
        break;
      }
    }
 
    file_.name = "c:/Try2.svx";
    stdFile_.name = "c:/Try2.avi";
    db_.host = "your.host.name";
    db_.user = "sa";
    db_.password = "sa";
    db_.name = "ServisionDB";
 
    var video = cameraToPlay.createStream(Type.Missing);
    // file_.saver is a Stream Collector, add the stream to it
    // for live streams time interval is ignored
    file_.saver.addStream(video, DateTime.Now, DateTime.Now);
 
    // a stream can be routed to several Steram Collectors -
    // so, save the video stream to a standard AVI file
    stdFile_.saver.addStream(video, DateTime.Now, DateTime.Now);
 
    // save the video stream to a SerVision Database as well
    db_.saver.addStream(video, DateTime.Now, DateTime.Now);
 
    // if there's a microphone attached to this camera, download the audio to the SVX file
    if (cameraToPlay.microphone != null)
    {
      var audio = cameraToPlay.microphone.createStream(Type.Missing);
      // for live streams time interval is ignored
      file_.saver.addStream(audio, DateTime.Now, DateTime.Now);
      db_.saver.addStream(audio, DateTime.Now, DateTime.Now);
      // start live audio stream
      audio.start(StreamQuality.qualHigh, false, false);
    }
 
    // start live video stream
    video.start(PictureSize.sizSmall, StreamQuality.qualHigh, false, false, false);
 
    // wait 20 seconds
    Thread.Sleep(20 * 1000);
 
    // saving streams to the file ends when saver.stop() is called or when all the streams stop
    file_.saver.stop();
    stdFile_.saver.stop();
    db_.saver.stop();
 
    video.stop();
    audio.stop();
  }
 
  [STAThread]
  static void Main()
  {
    storeLiveVideoAndAudio();
    Application.Run();
  }
}

Playing back Streams from a file

C#:

using System;
using System.Diagnostics;
using ClientCoreCOMLib;
using System.Windows.Forms; // for Application object
 
static class Demo
{
  static SVXFile file_ = new SVXFile();
  static AxSVVideoPlayerLib.AxWindow window_ = new AxSVVideoPlayerLib.AxWindow();
 
  public static void playStoredVideo()
  {
    file_.name = "c:/Try1.svx";
    StoredCameraStream video = file_.loader.video[1].createStream();
    putWindowOnForm(window_);
    (video as ICameraStream).player = (IBitmapWindow)window_.GetOcx();
    window_.Tag = video;
 
    // beginning of the 1st recording of the chunk
    DateTime begin = file_.loader.video[1].recordings[1].begin;
    Debug.WriteLine("Chunk begin: " + begin);
    // end of the last recording of the chunk
    DateTime end = file_.loader.video[1].recordings[file_.loader.video[1].recordings.Count].end;
    Debug.WriteLine("Chunk end: " + end);
    // do not designate the interval - play the whole chunk
    video.play(false, Type.Missing, Type.Missing);
    (video as _IProgressEvents_Event).progress += progress;
  }
 
  private static void progress(object sender, DateTime time, long bytesTransferred, int percentage)
  {
    Debug.WriteLine("Playing: " + time);
  }
 
  private static void putWindowOnForm(AxSVVideoPlayerLib.AxWindow window)
  {
    // implement it
  }
 
  [STAThread]
  static void Main()
  {
    playStoredVideo();
    Application.Run();
  }
}

Playing back Streams from a database

C#:

using System;
using System.Diagnostics;
using ClientCoreCOMLib;
using System.Windows.Forms; // for Application object
 
static class Demo
{
  static SVXDatabase db_ = new SVXDatabase();
  static AxSVVideoPlayerLib.AxWindow window_ = new AxSVVideoPlayerLib.AxWindow();
 
  public static void playVideoFromDatabase()
  {
    db_.host = "yourDBHost";
    db_.name = "yourDBName";
    db_.user = "sa";
    db_.password = "sa";
 
    StoredCameraStream video = db_.loader.video[1].createStream();
    putWindowOnForm(window_);
    (video as ICameraStream).player = (IBitmapWindow)window_.GetOcx();
    window_.Tag = video;
 
    // beginning of the 1st recording of the chunk
    DateTime begin = db_.loader.video[1].recordings[1].begin;
    Debug.WriteLine("Chunk begin: " + begin);
    // end of the last recording of the chunk
    DateTime end = db_.loader.video[1].recordings[db_.loader.video[1].recordings.Count].end;
    Debug.WriteLine("Chunk end: " + end);
    // do not designate the interval - play the whole chunk
    video.play(false, Type.Missing, Type.Missing);
    (video as _IProgressEvents_Event).progress += progress;
  }
 
  private static void progress(object sender, DateTime time, long bytesTransferred, int percentage)
  {
    Debug.WriteLine("Playing: " + time);
  }
 
  private static void putWindowOnForm(AxSVVideoPlayerLib.AxWindow window)
  {
    // implement it
  }
 
  [STAThread]
  static void Main()
  {
    playVideoFromDatabase();
    Application.Run();
  }
}

Serializing Client workspace

C#:

using System;
using System.Diagnostics;
using System.Collections.Generic;
using ClientCoreCOMLib;
using System.Windows.Forms; // for Application object
 
static class Demo
{
  static Reconnector reconnector_ = new Reconnector();
  static List<server> servers_ = new List<server>();
 
  static private void loadWorkspace()
  {
    Serializer ser = new Serializer();
    ser.location = "c:/Workspace1.xsp";
    ser.load();
 
    // reconnect loaded Servers and associate with Reconnector
    foreach (server server in ser.servers)
    {
      servers_.Add(server);
      reconnector_.beginScenario(server);
      // connect using stored Connection Properties
      (server as IAsyncServer).connectEx(server.connectionProps, null);
      // log in using stored User Properties
      (server as IAsyncServer).login(server.userProps.username, server.userProps.password, null);
      reconnector_.endScenario(server);
    }
 
    // restart streams
    foreach (var stream in ser.streams)
    {
      // if camera stream - set player
      if (stream is ICameraStream)
      {
        var window = getFreeWindow();
        (stream as ICameraStream).player = (IBitmapWindow)window.GetOcx();
        // hold the stream to prevent its disposal
        window.Tag = stream;
      }
      // resume() starts the stream with its stored settings
      if (stream is IPlaybackControl)
        (stream as IPlaybackControl).resume(false);
    }
  }
 
  static private void saveWorkspace()
  {
    Serializer ser = new Serializer();
    ser.location = "c:/Workspace2.xsp";
    // NOTE: its also possible to update a workspace, instead of overwriting it; 
    // to do this, perform ser.load() now -
    // the workspace will be loaded, and subsequent addServer() will only append to it
 
 
    // add Servers with all their Streams to the Serializer;
    // its also possible to add some particular Streams withou adding the whole Server
    foreach (var server in servers_)
      ser.addServer(server, true, false);
    ser.save();
  }
 
  private static AxSVVideoPlayerLib.AxWindow getFreeWindow()
  {
    // implement it
    return null;
  }
 
  [STAThread]
  static void Main()
  {
    loadWorkspace();
    saveWorkspace();
    Application.Run();
  }
}


Discovering SerVision Video Gateways available on the LAN

C#:

using System;
using System.Diagnostics;
using System.Collections.Generic;
using ClientCoreCOMLib;
using System.Windows.Forms; // for Application object
 
static class Demo
{
  static private void discoverGateways()
  {
    GatewayDiscovery disc = new GatewayDiscovery();
    disc.added += (g) => { Trace.WriteLine("Added: " + g.name + " - " + g.ip + ":" + g.port); };
    disc.removed += (g) => { Trace.WriteLine("Removed: " + g.name + " - " + g.ip + ":" + g.port); };
    disc.start();
  }
 
  [STAThread]
  static void Main()
  {
    discoverGateways();
    Application.Run();
  }
}


Acquiring info about Video Gateways behind a Video Distributer

C#:

using System;
using System.Diagnostics;
using System.Collections.Generic;
using ClientCoreCOMLib;
 
static class Demo
{
  static IServer server_ = new server();
  static LiveGPSStream liveGPSStream_;
  static EventerStream eventerStream_;
  public static void startVDStreams()
  {
    server_.connect(Encryption.enNone, "192.168.10.2", 9988);
    server_.login("anonymous", "guest");
    var err = server_.requestStreamingServices();
    if (err.value != 0)
    {
      Debug.WriteLine(err.message);
      return;
    }
    err = server_.requestNonstreamingServices();
    if (err.value != 0)
    {
      Debug.WriteLine(err.message);
      return;
    }
 
    var vd = server_ as IDistributor;
    if (vd != null)
      foreach (IGatewayInfo gateway in vd.gateways)
        Trace.WriteLine(gateway.ip + ":" + gateway.port);
    else
    {
      Trace.WriteLine("The server in not a VD");
    }
 
    foreach (ICamera cam in server_.cameras)
    {
      var gateway = (cam as IOrigin).gateway;
      Trace.WriteLine(cam.name + " from " + gateway.ip + ":" + gateway.port);
    }
 
    foreach (ISensor sen in server_.sensors)
      if (!(sen is IVMD))
      {
        var gateway = (sen as IOrigin).gateway;
        Trace.WriteLine(sen.name + " from " + gateway.ip + ":" + gateway.port);
      }
 
    // if GPS device exists
    if (server_.gps != null)
    {
      liveGPSStream_ = server_.gps.createStream();
      liveGPSStream_.frameReceived += (s, f) => 
      {
        var gateway = (f.gps as IOrigin).gateway;
        Trace.WriteLine("GPS from: " + gateway.ip + ":" + gateway.port);
      };
      // Only immediate streaming can be used on VD mixed streams, because the time-stamps are not steady
      (liveGPSStream_ as IStreamFeed).feed = StreamFeed.sfImmediate;
      // The Gateway will send GPS data every 5 second
      liveGPSStream_.start(5, false);
    }
 
    // if eventer exists
    if (server_.eventer != null)
    {
      eventerStream_ = server_.eventer.createStream();
      eventerStream_.eventsReceived += (s, events) => 
      {
        foreach (IEvent_ e in events)
        {
          var gateway = (e.sensor as IOrigin).gateway;
          Trace.WriteLine("Event from: " + gateway.ip + ":" + gateway.port);
        }
      };
      // Only immediate streaming can be used on VD mixed streams, because the time-stamps are not steady
      (eventerStream_ as IStreamFeed).feed = StreamFeed.sfImmediate;
      eventerStream_.start();
    }
  }
 
  [STAThread]
  static void Main()
  {
    startVDStreams();
    Application.Run();
  }
}

Using video player window, labels and frames

C#

using System;
using System.Diagnostics;
using ClientCoreCOMLib;
using SVVideoPlayerLib;
using System.Collections.Generic;
using System.Windows.Forms; // for Application object
 
static class Demo
{
  // the ActiveX should be imported from SVVideoPlayer.dll
  static AxSVVideoPlayerLib.AxWindow window_ = new AxSVVideoPlayerLib.AxWindow();
 
  static void putWindowOnForm(AxSVVideoPlayerLib.AxWindow window)
  {
    // implement it or put the AxWindow on a form in design-time
  }
 
  static Label_ btnClose_;
  static Label_ lblBlank_;
  static Label_ frmStreamStarted;
 
  // hold label and frame RCWs to prevent their garbage-collecting
  static List<Object> holder_ = new List<Object>();
  static void setupPlayer()
  {
    window_.setSize(320, 240);
    // the video will be stretched/squeezed to fit the window size, but the original aspect-ratio will be kept:
    window_.FitPicture = FitPicture.fpBestFit;
 
    // set-up a transparent label of the predefined type "ltClose"; it looks like a small "x" button in the upper-right corner:
    var btnClose = new Label_();
    holder_.Add(btnClose);
    btnClose.type = LabelType.ltClose;
    btnClose.opaque = false;
    // set the label to the window, giving it "btnClose" name; the name can be used later to access or remove the label:
    window_.setLabel("btnClose", btnClose, false);
    // the following an event is triggered, when the user clicks the label:
    btnClose.clicked += (sender, x, y, button, keys) =>
    {
      // stop & close the stream, which we set as window tag
      var stream = (IStream_)window_.Tag;
      if (stream != null)
        stream.close();
    };
 
    // set-up a label of the predefined type "ltBlank"; it's displayed until video-frames start coming:
    // ltBlank is an opaque Label aligned to client and having a predefined "striped" image
    var blank = new Label_();
    holder_.Add(blank);
    blank.type = LabelType.ltBlank;
    // "blank" name is essential here! it enables the above functionality;
    // the label doesn't necessarily has to have ltBlank type
    window_.setLabel("blank", blank, true);
 
    // set-up a frame; we'll use it later to highlight a video-stream start:
    var frame = new WindowFrame();
    holder_.Add(frame);
    // make frame "statically" invisible; it will be visible when blinking only
    frame.visible = false;
    frame.Alignment = Alignment.alClient;
    //NOTE: use ColorTranslator to map .NET colors to OLE colors
    frame.color = (uint)System.Drawing.ColorTranslator.ToOle(Color.Blue);
    window_.setFrame("frame", frame);
  }
 
  static void startLiveVideoFrom1stCamera()
  {
    server server = new server();
    server.connect(Encryption.enNone, "demo01.svgateway.com", 9980);
    server.login("guest", "guest");
    var err = server.requestStreamingServices();
    if (err.value == 0)
    {
      var stream = server.cameras[1].createStream(Type.Missing);
      // when stream object is destroyed, the live stream is stopped
      // so keep it from being garbage-collected
      window_.Tag = stream;
      (stream as _IStream_Events_Event).started += (sender) => { Debug.WriteLine("Started video from camera: " + (sender as ILiveCameraStream).camera.name); };
      putWindowOnForm(window_);
      (stream as ICameraStream).player = (ClientCoreCOMLib.IBitmapWindow)window_.GetOcx();
      stream.start(PictureSize.sizMedium, StreamQuality.qualHigh, false, false, false);
      // blinking frame will highlight the video-stream that has been just started :
      window_.getFrame("frame").blinking.blinkFor(5);
    }
  }
 
  [STAThread]
  static void Main()
  {
    setupPlayer();
    startLiveVideoFrom1stCamera();
    Application.Run();
  }
}

Storing video from Window to AVI file

C#

using System;
using System.Diagnostics;
using ClientCoreCOMLib;
using SVVideoPlayerLib;
using System.Collections.Generic;
using System.Windows.Forms; // for Application object
 
static class Demo
{
  // the ActiveX should be imported from SVVideoPlayer.dll
  static AxSVVideoPlayerLib.AxWindow window_ = new AxSVVideoPlayerLib.AxWindow();
 
  static void putWindowOnForm(AxSVVideoPlayerLib.AxWindow window)
  {
    // implement it or put the AxWindow on a form in design-time
  }
 
  static void storeVideoToFile()
  {
    window_.setSize(320, 240);
    window_.FitPicture = FitPicture.fpBestFit;
    var btnClose = new SVVideoPlayerLib.Label_();
    btnClose.type = LabelType.ltClose;
    btnClose.opaque = false;
    window_.setLabel("btnClose", btnClose, false);
    var lblDummy = new SVVideoPlayerLib.Label_();
    window_.setLabel("lblDummy", lblDummy, false);
    lblDummy.text = "This is a lablel";
 
    server server = new server();
    server.connect(Encryption.enNone, "demo01.svgateway.com", 9980);
    server.login("guest", "guest");
    var err = server.requestStreamingServices();
    if (err.value == 0)
    {
      var stream = server.cameras[1].createStream(Type.Missing);
      window_.Tag = stream;
      putWindowOnForm(window_);
      (stream as ICameraStream).player = (ClientCoreCOMLib.IBitmapWindow)window_.GetOcx();
      stream.start(PictureSize.sizMedium, StreamQuality.qualHigh, false, false, false);
      // NOTE: the video is saved in a WYSIWYG manner, 
      // i.e. the video in the AVI file will look exactly as it's seen in the Window, inluding label, frames etc.
      window_.startStoringToFile("c:/fromWindow1.avi", 128000, 10);
    }
  }
 
  static Timer timer = new Timer();
 
  [STAThread]
  static void Main()
  {
    storeVideoToFile();
    // wait 10 seconds and stop
    timer.Interval = 10000;
    timer.Tick += (a1, a2) =>
    {
      timer.stop();
      window_.stopStoringToFile();
    };
    timer.Enabled = true;
    Application.Run();
  }
}
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox