How to stream the camera image during an SIP video call in C#

This video demonstrates how you can stream the image of the USB and IP camera during an SIP video call in C#. You will see how you can download the Ozeki Camera SDK from the official website. Then how you can integrate the SDK in a Visual Studio solution as a reference. After this video you will know how you can display the image of the USB and IP camera. Moreover you will able to stream the camera image during an SIP video call.

 


Download Video: TutorialVideo10.zip
Download source code: Basic_CameraViewer_10.zip

DISCLAIMER: Please note that the following features will only work if your IP camera supports the given functionality. So please check the user manual of your IP camera to make sure it supports the feature that you wish to implement in C#.

 

Transcript

Welcome to the Ozeki Camera SDK video guide tutorial part ten. In this chapter We will create a simple project to connect USB camera and IP camera and then we will learn how to stream the image of the camera during an SIP video call.

This is the last video guide from our 10 part C# .NET camera tutorial series, in which we present how to use Ozeki Camera SDK to develop different kinds of camera solutions.

This SDK is:

  • ONVIF compliant
  • Easy to use
  • Forceful and powerful

Whether you're a beginner or an experienced C# developer you will certainly be able to implement the solutions presented in these tutorial videos, if you use this Camera SDK. This is gonna be a great video series. They contain short and practical code explanations.

This video will be exciting and fun. I hope you will enjoy it.

In this video the main steps are the following:

  • First step - Download the SDK from the website
  • Second step - Create WPF solution in Visual Studio
  • Third step - Implementing the camera viewer application
  • Fourth step - Extend the application with PTZ control function.
  • and finally the Fifth step - Check the result and we try out our application

And let's start now with the step one.

Before we start the developing we will need the Ozeki Camera SDK. You can download it on the www.camera-sdk.com. You need registrate yourself, which means adding a name, an email address and a reason why you need this SDK. After that you will get the downloading link. The installation is simple, but if you are not sure you can find a description on the Quick Start section of on our website.

First, we have to create a new WPF solution. Click on the New Project and choose the WPF project and give a name. Click on the OK button. When the project is opened, we have to add the OzekiSDK.dll and the System.Drawing.dll as a reference. When you find the files, select them and click on the OK button. We can see them in the reference list.

We will need some controls to handle our project. We need 2 groupbox controls to separate USB camera and IPcamera. The USB camera groupbox has 2 buttons to connect and disconnect to the camera.

Moreover, the IP camera groupbox has a little bit more controls. We'll need 3 textboxes for authentication. We have to give the current IP adress, username and password if it is required. There will be 2 necessary buttons to connect and disconnect to the camera.

Furthermore, we will create a cameraviewer in the CameraBox control. Finally, we create one more goupbox, for the new features that we will implement in the following tutorials. When the controls are ready, I create the buttons click event. And I resize our application.

We have to add 4 namespaces:

  • Ozeki.Media.IPCamera
  • Ozeki.Media.MediaHandlers.
  • Ozeki.Media.MediaHandlers.Video
  • and Ozeki.Media.Video.Controls

We need some variable to handle our application. We initialize the mediaconnector and the bitmapsourceprovider in the main constructor. After that we create and set the cameraviewer control and add it to the grid called Camerabox and we have to set the bitmapsourceprovider instance to the videoviewer control.

Finally, we have to write the connect and the disconnect buttons. We will get the default device to our web camera instance and start the viewer and connect our webcamera to the mediaconnector. In the disconnect_usb_camera_click event, we stop the viewer and the web camera. These were the web camera start and stop methods.

Now we implement the connect and the disconnect buttons for the IP camera. We have to know what is the correct IP adress of the camera. We probably need username and password for the connection. Based on the given data we connect to the selected IP camera. and start the viewer and the IP camera in the connect button click event. In the disconnect_ip_camera_click event, we stop the viewer and the IP camera. These were the IP camera connect and disconnect methods.

We will need a new class in our project, ADD - NEW class, Name: Softphone

I also have to use some namespaces in my class.

  • Ozeki.Media.MediaHandlers
  • Ozeki.VoIP
  • Ozeki.VoIP.SDK

I need some new field in my class.

SoftPhone, PhoneLine and PhoneCall and videosender property. Furthermore I need a MediaConnector and PhoneCallVideoSender object. I will subsricbe for 2 events in the other class, so i have to define here the OnRegistrationStateChanged event and OnCallStateChanged event.

I create a new softphone in the main constructor. I initialize the mediaconnector and phonecallvideosender in the main constructor. I write a new method to register the SIP account. The parameter list contains the necessary information. And I unsubscribe from RegistrationStateChanged event. And I create a new SIP acocunt. I create the phoneline here. I subscribe for 2 events here, which I will need.

Here is a new method, which will unregister our phoneline RegistrationStateChanged event - I will indicate this event.

StartCall method: In this method I start the dialing and create the call from the phoneline and the dialparameters object. SingleCall_CallStateChanged event, in this event I indicate the call state changes and if the call ends I disconnect the camera image from the call.

ConnectToCall method, in this method I connect the video to the call by mediaconnector object. DisconnectFromCall method I disconnect the video from the call in this method CloseCall method, I hang up the call.

This class is ready, lets countinue with the other class.

I have to extend the XAML code, with the new controls. I am going to use 2 big groupboxes, which will contain my controls. I define some rows. I will put the controls in these rows.

We need many data to create a SIP account.

Necessary:

  • Display name
  • Username
  • Authentication name
  • Password
  • Domain address
  • and Proxy address

Moreover I need 2 buttons for register the SIP account and unregister that.

PhoneCall groupbox. In this groupbox I will define more controls that I will use. Need a textbox for dial numbers and one more textbox for call state and 2 more buttons for starting the call and hang up the current call. Moreover I need to resize some control, to see all the controls in my application and finally I create the buttons click events and I remove the useless rows.

We need an instance from Softphone class, the one we finished previously. and we also need an IVideoSender object. I initialize the Softphone instance and subscribe for events in the constructor.

I have to access the GUIThread. I write an invoke method. Softphone_CallStateChanged event: In this event I will know what is the current call state Softphone_OnRegistrationStatechanged event: In this event I will know what is the actual registration state. The IVideoSender instance should be equal to the image of the web camera and to the videochannel of the IP camera.

SIPRegistrationButton Click event. I have to know the correct information of the SIP registration and i have to pass the details in the parameters list of the RegisterSipAccount method. SipUnRegistration_button, I unregister my phoneline.

CallButton Click event, I provide the value of the videosender to the videosender of the SoftPhone instance and I read out the dialnumber and I start the call. CallHangupButton_Click event, I close the actual call.

We are ready, let's run our application First, i connect one USB camera.

Hey. And now I register a SIP account, my telephone number will be 882 and I set the domain address. When I provide all the information I click on the register button and I see the registration is changed and I will call the 885 line. Both of the domain adresses are equal. I click on the call button, and I can see the call state is changing... David picks up the phone and now he can see me.

Now I try to connect one IP camera. I have to provide the correct detailed information and the camera image is appeared. I call again the 885 and this is the proof, we can send the image of the camera from USB camera, and from IP camera.

In this video the main steps are the following:

  • First step - Download the sdk from the website
  • Second step - Create WPF solution in Visual Studio
  • Third step - Implementing the camera viewer application
  • Fourth step - Extend the application with PTZ control function.
  • and finally the Fifth step - Check the result and we try out our application

Let's start now with the step one.

Before we start the developing we will need the Ozeki Camera SDK. You can download it on the www.camera-sdk.com. You need registrate yourself, which means add a name, email address and a reason why you need this SDK. After that you will get the downloading link. The installation is simple, but if you are not sure you can find a description on the Quick Start section of on our website.

First, we have to create a new WPF solution. Click on the New Project and choose the WPF project and give a name. Click on the OK button. When the project is opened, we have to add the System.Drawing.dll and the OzekiSDK.dll as a reference. When you find the file click on the OK button. We can see them in the reference list.

We will need some control to handle our project. We need 2 groupbox controls, to separate the USB camera and the IP camera. The USB camera groupbox has 2 buttons to connect and disconnect to the camera.

Moreover, the IP camera groupbox has a little bit more controls. We will need 3 textboxes for authentication. We have to give the current IP adress, username and password if it is required. 2 buttons are necessary to connect and disconnect to the camera.

Furthermore, we will create a cameraviewer in the CameraBox control. Finally, we create one more groupbox, for the new features that we will implement in the following tutorials. When the controls are ready, I create the buttons click event. And I resize our application.

We have to add 4 namespaces:

  • Ozeki.Media.IPCamera
  • Ozeki.Media.MediaHandlers.
  • Ozeki.Media.MediaHandlers.Video
  • and Ozeki.Media.Video.Controls

We need some variable to handle our application. We initialize the mediaconnector and the bitmapsourceprovider in the main constructor. After that we create and set the cameraviewer control and add it to the grid called Camerabox and we have to set the bitmapsourceprovider instance to the videoviewer control.

Finally, we have to write the connect and the disconnect buttons. We will get the default device to our webcamera instance and start the viewer and connect our webcamera to the mediaconnector. In the disconnect_usb_camera_click event, we stop the viewer and the webcamera. These were the webcamera start and stop methods.

Now we implement the connect and the disconnect buttons for the ipcamera. We have to know what is the correct IP adress of the camera. We'll probably need username and password for the connection. Based on the given data we connect to the selected IP camera. and start the viewer and the IP camera in the connect button click event. In the disconnect_ip_camera_click event, we stop the viewer and the IP camera. These were the IP camera connect and disconnect methods.

Unfortunatelly this was the last video in this tutorial series, but I hope you enjoyed it as much as we did.

If you liked this video and you want to learn more about further great solutions provided by Ozeki Camera SDK, then download the trial version from our website www.camera-sdk.com and follow our tutorial videos. For more information check out our website, and if you have any questions, send us an email to info@camera-sdk.com.

Thanks for watching. Bye.

More information