You are here

function brightcove_upload_and_ingest in Brightcove Video Connect 7.7

Same name and namespace in other branches
  1. 7.6 brightcove.module \brightcove_upload_and_ingest()

Parameters

$client_entity:

$url:

$profile:

$hash:

$parent_entity_type:

$parent_bundle_name:

$parent_field_name:

null|callable $metadata_callback:

null|array $form_state:

Return value

\Brightcove\Object\Video\Video

1 call to brightcove_upload_and_ingest()
_brightcove_upload_form_callback in ./brightcove.module
Upload the submitted video.

File

./brightcove.module, line 2591
Brightcove module is an integration layer between any modules using Brightcove API. It makes all necessary checks for the API and makes settings available to the user.

Code

function brightcove_upload_and_ingest($client_entity, $url, $profile, $hash, $parent_entity_type, $parent_bundle_name, $parent_field_name, callable $metadata_callback = NULL, $form_state = NULL) {
  brightcove_load_lib();

  /** @var \Brightcove\API\CMS $cms */

  /** @var \Brightcove\API\DI $di */
  list($cms, $di) = brightcove_create_classes($client_entity);
  $video = new \Brightcove\Object\Video\Video();
  $ingest_callback = NULL;
  if ($metadata_callback !== NULL) {
    $ingest_callback = $metadata_callback($video, $cms);
  }
  $video = $cms
    ->createVideo($video);
  $request = \Brightcove\API\Request\IngestRequest::createRequest($url, $profile);
  $request
    ->setCaptureImages(TRUE);
  $callback_metadata = module_invoke_all('brightcove_ingest_metadata', $form_state);
  if ($callback = brightcove_create_callback($hash, $video
    ->getId(), $client_entity->bcid, 0, $parent_entity_type, $parent_field_name, $parent_bundle_name, $callback_metadata)) {
    $request
      ->setCallbacks([
      $callback,
    ]);
  }
  if ($ingest_callback && is_callable($ingest_callback)) {
    $ingest_callback($request);
  }
  $di
    ->createIngest($video
    ->getId(), $request);
  return $video;
}