Exemple #1
0
 /**
  * Declares an association between this object and a conversionProfile2 object.
  *
  * @param      conversionProfile2 $v
  * @return     entry The current object (for fluent API support)
  * @throws     PropelException
  */
 public function setconversionProfile2(conversionProfile2 $v = null)
 {
     if ($v === null) {
         $this->setConversionProfileId(NULL);
     } else {
         $this->setConversionProfileId($v->getId());
     }
     $this->aconversionProfile2 = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the conversionProfile2 object, it will not be re-added.
     if ($v !== null) {
         $v->addentry($this);
     }
     return $this;
 }
 private static function shouldConvertProfileFlavors(conversionProfile2 $profile, mediaInfo $mediaInfo = null, flavorAsset $originalFlavorAsset)
 {
     $shouldConvert = true;
     if ($profile->getCreationMode() == conversionProfile2::CONVERSION_PROFILE_2_CREATION_MODE_AUTOMATIC_BYPASS_FLV) {
         KalturaLog::log("The profile created from old conversion profile with bypass flv");
         $isFlv = false;
         if ($mediaInfo) {
             $isFlv = KDLWrap::CDLIsFLV($mediaInfo);
         }
         if ($isFlv && $originalFlavorAsset->hasTag(flavorParams::TAG_MBR)) {
             KalturaLog::log("The source is mbr and flv, conversion will be bypassed");
             $shouldConvert = false;
         } else {
             KalturaLog::log("The source is NOT mbr or flv, conversion will NOT be bypassed");
         }
     }
     return $shouldConvert;
 }
 /**
  * @param conversionProfile2 $conversionProfile
  */
 protected function conversionProfileDeleted(conversionProfile2 $conversionProfile)
 {
     $this->syncableDeleted($conversionProfile->getId(), FileSyncObjectType::CONVERSION_PROFILE);
 }
 /**
  * Delete the relation of flavorParams <> conversionProfile2
  * 
  * @param conversionProfile2 $conversionProfileDb
  * @param string|array $notInFlavorIds comma sepeartaed id that should not be deleted
  */
 protected function deleteFlavorParamsRelation(conversionProfile2 $conversionProfileDb, $notInFlavorIds = null)
 {
     $c = new Criteria();
     $c->add(flavorParamsConversionProfilePeer::CONVERSION_PROFILE_ID, $conversionProfileDb->getId());
     if ($notInFlavorIds) {
         if (!is_array($notInFlavorIds)) {
             $notInFlavorIds = explode(',', $notInFlavorIds);
         }
         $c->add(flavorParamsConversionProfilePeer::FLAVOR_PARAMS_ID, $notInFlavorIds, Criteria::NOT_IN);
     }
     flavorParamsConversionProfilePeer::doDelete($c);
 }
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      conversionProfile2 $value A conversionProfile2 object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(conversionProfile2 $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
 public function loadFlavorParamsIds(conversionProfile2 $conversionProfile, $con = null)
 {
     $flavorParams = $conversionProfile->getflavorParamsConversionProfilesJoinflavorParams(null, $con);
     $flavorParamIds = array();
     foreach ($flavorParams as $flavorParam) {
         $flavorParamIds[] = $flavorParam->getFlavorParamsId();
     }
     $this->flavorParamsIds = implode(",", $flavorParamIds);
 }
 /**
  * Delete the relation of flavorParams <> conversionProfile2
  * 
  * @param conversionProfile2 $conversionProfileDb
  */
 protected function deleteFlavorParamsRelation(conversionProfile2 $conversionProfileDb)
 {
     $c = new Criteria();
     $c->add(flavorParamsConversionProfilePeer::CONVERSION_PROFILE_ID, $conversionProfileDb->getId());
     flavorParamsConversionProfilePeer::doDelete($c);
 }
 /**
  * Will return for each OLD ConversionProfile a new one, IF NEEDED.
  * The old conversionProfile will hold a reference to the new one, so if already created a new one, it will be re-used.
  * All the necessary flavorParams will be added too to fit the old conversion params.
  *  
  * @param ConversionProfile $conversion_profile
  * @return conversionProfile2
  */
 public static function createConversionProfile2FromConversionProfile(ConversionProfile $old_conversion_profile)
 {
     if (!$old_conversion_profile) {
         throw new Exception("Cannot create new conversionProfile2 for null");
     }
     if ($old_conversion_profile->getConversionProfile2Id()) {
         $new_profile = conversionProfile2Peer::retrieveByPK($old_conversion_profile->getConversionProfile2Id());
         if ($new_profile) {
             // found a valid new profile - return it
             return $new_profile;
         }
     }
     // whether there was no id or no profile - create on now and set it to be the conversionProfile2Id
     $new_profile = new conversionProfile2();
     $new_profile->setPartnerId($old_conversion_profile->getPartnerId());
     $new_name = $old_conversion_profile->getName();
     $new_name = $new_name ? $new_name : "From [{$old_conversion_profile->getId()}]";
     $new_profile->setName($new_name . " " . $old_conversion_profile->getProfileType());
     if ($old_conversion_profile->getBypassFlv()) {
         $new_profile->setCreationMode(conversionProfile2::CONVERSION_PROFILE_2_CREATION_MODE_AUTOMATIC_BYPASS_FLV);
         $map = flavorParams::TAG_WEB . "," . flavorParams::TAG_MBR;
     } else {
         $new_profile->setCreationMode(conversionProfile2::CONVERSION_PROFILE_2_CREATION_MODE_AUTOMATIC);
         $map = flavorParams::TAG_WEB;
     }
     $new_profile->setInputTagsMap($map);
     // use the OLD code to simulate what was performed on the old_conversion_profile to retrieve the old_conversion_params list
     $conv_client = new kConversionClientBase("", "", "", "");
     $old_conversion_command = $conv_client->createConversionCommandFromConverionProfile("src", "target", $old_conversion_profile);
     $description = '';
     foreach ($old_conversion_command->conversion_params_list as $old_conversion_params) {
         // use the helper utility to fill the gaps
         $desc = '';
         self::fixDimensionsByAspectRatio($old_conversion_params, $desc);
         $description .= $desc;
     }
     $new_profile->setDescription($description);
     $new_profile->save();
     // at this point - the all $old_conversion_params are filled with the values used by the old conversion servers
     // transform from old to new ...
     // create the flavorParams and the flavorParamsConversionParams table
     foreach ($old_conversion_command->conversion_params_list as $old_conversion_params) {
         $new_flavor_params = new flavorParams();
         // set all the properties for the new flavor_params
         $new_flavor_params->setPartnerId($old_conversion_profile->getPartnerId());
         $new_flavor_params->setCreationMode(flavorParams::FLAVOR_PARAMS_CREATION_MODE_AUTOMATIC);
         $audio_bitrate = $old_conversion_params->audio_bitrate;
         if (!$audio_bitrate) {
             $audio_bitrate = 96;
         }
         // if empty - hard-code 96
         $new_flavor_params->setAudioBitrate($audio_bitrate);
         // default
         $new_flavor_params->setAudioChannels(0);
         // default
         $new_flavor_params->setAudioResolution(0);
         $new_flavor_params->setAudioSampleRate(0);
         if ($old_conversion_profile->getCommercialTranscoder()) {
             // first comes ON2...
             $new_flavor_params->setConversionEngines(conversionEngineType::ON2 . "," . conversionEngineType::ENCODING_COM . "," . conversionEngineType::FFMPEG . "," . conversionEngineType::FFMPEG_AUX . "," . conversionEngineType::MENCODER);
             //
             $new_flavor_params->setConversionEnginesExtraParams($old_conversion_params->flix_params . "|" . $old_conversion_params->flix_params . "|" . $old_conversion_params->ffmpeg_params . "|" . $old_conversion_params->ffmpeg_params . "|" . $old_conversion_params->mencoder_params);
         } else {
             // first comes ffmpeg ...
             $new_flavor_params->setConversionEngines(conversionEngineType::FFMPEG . "," . conversionEngineType::FFMPEG_AUX . "," . conversionEngineType::MENCODER . "," . conversionEngineType::ON2 . "," . conversionEngineType::ENCODING_COM, ",");
             //
             $new_flavor_params->setConversionEnginesExtraParams($old_conversion_params->ffmpeg_params . "|" . $old_conversion_params->ffmpeg_params . "|" . $old_conversion_params->mencoder_params . "|" . $old_conversion_params->flix_params . "|" . $old_conversion_params->flix_params);
         }
         $target_format = "flv";
         // this code will always be called for flv files
         // the format can be flv | mp4 | mov | avi | mp3
         // IMPORTANT:
         // except for the FLV videos, none of the formats should be assumed WEB - they are not supposed to be played using our player at first stage.
         switch ($target_format) {
             case "mp3":
                 $new_flavor_params->setFormat("flv");
                 $new_flavor_params->setAudioCodec(flavorParams::AUDIO_CODEC_MP3);
                 // set default mp3
                 $new_flavor_params->setVideoCodec(flavorParams::VIDEO_CODEC_VP6);
                 /* $new_flavor_params->setTags ( flavorParams::TAG_WEB ); */
                 break;
             case "mp4":
                 $new_flavor_params->setFormat($target_format);
                 $new_flavor_params->setAudioCodec(flavorParams::AUDIO_CODEC_AAC);
                 $new_flavor_params->setVideoCodec(flavorParams::VIDEO_CODEC_H264);
                 $new_flavor_params->setTags(',mp4_export');
                 break;
             case "mov":
                 $new_flavor_params->setFormat($target_format);
                 $new_flavor_params->setAudioCodec(flavorParams::AUDIO_CODEC_AAC);
                 $new_flavor_params->setVideoCodec(flavorParams::VIDEO_CODEC_H264);
                 $new_flavor_params->setTags('mov_export');
                 break;
             case "avi":
                 $new_flavor_params->setFormat($target_format);
                 $new_flavor_params->setAudioCodec(flavorParams::AUDIO_CODEC_MP3);
                 $new_flavor_params->setVideoCodec(flavorParams::VIDEO_CODEC_H264);
                 $new_flavor_params->setTags('avi_export');
                 break;
             case "flv":
                 $new_flavor_params->setFormat($target_format);
                 $new_flavor_params->setAudioCodec(flavorParams::AUDIO_CODEC_MP3);
                 $new_flavor_params->setVideoCodec(flavorParams::VIDEO_CODEC_VP6);
                 $new_flavor_params->setTags(flavorParams::TAG_WEB . "," . flavorParams::TAG_MBR);
                 break;
         }
         $new_flavor_params->setName($new_name);
         $new_flavor_params->setFrameRate(0);
         // DONT set the framerate $old_conversion_params->framerate );
         if ($old_conversion_params->gop_size == 5) {
             $new_flavor_params->setGopSize(5);
             $new_flavor_params->removeTag(flavorParams::TAG_MBR);
             $new_flavor_params->addTag(flavorParams::TAG_EDIT);
         } else {
             $new_flavor_params->setGopSize(0);
             // 0 will automatically allow default gopsize
         }
         $new_flavor_params->setWidth($old_conversion_params->width);
         $new_flavor_params->setHeight($old_conversion_params->height);
         $new_flavor_params->setVersion(1);
         $new_flavor_params->setReadyBehavior(flavorParamsConversionProfile::READY_BEHAVIOR_OPTIONAL);
         $new_flavor_params->setVideoBitrate($old_conversion_params->bitrate ? $old_conversion_params->bitrate : "");
         // TODO - fill the rest ...
         $new_flavor_params->save();
         // add to the 1-to-many table
         $flavor_params_conversion_profile = new flavorParamsConversionProfile();
         $flavor_params_conversion_profile->setConversionProfileId($new_profile->getId());
         $flavor_params_conversion_profile->setFlavorParamsId($new_flavor_params->getId());
         $flavor_params_conversion_profile->setReadyBehavior($new_flavor_params->getReadyBehavior());
         $flavor_params_conversion_profile->save();
     }
     // always add to the *source* flavotParams to the 1-to-many table
     $flavor_params_conversion_profile = new flavorParamsConversionProfile();
     $flavor_params_conversion_profile->setConversionProfileId($new_profile->getId());
     $flavor_params_conversion_profile->setFlavorParamsId(flavorParams::SOURCE_FLAVOR_ID);
     $flavor_params_conversion_profile->save();
     // point to the new profile and save the old one
     $old_conversion_profile->setConversionProfile2Id($new_profile->getId());
     $old_conversion_profile->save();
     return $new_profile;
 }
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      conversionProfile2 $value A conversionProfile2 object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(conversionProfile2 $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         if (isset(self::$instances[$key]) || count(self::$instances) < kConf::get('max_num_instances_in_pool')) {
             self::$instances[$key] = $obj;
             kMemoryManager::registerPeer('conversionProfile2Peer');
         }
     }
 }