Пример #1
0
 public static function getCoreDeliveryProfileInstanceByType($type)
 {
     $coreType = kPluginableEnumsManager::apiToCore('DeliveryProfileType', $type);
     $class = DeliveryProfilePeer::getClassByDeliveryProfileType($coreType);
     return new $class();
 }
function createDelivery($key, $type, &$urlManager)
{
    $deliveryType = $type[0];
    $streamerType = $type[1];
    $deliveryProfileClz = DeliveryProfilePeer::getClassByDeliveryProfileType($deliveryType);
    $deliveryProfile = new $deliveryProfileClz();
    $typename = preg_split('/(?=[A-Z])/', $deliveryProfileClz);
    $name = $key . " " . implode(" ", $typename);
    $deliveryProfile->setName($name);
    $deliveryProfile->setSystemName($name);
    $deliveryProfile->setDescription($name);
    $deliveryProfile->setType($deliveryType);
    $deliveryProfile->setStreamerType($streamerType);
    $deliveryProfile->setUrl($key);
    $deliveryProfile->setIsDefault(false);
    $deliveryProfile->setPartnerId(0);
    switch ($deliveryType) {
        case DeliveryProfileType::AKAMAI_HTTP:
            $host = find("params.http_header_host", $urlManager);
            if ($host) {
                $recognizer = new kUrlRecognizer();
                $recognizer->setHosts(explode(",", $host));
                $deliveryProfile->setRecognizer($recognizer);
            }
            $useIntelliseek = find("params.enable_intelliseek", $urlManager);
            if ($useIntelliseek) {
                $deliveryProfile->setUseIntelliseek(true);
            }
            break;
        case DeliveryProfileType::AKAMAI_RTSP:
            $host = find("params.rtsp_host", $urlManager);
            if ($host) {
                $deliveryProfile->setUrl($host);
            }
            break;
        case DeliveryProfileType::AKAMAI_RTMP:
            $enforce = find("params.enforce_rtmpe", $urlManager);
            if ($enforce) {
                $deliveryProfile->setEnforceRtmpe($enforce);
            }
            break;
        case DeliveryProfileType::AKAMAI_HD:
            $host = find("params.hd_flash", $urlManager);
            if ($host) {
                $deliveryProfile->setUrl($host);
            }
            break;
        case DeliveryProfileType::AKAMAI_HDS:
            $host = find("params.hd_secure_hds", $urlManager);
            if ($host) {
                $deliveryProfile->setUrl($host);
            }
            break;
        case DeliveryProfileType::AKAMAI_HLS_MANIFEST:
            $host = find("params.hd_ios", $urlManager);
            if ($host) {
                $deliveryProfile->setUrl($host);
            }
            $host = find("params.hd_secure_ios", $urlManager);
            if ($host) {
                $deliveryProfile->setUrl($host);
            }
            break;
    }
    return $deliveryProfile;
}