/** * Will determine the conversion string for the entry id. * This depends on the partner and the nature of the file */ public static function getConversionStringForEntry($entry_id, $file_name) { $entry = entryPeer::retrieveByPK($entry_id); if (!$entry) { return null; } $conversion_profile_id = $entry->getConversionQuality(); $partner = PartnerPeer::retrieveByPK($entry->getPartnerId()); if (!$partner) { return null; } // VERY BAD !! // check the type of the file // if of type flv - check for flvConversionString $conversion_str = ""; // prefer the conversion_profile over the conversion_string (which is obsolete) if (!$conversion_profile_id) { $conversion_profile_id = $partner->getDefConversionProfileType(); } if (!$conversion_profile_id) { if (myFlvStaticHandler::isFlv($file_name)) { $conversion_str = $partner->getFlvConversionString(); } if (!$conversion_str) { $conversion_str = $partner->getConversionString(); } /// TODO - optimize - check according to the conversion string if need to fetch data from the file list($video_width, $video_height) = myFileConverter::getVideoDimensions($file_name); $conversion_str = myFileConverter::formatConversionString($conversion_str, $video_width, $video_height); } // if the $conversion_profile_id is not specified on the entry - look at the partner's conversion_string // TODO - HACK, this is until we have a default conversion_profile for the partner if (!$conversion_profile_id && strpos($conversion_str, "!") === 0) { // the conversion string strart with ! - use this as the default conversionQuality of the partner // copy it on the entry - it will follow the entry from this point onwards $conversion_profile_id = substr($conversion_str, 1); // without the ! } // update the entry if there is a better $conversion_profile_id than the original one the entry had if ($conversion_profile_id && $conversion_profile_id != $entry->getConversionQuality()) { $entry->setConversionQuality($conversion_profile_id); $entry->save(); } return array($conversion_str, $conversion_profile_id); }