Suggestions

close search

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

Visit the Vonage API Developer Portal

Class: OpenTok::Archives

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

Overview

A class for working with OpenTok archives.

Instance Method Summary

Instance Method Details

#add_stream(archive_id, stream_id, options) ⇒ Object

Adds a stream to currently running composed archive that was started with the streamMode set to “manual”. For a description of the feature, see https://tokbox.com/developer/rest/#selecting-archive-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 archive. If you set both has_audio and has_video to false, you will get error response.

Parameters:

  • archive_id (String)

    The archive ID.

  • stream_id (String)

    The ID for the stream to be added to the archive

  • opts (Hash)

    a customizable set of options

Raises:

  • (ArgumentError)

    The archive_id parameter is empty.

  • (ArgumentError)

    The stream_id parameter is empty.

  • (ArgumentError)

    The has_audio and has_video properties of the options parameter are both set to “false”

#all(options = {}) ⇒ ArchiveList

Returns an ArchiveList, which is an array of archives that are completed and in-progress, for your API key.

Parameters:

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

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

Options Hash (options):

  • :offset (integer)

    Optional. 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. If you do not specify an offset, 0 is used.

  • :count (integer)

    Optional. The number of archives to be returned. The maximum number of archives returned is 1000.

  • :session_id (String)

    Optional. The session ID that archives belong to. This is useful when listing multiple archives for an automatically archived session.

Returns:

  • (ArchiveList)

    An ArchiveList object, which is an array of Archive objects.

Raises:

  • (ArgumentError)

#create(session_id, options = {}) ⇒ Archive

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 use the OpenTok Media Router (sessions with the media mode set to routed); you cannot archive sessions with the media mode set to relayed.

For more information on archiving, see the OpenTok archiving programming guide.

Parameters:

  • session_id (String)

    The session ID of the OpenTok session to archive.

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

    A hash with the keys 'name', 'has_audio', 'has_video', and 'output_mode'.

Options Hash (options):

  • :name (String)

    This is 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 SDKs.

  • :has_audio (true, false)

    Whether the archive will include an audio track (true) or not false). The default value is true (an audio track is included). If you set both has_audio and has_video to false, the call to the create() method results in an error.

  • :has_video (true, false)

    Whether the archive will include a video track (true) or not false). The default value is true (a video track is included). If you set both has_audio and has_video to false, the call to the create() method results in an error.

  • :multiArchiveTag (String) — default: Optional

    Set this to support recording multiple archives for the same session simultaneously. Set this to a unique string for each simultaneous archive of an ongoing session. You must also set this option when manually starting an archive that is automatically archived. Note that the `multiArchiveTag` value is not included in the response for the methods to list archives and retrieve archive information. If you do not specify a unique `multiArchiveTag`, you can only record one archive at a time for a given session. See Simultaneous archives.

  • :output_mode (String)

    Whether all streams in the archive are recorded to a single file (:composed, the default) or to individual files (:individual). For more information on archiving and the archive file formats, see the OpenTok archiving programming guide.

  • :resolution (String)

    The resolution of the archive, either “640x480” (SD landscape, the default), “1280x720” (HD landscape), “1920x1080” (FHD landscape), “480x640” (SD portrait), “720x1280” (HD portrait), or “1080x1920” (FHD portrait). This property only applies to composed archives. If you set this property and set the outputMode property to “individual”, a call to the method results in an error.

  • :streamMode (String) — default: Optional

    Whether streams included in the archive are selected automatically (“auto”, the default) or manually (“manual”). When streams are selected automatically (“auto”), all streams in the session can be included in the archive. When streams are selected manually (“manual”), you specify streams to be included based on calls to the #add_stream method. You can specify whether a stream's audio, video, or both are included in the archive. In composed archives, in both automatic and manual modes, the archive composer includes streams based on stream prioritization rules. Important: this feature is currently available in the Standard environment only.

  • :layout (Hash)

    Specify this to assign the initial layout type for the archive. This applies only to composed archives. This is a hash containing three keys: :type, :stylesheet<code> and <code>:screenshare_type. Valid values for :type are “bestFit” (best fit), “custom” (custom),

    "horizontalPresentation" (horizontal presentation),
    

    “pip” (picture-in-picture), and “verticalPresentation” (vertical presentation)). If you specify a “custom” layout type, set the :stylesheet key to the stylesheet (CSS). (For other layout types, do not set the :stylesheet key.) Valid values for :screenshare_type are “bestFit”, “pip”, “verticalPresentation”, “horizontalPresentation”. This property is optional. If it is specified, then the :type property *must* be set to “bestFit”. If you do not specify an initial layout type, the archive uses the best fit layout type. For more information, see Customizing the video layout for composed archives.

Returns:

  • (Archive)

    The Archive object, which includes properties defining the archive, including the archive ID.

Raises:

  • (OpenTokArchiveError)

    The archive could not be started. The request was invalid or the session has no connected clients.

  • (OpenTokAuthenticationError)

    Authentication failed while starting an archive. Invalid API key.

  • (OpenTokArchiveError)

    The archive could not be started. The session ID does not exist.

  • (OpenTokArchiveError)

    The archive could not be started. The session could be peer-to-peer or the session is already being recorded.

  • (OpenTokArchiveError)

    The archive could not be started.

#delete_by_id(archive_id) ⇒ Object

Deletes an OpenTok archive.

You can only delete an archive which has a status of “available”, “uploaded”, or “deleted”. 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. For a “deleted” archive, the archive remains deleted.

Parameters:

  • archive_id (String)

    The archive ID of the archive you want to delete.

Raises:

#find(archive_id) ⇒ Archive

Gets an Archive object for the given archive ID.

Parameters:

  • archive_id (String)

    The archive ID.

Returns:

  • (Archive)

    The Archive object.

Raises:

#layout(archive_id, options = {}) ⇒ Object

Sets the layout type for a composed archive. For a description of layout types, see Customizing the video layout for composed archives.

Parameters:

  • archive_id (String)

    The archive ID.

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

    a customizable set of options

Options Hash (options):

  • :type (String)

    The layout type. Set this to “bestFit”, “pip”, “verticalPresentation”, “horizontalPresentation”, “focus”, or “custom”.

  • :stylesheet (String)

    The stylesheet for a custom layout. Set this parameter if you set type to "custom". Otherwise, leave it undefined.

  • :screenshare_type (String)

    The screenshare layout type. Set this to “bestFit”, “pip”, “verticalPresentation” or “horizonalPresentation”. If this is defined, then the type parameter must be set to "bestFit".

Raises:

  • (ArgumentError)

    The archive_id or options parameter is empty. Or the “custom” type was specified without a stylesheet option. Or a stylesheet was passed in for a type other than custom. Or an invalid type was passed in.

  • (OpenTokAuthenticationError)

    Authentication failed.

  • (ArgumentError)

    The archive_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.

  • (OpenTokError)

    OpenTok server error.

  • (OpenTokArchiveError)

    Setting the layout failed.

#remove_stream(archive_id, stream_id) ⇒ Object

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

Parameters:

  • archive_id (String)

    The archive ID.

  • stream_id (String)

    The ID for the stream to be removed from the archive

Raises:

  • (ArgumentError)

    The archive_id parameter id is empty.

  • (ArgumentError)

    The stream_id parameter is empty.

#stop_by_id(archive_id) ⇒ Archive

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.

Parameters:

  • archive_id (String)

    The archive ID of the archive you want to stop recording.

Returns:

  • (Archive)

    The Archive object corresponding to the archive being stopped.

Raises: