Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding new class and fixing IngestRequest class to allow retranscoding requests. #18

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions lib/Brightcove/API/Request/IngestRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class IngestRequest extends ObjectBase {
/**
* @var IngestRequestMaster
* @var IngestRequestMaster|IngestRequestRetranscode
*/
protected $master;

Expand Down Expand Up @@ -44,10 +44,15 @@ public function __construct() {
$this->fieldAliases["capture_images"] = "capture-images";
}

public static function createRequest($url, $profile) {
public static function createRequest($profile, $url = null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the parameter order shouldn't be swapped, and the possiblity of a null url should be documented (we cannot drop PHP 5 now, but in PHP 7.1+ the type should be ?string).

$request = new self();
$request->setMaster(new IngestRequestMaster());
$request->getMaster()->setUrl($url);
if ($url !== null) {
$request->setMaster(new IngestRequestMaster());
$request->getMaster()->setUrl($url);
} else {
$request->setMaster(new IngestRequestRetranscode());
$request->getMaster()->setUseArchivedMaster(true);
}
$request->setProfile($profile);

return $request;
Expand All @@ -65,17 +70,17 @@ public function applyJSON(array $json) {
}

/**
* @return IngestRequestMaster
* @return IngestRequestMaster|IngestRequestRetranscode
*/
public function getMaster() {
return $this->master;
}

/**
* @param IngestRequestMaster $master
* @param IngestRequestMaster|IngestRequestRetranscode $master
* @return $this
*/
public function setMaster(IngestRequestMaster $master = NULL) {
public function setMaster(ObjectBase $master = NULL) {
$this->master = $master;
$this->fieldChanged('master');
return $this;
Expand Down
34 changes: 34 additions & 0 deletions lib/Brightcove/API/Request/IngestRequestRetranscode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace Brightcove\API\Request;

use Brightcove\Object\ObjectBase;

class IngestRequestRetranscode extends ObjectBase {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to have a common ancestor for IngestRequestMaster and IngestRequestRetranscode even if they have no common properties. This would signal that they are related.

protected $use_archived_master;

public function applyJSON(array $json)
{
parent::applyJSON($json);
$this->applyProperty($json, 'use_archived_master');
}

/**
* @return string
*/
public function getUseArchivedMaster()
{
return $this->getUseArchivedMaster();
}

/**
* @param string $use_archived_master
* @return $this
*/
public function setUseArchivedMaster($bool = true)
{
$this->use_archived_master = $bool;
$this->fieldChanged('use_archived_master');
return $this;
}
}
2 changes: 1 addition & 1 deletion test/Brightcove/Test/VideoCRUDTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function testVideoObjectCreation() {
* @depends testVideoObjectCreation
*/
public function testVideoIngestion($video_id) {
$request = IngestRequest::createRequest('http://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_480p_surround-fix.avi', 'high-bandwidth-devices');
$request = IngestRequest::createRequest('high-bandwidth-devices', 'http://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_480p_surround-fix.avi');
if (!empty($this->callback_addr_remote)) {
$request->setCallbacks([$this->callback_addr_remote]);
}
Expand Down