Use of the RTC API under Visual Studio .NET
[20 mn of reading - published 4/30/2004 4:19:48 PM - Target : Confirmé]
|
   
|
Author
3. Use RTC API
This paragraph allows us to move from theory to the practise.
We will see the use of the principal methods of the “master” class.
3.1. Initialization of a session
-
The initialization of a session permits to determine
several things:
-
• The type of communication • The events which you
wish to collect • The creation of the event manager. • The definition
of the listening mode
During next paragraphs, we will see the values which we must
allot to the various methods and properties. private RTCClientClass
_rtc = new RTCClientClass(); //Initialization
of the object. _rtc.Initialize();
//Séléctionne types of communication.
_rtc.SetPreferredMediaTypes(0x00000002 | 0x00000001 | 0x00000008
| 0x00000004, true) ; //Definition
of the filter of event so that it collects events RTC. _rtc.EventFilter
= 0x00000004 | 0x00000020; //Creation
of the manager of event _rtc.IRTCEventNotification_Event_Event
+ =new IRTCEventNotification_EventEventHandler(RTC_IRTCEventNotification_Event_Event);
//Definition of the mode of listening of customer
RTC. //RTCLM_BOTH opens port SIP (standard 5060) + a dynamic port.
_rtc.ListenForIncomingSessions = RTC_LISTEN_MODE.RTCLM_BOTH;
3.2. Creation of an communication session
Before you can dial a call with RTC, you must create and
initialize a session of communication. You can dial the call in writing
an address IP, an E-mail address or the phone number of the participant.
However, these 2 last functionalities require a SIP server. But we don’t talk
about it in this article. Visit the Microsoft MSDN for more information
on SIP server. The RTC API does not currently support the visual
sessions of several connections. Thus the application must initially check that
a visual session of communication is not already in hand, before launching a
new session. To call another PC, it is necessary to identify the
type of session RTC and to create it by using the interface of IRTCSession.
The following code illustrates how to create the session. private
IRTCSession _session; //To
create and initializes a session of communication. //RTCST_PC_TO_PC: the
type of the session, here of PC PC defines. _session
= _rtc.CreateSession(RTC_SESSION_TYPE.RTCST_PC_TO_PC,null,null,0)
//Addition the participant in the session.
_session.AddParticipant(adresseIP, name);
3.3. Creation of the event manager
To create the event manager related to component RTC, it
should be implemented the IRTCEventNotification_Event interface: //Creation
of event manager _rtc.IRTCEventNotification_Event_Event
+ =new IRTCEventNotification_EventEventHandler(RTC_IRTCEventNotification_Event_Event);
This implementation creates a method RTC_IRTCEventNotification_Event_Event(),
with like parameter a constant of the type RTC_EVENT and a object.
3.4. Configuration of the EventFilter property
As we explained in the previous paragraph, once the manager
created, we have to parameterize the EventFilter property. This property
takes the value of constants of the types RTCE _ Example of parameter
of the EventFilter property : In this example, the application
will collect event RTCE_MEDIA. //Definition
of the filter of event so that it collects events RTC. _rtc.EventFilter
= 0x00000020; The value hexadecimal 0x00000020 corresponds
to the value of the constant RTCE_MEDIA. It is possible to define
several events RTC in this property using one or "|". //Definition
of the filter of event so that it collects events RTC. _rtc.EventFilter
= 0x00000080 | 0x00000020; In this example, the application
will collect the events of the types RTCE_MEDIA (0X00000020) and RTCE_MESSAGING
(0X00000080).
3.5. Configuration of the SetPreferredMediaTypes method
This method determines the actions which you wish to carry
out (to receive the sound, to send video) The method takes in parameter
the value of the constants of the types RTCMT _ and Boolean. //To
receive sound _rtc.SetPreferredMediaTypes(0x00000002,
true) ; The hexadecimal value corresponds to the value
of the constant RTCMT_AUDIO_RECEIVE. The application is configured to receive
sound. It is also possible to define several values by using one or
"|". //To receive and send sound
_rtc.SetPreferredMediaTypes(0x00000002 | 0x000000001, true) ;
This example of code you enables to receive and send sound. The hexadecimal
value (0X00000001) corresponds to the value of the constant RTCMT_AUDIO_SEND.
3.6. Method OnIRTCMediaEvent
This method is called when an event RTCE_MEDIA is detected
in the manager. It permits to stick it video that you wish to send
or receive. For that, it is necessary to configure the method get_IVideoWindow().
This method takes in parameter a constant of the type RTC_VIDEO_DEVICE.
-
The constant RTC_VIDEO_DEVICE are:
-
• RTCVD_PREVIEW: to stick the video which one wishes
to send • RTCVD_RECEIVE: to stick the video which one received
3.7. Method OnIRTCSessionStateChangeEvent
This method is called when the IRTCSessionStateChangeEvent
event is detected in the manager. This example of code permits to
accept a request for connection to your conference.
3.8. Sharing application and whitheboard
To share an application or a whiteboard, it is necessary
to configure component RTC so that it can send or receive information of the
T120 types. This configuration is done using the method SetPreferredMediaTypes().
Then it is necessary to use the method get_IsT120AppletRunning() of the RTCClientClass
class to launch the "module" sharing application or whiteboard. This method
takes in parameter a constant of the type RTC_T120_APPLET.
-
The constant RTC_T120_APPLET are:
-
• RTCA_APPSHARING: divide of application • RTCA_WHITEBOARD:
whiteboard
//Lance the "module" shares application
_rtc.get_IsT120AppletRunning(RTC_T120_APPLET.RTCTA_APPSHARING);
//Lance the "module" whiteboard
_rtc.get_IsT120AppletRunning(RTC_T120_APPLET.RTCTA_WHITEBOARD);
You will be able to find, all this information (methods, properties and constants)
on the site of the MSDN of Microsoft: http://msdn.microsoft.com/library/default.asp
|