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.



269
270
271
272
273
274
275
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 269

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



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

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

#fetchCompositionHookInstance

Fetch a CompositionHookInstance

Returns:



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

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

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

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

#to_sObject

Provide a user friendly representation



380
381
382
383
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 380

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.

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

    When activated, the Composition Hook is enabled and a composition will be triggered for every Video room completed by this account from this point onwards; ‘false` indicates the Composition Hook is left inactive.

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

    A JSON object defining the video layout of the Composition Hook in terms of regions. See the section [Managing Video Layouts](#managing-video-layouts) below 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 [Managing Video Layouts](#managing-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 numbers 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 [Managing Video Layouts](#managing-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:



355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 355

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