Class: OpenTok::Sip

Inherits:
Object
  • Object
show all
Defined in:
lib/opentok/sip.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Sip

Returns a new instance of Sip.



76
77
78
# File 'lib/opentok/sip.rb', line 76

def initialize(client)
  @client = client
end

Instance Method Details

#dial(session_id, token, sip_uri, opts) ⇒ Object

Dials a SIP gateway to input an audio-only stream into your OpenTok session. See the / OpenTok SIP developer guide.

Examples:

opts = { "from" => "[email protected]",
  "auth" => { "username" => sip_username,
    "password" => sip_password },
  "headers" => { "X-KEY1" => "value1",
    "X-KEY1" => "value2" },
  "secure" => "true",
  "video" => "true",
  "observe_force_mute" => "true"
}
response = opentok.sip.dial(session_id, token, "sip:[email protected];transport=tls", opts)

Parameters:

  • session_id (String)

    The session ID corresponding to the session to which the SIP gateway will connect.

  • token (String)

    The token for the session ID with which the SIP user will use to connect.

  • sip_uri (String)

    The SIP URI the OpenTok SIP gateway will dial.

  • opts (Hash)

    A hash defining options for the SIP call. For example:

Options Hash (opts):

  • :from (String)

    The number or string that will be sent to the final SIP number as the caller. It must be a string in the form of “[email protected]”, where from can be a string or a number. If from is set to a number (for example, “[email protected]”), it will show up as the incoming number on PSTN phones. If from is undefined or set to a string (for example, “[email protected]”), +00000000 will show up as the incoming number on PSTN phones.

  • :headers (Hash)

    This hash defines custom headers to be added to the SIP ​INVITE​ request initiated from OpenTok to the your SIP platform.

  • :auth (Hash)

    This object contains the username and password to be used in the the SIP INVITE​ request for HTTP digest authentication, if it is required by your SIP platform.

  • :secure (true, false)

    Whether the media must be transmitted encrypted (​true​) or not (​false​, the default).

  • :video (true, false)

    Whether the SIP call will include video (​true​) or not (​false​, the default). With video included, the SIP client’s video is included in the OpenTok stream that is sent to the OpenTok session. The SIP client will receive a single composed video of the published streams in the OpenTok session.

  • :observe_force_mute (true, false)

    Whether the SIP end point observes force mute moderation (true) or not (false, the default).

  • :streams (Array)

    An array of stream IDs for streams to include in the SIP call. If you do not set this property, all streams in the session are included in the call.



50
51
52
# File 'lib/opentok/sip.rb', line 50

def dial(session_id, token, sip_uri, opts)
  response = @client.dial(session_id, token, sip_uri, opts)
end

#play_dtmf_to_connection(session_id, connection_id, dtmf_digits) ⇒ Object

Sends DTMF digits to a specific client connected to an OpnTok session.

the DTMF signal is being sent to. A p indicates a pause of 500ms (if you need to add a delay in sending the digits).

Parameters:

  • session_id (String)

    The session ID.

  • connection_id (String)

    The connection ID of the specific connection that

  • dtmf_digits (String)

    The DTMF digits to send. This can include 0-9, “*”, “#”, and “p”.

Raises:

  • (ArgumentError)


61
62
63
64
# File 'lib/opentok/sip.rb', line 61

def play_dtmf_to_connection(session_id, connection_id, dtmf_digits)
  raise ArgumentError, "invalid DTMF digits" unless dtmf_digits_valid?(dtmf_digits)
  response = @client.play_dtmf_to_connection(session_id, connection_id, dtmf_digits)
end

#play_dtmf_to_session(session_id, dtmf_digits) ⇒ Object

Sends DTMF digits to all clients connected to an OpnTok session.

A p indicates a pause of 500ms (if you need to add a delay in sending the digits).

Parameters:

  • session_id (String)

    The session ID.

  • dtmf_digits (String)

    The DTMF digits to send. This can include 0-9, “*”, “#”, and “p”.

Raises:

  • (ArgumentError)


71
72
73
74
# File 'lib/opentok/sip.rb', line 71

def play_dtmf_to_session(session_id, dtmf_digits)
  raise ArgumentError, "invalid DTMF digits" unless dtmf_digits_valid?(dtmf_digits)
  response = @client.play_dtmf_to_session(session_id, dtmf_digits)
end