Tutorial 3 – Simple Video

Requirements:
Tutorial 2 – Getting Camera Information


From the previous tutorial, we left off with the ability to get information about cameras in the system.

In this tutorial we’ll actually stream video from them.

First, add the following Reference to your .NET application from the SDK folder:

  • AxHeimdallLib.dll

Also, add the following system References to your .NET application:

  • System.Drawing
  • System.Windows.Forms

The main component that we’ll be dealing with throughout this tutorial is AxAuga. AxAuga is the streaming/decoding/rendering part of the SDK. It actually has quite a bit of functionality, but in this tutorial we’ll focus on its ability to display video.

First off, we need to create an instance of AxAuga:

AxAuga is an ActiveX Control that can be used as a Control for a Windows Form. So, the next step will be to create a Windows Form for the AxAuga Control to be hosted in:

Now that we have a Form and a Control, let’s do some setup once the Form has been Shown. It’s important to note that all rendering work with an AxAuga instance must be done after calling Application.Run as we’ll see shortly. Here’s the AxAuga initialization code during Shown:

On Shown we add the AxAuga instance as a Control to the video Form. This makes it so AxAuga has a place to render the video to. Then we call Init on the AxAuga instance to set it up. Init takes one argument, which is the monitor ID to display on. In our case, we’ll give it the empty string to allow AxAuga to decide for us.

It is important to note that by calling auga.Init() the application is set to Direct3D Mode. By not calling auga.Init(), the application will run in GDI mode.

Now that we have added the Control and Init’d it we need to give AxAuga the privileges to stream, like so:

SetCameraIDispatch takes the ID of the camera, and the camera’s IDispatch interface. This gives AxAuga direct access to the camera for privileges to stream.

Once we have streaming privileges, let’s setup the video viewport. The video viewport is an area on the Control that video will be displayed in. We then associate the live URL from the camera to the viewport:

AxAuga’s method SetViewportSource takes a viewport ID and a URL to stream from; Viewport ID 0 is setup by default. We use the live URL from the camera to associate it to the viewport.

We’ve done everything that needs to be done during the Form Shown. Now during Form Closing we need to do some cleanup so that we don’t leak AxAuga’s resources:

When the Closing event is sent to the Form we call AxAuga’s Shutdown method on the instance. Shutdown frees all of the resources we needed to stream and display the video.

The final thing to do is to run our Form:

A single Windows Form window will appear and start streaming the first camera from our camera list. Playback Controls on the video will be fully functioning assuming the user that retrieved the camera has permissions to make playback operations.

Screenshots of the final program:
Series-1-Tutorial-3-2
Series-1-Tutorial-3-1

That’s about it, so now we can show video in a 1×1 layout.


Next:
Tutorial 4 – Display Layouts vport