diff --git a/lib/Brightcove/API/Request/IngestRequest.php b/lib/Brightcove/API/Request/IngestRequest.php index 7fe71d6..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; @@ -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) { $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; @@ -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; diff --git a/lib/Brightcove/API/Request/IngestRequestRetranscode.php b/lib/Brightcove/API/Request/IngestRequestRetranscode.php new file mode 100644 index 0000000..51cafc6 --- /dev/null +++ b/lib/Brightcove/API/Request/IngestRequestRetranscode.php @@ -0,0 +1,34 @@ +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; + } +} 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]); }