class Twilio::REST::Video::V1::CompositionList
Public Class Methods
Initialize the CompositionList
@param [Version] version Version
that contains the resource @return [CompositionList] CompositionList
Twilio::REST::ListResource::new
# File lib/twilio-ruby/rest/video/v1/composition.rb 18 def initialize(version) 19 super(version) 20 21 # Path Solution 22 @solution = {} 23 @uri = "/Compositions" 24 end
Public Instance Methods
Create the CompositionInstance
@param [String] room_sid The SID of the Group Room with the media tracks to be
used as composition sources.
@param [Hash] video_layout An object that describes the video layout of the
composition in terms of regions. See {Specifying Video Layouts}[https://www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts] for more info. Please, be aware that either video_layout or audio_sources have to be provided to get a valid creation request
@param [Array] audio_sources An array of track names from the same group
room to merge into the new composition. Can include zero or more track names. The new composition includes all audio sources specified in `audio_sources` except for those specified in `audio_sources_excluded`. The track names in this parameter can include an asterisk as a wild card character, which will match zero or more characters in a track name. For example, `student*` includes `student` as well as `studentTeam`. Please, be aware that either video_layout or audio_sources have to be provided to get a valid creation request
@param [Array] audio_sources_excluded An array of track names to
exclude. The new composition includes all audio sources specified in `audio_sources` except for those specified in `audio_sources_excluded`. The track names in this parameter can include an asterisk as a wild card character, which will match zero or more characters in a track name. For example, `student*` excludes `student` as well as `studentTeam`. This parameter can also be empty.
@param [String] resolution A string that describes the columns (width) and rows
(height) of the generated composed video in pixels. Defaults to `640x480`. The string's format is `{width}x{height}` where: * 16 <= `{width}` <= 1280 * 16 <= `{height}` <= 1280 * `{width}` * `{height}` <= 921,600 Typical values are: * HD = `1280x720` * PAL = `1024x576` * VGA = `640x480` * CIF = `320x240` Note that the `resolution` imposes an aspect ratio to the resulting composition. When the original video tracks are constrained by the aspect ratio, they are scaled to fit. See {Specifying Video Layouts}[https://www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts] for more info.
@param [composition.Format] format The container format of the composition's
media files. Can be: `mp4` or `webm` and the default is `webm`. If you specify `mp4` or `webm`, you must also specify one or more `audio_sources` and/or a `video_layout` element that contains a valid `video_sources` list, otherwise an error occurs.
@param [String] status_callback The URL we should call using the
`status_callback_method` to send status information to your application on every composition event. If not provided, status callback events will not be dispatched.
@param [String] status_callback_method The HTTP
method we should use to call
`status_callback`. Can be: `POST` or `GET` and the default is `POST`.
@param [Boolean] trim Whether to clip the intervals where there is no active
media in the composition. The default is `true`. Compositions with `trim` enabled are shorter when the Room is created and no Participant joins for a while as well as if all the Participants leave the room and join later, because those gaps will be removed. See {Specifying Video Layouts}[https://www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts] for more info.
@return [CompositionInstance] Created CompositionInstance
# File lib/twilio-ruby/rest/video/v1/composition.rb 210 def create(room_sid: nil, video_layout: :unset, audio_sources: :unset, audio_sources_excluded: :unset, resolution: :unset, format: :unset, status_callback: :unset, status_callback_method: :unset, trim: :unset) 211 data = Twilio::Values.of({ 212 'RoomSid' => room_sid, 213 'VideoLayout' => Twilio.serialize_object(video_layout), 214 'AudioSources' => Twilio.serialize_list(audio_sources) { |e| e }, 215 'AudioSourcesExcluded' => Twilio.serialize_list(audio_sources_excluded) { |e| e }, 216 'Resolution' => resolution, 217 'Format' => format, 218 'StatusCallback' => status_callback, 219 'StatusCallbackMethod' => status_callback_method, 220 'Trim' => trim, 221 }) 222 223 payload = @version.create('POST', @uri, data: data) 224 225 CompositionInstance.new(@version, payload, ) 226 end
When passed a block, yields CompositionInstance
records from the API. This operation lazily loads records as efficiently as possible until the limit is reached.
# File lib/twilio-ruby/rest/video/v1/composition.rb 93 def each 94 limits = @version.read_limits 95 96 page = self.page(page_size: limits[:page_size], ) 97 98 @version.stream(page, 99 limit: limits[:limit], 100 page_limit: limits[:page_limit]).each {|x| yield x} 101 end
Retrieve a single page of CompositionInstance
records from the API. Request
is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page
of CompositionInstance
# File lib/twilio-ruby/rest/video/v1/composition.rb 139 def get_page(target_url) 140 response = @version.domain.request( 141 'GET', 142 target_url 143 ) 144 CompositionPage.new(@version, response, @solution) 145 end
Lists CompositionInstance
records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [composition.Status] status Read only Composition resources with this
status. Can be: `enqueued`, `processing`, `completed`, `deleted`, or `failed`.
@param [Time] date_created_after Read only Composition resources created on or
after this {ISO 8601}[https://en.wikipedia.org/wiki/ISO_8601] date-time with time zone.
@param [Time] date_created_before Read only Composition resources created before
this ISO 8601 date-time with time zone.
@param [String] room_sid Read only Composition resources with this Room SID. @param [Integer] limit Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
@param [Integer] page_size Number of records to fetch per request, when
not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000)
@return [Array] Array of up to limit results
# File lib/twilio-ruby/rest/video/v1/composition.rb 45 def list(status: :unset, date_created_after: :unset, date_created_before: :unset, room_sid: :unset, limit: nil, page_size: nil) 46 self.stream( 47 status: status, 48 date_created_after: date_created_after, 49 date_created_before: date_created_before, 50 room_sid: room_sid, 51 limit: limit, 52 page_size: page_size 53 ).entries 54 end
Retrieve a single page of CompositionInstance
records from the API. Request
is executed immediately. @param [composition.Status] status Read only Composition resources with this
status. Can be: `enqueued`, `processing`, `completed`, `deleted`, or `failed`.
@param [Time] date_created_after Read only Composition resources created on or
after this {ISO 8601}[https://en.wikipedia.org/wiki/ISO_8601] date-time with time zone.
@param [Time] date_created_before Read only Composition resources created before
this ISO 8601 date-time with time zone.
@param [String] room_sid Read only Composition resources with this Room SID. @param [String] page_token PageToken provided by the API @param [Integer] page_number Page
Number, this value is simply for client state @param [Integer] page_size Number of records to return, defaults to 50 @return [Page] Page
of CompositionInstance
# File lib/twilio-ruby/rest/video/v1/composition.rb 118 def page(status: :unset, date_created_after: :unset, date_created_before: :unset, room_sid: :unset, page_token: :unset, page_number: :unset, page_size: :unset) 119 params = Twilio::Values.of({ 120 'Status' => status, 121 'DateCreatedAfter' => Twilio.serialize_iso8601_datetime(date_created_after), 122 'DateCreatedBefore' => Twilio.serialize_iso8601_datetime(date_created_before), 123 'RoomSid' => room_sid, 124 'PageToken' => page_token, 125 'Page' => page_number, 126 'PageSize' => page_size, 127 }) 128 129 response = @version.page('GET', @uri, params: params) 130 131 CompositionPage.new(@version, response, @solution) 132 end
Streams CompositionInstance
records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [composition.Status] status Read only Composition resources with this
status. Can be: `enqueued`, `processing`, `completed`, `deleted`, or `failed`.
@param [Time] date_created_after Read only Composition resources created on or
after this {ISO 8601}[https://en.wikipedia.org/wiki/ISO_8601] date-time with time zone.
@param [Time] date_created_before Read only Composition resources created before
this ISO 8601 date-time with time zone.
@param [String] room_sid Read only Composition resources with this Room SID. @param [Integer] limit Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit.
@param [Integer] page_size Number of records to fetch per request, when
not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000)
@return [Enumerable] Enumerable that will yield up to limit results
# File lib/twilio-ruby/rest/video/v1/composition.rb 75 def stream(status: :unset, date_created_after: :unset, date_created_before: :unset, room_sid: :unset, limit: nil, page_size: nil) 76 limits = @version.read_limits(limit, page_size) 77 78 page = self.page( 79 status: status, 80 date_created_after: date_created_after, 81 date_created_before: date_created_before, 82 room_sid: room_sid, 83 page_size: limits[:page_size], 84 ) 85 86 @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) 87 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/video/v1/composition.rb 230 def to_s 231 '#<Twilio.Video.V1.CompositionList>' 232 end