private function getPlayReadyTemplate() { $template = new PlayReadyLicenseResponseTemplate(); $template->setResponseCustomData('test custom data'); $licenseTemplate = new PlayReadyLicenseTemplate(); $template->setLicenseTemplates(array($licenseTemplate)); $licenseTemplate->setLicenseType(PlayReadyLicenseType::PERSISTENT); $licenseTemplate->setBeginDate(new \DateTime('now')); $licenseTemplate->setRelativeExpirationDate(new \DateInterval('PT6H')); $licenseTemplate->setContentKey(new ContentEncryptionKeyFromHeader()); $playRight = new PlayReadyPlayRight(); $licenseTemplate->setPlayRight($playRight); $playRight->setAgcAndColorStripeRestriction(new AgcAndColorStripeRestriction(1)); $playRight->setAllowPassingVideoContentToUnknownOutput(UnknownOutputPassingOption::ALLOWED); $playRight->setAnalogVideoOpl(100); $playRight->setCompressedDigitalAudioOpl(300); $playRight->setCompressedDigitalVideoOpl(400); $playRight->setExplicitAnalogTelevisionOutputRestriction(new ExplicitAnalogTelevisionRestriction(0, true)); $playRight->setImageConstraintForAnalogComponentVideoRestriction(true); $playRight->setImageConstraintForAnalogComputerMonitorRestriction(true); $playRight->setScmsRestriction(new ScmsRestriction(2)); $playRight->setUncompressedDigitalAudioOpl(250); $playRight->setUncompressedDigitalVideoOpl(270); return $template; }
/** * @covers WindowsAzure\MediaServices\Templates\PlayReadyLicenseTemplate::getRelativeExpirationDate * @covers WindowsAzure\MediaServices\Templates\PlayReadyLicenseTemplate::setRelativeExpirationDate */ public function testGetSetRelativeExpirationDate() { // Setup $entity = new PlayReadyLicenseTemplate(); $payload = new \DateInterval('PT30S'); // Test $entity->setRelativeExpirationDate($payload); $result = $entity->getRelativeExpirationDate(); // Assert $this->assertEquals($payload, $result); }
/** * @covers \WindowsAzure\MediaServices\Templates\MediaServicesLicenseTemplateSerializer::serialize * @covers \WindowsAzure\MediaServices\Templates\MediaServicesLicenseTemplateSerializer::deserialize */ public function testRoundTripTest() { $template = new PlayReadyLicenseResponseTemplate(); $template->setResponseCustomData('test custom data'); $licenseTemplate = new PlayReadyLicenseTemplate(); $template->setLicenseTemplates(array($licenseTemplate)); $licenseTemplate->setLicenseType(PlayReadyLicenseType::PERSISTENT); $licenseTemplate->setBeginDate(new \DateTime('now')); $licenseTemplate->setRelativeExpirationDate(new \DateInterval('PT6H')); $licenseTemplate->setContentKey(new ContentEncryptionKeyFromKeyIdentifier('test custom id')); $playRight = new PlayReadyPlayRight(); $licenseTemplate->setPlayRight($playRight); $playRight->setAgcAndColorStripeRestriction(new AgcAndColorStripeRestriction(1)); $playRight->setAllowPassingVideoContentToUnknownOutput(UnknownOutputPassingOption::ALLOWED); $playRight->setAnalogVideoOpl(100); $playRight->setCompressedDigitalAudioOpl(300); $playRight->setCompressedDigitalVideoOpl(400); $playRight->setExplicitAnalogTelevisionOutputRestriction(new ExplicitAnalogTelevisionRestriction(0, true)); $playRight->setImageConstraintForAnalogComponentVideoRestriction(true); $playRight->setImageConstraintForAnalogComputerMonitorRestriction(true); $playRight->setScmsRestriction(new ScmsRestriction(2)); $playRight->setUncompressedDigitalAudioOpl(250); $playRight->setUncompressedDigitalVideoOpl(270); $result = MediaServicesLicenseTemplateSerializer::serialize($template); $playreadyLicense = MediaServicesLicenseTemplateSerializer::deserialize($result); $this->assertEqualsLicenseResponseTemplate($template, $playreadyLicense); }
/** * @param mixed $xmlElement * * @return PlayReadyLicenseTemplate */ private static function deserializePlayReadyLicenseTemplate($xmlElement) { if (!isset($xmlElement->PlayRight)) { throw new \RuntimeException("The PlayReadyLicenseTemplate must contains an 'PlayRight' element"); } if (!isset($xmlElement->ContentKey)) { throw new \RuntimeException("The PlayReadyLicenseTemplate must contains an 'ContentKey' element"); } $result = new PlayReadyLicenseTemplate(); if (isset($xmlElement->AllowTestDevices)) { $result->setAllowTestDevices($xmlElement->AllowTestDevices == 'true'); } if (isset($xmlElement->BeginDate)) { if (isset($xmlElement->BeginDate->attributes(Resources::XSI_XML_NAMESPACE)->nil) && $xmlElement->BeginDate->attributes(Resources::XSI_XML_NAMESPACE)->nil == 'true') { $result->setBeginDate(null); } else { $result->setBeginDate(new \DateTime((string) $xmlElement->BeginDate)); } } if (isset($xmlElement->ExpirationDate)) { if (isset($xmlElement->ExpirationDate->attributes(Resources::XSI_XML_NAMESPACE)->nil) && $xmlElement->ExpirationDate->attributes(Resources::XSI_XML_NAMESPACE)->nil == 'true') { $result->setExpirationDate(null); } else { $result->setExpirationDate(new \DateTime((string) $xmlElement->setExpirationDate)); } } if (isset($xmlElement->RelativeBeginDate)) { $result->setRelativeBeginDate(new \DateInterval((string) $xmlElement->RelativeBeginDate)); } if (isset($xmlElement->RelativeExpirationDate)) { $result->setRelativeExpirationDate(new \DateInterval((string) $xmlElement->RelativeExpirationDate)); } if (isset($xmlElement->GracePeriod)) { $result->setGracePeriod(new \DateInterval((string) $xmlElement->GracePeriod)); } $result->setPlayRight(self::deserializePlayReadyPlayRight($xmlElement->PlayRight)); if (isset($xmlElement->LicenseType)) { $result->setLicenseType((string) $xmlElement->LicenseType); } $result->setContentKey(self::deserializePlayReadyContentKey($xmlElement->ContentKey)); return $result; }