Suggestions

close search

Add Messaging, Voice, and Authentication to your apps with Vonage Communications APIs

Visit the Vonage API Developer Portal

Class: OpenTok::Broadcast

Inherits:
Object
Defined in:
lib/opentok/broadcast.rb

Overview

Represents a live streaming broadcast of an OpenTok session. See / Live streaming broadcasts.

Instance Attribute Summary

Instance Method Summary

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object

Instance Attribute Details

#broadcastUrlsHash

is defined as follows: This object defines the types of broadcast streams you want to start (both HLS and RTMP). You can include HLS, RTMP, or both as broadcast streams. If you include RTMP streaming, you can specify up to five target RTMP streams (or just one). The (:hls) property is set to an empty [Hash] object. The HLS URL is returned in the response. The (:rtmp) property is set to an [Array] of Rtmp [Hash] properties. For each RTMP stream, specify (:serverUrl) for the RTMP server URL, (:streamName) such as the YouTube Live stream name or the Facebook stream key), and (optionally) (:id), a unique ID for the stream.

Returns:

  • (Hash)

    the current value of broadcastUrls

#created_atint

The time at which the broadcast was created, in milliseconds since the UNIX epoch.

Returns:

  • (int)

    the current value of created_at

#idstring

The broadcast ID.

Returns:

  • (string)

    the current value of id

#multi_broadcast_tagObject (readonly)

Returns the value of attribute multi_broadcast_tag.

#project_idstring

The API key associated with the broadcast.

Returns:

  • (string)

    the current value of project_id

#resolutionstring

The resolution of the broadcast: either “640x480” (SD landscape, the default), “1280x720” (HD landscape), “1920x1080” (FHD landscape), “480x640” (SD portrait), “720x1280” (HD portrait), or “1080x1920” (FHD portrait). You may want to use a portrait aspect ratio for broadcasts that include video streams from mobile devices (which often use the portrait aspect ratio). This property is optional.

Returns:

  • (string)

    the current value of resolution

#session_idstring

The session ID of the OpenTok session associated with this broadcast.

Returns:

  • (string)

    the current value of session_id

#statusstring

The status of the RTMP stream.

  • “connecting” – The OpenTok platform is in the process of connecting to the remote RTMP server.

    This is the initial state, and it is the status if you start when there are no streams published in the session.
    It changes to "live" when there are streams (or it changes to one of the other states).
    
  • “live – The OpenTok platform has successfully connected to the remote RTMP server, and the media is streaming.

  • “offline” – The OpenTok platform could not connect to the remote RTMP server. This is due to an unreachable server or an error in the RTMP handshake. Causes include rejected RTMP connections, non-existing RTMP applications, rejected stream names, authentication errors, etc. Check that the server is online, and that you have provided the correct server URL and stream name.

  • “error” – There is an error in the OpenTok platform.

Returns:

  • (string)

    the current value of status

#streamModestring

Whether streams included in the broadcast are selected automatically (“auto”, the default) or manually (“manual”).

Returns:

  • (string)

    the current value of streamMode

#updated_atint

For this start method, this timestamp matches the createdAt timestamp.

Returns:

  • (int)

    the current value of updated_at

Instance Method Details

#add_stream(stream_id, opts = {}) ⇒ Object

Adds a stream to currently running broadcast that was started with the streamMode set to “manual”. For a description of the feature, see https://tokbox.com/developer/rest/#selecting-broadcast-streams.

You can call the method repeatedly with add_stream set to the same stream ID, to toggle the stream's audio or video in the broadcast. If you set both has_audio and has_video to false, you will get error response.

Parameters:

  • stream_id (String)

    The ID for the stream to be added to the broadcast

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

    a customizable set of options

Options Hash (opts):

  • :has_audio (true, false) — default: Boolean, optional

    — Whether the broadcast should include the stream's audio (true, the default) or not (false).

  • :has_video (true, false) — default: Boolean, optional

    — Whether the broadcast should include the stream's video (true, the default) or not (false).

Raises:

#layout(opts = {}) ⇒ Object

Sets the layout of the OpenTok broadcast.

You can dynamically change the layout type of a broadcast while it is being broadcast. For more information, see Configuring video layout for OpenTok live streaming broadcasts.

Refer to https://tokbox.com/developer/rest/#change_composed_archive_layout

Parameters:

  • options (Hash)

    a customizable set of options

Raises:

  • (OpenTokBroadcastError)

    The broadcast layout could not be updated.

  • (OpenTokAuthenticationError)

    Authentication failed. Invalid API key or secret.

  • (OpenTokError)

    OpenTok server error.

  • (ArgumentError)

    The broadcast_id or options parameter is empty.

  • (ArgumentError)

    The “custom” type was specified without a stylesheet option.

  • (ArgumentError)

    A stylesheet was passed in for a type other than custom. Or an invalid type was passed in.

  • (ArgumentError)

    An invalid layout type was passed in.

#remove_stream(stream_id) ⇒ Object

Removes a stream to currently running broadcast that was started with the streamMode set to “manual”. For a description of the feature, see https://tokbox.com/developer/rest/#selecting-broadcast-streams.

Parameters:

  • stream_id (String)

    The ID for the stream to be removed from the broadcast

Raises:

#stopObject

Stops the OpenTok broadcast.

#to_jsonObject

A JSON-encoded string representation of the broadcast.