using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace MyRTCVideoPhone
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox txtLocalURI;
private System.Windows.Forms.TextBox txtRemoteURI;
private System.Windows.Forms.Label lblLocalURI;
private System.Windows.Forms.Label lblRemoteURI;
private System.Windows.Forms.Button btnConnect;
private System.Windows.Forms.Button btnWizard;
private System.Windows.Forms.Button btnTerminate;
private System.Windows.Forms.Button btnClose;
private System.Windows.Forms.Button btnAnswer;
private System.Windows.Forms.CheckBox chkAutoAnswer;
private System.Windows.Forms.PictureBox picLogo;
private System.Windows.Forms.Label lblStatus;
private System.Windows.Forms.Panel pnlVideoR;
private System.Windows.Forms.Panel pnlVideoS;
private System.Windows.Forms.PictureBox picVideoR;
private System.Windows.Forms.PictureBox picVideoS;
private System.Windows.Forms.Label lblVideoR;
private System.Windows.Forms.Label lblVideoS;
private System.Windows.Forms.TextBox txtStatus;
private System.Windows.Forms.Label lblIm;
private System.Windows.Forms.TextBox txtIm;
private System.Windows.Forms.Button btnSend;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.txtLocalURI = new System.Windows.Forms.TextBox();
this.txtRemoteURI = new System.Windows.Forms.TextBox();
this.lblLocalURI = new System.Windows.Forms.Label();
this.lblRemoteURI = new System.Windows.Forms.Label();
this.btnConnect = new System.Windows.Forms.Button();
this.btnWizard = new System.Windows.Forms.Button();
this.btnTerminate = new System.Windows.Forms.Button();
this.btnClose = new System.Windows.Forms.Button();
this.btnAnswer = new System.Windows.Forms.Button();
this.chkAutoAnswer = new System.Windows.Forms.CheckBox();
this.picLogo = new System.Windows.Forms.PictureBox();
this.txtStatus = new System.Windows.Forms.TextBox();
this.lblStatus = new System.Windows.Forms.Label();
this.pnlVideoR = new System.Windows.Forms.Panel();
this.picVideoR = new System.Windows.Forms.PictureBox();
this.pnlVideoS = new System.Windows.Forms.Panel();
this.picVideoS = new System.Windows.Forms.PictureBox();
this.lblVideoR = new System.Windows.Forms.Label();
this.lblVideoS = new System.Windows.Forms.Label();
this.lblIm = new System.Windows.Forms.Label();
this.txtIm = new System.Windows.Forms.TextBox();
this.btnSend = new System.Windows.Forms.Button();
this.pnlVideoR.SuspendLayout();
this.pnlVideoS.SuspendLayout();
this.SuspendLayout();
//
// txtLocalURI
//
this.txtLocalURI.Location = new System.Drawing.Point(8, 40);
this.txtLocalURI.Name = "txtLocalURI";
this.txtLocalURI.Size = new System.Drawing.Size(184, 20);
this.txtLocalURI.TabIndex = 0;
this.txtLocalURI.Text = "Local URI";
//
// txtRemoteURI
//
this.txtRemoteURI.Location = new System.Drawing.Point(8, 112);
this.txtRemoteURI.Name = "txtRemoteURI";
this.txtRemoteURI.Size = new System.Drawing.Size(184, 20);
this.txtRemoteURI.TabIndex = 1;
this.txtRemoteURI.Text = "textBox2";
//
// lblLocalURI
//
this.lblLocalURI.BackColor = System.Drawing.SystemColors.WindowText;
this.lblLocalURI.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.lblLocalURI.ForeColor = System.Drawing.SystemColors.HighlightText;
this.lblLocalURI.Location = new System.Drawing.Point(16, 8);
this.lblLocalURI.Name = "lblLocalURI";
this.lblLocalURI.TabIndex = 2;
this.lblLocalURI.Text = "Local URI";
this.lblLocalURI.Click += new System.EventHandler(this.label1_Click);
//
// lblRemoteURI
//
this.lblRemoteURI.BackColor = System.Drawing.SystemColors.ControlText;
this.lblRemoteURI.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.lblRemoteURI.ForeColor = System.Drawing.SystemColors.HighlightText;
this.lblRemoteURI.Location = new System.Drawing.Point(8, 80);
this.lblRemoteURI.Name = "lblRemoteURI";
this.lblRemoteURI.TabIndex = 3;
this.lblRemoteURI.Text = "Remote URI";
//
// btnConnect
//
this.btnConnect.BackColor = System.Drawing.SystemColors.ControlLight;
this.btnConnect.Cursor = System.Windows.Forms.Cursors.Arrow;
this.btnConnect.Location = new System.Drawing.Point(16, 144);
this.btnConnect.Name = "btnConnect";
this.btnConnect.Size = new System.Drawing.Size(104, 23);
this.btnConnect.TabIndex = 4;
this.btnConnect.Text = "Connect";
this.btnConnect.Click += new System.EventHandler(this.btnConnect_Click);
//
// btnWizard
//
this.btnWizard.BackColor = System.Drawing.SystemColors.ControlLight;
this.btnWizard.Location = new System.Drawing.Point(16, 176);
this.btnWizard.Name = "btnWizard";
this.btnWizard.Size = new System.Drawing.Size(104, 23);
this.btnWizard.TabIndex = 5;
this.btnWizard.Text = "Calibrate";
this.btnWizard.Click += new System.EventHandler(this.btnWizard_Click);
//
// btnTerminate
//
this.btnTerminate.BackColor = System.Drawing.SystemColors.ControlLight;
this.btnTerminate.Enabled = false;
this.btnTerminate.Location = new System.Drawing.Point(16, 216);
this.btnTerminate.Name = "btnTerminate";
this.btnTerminate.Size = new System.Drawing.Size(104, 23);
this.btnTerminate.TabIndex = 6;
this.btnTerminate.Text = "End Call";
this.btnTerminate.Click += new System.EventHandler(this.btnTerminate_Click);
//
// btnClose
//
this.btnClose.BackColor = System.Drawing.SystemColors.ControlLight;
this.btnClose.Location = new System.Drawing.Point(16, 256);
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(104, 23);
this.btnClose.TabIndex = 7;
this.btnClose.Text = "Close";
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
//
// btnAnswer
//
this.btnAnswer.BackColor = System.Drawing.SystemColors.ControlLight;
this.btnAnswer.Enabled = false;
this.btnAnswer.Location = new System.Drawing.Point(248, 40);
this.btnAnswer.Name = "btnAnswer";
this.btnAnswer.Size = new System.Drawing.Size(104, 23);
this.btnAnswer.TabIndex = 8;
this.btnAnswer.Text = "Answer";
this.btnAnswer.Click += new System.EventHandler(this.btnAnswer_Click);
//
// chkAutoAnswer
//
this.chkAutoAnswer.ForeColor = System.Drawing.SystemColors.HighlightText;
this.chkAutoAnswer.Location = new System.Drawing.Point(376, 40);
this.chkAutoAnswer.Name = "chkAutoAnswer";
this.chkAutoAnswer.TabIndex = 9;
this.chkAutoAnswer.Text = "AutoAnswer";
//
// picLogo
//
this.picLogo.Image = ((System.Drawing.Image)(resources.GetObject("picLogo.Image")));
this.picLogo.Location = new System.Drawing.Point(240, 64);
this.picLogo.Name = "picLogo";
this.picLogo.Size = new System.Drawing.Size(304, 256);
this.picLogo.TabIndex = 10;
this.picLogo.TabStop = false;
this.picLogo.Click += new System.EventHandler(this.picLogo_Click);
//
// txtStatus
//
this.txtStatus.AcceptsReturn = true;
this.txtStatus.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.txtStatus.ForeColor = System.Drawing.SystemColors.ControlText;
this.txtStatus.Location = new System.Drawing.Point(8, 328);
this.txtStatus.Multiline = true;
this.txtStatus.Name = "txtStatus";
this.txtStatus.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.txtStatus.Size = new System.Drawing.Size(560, 48);
this.txtStatus.TabIndex = 11;
this.txtStatus.Text = "";
this.txtStatus.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
//
// lblStatus
//
this.lblStatus.ForeColor = System.Drawing.SystemColors.HighlightText;
this.lblStatus.Location = new System.Drawing.Point(24, 304);
this.lblStatus.Name = "lblStatus";
this.lblStatus.TabIndex = 12;
this.lblStatus.Text = "Client Status";
//
// pnlVideoR
//
this.pnlVideoR.Controls.Add(this.picVideoR);
this.pnlVideoR.Location = new System.Drawing.Point(592, 64);
this.pnlVideoR.Name = "pnlVideoR";
this.pnlVideoR.Size = new System.Drawing.Size(144, 112);
this.pnlVideoR.TabIndex = 13;
//
// picVideoR
//
this.picVideoR.BackColor = System.Drawing.SystemColors.ScrollBar;
this.picVideoR.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.picVideoR.Location = new System.Drawing.Point(8, 8);
this.picVideoR.Name = "picVideoR";
this.picVideoR.Size = new System.Drawing.Size(129, 97);
this.picVideoR.TabIndex = 0;
this.picVideoR.TabStop = false;
//
// pnlVideoS
//
this.pnlVideoS.Controls.Add(this.picVideoS);
this.pnlVideoS.Location = new System.Drawing.Point(584, 296);
this.pnlVideoS.Name = "pnlVideoS";
this.pnlVideoS.Size = new System.Drawing.Size(144, 120);
this.pnlVideoS.TabIndex = 14;
//
// picVideoS
//
this.picVideoS.BackColor = System.Drawing.SystemColors.ScrollBar;
this.picVideoS.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.picVideoS.Location = new System.Drawing.Point(8, 8);
this.picVideoS.Name = "picVideoS";
this.picVideoS.Size = new System.Drawing.Size(129, 97);
this.picVideoS.TabIndex = 0;
this.picVideoS.TabStop = false;
//
// lblVideoR
//
this.lblVideoR.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.lblVideoR.ForeColor = System.Drawing.SystemColors.HighlightText;
this.lblVideoR.Location = new System.Drawing.Point(600, 40);
this.lblVideoR.Name = "lblVideoR";
this.lblVideoR.Size = new System.Drawing.Size(136, 23);
this.lblVideoR.TabIndex = 15;
this.lblVideoR.Text = "Vedio In";
//
// lblVideoS
//
this.lblVideoS.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.lblVideoS.ForeColor = System.Drawing.SystemColors.HighlightText;
this.lblVideoS.Location = new System.Drawing.Point(592, 264);
this.lblVideoS.Name = "lblVideoS";
this.lblVideoS.Size = new System.Drawing.Size(136, 23);
this.lblVideoS.TabIndex = 16;
this.lblVideoS.Text = "Vedio Out";
//
// lblIm
//
this.lblIm.ForeColor = System.Drawing.SystemColors.HighlightText;
this.lblIm.Location = new System.Drawing.Point(8, 384);
this.lblIm.Name = "lblIm";
this.lblIm.TabIndex = 17;
this.lblIm.Text = "message";
//
// txtIm
//
this.txtIm.Location = new System.Drawing.Point(8, 416);
this.txtIm.Multiline = true;
this.txtIm.Name = "txtIm";
this.txtIm.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.txtIm.Size = new System.Drawing.Size(560, 88);
this.txtIm.TabIndex = 18;
this.txtIm.Text = "";
//
// btnSend
//
this.btnSend.BackColor = System.Drawing.SystemColors.GrayText;
this.btnSend.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.btnSend.ForeColor = System.Drawing.SystemColors.ControlText;
this.btnSend.Location = new System.Drawing.Point(576, 448);
this.btnSend.Name = "btnSend";
this.btnSend.TabIndex = 19;
this.btnSend.Text = "send";
this.btnSend.Click += new System.EventHandler(this.btnSend_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.BackColor = System.Drawing.SystemColors.ControlText;
this.ClientSize = new System.Drawing.Size(744, 518);
this.Controls.Add(this.btnSend);
this.Controls.Add(this.txtIm);
this.Controls.Add(this.lblIm);
this.Controls.Add(this.lblVideoS);
this.Controls.Add(this.lblVideoR);
this.Controls.Add(this.pnlVideoS);
this.Controls.Add(this.pnlVideoR);
this.Controls.Add(this.lblStatus);
this.Controls.Add(this.txtStatus);
this.Controls.Add(this.picLogo);
this.Controls.Add(this.chkAutoAnswer);
this.Controls.Add(this.btnAnswer);
this.Controls.Add(this.btnClose);
this.Controls.Add(this.btnTerminate);
this.Controls.Add(this.btnWizard);
this.Controls.Add(this.btnConnect);
this.Controls.Add(this.lblRemoteURI);
this.Controls.Add(this.lblLocalURI);
this.Controls.Add(this.txtRemoteURI);
this.Controls.Add(this.txtLocalURI);
this.Name = "Form1";
this.Text = "MyRTCVideoPhone";
this.Closing += new System.ComponentModel.CancelEventHandler(this.Form1_Closing);
this.Load += new System.EventHandler(this.Form1_Load);
this.pnlVideoR.ResumeLayout(false);
this.pnlVideoS.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
//Add Event Handler for the Client EventNotification Event
this.oClient.IRTCEventNotification_Event_Event+=new RTCCORELib.IRTCEventNotification_EventEventHandler(oClient_IRTCEventNotification_Event_Event);
oClient.Initialize();
oClient.EventFilter = RTC_EVENTFILTERS;
oClient.ListenForIncomingSessions = RTCCORELib.RTC_LISTEN_MODE.RTCLM_BOTH;
oClient.SetPreferredMediaTypes(RTCMT_ALL , true);
// Get IVideoWindow objects for Incoming and outgoing video streams.
oVideoSend = oClient.get_IVideoWindow(RTCCORELib.RTC_VIDEO_DEVICE.RTCVD_PREVIEW);
oVideoRecv = oClient.get_IVideoWindow(RTCCORELib.RTC_VIDEO_DEVICE.RTCVD_RECEIVE);
//Display local user uri
txtLocalURI.Text = oClient.LocalUserURI;
DisplayStatus("RTCClientClass is initialized And Listening.");
}
private void label1_Click(object sender, System.EventArgs e)
{
}
private void textBox1_TextChanged(object sender, System.EventArgs e)
{
}
#region "Constants"
// Flags for CreateSession/AddBuddy
private const int RTCCS_FORCE_PROFILE = 0x1;
private const int RTCCS_FAIL_ON_REDIRECT = 0x2;
// Media Types
private const int RTCMT_AUDIO_SEND = 0x1;
private const int RTCMT_AUDIO_RECEIVE = 0x2;
private const int RTCMT_VIDEO_SEND = 0x4;
private const int RTCMT_VIDEO_RECEIVE = 0x8;
private const int RTCMT_T120_SENDRECV = 0x10;
private const int RTCMT_ALL_RTP = 0xF;
private const int RTCMT_ALL = 0x1F;
// Session types
private const int RTCSI_PC_TO_PC = 0x1;
private const int RTCSI_PC_TO_PHONE = 0x2;
private const int RTCSI_PHONE_TO_PHONE = 0x4;
private const int RTCSI_IM = 0x8;
// Transports
private const int RTCTR_UDP = 0x1;
private const int RTCTR_TCP = 0x2;
private const int RTCTR_TLS = 0x4;
// Registration Flags
private const int RTCRF_REGISTER_INVITE_SESSIONS = 0x1;
private const int RTCRF_REGISTER_MESSAGE_SESSIONS = 0x2;
private const int RTCRF_REGISTER_PRESENCE = 0x4;
private const int RTCRF_REGISTER_ALL = 0x7;
// Event filters
private const int RTCEF_CLIENT = 0x1;
private const int RTCEF_REGISTRATION_STATE_CHANGE = 0x2;
private const int RTCEF_SESSION_STATE_CHANGE = 0x4;
private const int RTCEF_SESSION_OPERATION_COMPLETE = 0x8;
private const int RTCEF_PARTICIPANT_STATE_CHANGE = 0x10;
private const int RTCEF_MEDIA = 0x20;
private const int RTCEF_INTENSITY = 0x40;
private const int RTCEF_MESSAGING = 0x80;
private const int RTCEF_BUDDY = 0x100;
private const int RTCEF_WATCHER = 0x200;
private const int RTCEF_PROFILE = 0x400;
private const int RTCEF_ALL = 0x1FFFFFF;
//RTC_EVENTFILTERS will be used to register for receiving events.
private const int RTC_EVENTFILTERS = RTCEF_CLIENT | RTCEF_SESSION_STATE_CHANGE | RTCEF_MEDIA | RTCEF_MESSAGING | RTCEF_BUDDY | RTCEF_PARTICIPANT_STATE_CHANGE ;
// Constants related to the IVideoInterface. These are used
private const int WS_CHILD = 0x40000000;
private const int WS_CLIPSIBLINGS = 0x4000000;
#endregion
#region "Class Level Object and Interface Declarations"
private RTCCORELib.IRTCSession oSession;
private RTCCORELib.IRTCProfile oProfile;
private RTCCORELib.IVideoWindow oVideoSend;
private RTCCORELib.IVideoWindow oVideoRecv;
private RTCCORELib.IRTCMessagingEvent MessagingEvent;
private RTCCORELib.IRTCParticipant oParticipant;
private RTCCORELib.RTCClientClass oClient = new RTCCORELib.RTCClientClass();
#endregion
#region
private void DisplayStatus( string strStatus )
{
txtStatus.Text = "\r\n" + strStatus + txtStatus.Text;
}
private void oClient_IRTCEventNotification_Event_Event( RTCCORELib.RTC_EVENT RTCEvent, object pEvent)
{
switch(RTCEvent )
{
case RTCCORELib.RTC_EVENT.RTCE_SESSION_STATE_CHANGE:
SessionStateEvent(pEvent);
break;
case RTCCORELib.RTC_EVENT.RTCE_MEDIA:
MediaEvent(pEvent);
break;
case RTCCORELib.RTC_EVENT.RTCE_MESSAGING:
IM(pEvent);
break;
}
}
private void SessionStateEvent( object pEvent )
{
RTCCORELib.IRTCSessionStateChangeEvent objSessionEvent;
objSessionEvent = (RTCCORELib.IRTCSessionStateChangeEvent)pEvent;
RTCCORELib.RTC_SESSION_STATE x;
x = objSessionEvent.State;
switch( x )
{
case RTCCORELib.RTC_SESSION_STATE.RTCSS_IDLE :
DisplayStatus("IDLE");
break;
case RTCCORELib.RTC_SESSION_STATE.RTCSS_INCOMING :
// Answer incoming only if there is no other session connected
bool OkToAnswer = false;
if (oSession == null )
{
OkToAnswer = true;
}
else
{
if( oSession.State != RTCCORELib.RTC_SESSION_STATE.RTCSS_CONNECTED )
{
OkToAnswer = true;
}
}
if(OkToAnswer)
{
DisplayStatus("INCOMING");
btnTerminate.Enabled = true;
btnConnect.Enabled = false;
btnAnswer.Enabled = true;
//Play a ring on the local PC to alert user of incoming call.
oClient.PlayRing(RTCCORELib.RTC_RING_TYPE.RTCRT_PHONE, true);
//Get the incoming session.
oSession = objSessionEvent.Session;
//Automatically answer if Auto Answer is checked.
if( chkAutoAnswer.CheckState == CheckState.Checked )
{
oSession.Answer();
}
}
break;
case RTCCORELib.RTC_SESSION_STATE.RTCSS_ANSWERING :
DisplayStatus("ANSWERING");
// Stop the ringing
oClient.PlayRing(RTCCORELib.RTC_RING_TYPE.RTCRT_PHONE, false);
//Answer button has been pressed, now disable it.
btnAnswer.Enabled = false;
break;
case RTCCORELib.RTC_SESSION_STATE.RTCSS_INPROGRESS :
DisplayStatus("INPROGRESS");
//Disable and enable appropriate buttons.
btnConnect.Enabled = false;
btnTerminate.Enabled = true;
btnWizard.Enabled = false;
break;
case RTCCORELib.RTC_SESSION_STATE.RTCSS_CONNECTED :
DisplayStatus("CONNECTED");
// if ( this.txtIm.Text != null)
// {
// btnSend.Enabled = true;
// }
btnTerminate.Enabled = true;
break;
case RTCCORELib.RTC_SESSION_STATE.RTCSS_DISCONNECTED :
//Free session and participant objects
oSession = null;
oParticipant = null;
DisplayStatus("DISCONNECTED");
btnAnswer.Enabled = false;
btnTerminate.Enabled = false;
btnConnect.Enabled = true;
btnWizard.Enabled = true;
//btnSend.Enabled = false;
break;
}
objSessionEvent = null;
}
//Instant Messaging
private void IM(object pEvent)
{
RTCCORELib.IRTCMessagingEvent oIMEvent;
RTCCORELib.RTC_MESSAGING_EVENT_TYPE IMEV;
oIMEvent = ((RTCCORELib.IRTCMessagingEvent)(pEvent));
IMEV=oIMEvent.EventType;
if ( IMEV== RTCCORELib.RTC_MESSAGING_EVENT_TYPE.RTCMSET_MESSAGE)
txtIm.Text=MessagingEvent.Message;
}
// MediaType = oIMevent.MediaType;
private void MediaEvent(object pEvent)
{
int MediaType = 0;
RTCCORELib.IRTCMediaEvent oMediaEvent;
RTCCORELib.RTC_MEDIA_EVENT_TYPE EventType;
// Cast pEvent it to the IRTCMediaEvent Interface
oMediaEvent = ((RTCCORELib.IRTCMediaEvent)(pEvent));
EventType = oMediaEvent.EventType;
MediaType = oMediaEvent.MediaType;
if (EventType == RTCCORELib.RTC_MEDIA_EVENT_TYPE.RTCMET_STARTED)
{
if (MediaType == RTCMT_VIDEO_SEND)
{
oVideoSend.WindowStyle = WS_CHILD | WS_CLIPSIBLINGS;
oVideoSend.Owner = picVideoS.Handle.ToInt32();
oVideoSend.SetWindowPosition(0, 0, 130, 104);
oVideoSend.Visible = 1;
}
if (MediaType == RTCMT_VIDEO_RECEIVE)
{
oVideoRecv.WindowStyle = WS_CHILD | WS_CLIPSIBLINGS;
oVideoRecv.Owner = picVideoR.Handle.ToInt32();
oVideoRecv.SetWindowPosition(0, 0, 130, 104);
oVideoRecv.Visible = 1;
}
}
else if (EventType == RTCCORELib.RTC_MEDIA_EVENT_TYPE.RTCMET_STOPPED)
{
if (MediaType == RTCMT_VIDEO_RECEIVE)
{
oVideoRecv.Visible = 0;
oVideoRecv.Owner = 0;
}
else
{
oVideoSend.Visible = 0;
oVideoSend.Owner = 0;
}
}
oMediaEvent = null;
}
#endregion
private void picLogo_Click(object sender, System.EventArgs e)
{
}
private void btnConnect_Click(object sender, System.EventArgs e)
{
string strRemoteURI;
strRemoteURI = this.txtRemoteURI.Text.Trim();
//oSession = oClient.CreateSession(RTCCORELib.RTC_SESSION_TYPE.RTCST_PC_TO_PC, null, null, 0x2);
oSession = oClient.CreateSession(RTCCORELib.RTC_SESSION_TYPE.RTCST_IM, null, null, 0x2);
// oSession = oClient.CreateSession(RTCCORELib.RTC_SESSION_TYPE.RTCST_PC_TO_PHONE, null, null, 0x2);
oParticipant = oSession.AddParticipant(strRemoteURI, "Dummy Name");
}
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
// Terminating any connected session
if(oSession != null)
{
oSession.Terminate((RTCCORELib.RTC_TERMINATE_REASON.RTCTR_SHUTDOWN));
}
// Shutting down RTCClient object
if(oClient !=null)
{
// Call prepare for shutdown call shutdown.
oClient.PrepareForShutdown();
// Shutdown must be called before the client object is released.
oClient.Shutdown();
}
//Freeing memory
oSession = null;
oVideoSend = null;
oVideoRecv = null;
oParticipant = null;
oClient = null;
GC.Collect();
}
private void btnClose_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void btnTerminate_Click(object sender, System.EventArgs e)
{
if (oSession.State == RTCCORELib.RTC_SESSION_STATE.RTCSS_INCOMING)
{
//Reject Any Incoming call
oSession.Terminate(RTCCORELib.RTC_TERMINATE_REASON.RTCTR_REJECT);
//Cancel Ringing
oClient.PlayRing(RTCCORELib.RTC_RING_TYPE.RTCRT_PHONE, false);
}
else
{
//Normal Session Termination (connected)
oSession.Terminate(RTCCORELib.RTC_TERMINATE_REASON.RTCTR_NORMAL);
}
}
private void btnWizard_Click(object sender, System.EventArgs e)
{
oClient.InvokeTuningWizard(this.Handle.ToInt32());
}
private void btnAnswer_Click(object sender, System.EventArgs e)
{
try
{
oSession.Answer();
}
catch (System.Exception ex)
{
DisplayStatus(ex.Message);
}
}
private void btnSend_Click(object sender, System.EventArgs e)
{
string strRemoteURI;
strRemoteURI = this.txtRemoteURI.Text.Trim();
//oSession = oClient.CreateSession(RTCCORELib.RTC_SESSION_TYPE.RTCST_IM, null, null, 0x2);
//oParticipant = oSession.AddParticipant(strRemoteURI, "Dummy Name");
oSession.SendMessage(txtIm.Text,txtIm.Text,0);
}
}
}
and i cann't send or recieve im messages i dont understand how to send and recieve if any one know how to plz reply me :) thx in advance x_factor