Class: OpenTok::Renders

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

Overview

A class for working with OpenTok Experience Composer renders. See / Experience Composer.

Instance Method Summary collapse

Instance Method Details

#find(render_id) ⇒ Render

Gets a Render object for the given render ID.

Parameters:

  • render_id (String)

    (Required) The render ID.

Returns:

  • (Render)

    The render object, which includes properties defining the render.

Raises:



79
80
81
82
83
84
# File 'lib/opentok/renders.rb', line 79

def find(render_id)
  raise ArgumentError, "render_id not provided" if render_id.to_s.empty?

  render_json = @client.get_render(render_id.to_s)
  Render.new self, render_json
end

#list(options = {}) ⇒ RenderList

Returns a RenderList, which is an array of Experience Composers renders that are associated with a project.

Parameters:

  • options (Hash) (defaults to: {})

    A hash with keys defining which range of renders to retrieve.

Options Hash (options):

  • :offset (integer) — default: Optional

    . The start offset for the list of Experience Composer renders. The default is 0.

  • :count (integer)

    Optional. The number of Experience Composer renders to retrieve starting at the offset. The default value is 50 and the maximum is 1000.

Returns:

  • (RenderList)

    An RenderList object, which is an array of Render objects.

Raises:

  • (ArgumentError)


94
95
96
97
98
99
# File 'lib/opentok/renders.rb', line 94

def list(options = {})
  raise ArgumentError, "Limit is invalid" unless options[:count].nil? || (0..1000).include?(options[:count])

  render_list_json = @client.list_renders(options[:offset], options[:count])
  RenderList.new self, render_list_json
end

#start(session_id, options = {}) ⇒ Render

Starts an Experience Composer render for an OpenTok session.

Parameters:

  • session_id (String)

    (Required) The session ID of the OpenTok session that will include the Experience Composer stream.

  • options (Hash) (defaults to: {})

    (Required) A hash defining options for the render.

Options Hash (options):

  • :token (String) — default: Required

    A valid OpenTok token with a Publisher role and (optionally) connection data to be associated with the output stream.

  • :url (String) — default: Required

    A publicly reachable URL controlled by the customer and capable of generating the content to be rendered without user intervention. The minimum length of the URL is 15 characters and the maximum length is 2048 characters.

  • :max_duration (Integer) — default: Optional

    The maximum time allowed for the Experience Composer, in seconds. After this time, it is stopped automatically, if it is still running. The maximum value is 36000 (10 hours), the minimum value is 60 (1 minute), and the default value is 7200 (2 hours). When the Experience Composer ends, its stream is unpublished and an event is posted to the callback URL, if configured in the Account Portal.

  • :resolution (String)

    The resolution of the Experience Composer, either “640x480” (SD landscape), “480x640” (SD portrait), “1280x720” (HD landscape), “720x1280” (HD portrait), “1920x1080” (FHD landscape), or “1080x1920” (FHD portrait). By default, this resolution is “1280x720” (HD landscape, the default).

  • :properties (Hash) — default: Optional

    The initial configuration of Publisher properties for the composed output stream. The properties object contains the key :name (String) which serves as the name of the composed output stream which is published to the session. The name must have a minimum length of 1 and a maximum length of 200.

Returns:

  • (Render)

    The render object, which includes properties defining the render, including the render ID.

Raises:



42
43
44
45
46
47
48
49
50
# File 'lib/opentok/renders.rb', line 42

def start(session_id, options = {})
  raise ArgumentError, "session_id not provided" if session_id.to_s.empty?
  raise ArgumentError, "options cannot be empty" if options.empty?
  raise ArgumentError, "token property is required in options" unless options.has_key?(:token)
  raise ArgumentError, "url property is required in options" unless options.has_key?(:url)

  render_json = @client.start_render(session_id, options)
  Render.new self, render_json
end

#stop(render_id) ⇒ Render

Stops an OpenTok Experience Composer render.

Parameters:

  • render_id (String)

    (Required) The render ID.

Returns:

  • (Render)

    The render object, which includes properties defining the render.

Raises:



62
63
64
65
66
67
# File 'lib/opentok/renders.rb', line 62

def stop(render_id)
  raise ArgumentError, "render_id not provided" if render_id.to_s.empty?

  render_json = @client.stop_render(render_id)
  Render.new self, render_json
end