Exemple #1
0
 /**
  *
  * @param entry $clipEntry new entry to copy and adjust cue points from root entry to
  */
 public static function copyCuePointsToClipEntry(entry $clipEntry)
 {
     $clipAtts = self::getClipAttributesFromEntry($clipEntry);
     if (!is_null($clipAtts)) {
         $sourceEntry = entryPeer::retrieveByPK($clipEntry->getSourceEntryId());
         if (is_null($sourceEntry)) {
             KalturaLog::info("Didn't copy cuePoints for entry [{$clipEntry->getId()}] because source entry [" . $clipEntry->getSourceEntryId() . "] wasn't found");
             return;
         }
         $sourceEntryDuration = $sourceEntry->getLengthInMsecs();
         $clipStartTime = $clipAtts->getOffset();
         if (is_null($clipStartTime)) {
             $clipStartTime = 0;
         }
         $clipDuration = $clipAtts->getDuration();
         if (is_null($clipDuration)) {
             $clipDuration = $sourceEntryDuration;
         }
         $c = new KalturaCriteria();
         $c->add(CuePointPeer::ENTRY_ID, $clipEntry->getSourceEntryId());
         if ($clipDuration < $sourceEntryDuration) {
             $c->addAnd(CuePointPeer::START_TIME, $clipStartTime + $clipDuration, KalturaCriteria::LESS_EQUAL);
         }
         if ($clipStartTime > 0) {
             $c->addAnd(CuePointPeer::START_TIME, $clipStartTime, KalturaCriteria::GREATER_EQUAL);
             $c->addOr(CuePointPeer::START_TIME, 0, KalturaCriteria::EQUAL);
         }
         $c->addAscendingOrderByColumn(CuePointPeer::CREATED_AT);
         $rootEntryCuePointsToCopy = CuePointPeer::doSelect($c);
         if (count($rootEntryCuePointsToCopy) <= self::MAX_CUE_POINTS_TO_COPY_TO_CLIP) {
             foreach ($rootEntryCuePointsToCopy as $cuePoint) {
                 $cuePoint->copyToClipEntry($clipEntry, $clipStartTime, $clipDuration);
             }
         } else {
             KalturaLog::alert("Can't copy cuePoints for entry [{$clipEntry->getId()}] because cuePoints count exceeded max limit of [" . self::MAX_CUE_POINTS_TO_COPY_TO_CLIP . "]");
         }
     }
 }