Class: Twilio::REST::Video::V1::CompositionHookInstance

Inherits:
InstanceResource 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, payload, sid: nil) ⇒ CompositionHookInstance

Initialize the CompositionHookInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • sid (String) (defaults to: nil)

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



396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 396

def initialize(version, payload, sid: nil)
  super(version)

  # Marshaled Properties
  @properties = {
      'account_sid' => payload['account_sid'],
      'friendly_name' => payload['friendly_name'],
      'enabled' => payload['enabled'],
      'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
      'date_updated' => payload['date_updated'],
      'sid' => payload['sid'],
      'audio_sources' => payload['audio_sources'],
      'audio_sources_excluded' => payload['audio_sources_excluded'],
      'video_layout' => payload['video_layout'],
      'resolution' => payload['resolution'],
      'trim' => payload['trim'],
      'format' => payload['format'],
      'status_callback' => payload['status_callback'],
      'status_callback_method' => payload['status_callback_method'],
      'url' => payload['url'],
  }

  # Context
  @instance_context = nil
  @params = {'sid' => sid || @properties['sid'], }
end

Instance Method Details

#account_sidString

Returns Twilio Account SID.

Returns:

  • (String)

    Twilio Account SID.



436
437
438
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 436

def 
  @properties['account_sid']
end

#audio_sourcesString

Returns A list of audio sources related to this Composition Hook.

Returns:

  • (String)

    A list of audio sources related to this Composition Hook.



472
473
474
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 472

def audio_sources
  @properties['audio_sources']
end

#audio_sources_excludedString

Returns A list of audio sources excluded related to this Composition Hook.

Returns:

  • (String)

    A list of audio sources excluded related to this Composition Hook.



478
479
480
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 478

def audio_sources_excluded
  @properties['audio_sources_excluded']
end

#contextCompositionHookContext

Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context

Returns:



427
428
429
430
431
432
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 427

def context
  unless @instance_context
    @instance_context = CompositionHookContext.new(@version, @params['sid'], )
  end
  @instance_context
end

#date_createdTime

Returns Date when the Composition Hook Resource was created.

Returns:

  • (Time)

    Date when the Composition Hook Resource was created.



454
455
456
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 454

def date_created
  @properties['date_created']
end

#date_updatedString

Returns Date when the Composition Hook was last updated.

Returns:

  • (String)

    Date when the Composition Hook was last updated.



460
461
462
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 460

def date_updated
  @properties['date_updated']
end

#deleteBoolean

Deletes the CompositionHookInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



534
535
536
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 534

def delete
  context.delete
end

#enabledBoolean

Returns Boolean flag for activating the Composition Hook.

Returns:

  • (Boolean)

    Boolean flag for activating the Composition Hook.



448
449
450
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 448

def enabled
  @properties['enabled']
end

#fetchCompositionHookInstance

Fetch a CompositionHookInstance

Returns:



527
528
529
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 527

def fetch
  context.fetch
end

#formatcomposition_hook.Format

Returns The file format for the Compositions triggered by the Composition Hook.

Returns:

  • (composition_hook.Format)

    The file format for the Compositions triggered by the Composition Hook.



502
503
504
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 502

def format
  @properties['format']
end

#friendly_nameString

Returns Friendly name of the Composition Hook to be shown in the console.

Returns:

  • (String)

    Friendly name of the Composition Hook to be shown in the console.



442
443
444
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 442

def friendly_name
  @properties['friendly_name']
end

#inspectObject

Provide a detailed, user friendly representation



618
619
620
621
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 618

def inspect
  values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
  "<Twilio.Video.V1.CompositionHookInstance #{values}>"
end

#resolutionString

Returns Pixel resolution of the composed video.

Returns:

  • (String)

    Pixel resolution of the composed video.



490
491
492
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 490

def resolution
  @properties['resolution']
end

#sidString

Returns A 34-character string that uniquely identifies this Composition Hook.

Returns:

  • (String)

    A 34-character string that uniquely identifies this Composition Hook.



466
467
468
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 466

def sid
  @properties['sid']
end

#status_callbackString

Returns The status_callback.

Returns:

  • (String)

    The status_callback



508
509
510
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 508

def status_callback
  @properties['status_callback']
end

#status_callback_methodString

Returns The status_callback_method.

Returns:

  • (String)

    The status_callback_method



514
515
516
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 514

def status_callback_method
  @properties['status_callback_method']
end

#to_sObject

Provide a user friendly representation



611
612
613
614
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 611

def to_s
  values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
  "<Twilio.Video.V1.CompositionHookInstance #{values}>"
end

#trimBoolean

Returns Boolean flag for clipping intervals that have no media.

Returns:

  • (Boolean)

    Boolean flag for clipping intervals that have no media.



496
497
498
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 496

def trim
  @properties['trim']
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:



594
595
596
597
598
599
600
601
602
603
604
605
606
607
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 594

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)
  context.update(
      friendly_name: friendly_name,
      enabled: enabled,
      video_layout: video_layout,
      audio_sources: audio_sources,
      audio_sources_excluded: audio_sources_excluded,
      trim: trim,
      format: format,
      resolution: resolution,
      status_callback: status_callback,
      status_callback_method: status_callback_method,
  )
end

#urlString

Returns The absolute URL for this resource.

Returns:

  • (String)

    The absolute URL for this resource.



520
521
522
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 520

def url
  @properties['url']
end

#video_layoutHash

Returns The JSON video layout description.

Returns:

  • (Hash)

    The JSON video layout description.



484
485
486
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 484

def video_layout
  @properties['video_layout']
end