Class: OpenTok::Archive
- Inherits:
-
Object
- Object
- OpenTok::Archive
- Defined in:
- lib/opentok/archive.rb
Overview
Represents an archive of an OpenTok session.
"1920x1080" (FHD landscape), "480x640" (SD portrait), "720x1280" (HD portrait), or "1080x1920" (FHD portrait).
You may want to use a portrait aspect ratio for archives that include video streams from mobile devices (which often use the portrait aspect ratio).
This property is only set for composed archives.
Instance Attribute Summary collapse
-
#created_at ⇒ int
The time at which the archive was created, in milliseconds since the UNIX epoch.
-
#duration ⇒ string
The duration of the archive, in seconds.
-
#has_audio ⇒ true, false
Whether the archive has an audio track (true) or not (false).
-
#has_video ⇒ true, false
Whether the archive has a video track (true) or not (false).
-
#id ⇒ string
The archive ID.
-
#multi_archive_tag ⇒ Object
readonly
Returns the value of attribute multi_archive_tag.
-
#name ⇒ string
The name of the archive.
-
#output_mode ⇒ String
Whether all streams in the archive are recorded to a single file (
:composed
) or to individual files (:individual
). -
#projectId ⇒ string
The API key associated with the archive.
-
#reason ⇒ string
For archives with the status “stopped” or “failed”, this string describes the reason the archive stopped (such as “maximum duration exceeded”) or failed.
-
#resolution ⇒ string
The resolution of the archive, either “640x480” (SD landscape, the default), “1280x720” (HD landscape),.
-
#session_id ⇒ string
The session ID of the OpenTok session associated with this archive.
-
#size ⇒ float
The size of the MP4 file.
-
#status ⇒ string
The status of the archive, which can be one of the following:.
-
#stream_mode ⇒ Object
readonly
Returns the value of attribute stream_mode.
-
#streamMode ⇒ string
Whether streams included in the archive are selected automatically (“auto”, the default) or manually (“manual”).
-
#url ⇒ string
The download URL of the available MP4 file.
Instance Method Summary collapse
-
#add_stream(stream_id, opts = {}) ⇒ Object
Adds a stream to currently running composed archive that was started with the streamMode set to “manual”.
-
#delete ⇒ Object
Deletes an OpenTok archive.
-
#layout(opts = {}) ⇒ Object
Sets the layout type for a composed archive.
-
#remove_stream(stream_id) ⇒ Object
Removes a stream to currently running composed archive that was started with the streamMode set to “manual”.
-
#stop ⇒ Object
Stops an OpenTok archive that is being recorded.
-
#to_json ⇒ Object
A JSON-encoded string representation of the archive.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
191 192 193 194 195 196 197 198 199 200 201 202 203 |
# File 'lib/opentok/archive.rb', line 191 def method_missing(method, *args, &block) camelized_method = method.to_s.camelize(:lower) if @json.has_key? camelized_method and args.empty? # TODO: convert create_time method call to a Time object if camelized_method == 'outputMode' @json[camelized_method].to_sym else @json[camelized_method] end else super method, *args, &block end end |
Instance Attribute Details
#created_at ⇒ int
The time at which the archive was created, in milliseconds since the UNIX epoch.
74 75 76 |
# File 'lib/opentok/archive.rb', line 74 def created_at @created_at end |
#duration ⇒ string
The duration of the archive, in seconds.
74 75 76 |
# File 'lib/opentok/archive.rb', line 74 def duration @duration end |
#has_audio ⇒ true, false
Whether the archive has an audio track (true) or not (false).
74 75 76 |
# File 'lib/opentok/archive.rb', line 74 def has_audio @has_audio end |
#has_video ⇒ true, false
Whether the archive has a video track (true) or not (false).
74 75 76 |
# File 'lib/opentok/archive.rb', line 74 def has_video @has_video end |
#id ⇒ string
The archive ID.
74 75 76 |
# File 'lib/opentok/archive.rb', line 74 def id @id end |
#multi_archive_tag ⇒ Object (readonly)
Returns the value of attribute multi_archive_tag.
75 76 77 |
# File 'lib/opentok/archive.rb', line 75 def multi_archive_tag @multi_archive_tag end |
#name ⇒ string
The name of the archive. If no name was provided when the archive was created, this is set to null.
74 75 76 |
# File 'lib/opentok/archive.rb', line 74 def name @name end |
#output_mode ⇒ String
Whether all streams in the archive are recorded to a single file (:composed
) or to individual files (:individual
).
74 75 76 |
# File 'lib/opentok/archive.rb', line 74 def output_mode @output_mode end |
#projectId ⇒ string
The API key associated with the archive.
74 75 76 |
# File 'lib/opentok/archive.rb', line 74 def projectId @projectId end |
#reason ⇒ string
For archives with the status “stopped” or “failed”, this string describes the reason the archive stopped (such as “maximum duration exceeded”) or failed.
74 75 76 |
# File 'lib/opentok/archive.rb', line 74 def reason @reason end |
#resolution ⇒ string
The resolution of the archive, either “640x480” (SD landscape, the default), “1280x720” (HD landscape),
74 75 76 |
# File 'lib/opentok/archive.rb', line 74 def resolution @resolution end |
#session_id ⇒ string
The session ID of the OpenTok session associated with this archive.
74 75 76 |
# File 'lib/opentok/archive.rb', line 74 def session_id @session_id end |
#size ⇒ float
The size of the MP4 file. For archives that have not been generated, this value is set to 0.
74 75 76 |
# File 'lib/opentok/archive.rb', line 74 def size @size end |
#status ⇒ string
The status of the archive, which can be one of the following:
-
“available” – The archive is available for download from the OpenTok cloud.
-
“expired” – The archive is no longer available for download from the OpenTok cloud.
-
“failed” – The archive recording failed.
-
“paused” – The archive is in progress and no clients are publishing streams to the session. When an archive is in progress and any client publishes a stream, the status is “started”. When an archive is paused, nothing is recorded. When a client starts publishing a stream, the recording starts (or resumes). If all clients disconnect from a session that is being archived, the status changes to “paused”, and after 60 seconds the archive recording stops (and the status changes to “stopped”).
-
“started” – The archive started and is in the process of being recorded.
-
“stopped” – The archive stopped recording.
-
“uploaded” – The archive is available for download from the the upload target Amazon S3 bucket or Windows Azure container you set for your OpenTok project.
74 75 76 |
# File 'lib/opentok/archive.rb', line 74 def status @status end |
#stream_mode ⇒ Object (readonly)
Returns the value of attribute stream_mode.
75 76 77 |
# File 'lib/opentok/archive.rb', line 75 def stream_mode @stream_mode end |
#streamMode ⇒ string
Whether streams included in the archive are selected automatically (“auto”, the default) or manually (“manual”).
74 75 76 |
# File 'lib/opentok/archive.rb', line 74 def streamMode @streamMode end |
#url ⇒ string
The download URL of the available MP4 file. This is only set for an archive with the status set to “available”; for other archives, (including archives with the status “uploaded”) this property is set to null. The download URL is obfuscated, and the file is only available from the URL for 10 minutes. To generate a new URL, call the Archive.listArchives() or OpenTok.getArchive() method.
74 75 76 |
# File 'lib/opentok/archive.rb', line 74 def url @url end |
Instance Method Details
#add_stream(stream_id, opts = {}) ⇒ 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.
171 172 173 174 |
# File 'lib/opentok/archive.rb', line 171 def add_stream(stream_id, opts = {}) raise OpenTokArchiveError, "stream_mode must be manual in order to add a stream" unless @json['streamMode'] == 'manual' @interface.add_stream(@json['id'], stream_id, opts) end |
#delete ⇒ Object
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.
104 105 106 107 |
# File 'lib/opentok/archive.rb', line 104 def delete # TODO: validate returned json fits schema @json = @interface.delete_by_id @json['id'] end |
#layout(opts = {}) ⇒ Object
Sets the layout type for a composed archive. For a description of layout types, see Customizing the video layout for composed archives.
145 146 147 148 |
# File 'lib/opentok/archive.rb', line 145 def layout(opts= {}) # TODO: validate returned json fits schema @json = @interface.layout(@json['id'], opts) end |
#remove_stream(stream_id) ⇒ Object
Removes 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.
185 186 187 188 |
# File 'lib/opentok/archive.rb', line 185 def remove_stream(stream_id) raise OpenTokArchiveError, "stream_mode must be manual in order to remove a stream" unless @json['streamMode'] == 'manual' @interface.remove_stream(@json['id'], stream_id) end |
#stop ⇒ Object
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.
94 95 96 97 |
# File 'lib/opentok/archive.rb', line 94 def stop # TODO: validate returned json fits schema @json = @interface.stop_by_id @json['id'] end |
#to_json ⇒ Object
A JSON-encoded string representation of the archive.
86 87 88 |
# File 'lib/opentok/archive.rb', line 86 def to_json @json.to_json end |