Look at the prerequisites:
PBX: To be able to make and receive video calls you, a phone system (e.g. Asterisk) is essentially needed. You need to add a new SIP account in your PBX for this application.Visual Studio: This solution is based on a console softphone, so a new Visual C# Console Application is just enough.
VoIPSDK.dll: The necessary .dll file can be found on this website: http://www.voip-sip-sdk.com/. It should be added to your references.
Test phone: To test your application you can use any VoIP phone stat supports video calling (e.g. Bria softphone).
The C# code to make a SIP video call:
using System;
using Ozeki.Media.MediaHandlers;
using Ozeki.Media.MediaHandlers.Video;
using Ozeki.VoIP;
using Ozeki.VoIP.SDK;
namespace Video_call
{
internal class Program
{
private static ISoftPhone softphone; // softphone object
private static IPhoneLine phoneLine; // phoneline object
private static IPhoneCall call;
private static string numberToDial;
private static MediaConnector mediaConnector;
private static void Main(string[] args)
{
// Create a softphone object with RTP port range 5000-10000
softphone = SoftPhoneFactory.CreateSoftPhone(5000, 10000);
// SIP account registration data, (supplied by your VoIP service provider)
var registrationRequired = true;
var userName = "444";
var displayName = "444";
var authenticationId = "444";
var registerPassword = "444";
var domainHost = "192.168.115.25";
var domainPort = 5060;
var account = new SIPAccount(registrationRequired, displayName, userName, authenticationId, registerPassword, domainHost, domainPort);
// Send SIP regitration request
RegisterAccount(account);
// Prevents the termination of the application
Console.ReadLine();
}
static void RegisterAccount(SIPAccount account)
{
try
{
phoneLine = softphone.CreatePhoneLine(account);
phoneLine.RegistrationStateChanged += sipAccount_RegStateChanged;
softphone.RegisterPhoneLine(phoneLine);
}
catch (Exception ex)
{
Console.WriteLine("Error during SIP registration: " + ex);
}
}
private static void sipAccount_RegStateChanged(object sender, RegistrationStateChangedArgs e)
{
Console.WriteLine(e.State);
if (e.State == RegState.RegistrationSucceeded)
CreateCall();
}
static void CreateCall()
{
//numberToDial = "333";
//call = softphone.CreateCallObject(phoneLine, numberToDial);
var dialParams = new DialParameters("333");
dialParams.CallType = CallType.AudioVideo;
call = softphone.CreateCallObject(phoneLine, dialParams);
mediaConnector = new MediaConnector();
var phoneCallVideoSender = new PhoneCallVideoSender();
var cam = WebCamera.GetDefaultDevice();
if (cam != null)
{
cam.Start();
mediaConnector.Connect(cam, phoneCallVideoSender);
}
phoneCallVideoSender.AttachToCall(call);
call.CallStateChanged += call_CallStateChanged;
call.Start();
}
static void call_CallStateChanged(object sender, CallStateChangedArgs e)
{
Console.WriteLine("\nCall state: {0}.", e.State);
}
}
}
Test the program:
To make a test call, provide valid SIP account details for this console application to be able to register to your PBX, then specify a telephone number to be dialled (it can be an other SIP account that has been previously registered to the PBX). After running the application, it dials the provided phone number automatically meanwhile sending the image of the webcamera.
TAGS :
can i know how can i get remote caller video in softphone.
ReplyDelete