From 7b23eebf582fdb178d3b489a7a05f0ddc035b470 Mon Sep 17 00:00:00 2001 From: Benjamin Zaslavsky Date: Wed, 29 Jun 2016 16:59:32 +0200 Subject: [PATCH 1/3] Added new class for Reingestion requests, modified IngestRequest class consequently --- lib/Brightcove/API/Request/IngestRequest.php | 9 +++-- .../API/Request/IngestRequestRetranscode.php | 34 +++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 lib/Brightcove/API/Request/IngestRequestRetranscode.php diff --git a/lib/Brightcove/API/Request/IngestRequest.php b/lib/Brightcove/API/Request/IngestRequest.php index 7fe71d6..8eb23c8 100644 --- a/lib/Brightcove/API/Request/IngestRequest.php +++ b/lib/Brightcove/API/Request/IngestRequest.php @@ -46,8 +46,13 @@ public function __construct() { public static function createRequest($url, $profile) { $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; diff --git a/lib/Brightcove/API/Request/IngestRequestRetranscode.php b/lib/Brightcove/API/Request/IngestRequestRetranscode.php new file mode 100644 index 0000000..e2b6dca --- /dev/null +++ b/lib/Brightcove/API/Request/IngestRequestRetranscode.php @@ -0,0 +1,34 @@ +applyProperty($json, 'url'); + } + + /** + * @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; + } +} From 8cc7b4153623e0319902148bdeec58236cd27abf Mon Sep 17 00:00:00 2001 From: Benjamin Zaslavsky Date: Wed, 29 Jun 2016 17:03:28 +0200 Subject: [PATCH 2/3] Fixed IngestRequest::createRequest param order --- lib/Brightcove/API/Request/IngestRequest.php | 2 +- test/Brightcove/Test/VideoCRUDTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Brightcove/API/Request/IngestRequest.php b/lib/Brightcove/API/Request/IngestRequest.php index 8eb23c8..a2ea135 100644 --- a/lib/Brightcove/API/Request/IngestRequest.php +++ b/lib/Brightcove/API/Request/IngestRequest.php @@ -44,7 +44,7 @@ public function __construct() { $this->fieldAliases["capture_images"] = "capture-images"; } - public static function createRequest($url, $profile) { + public static function createRequest($profile, $url = null) { $request = new self(); if ($url !== null) { $request->setMaster(new IngestRequestMaster()); diff --git a/test/Brightcove/Test/VideoCRUDTest.php b/test/Brightcove/Test/VideoCRUDTest.php index a84911d..85ee27f 100644 --- a/test/Brightcove/Test/VideoCRUDTest.php +++ b/test/Brightcove/Test/VideoCRUDTest.php @@ -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]); } From 26d79c498e2de78c430274410a9dc2b27e799d1f Mon Sep 17 00:00:00 2001 From: Benjamin Zaslavsky Date: Wed, 29 Jun 2016 17:14:42 +0200 Subject: [PATCH 3/3] Various fixes and minor corrections for adaptation --- lib/Brightcove/API/Request/IngestRequest.php | 8 ++++---- lib/Brightcove/API/Request/IngestRequestRetranscode.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/Brightcove/API/Request/IngestRequest.php b/lib/Brightcove/API/Request/IngestRequest.php index a2ea135..a6e933f 100644 --- a/lib/Brightcove/API/Request/IngestRequest.php +++ b/lib/Brightcove/API/Request/IngestRequest.php @@ -6,7 +6,7 @@ class IngestRequest extends ObjectBase { /** - * @var IngestRequestMaster + * @var IngestRequestMaster|IngestRequestRetranscode */ protected $master; @@ -70,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; diff --git a/lib/Brightcove/API/Request/IngestRequestRetranscode.php b/lib/Brightcove/API/Request/IngestRequestRetranscode.php index e2b6dca..51cafc6 100644 --- a/lib/Brightcove/API/Request/IngestRequestRetranscode.php +++ b/lib/Brightcove/API/Request/IngestRequestRetranscode.php @@ -10,7 +10,7 @@ class IngestRequestRetranscode extends ObjectBase { public function applyJSON(array $json) { parent::applyJSON($json); - $this->applyProperty($json, 'url'); + $this->applyProperty($json, 'use_archived_master'); } /**