By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,117 Members | 2,178 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,117 IT Pros & Developers. It's quick & easy.

How to set TLS security using RTC API's

P: n/a
Hi,

I am developing simple peer-peer RTC application for monitoring the SDP packets and i need to set the TLS security for the transport.
But iam struggling to achieving this.

Iam using IP addresses as SIP URI for communication.

I am using IRTCClientProvisioning::GetProfile()
IRTCClientProfile::EnablePrsenceEx()
IRTCClientProvisioning::EnableProfileEx()
But iam not able to establish a connection between 2 endpoints as iam not able to register to the server.

This is the code snippet :

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using RTCCORELib;
using System.Xml;
using System.Xml.Serialization;

namespace RTC_1._api
{
public partial class Form1 : Form
{
RTCClientClass _rtc = new RTCClientClass();
IRTCClientProvisioning2 userCreation;
IRTCSession _session; //To create and initializes a session of communication.
IRTCProfile userprofile; //An object for the profile of the user
IRTCClientPresence2 presence;

public Form1()
{
InitializeComponent();
}

public void RTC_IRTCEventNotification_Event_Event(RTC_EVENT RTC_event, object pEvent)
{

switch (RTC_event)
{
case RTC_EVENT.RTCE_SESSION_STATE_CHANGE:
{
IRTCSessionStateChangeEvent sessionEvent = null;
sessionEvent = (IRTCSessionStateChangeEvent)pEvent;
OnIRTCSessionStateChangeEvent(sessionEvent);
break;
}
case RTC_EVENT.RTCE_MEDIA:
{
IRTCMediaEvent mediaEvent = null;
mediaEvent = (IRTCMediaEvent)pEvent;
OnIRTCMediaEvent(mediaEvent);
break;
}
case RTC_EVENT.RTCE_MESSAGING:
{
IRTCMessagingEvent IMEvent = null;
IMEvent = (IRTCMessagingEvent)pEvent;
OnIRTCIMEvent(IMEvent);
break;
}
case RTC_EVENT.RTCE_PROFILE:
{
MessageBox.Show("RTCE_PROFILE");
IRTCProfileEvent2 profileEvent = null;
profileEvent = (IRTCProfileEvent2)pEvent;
OnProfileEvent(profileEvent);
break;
}
case RTC_EVENT.RTCE_REGISTRATION_STATE_CHANGE:
{
MessageBox.Show("RTCE_REGISTRATION_STATE_CHANGE");
IRTCRegistrationStateChangeEvent regEvent = null;
regEvent = (IRTCRegistrationStateChangeEvent)pEvent;
OnRegChangeEvent(regEvent);
break;
}
case RTC_EVENT.RTCE_CLIENT:
{
IRTCClientEvent clientEvent;
clientEvent = (IRTCClientEvent)pEvent;
OnClientEvent(clientEvent);
break;
}
}
}

private void OnClientEvent(IRTCClientEvent clientEvent)
{
RTC_CLIENT_EVENT_TYPE clientState;
clientState = clientEvent.EventType;
if (clientState == RTC_CLIENT_EVENT_TYPE.RTCCET_ASYNC_CLEANUP_DONE)
{
MessageBox.Show("srinivas akella");
}
}

private void OnRegChangeEvent(IRTCRegistrationStateChangeEvent regEvent)
{
RTC_REGISTRATION_STATE regState;
regState = regEvent.State;
switch (regState)
{
case RTC_REGISTRATION_STATE.RTCRS_REGISTERING:
MessageBox.Show("RTCRS_REGISTERING");
break;
case RTC_REGISTRATION_STATE.RTCRS_REGISTERED:
MessageBox.Show("RTCRS_REGISTERED");
break;
case RTC_REGISTRATION_STATE.RTCRS_LOGGED_OFF:
MessageBox.Show("RTCRS_LOGGED_OFF");
break;
case RTC_REGISTRATION_STATE.RTCRS_ERROR:
MessageBox.Show("RTCRS_ERROR");
break;

}

}

private void OnProfileEvent(IRTCProfileEvent2 pEvent)
{
if(pEvent.EventType == RTC_PROFILE_EVENT_TYPE.RTCPFET_PROFILE_GET)
{
if (pEvent.StatusCode == 0)
{
MessageBox.Show("1");
userprofile = (IRTCProfile)pEvent.Profile;
presence.EnablePresenceEx(userprofile, "bb", 0);
presence.SetLocalPresenceInfo(RTC_PRESENCE_STATUS. RTCXS_PRESENCE_ONLINE, null);
userCreation.EnableProfileEx(userprofile, 0x0000000F, 0x0000000F);
MessageBox.Show("1");
}

}
}
void OnIRTCIMEvent(IRTCMessagingEvent IMEvent)
{
if (IMEvent.EventType == RTC_MESSAGING_EVENT_TYPE.RTCMSET_MESSAGE)
{
string messageReceivedFromUserUri = IMEvent.Participant.UserURI;
string messageHeader =IMEvent.MessageHeader;
string message = IMEvent.Message;
MessageBox.Show(messageReceivedFromUserUri + " : " + message);

}

}
void OnIRTCSessionStateChangeEvent(IRTCSessionStateChan geEvent sessionevent)
{

RTC_SESSION_STATE sessionState;
sessionState = sessionevent.State;
switch (sessionState)
{

case RTC_SESSION_STATE.RTCSS_IDLE:
textBox3.Text = "Session is IDLE";
break;

case RTC_SESSION_STATE.RTCSS_INCOMING:

textBox3.Text = "Session is INCOMING";
//Play a ring on the local PC to alert user of incoming call.
objRTC.PlayRing(RTC_RING_TYPE.RTCRT_PHONE, true);
//Get the incoming session.
objSession = sessionevent.Session;
objSession.Answer();
break;

case RTC_SESSION_STATE.RTCSS_ANSWERING:
textBox3.Text = "Session is ANSWERING";
// Stop the ringing
objRTC.PlayRing(RTC_RING_TYPE.RTCRT_PHONE, false);
break;

case RTC_SESSION_STATE.RTCSS_INPROGRESS:
textBox3.Text = "Session is INPROGRESS";
break;

case RTC_SESSION_STATE.RTCSS_CONNECTED:
textBox3.Text = "Session is CONNECTED";
break;

case RTC_SESSION_STATE.RTCSS_DISCONNECTED:
textBox3.Text = "Session is DISCONNECTED";
objSession = null;
break;
}
}

void OnIRTCMediaEvent(IRTCMediaEvent mediaEvent)
{
RTC_MEDIA_EVENT_TYPE mediaType;
IVideoWindow videoWindow = null;

mediaType = mediaEvent.EventType;
switch (mediaType)
{
case RTC_MEDIA_EVENT_TYPE.RTCMET_STARTED:
{
videoWindow = objRTC.get_IVideoWindow(RTC_VIDEO_DEVICE.RTCVD_REC EIVE);
videoWindow.SetWindowPosition(100, 100, 400, 400);
videoWindow.Visible = 1;
textBox4.Text = "Video Window is Openend";
break;
}

case RTC_MEDIA_EVENT_TYPE.RTCMET_FAILED:
{
textBox4.Text = "Video Session is failed";
break;
}

case RTC_MEDIA_EVENT_TYPE.RTCMET_STOPPED:
{
textBox4.Text = "Video Session is closed";
videoWindow.Visible = 0;
videoWindow = null;
break;

}
}
}
RTCClientClass objRTC = new RTCClientClass();
IRTCSession objSession;
private void Connect_Click(object sender, EventArgs e)
{
userCreation = _rtc;
presence = _rtc;
_rtc.Initialize();
_rtc.SetPreferredMediaTypes(0x0000001F, true);
_rtc.EventFilter = 0x00000080 | 0x00000004 | 0x00000020 | 0x00000400 | 0x00000002;
_rtc.IRTCEventNotification_Event_Event += new IRTCEventNotification_EventEventHandler(RTC_IRTCEv entNotification_Event_Event);
_rtc.ListenForIncomingSessions = RTC_LISTEN_MODE.RTCLM_BOTH;
userCreation.GetProfile(null, null, "172.25.218.48", "172.25.218.1", 4, 0);
MessageBox.Show("Over");
}

private void CreateSession_Click(object sender, EventArgs e)
{
_session = _rtc.CreateSession(RTC_SESSION_TYPE.RTCST_PC_TO_PC , null, userprofile, 0x00000001);
_session.AddParticipant("172.25.218.144", "srinivas");

}

}
}
what could be the problem in registering the profile with the server.

how to register for a server if IP addresses are used for peer-peer communication.

I would be greatful to u if u provide any pointers.

Jun 27 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.