Class: Twilio::REST::Video::V1::CompositionHookContext

Inherits:
InstanceContext show all
Defined in:
lib/twilio-ruby/rest/video/v1/composition_hook.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ CompositionHookContext

Initialize the CompositionHookContext

Parameters:

  • version (Version)

    Version that contains the resource

  • sid (String)

    The SID of the CompositionHook resource to fetch.


284
285
286
287
288
289
290
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 284

def initialize(version, sid)
  super(version)

  # Path Solution
  @solution = {sid: sid, }
  @uri = "/CompositionHooks/#{@solution[:sid]}"
end

Instance Method Details

#deleteBoolean

Delete the CompositionHookInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise


304
305
306
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 304

def delete
   @version.delete('DELETE', @uri)
end

#fetchCompositionHookInstance

Fetch the CompositionHookInstance

Returns:


295
296
297
298
299
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 295

def fetch
  payload = @version.fetch('GET', @uri)

  CompositionHookInstance.new(@version, payload, sid: @solution[:sid], )
end

#inspectObject

Provide a detailed, user friendly representation


403
404
405
406
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 403

def inspect
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
  "#<Twilio.Video.V1.CompositionHookContext #{context}>"
end

#to_sObject

Provide a user friendly representation


396
397
398
399
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 396

def to_s
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
  "#<Twilio.Video.V1.CompositionHookContext #{context}>"
end

#update(friendly_name: nil, enabled: :unset, video_layout: :unset, audio_sources: :unset, audio_sources_excluded: :unset, trim: :unset, format: :unset, resolution: :unset, status_callback: :unset, status_callback_method: :unset) ⇒ CompositionHookInstance

Update the CompositionHookInstance

Parameters:

  • friendly_name (String) (defaults to: nil)

    A descriptive string that you create to describe the resource. It can be up to 100 characters long and it must be unique within the account.

  • enabled (Boolean) (defaults to: :unset)

    Whether the composition hook is active. When `true`, the composition hook will be triggered for every completed Group Room in the account. When `false`, the composition hook never triggers.

  • video_layout (Hash) (defaults to: :unset)

    A JSON object that describes the video layout of the composition hook in terms of regions. See Specifying Video Layouts for more info.

  • audio_sources (Array[String]) (defaults to: :unset)

    An array of track names from the same group room to merge into the compositions created by the composition hook. Can include zero or more track names. A composition triggered by the composition hook includes all audio sources specified in `audio_sources` except those specified in `audio_sources_excluded`. The track names in this parameter can include an asterisk as a wild card character, which matches zero or more characters in a track name. For example, `student*` includes tracks named `student` as well as `studentTeam`.

  • audio_sources_excluded (Array[String]) (defaults to: :unset)

    An array of track names to exclude. A composition triggered by the composition hook 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 matches zero or more characters in a track name. For example, `student*` excludes `student` as well as `studentTeam`. This parameter can also be empty.

  • trim (Boolean) (defaults to: :unset)

    Whether to clip the intervals where there is no active media in the compositions triggered by the composition hook. 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 for more info.

  • format (composition_hook.Format) (defaults to: :unset)

    The container format of the media files used by the compositions created by the composition hook. Can be: `mp4` or `webm` and the default is `webm`. If `mp4` or `webm`, `audio_sources` must have one or more tracks and/or a `video_layout` element must contain a valid `video_sources` list, otherwise an error occurs.

  • resolution (String) (defaults to: :unset)

    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 `widthxheight` 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 for more info.

  • status_callback (String) (defaults to: :unset)

    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.

  • status_callback_method (String) (defaults to: :unset)

    The HTTP method we should use to call `status_callback`. Can be: `POST` or `GET` and the default is `POST`.

Returns:


375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 375

def update(friendly_name: nil, enabled: :unset, video_layout: :unset, audio_sources: :unset, audio_sources_excluded: :unset, trim: :unset, format: :unset, resolution: :unset, status_callback: :unset, status_callback_method: :unset)
  data = Twilio::Values.of({
      'FriendlyName' => friendly_name,
      'Enabled' => enabled,
      'VideoLayout' => Twilio.serialize_object(video_layout),
      'AudioSources' => Twilio.serialize_list(audio_sources) { |e| e },
      'AudioSourcesExcluded' => Twilio.serialize_list(audio_sources_excluded) { |e| e },
      'Trim' => trim,
      'Format' => format,
      'Resolution' => resolution,
      'StatusCallback' => status_callback,
      'StatusCallbackMethod' => status_callback_method,
  })

  payload = @version.update('POST', @uri, data: data)

  CompositionHookInstance.new(@version, payload, sid: @solution[:sid], )
end