Contains methods for creating OpenTok sessions, generating tokens, and working with archives. More...
Public Member Functions | |
OpenTok (int apiKey, string apiSecret) | |
Creates an OpenTok object. More... | |
OpenTok (int apiKey, string apiSecret, string apiUrl) | |
For Vonage internal use. More... | |
Session | CreateSession (string location="", MediaMode mediaMode=MediaMode.RELAYED, ArchiveMode archiveMode=ArchiveMode.MANUAL) |
Creates a new OpenTok session. More... | |
string | GenerateToken (string sessionId, Role role=Role.PUBLISHER, double expireTime=0, string data=null, List< string > initialLayoutClassList=null) |
Creates a token for connecting to an OpenTok session. In order to authenticate a user connecting to an OpenTok session, the client passes a token when connecting to the session. More... | |
Archive | StartArchive (string sessionId, string name="", bool hasVideo=true, bool hasAudio=true, OutputMode outputMode=OutputMode.COMPOSED, string resolution=null, ArchiveLayout layout=null) |
Starts archiving an OpenTok session. More... | |
Archive | StopArchive (string archiveId) |
Stops an OpenTok archive that is being recorded. More... | |
ArchiveList | ListArchives (int offset=0, int count=0, string sessionId="") |
Returns a List of Archive objects, representing archives that are both both completed and in-progress, for your API key. More... | |
Archive | GetArchive (string archiveId) |
Gets an Archive object for the given archive ID. More... | |
void | DeleteArchive (string archiveId) |
Deletes an OpenTok archive. More... | |
Stream | GetStream (string sessionId, string streamId) |
Gets a Stream object for the given stream ID. More... | |
StreamList | ListStreams (string sessionId) |
Returns a List of Stream objects, representing streams that are in-progress, for the session ID. More... | |
void | ForceDisconnect (string sessionId, string connectionId) |
Force a specific client to disconnect from an OpenTok session. More... | |
Broadcast | StartBroadcast (string sessionId, Boolean hls=true, List< Rtmp > rtmpList=null, string resolution=null, int maxDuration=7200, BroadcastLayout layout=null) |
Use this method to start a live streaming for an OpenTok session. This broadcasts the session to an HLS (HTTP live streaming) or to RTMP streams. More... | |
Broadcast | StopBroadcast (string broadcastId) |
Use this method to stop a live broadcast of an OpenTok session. Note that broadcasts automatically stop 120 minutes after they are started. More... | |
Broadcast | GetBroadcast (string broadcastId) |
Use this method to get a live streaming broadcast object of an OpenTok session. More... | |
void | SetBroadcastLayout (string broadcastId, BroadcastLayout layout) |
Sets the layout type for the broadcast. For a description of layout types, see Configuring the video layout for OpenTok live streaming broadcasts. More... | |
bool | SetArchiveLayout (string archiveId, ArchiveLayout layout) |
Allows you to Dynamically change the layout of a composed archive while it's being recorded see Customizing the video layout for composed archives for details regarding customizing a layout. More... | |
void | SetStreamClassLists (string sessionId, List< StreamProperties > streams) |
Sets the layout class list for streams in a session. Layout classes are used in the layout for composed archives and live streaming broadcasts. For more information, see Customizing the video layout for composed archives and Configuring video layout for OpenTok live streaming broadcasts. More... | |
void | Signal (string sessionId, SignalProperties signalProperties, string connectionId=null) |
Sends a signal to clients (or a specific client) connected to an OpenTok session. More... | |
void | SetDefaultRequestTimeout (int timeout) |
Set's the default request timeout (in milliseconds) for all WebRequest's sent by the SDK More... | |
void | PlayDTMF (string sessionId, string digits, string connectionId=null) |
Send DTMF digits to all participants in an active OpenTok session or to a specific client connected to that session. More... | |
Task | PlayDTMFAsync (string sessionId, string digits, string connectionId=null) |
Send DTMF digits to all participants in an active OpenTok session or to a specific client connected to that session. More... | |
void | Dial (string sessionId, string token, string sipUri, DialOptions options=null) |
Connects a SIP platform to an OpenTok session. More... | |
Task | DialAsync (string sessionId, string token, string sipUri, DialOptions options=null) |
Connects a SIP platform to an OpenTok session. More... | |
void | ForceMuteStream (string sessionId, string streamId) |
Force the publisher of a specific stream to mute its published audio. More... | |
async Task | ForceMuteStreamAsync (string sessionId, string streamId) |
Force the publisher of a specific stream to mute its published audio. More... | |
void | ForceMuteAll (string sessionId, string[] excludedStreamIds) |
Forces all streams (except for an optional list of streams) in a session to mute published audio. More... | |
async Task | ForceMuteAllAsync (string sessionId, string[] excludedStreamIds) |
Forces all streams (except for an optional list of streams) in a session to mute published audio. More... | |
void | DisableForceMute (string sessionId) |
Disables the active mute state of the session. After you call this method, new streams published to the session will no longer have audio muted. More... | |
async Task | DisableForceMuteAsync (string sessionId) |
Disables the active mute state of the session. After you call this method, new streams published to the session will no longer have audio muted. More... |
Properties | |
int | ApiKey [get] |
The OpenTok API key passed into the OpenTok() constructor. More... | |
string | ApiSecret [get] |
The OpenTok API secret passed into the OpenTok() constructor. More... | |
HttpClient | Client [get, set] |
For internal use More... | |
bool | Debug [get, set] |
Enables writing request/response details to console. Don't use in a production environment. More... |
Contains methods for creating OpenTok sessions, generating tokens, and working with archives.
To create a new OpenTok object, call the OpenTok() constructor with your OpenTok API key and the API secret for your OpenTok project. Do not publicly share your API secret. You will use it with the OpenTok constructor (only on your web server) to create OpenTok sessions.
OpenTokSDK.OpenTok.OpenTok | ( | int | apiKey, |
string | apiSecret | ||
) |
Creates an OpenTok object.
apiKey | Your OpenTok API key. (See the Vonage Video API account page |
apiSecret | Your OpenTok API secret. (See the Vonage Video API account page |
OpenTokSDK.OpenTok.OpenTok | ( | int | apiKey, |
string | apiSecret, | ||
string | apiUrl | ||
) |
For Vonage internal use.
apiKey | |
apiSecret | |
apiUrl |
Session OpenTokSDK.OpenTok.CreateSession | ( | string | location = "" , |
MediaMode | mediaMode = MediaMode.RELAYED , |
||
ArchiveMode | archiveMode = ArchiveMode.MANUAL |
||
) |
Creates a new OpenTok session.
OpenTok sessions do not expire. However, authentication tokens do expire (see the generateToken() method). Also note that sessions cannot explicitly be destroyed.
A session ID string can be up to 255 characters long.
Calling this method results in an OpenTokException in the event of an error. Check the error message for details.
You can also create a session using the OpenTok REST API or by logging in to your Vonage Video API account.
location | An IP address that the OpenTok servers will use to situate the session in its global network. If you do not set a location hint, the OpenTok servers will be based on the first client connecting to the session. |
mediaMode | Whether the session will transmit streams using the OpenTok Media Router (MediaMode.ROUTED) or not (MediaMode.RELAYED). By default, the setting is MediaMode.RELAYED. |
With the parameter set to MediaMode.RELAYED, the session will attempt to transmit streams directly between clients. If clients cannot connect due to firewall restrictions, the session uses the OpenTok TURN server to relay streams.
The OpenTok Media Router provides the following benefits:
archiveMode | Whether the session is automatically archived (ArchiveMode.ALWAYS) or not (ArchiveMode.MANUAL). By default, the setting is ArchiveMode.MANUAL and you must call the StartArchive method of the OpenTok object to start archiving. To archive the session (either automatically or not), you must set the mediaMode parameter to MediaMode.ROUTED |
void OpenTokSDK.OpenTok.DeleteArchive | ( | string | archiveId | ) |
Deletes an OpenTok archive.
You can only delete an archive which has a status of "available" or "uploaded". Deleting an archive removes its record from the list of archives. For an "available" archive, it also removes the archive file, making it unavailable for download.
archiveId | The archive ID of the archive you want to delete. |
void OpenTokSDK.OpenTok.Dial | ( | string | sessionId, |
string | token, | ||
string | sipUri, | ||
DialOptions | options = null |
||
) |
Connects a SIP platform to an OpenTok session.
For more information, including technical details and security considerations, see the the OpenTok SIP interconnect developer guide.
sessionId | The session ID corresponding to the session to which the user will connect. |
token | The token for the session ID with which the SIP user will use to connect. |
sipUri | The SIP URI to be used as destination of the SIP call initiated from OpenTok to your SIP platform. If the SIP URI contains a transport=tls header, the negotiation between OpenTok and the SIP endpoint will be done securely. Note that this will only apply to the negotiation itself, and not to the transmission of audio. If you also audio transmission to be encrypted, set the Secure property of the of the DialOptions object passed into the options parameter to true . This is an example of setting sipUri for a secure call negotiation: "sip:user@sip.partner.com;transport=tls" . This is an example of insecure call negotiation: "sip:user@sip.partner.com" . |
options | Optional parameters for SIP dialing. |
Task OpenTokSDK.OpenTok.DialAsync | ( | string | sessionId, |
string | token, | ||
string | sipUri, | ||
DialOptions | options = null |
||
) |
Connects a SIP platform to an OpenTok session.
For more information, including technical details and security considerations, see the the OpenTok SIP interconnect developer guide.
Also see OpenTok.Dial.
sessionId | The session ID corresponding to the session to which the user will connect. |
token | The token for the session ID with which the SIP user will use to connect. |
sipUri | The SIP URI to be used as destination of the SIP call initiated from OpenTok to your SIP platform. If the SIP URI contains a transport=tls header, the negotiation between OpenTok and the SIP endpoint will be done securely. Note that this will only apply to the negotiation itself, and not to the transmission of audio. If you also audio transmission to be encrypted, set the Secure property of the of the DialOptions object passed into the options parameter to true . This is an example of setting sipUri for a secure call negotiation: "sip:user@sip.partner.com;transport=tls" . This is an example of insecure call negotiation: "sip:user@sip.partner.com" . |
options | Optional parameters for SIP dialing. |
void OpenTokSDK.OpenTok.DisableForceMute | ( | string | sessionId | ) |
Disables the active mute state of the session. After you call this method, new streams published to the session will no longer have audio muted.
After you call the ForceMuteAll method, any streams published after the call are published with audio muted. Call the DisableForceMute()
method automatically muted.
Also see the DisableForceMuteAsync method.
sessionId | The session ID. |
OpenTokArgumentException | Thrown when the session ID is invalid. |
OpenTokWebException | Thrown when an HTTP error has occurred. |
async Task OpenTokSDK.OpenTok.DisableForceMuteAsync | ( | string | sessionId | ) |
Disables the active mute state of the session. After you call this method, new streams published to the session will no longer have audio muted.
After you call the ForceMuteAllAsync method, any streams published after the call are published with audio muted. Call the DisableForceMuteAsync()
method automatically muted.
Also see the DisableForceMutec method.
sessionId | The session ID. |
OpenTokArgumentException | Thrown when the session ID is invalid. |
OpenTokWebException | Thrown when an HTTP error has occurred. |
void OpenTokSDK.OpenTok.ForceDisconnect | ( | string | sessionId, |
string | connectionId | ||
) |
Force a specific client to disconnect from an OpenTok session.
sessionId | The session ID corresponding to the session. |
connectionId | The connectionId of the connection in a session. |
void OpenTokSDK.OpenTok.ForceMuteAll | ( | string | sessionId, |
string [] | excludedStreamIds | ||
) |
Forces all streams (except for an optional list of streams) in a session to mute published audio.
In addition to existing streams, any streams that are published after the call to this method are published with audio muted. You can remove the mute state of a session by calling the DisableForceMute method.
Also see the ForceMuteAllAsync and ForceMuteStream methods.
sessionId | The ID of session. |
excludedStreamIds | The stream IDs of streams that will not be muted. |
OpenTokArgumentException | Thrown when the session ID is invalid. |
OpenTokWebException | Thrown when an HTTP error has occurred. |
async Task OpenTokSDK.OpenTok.ForceMuteAllAsync | ( | string | sessionId, |
string [] | excludedStreamIds | ||
) |
Forces all streams (except for an optional list of streams) in a session to mute published audio.
In addition to existing streams, any streams that are published after the call to this method are published with audio muted. You can remove the mute state of a session by calling the DisableForceMuteAsync method.
Also see the ForceMuteAll and ForceMuteStreamAsync methods.
sessionId | The ID of session. |
excludedStreamIds | The stream IDs of streams that will not be muted. |
OpenTokArgumentException | Thrown when the session ID is invalid. |
OpenTokWebException | Thrown when an HTTP error has occurred. |
void OpenTokSDK.OpenTok.ForceMuteStream | ( | string | sessionId, |
string | streamId | ||
) |
Force the publisher of a specific stream to mute its published audio.
Also see the ForceMuteAll and ForceMuteStreamAsync methods.
sessionId | The session ID of the session that includes the stream. |
streamId | The stream ID. |
OpenTokArgumentException | Thrown when session or stream ID is invalid. |
OpenTokWebException | Thrown when an HTTP error has occurred. |
async Task OpenTokSDK.OpenTok.ForceMuteStreamAsync | ( | string | sessionId, |
string | streamId | ||
) |
Force the publisher of a specific stream to mute its published audio.
Also see the ForceMuteAll and ForceMuteStream methods.
sessionId | The session ID of the session that includes the stream. |
streamId | The stream ID. |
OpenTokArgumentException | Thrown when session or stream ID is invalid. |
OpenTokWebException | Thrown when an HTTP error has occurred. |
string OpenTokSDK.OpenTok.GenerateToken | ( | string | sessionId, |
Role | role = Role.PUBLISHER , |
||
double | expireTime = 0 , |
||
string | data = null , |
||
List< string > | initialLayoutClassList = null |
||
) |
Creates a token for connecting to an OpenTok session. In order to authenticate a user connecting to an OpenTok session, the client passes a token when connecting to the session.
For testing, you can also generate test tokens by logging in to your Vonage Video API account.
sessionId | The session ID corresponding to the session to which the user will connect. |
role | The role for the token. Valid values are defined in the Role enum:
|
expireTime | The expiration time of the token, in seconds since the UNIX epoch. Pass in 0 to use the default expiration time of 24 hours after the token creation time. The maximum expiration time is 30 days after the creation time. |
data | A string containing connection metadata describing the end-user. For example, you can pass the user ID, name, or other data describing the end-user. The length of the string is limited to 1000 characters. This data cannot be updated once it is set. |
initialLayoutClassList | A list of strings values containing the initial layout for the stream. |
Archive OpenTokSDK.OpenTok.GetArchive | ( | string | archiveId | ) |
Broadcast OpenTokSDK.OpenTok.GetBroadcast | ( | string | broadcastId | ) |
Use this method to get a live streaming broadcast object of an OpenTok session.
For more information on broadcasting, see the Broadcast developer guide.
broadcastId | The broadcast ID of the broadcasting session |
Stream OpenTokSDK.OpenTok.GetStream | ( | string | sessionId, |
string | streamId | ||
) |
ArchiveList OpenTokSDK.OpenTok.ListArchives | ( | int | offset = 0 , |
int | count = 0 , |
||
string | sessionId = "" |
||
) |
Returns a List of Archive objects, representing archives that are both both completed and in-progress, for your API key.
offset | The index offset of the first archive. 0 is offset of the most recently started archive. 1 is the offset of the archive that started prior to the most recent archive. |
count | The number of archives to be returned. The maximum number of archives returned is 1000. |
sessionId | The session ID. |
StreamList OpenTokSDK.OpenTok.ListStreams | ( | string | sessionId | ) |
void OpenTokSDK.OpenTok.PlayDTMF | ( | string | sessionId, |
string | digits, | ||
string | connectionId = null |
||
) |
Send DTMF digits to all participants in an active OpenTok session or to a specific client connected to that session.
sessionId | The session ID corresponding to the session that will receive the DTMF string. |
connectionId | The connection connection ID of the client you are sending the DTMF signal to. Leave this empty to send a DTMF signal to all clients connected to the session. |
digits | This is the string of DTMF digits to send. This can include 0-9, '*', '#', and 'p'. A p indicates a pause of 500ms (if you need to add a delay in sending the digits). |
Task OpenTokSDK.OpenTok.PlayDTMFAsync | ( | string | sessionId, |
string | digits, | ||
string | connectionId = null |
||
) |
Send DTMF digits to all participants in an active OpenTok session or to a specific client connected to that session.
sessionId | The session ID corresponding to the session that will receive the DTMF string. |
connectionId | The connection connection ID of the client you are sending the DTMF signal to. Leave this empty to send a DTMF signal to all clients connected to the session. |
digits | This is the string of DTMF digits to send. This can include 0-9, '*', '#', and 'p'. A p indicates a pause of 500ms (if you need to add a delay in sending the digits). |
bool OpenTokSDK.OpenTok.SetArchiveLayout | ( | string | archiveId, |
ArchiveLayout | layout | ||
) |
Allows you to Dynamically change the layout of a composed archive while it's being recorded see Customizing the video layout for composed archives for details regarding customizing a layout.
archiveId | |
layout |
void OpenTokSDK.OpenTok.SetBroadcastLayout | ( | string | broadcastId, |
BroadcastLayout | layout | ||
) |
Sets the layout type for the broadcast. For a description of layout types, see Configuring the video layout for OpenTok live streaming broadcasts.
broadcastId | The broadcast ID of the broadcasting session. |
layout | The BroadcastLayout that defines layout options for the broadcast. |
void OpenTokSDK.OpenTok.SetDefaultRequestTimeout | ( | int | timeout | ) |
Set's the default request timeout (in milliseconds) for all WebRequest's sent by the SDK
timeout |
void OpenTokSDK.OpenTok.SetStreamClassLists | ( | string | sessionId, |
List< StreamProperties > | streams | ||
) |
Sets the layout class list for streams in a session. Layout classes are used in the layout for composed archives and live streaming broadcasts. For more information, see Customizing the video layout for composed archives and Configuring video layout for OpenTok live streaming broadcasts.
You can set the initial layout class list for streams published by a client when you generate used by the client. See the GenerateToken method.
sessionId | The sessionId |
streams | A list of StreamsProperties that defines class lists for one or more streams in the session. |
void OpenTokSDK.OpenTok.Signal | ( | string | sessionId, |
SignalProperties | signalProperties, | ||
string | connectionId = null |
||
) |
Sends a signal to clients (or a specific client) connected to an OpenTok session.
sessionId | The OpenTok sessionId where the signal will be sent. |
signalProperties | This signalProperties defines the payload for the signal. |
connectionId | An optional parameter used to send the signal to a specific connection in a session. |
Archive OpenTokSDK.OpenTok.StartArchive | ( | string | sessionId, |
string | name = "" , |
||
bool | hasVideo = true , |
||
bool | hasAudio = true , |
||
OutputMode | outputMode = OutputMode.COMPOSED , |
||
string | resolution = null , |
||
ArchiveLayout | layout = null |
||
) |
Starts archiving an OpenTok session.
Clients must be actively connected to the OpenTok session for you to successfully start recording an archive.
You can only record one archive at a time for a given session. You can only record archives of sessions that uses the OpenTok Media Router (sessions with the media mode set to routed); you cannot archive sessions with the media mode set to relayed.
Note that you can have the session be automatically archived by setting the archiveMode parameter of the CreateSession method to ArchiveMode.ALWAYS.
sessionId | The session ID of the OpenTok session to archive. |
name | The name of the archive. You can use this name to identify the archive. It is a property of the Archive object, and it is a property of archive-related events in the OpenTok client libraries. |
hasVideo | Whether the archive will record video (true) or not (false). The default value is true (video is recorded). If you set both hasAudio and hasVideo to false, the call to the StartArchive method results in an error. |
hasAudio | Whether the archive will record audio (true) or not (false). The default value is true (audio is recorded). If you set both hasAudio and hasVideo to false, the call to the StartArchive method results in an error. |
outputMode | Whether all streams in the archive are recorded to a single file (OutputMode.COMPOSED, the default) or to individual files (OutputMode.INDIVIDUAL). |
resolution | The resolution for the archive. The default for OutputMode.COMPOSED is "640x480". You cannot specify the resolution for OutputMode.INDIVIDUAL. |
layout | The layout that you want to use for your archive. If type is set to LayoutType.custom you must provide a StyleSheet string to Vonage how to layout your archive. |
Broadcast OpenTokSDK.OpenTok.StartBroadcast | ( | string | sessionId, |
Boolean | hls = true , |
||
List< Rtmp > | rtmpList = null , |
||
string | resolution = null , |
||
int | maxDuration = 7200 , |
||
BroadcastLayout | layout = null |
||
) |
Use this method to start a live streaming for an OpenTok session. This broadcasts the session to an HLS (HTTP live streaming) or to RTMP streams.
To successfully start broadcasting a session, at least one client must be connected to the session.
The live streaming broadcast can target one HLS endpoint and up to five RTMP servers simultaneously for a session. You can only start live streaming for sessions that use the OpenTok Media Router (with the media mode set to routed); you cannot use live streaming with sessions that have the media mode set to relayed OpenTok Media Router. See The OpenTok Media Router and media modes.
For more information on broadcasting, see the Broadcast developer guide.
sessionId | The session ID corresponding to the session. |
hls | Whether to include an HLS broadcast. |
rtmpList | A list of Rtmp objects, defining RTMP streams to be broadcast (up to five). |
resolution | The resolution of the broadcast video. This can be set to either "640x480" or "1280x720". |
maxDuration | The maximum duration for the broadcast, in seconds. The broadcast will automatically stop when the maximum duration is reached. You can set the maximum duration to a value from 60 (60 seconds) to 36000 (10 hours). The default maximum duration is 2 hours (7,200 seconds). |
layout | Specify this BroadcastLayout object to assign the initial layout type for the broadcast. |
Archive OpenTokSDK.OpenTok.StopArchive | ( | string | archiveId | ) |
Stops an OpenTok archive that is being recorded.
Archives automatically stop recording after 120 minutes or when all clients have disconnected from the session being archived.
archiveId | The archive ID of the archive you want to stop recording. |
Broadcast OpenTokSDK.OpenTok.StopBroadcast | ( | string | broadcastId | ) |
Use this method to stop a live broadcast of an OpenTok session. Note that broadcasts automatically stop 120 minutes after they are started.
For more information on broadcasting, see the Broadcast developer guide.
broadcastId | The broadcast ID of the broadcasting session |
|
The OpenTok API key passed into the OpenTok() constructor.
|
The OpenTok API secret passed into the OpenTok() constructor.
|
For internal use
|
Enables writing request/response details to console. Don't use in a production environment.