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

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

Overview

PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact [email protected].

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ CompositionHookContext

Initialize the CompositionHookContext

Parameters:

  • version (Version)

    Version that contains the resource

  • sid (String)

    The Composition Hook Sid that uniquely identifies the Composition Hook to fetch.



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

def initialize(version, sid)
  super(version)

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

Instance Method Details

#deleteBoolean

Deletes the CompositionHookInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



320
321
322
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 320

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

#fetchCompositionHookInstance

Fetch a CompositionHookInstance

Returns:



305
306
307
308
309
310
311
312
313
314
315
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 305

def fetch
  params = Twilio::Values.of({})

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

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

#inspectObject

Provide a detailed, user friendly representation



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

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

#to_sObject

Provide a user friendly representation



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

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)

    Friendly name of the Composition Hook to be shown in the console, must be unique per account and up to 100 characters.

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

    Boolean flag indicating if the Composition Hook is active. Possible values are ‘true` or `false`. When `true`, the Composition Hook will be triggered for every completed Group Room on this account. When `false`, the Composition Hook never triggers.

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

    A JSON object defining the video layout of the Composition Hook in terms of regions. See the section [Specifying Video Layouts](www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for further information.

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

    An array of audio sources to merge. All the specified sources must belong to the same Group Room. It can include zero or more Track names. These can be specified using wildcards (e.g. ‘student*`). The use of `[*]` has semantics “all if any” meaning zero or more (i.e. all) depending on whether the Group Room had audio tracks.

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

    An array of audio sources to exclude from the Composition Hook. Any new Composition triggered by the Composition Hook shall include all audio sources specified in ‘AudioSources` except for the ones specified in `AudioSourcesExcluded`. This parameter may include zero or more Track names. These can be specified using wildcards (e.g. `student*`).

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

    When activated, clips all the intervals where there is no active media in the Compositions triggered by the Composition Hook. This results in shorter compositions in cases when the Room was created but no Participant joined for some time, or if all the Participants left the room and joined at a later stage, as those gaps will be removed. You can find further information in the [Specifying Video Layouts](www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) section. Defaults to ‘true`.

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

    Container format of the Composition media files created by the Composition Hook. Can be any of the following: ‘mp4`, `webm`. The use of `mp4` or `webm` makes mandatory the specification of `AudioSources` and/or one `VideoLayout` element containing a valid `video_sources` list, otherwise an error is fired. Defaults to `webm`.

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

    A string representing the number of pixels for rows (width) and columns (height) of the generated composed video. This string must have the format ‘widthxheight`. This parameter must comply with the following constraints: `width >= 16 && width <= 1280`, `height >= 16 && height <= 1280`, `width * height <= 921,600`. Typical values are: HD = `1280x720`, PAL

    ‘1024x576`, VGA = `640x480`, CIF = `320x240`. Note that the `Resolution`

    implicitly imposes an aspect ratio to the resulting composition. When the original video tracks get constrained by this aspect ratio they are scaled-down to fit. You can find detailed information in the [Specifying Video Layouts](www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) section. Defaults to ‘640x480`.

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

    A URL that Twilio sends asynchronous webhook requests to on every composition event. If not provided, status callback events will not be dispatched.

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

    HTTP method Twilio should use when requesting the above URL. Defaults to ‘POST`.

Returns:



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

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