本文整理汇总了PHP中assetPeer::retrieveBestEditByEntryId方法的典型用法代码示例。如果您正苦于以下问题:PHP assetPeer::retrieveBestEditByEntryId方法的具体用法?PHP assetPeer::retrieveBestEditByEntryId怎么用?PHP assetPeer::retrieveBestEditByEntryId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类assetPeer
的用法示例。
在下文中一共展示了assetPeer::retrieveBestEditByEntryId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fixMetadataImpl
/**
* here we'll manipulate the video asset and set the from_byte & to_byte from the milliseconds
*
*/
private static function fixMetadataImpl(&$xml_doc, &$total_duration, $timeline)
{
self::log(__METHOD__);
/*
$xml_doc = new DOMDocument();
$xml_doc->loadXML( $content );
*/
// $meatadata_elem_list = $xml_doc->getElementsByTagName( "MetaData" );
// if ( $meatadata_elem_list != null && $meatadata_elem_list->length > 0 )
$duration_list = $xml_doc->getElementsByTagName("SeqDuration");
if ($duration_list != null && $duration_list->length > 0) {
$total_duration = $duration_list->item(0)->nodeValue;
}
$xpath = new DOMXPath($xml_doc);
$assets = $xpath->query($timeline == "video" ? "//VideoAssets/vidAsset" : ($timeline == "audio" ? "//AudioAssets/AudAsset" : "//VoiceAssets/voiAsset"));
$lastTimestamp = 0;
$real_start_byte = 0;
// the start byte of the current clip in the final merged stream
$calculated_total_bytes = 0;
// use the entryPool and a 2-pass iteration to reduce the hits to the DB
$id_list = array();
$entry_pool = new entryPool();
// first pass - populate the entryPool in a single request to the DB
self::log(__METHOD__, "Before assets");
foreach ($assets as $asset) {
$type = $asset->getAttribute("type");
if ($type != "VIDEO" && $type != "AUDIO") {
continue;
}
// fetch the file name from the DB
$asset_id = $asset->getAttribute("k_id");
$id_list[] = $asset_id;
}
self::log(__METHOD__, "After assets", count($id_list), $id_list);
if ($id_list) {
$entry_pool->addEntries(entryPeer::retrieveByPKsNoFilter($id_list));
}
// second pass - the entryPool is supposed to already be populated
$was_modified = false;
foreach ($assets as $asset) {
// fix only VIDEO assets
$type = $asset->getAttribute("type");
if ($type != "VIDEO" && $type != "AUDIO") {
continue;
}
// fetch the file name from the DB
$asset_id = $asset->getAttribute("k_id");
self::log(__METHOD__, "in loop", $asset_id);
//$entry = entryPeer::retrieveByPKNoFilter( $asset_id );
$entry = $entry_pool->retrieveByPK($asset_id);
// is supposed to exist already in the pool
if ($entry == NULL) {
// set an error on the asset element
$asset->setAttribute("fix_status", "error in k_id [{$asset_id}]");
$was_modified = true;
continue;
} elseif ($entry->getStatus() == entryStatus::DELETED) {
// set an error on the asset element
$asset->setAttribute("fix_status", "error in k_id [{$asset_id}] - asset was deleted");
$was_modified = true;
continue;
}
$file_name = null;
//TODO: need to work on only an FLV asset
$flavor_asset_play = assetPeer::retrieveBestPlayByEntryId($entry->getId());
if (!$flavor_asset_play) {
KalturaLog::log(__METHOD__ . ' ' . __LINE__ . ' no play flavor asset for entry ' . $entry->getId());
} else {
$file_name = kFileSyncUtils::getReadyLocalFilePathForKey($flavor_asset_play->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET));
}
$use_multi_flavor = false;
$flv_file_name_edit = false;
$flavor_asset_edit = assetPeer::retrieveBestEditByEntryId($entry->getId());
if (!$flavor_asset_edit) {
KalturaLog::log(__METHOD__ . ' ' . __LINE__ . ' no edit flavor asset for entry ' . $entry->getId());
} else {
$flv_file_name_edit = kFileSyncUtils::getReadyLocalFilePathForKey($flavor_asset_edit->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET));
$use_multi_flavor = $flv_file_name_edit && file_exists($flv_file_name_edit) && $timeline == "video";
}
if (!$flv_file_name_edit && !$file_name) {
KalturaLog::log(__METHOD__ . ' ' . __LINE__ . ' no edit & play flavor assets for entry ' . $entry->getId());
continue;
}
$flv_file_name = kFile::fixPath($file_name);
$stream_info_list = $asset->getElementsByTagName("StreamInfo");
foreach ($stream_info_list as $stream_info) {
$file_name = "?";
try {
$stream_info->setAttribute("file_name", kFileSyncUtils::getReadyLocalFilePathForKey($flavor_asset_play->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET)));
// replaced__getDataPath
$start_byte = $stream_info->getAttribute("start_byte");
$end_byte = $stream_info->getAttribute("end_byte");
$total_bytes = $stream_info->getAttribute("total_bytes");
if ($start_byte == NULL) {
$start_byte = self::MISSING_VALUE;
}
//.........这里部分代码省略.........
示例2: execute
//.........这里部分代码省略.........
//
$streamer = $this->getRequestParameter("streamer");
//
if (substr($streamer, 0, 4) == "rtmp") {
// the fms may add .mp4 to the end of the url
$streamer = "rtmp";
}
// grab seek_from_bytes parameter and normalize url
$seek_from_bytes = $this->getRequestParameter("seek_from_bytes", -1);
$request = str_replace("/seek_from_bytes/{$seek_from_bytes}", "", $request);
if ($seek_from_bytes <= 0) {
$seek_from_bytes = -1;
}
// grab seek_from parameter and normalize url
$seek_from = $this->getRequestParameter("seek_from", -1);
$request = str_replace("/seek_from/{$seek_from}", "", $request);
if ($seek_from <= 0) {
$seek_from = -1;
}
$this->dump_from_byte = 0;
// reset accurate seek from timestamp
$seek_from_timestamp = -1;
// backward compatibility
if ($flavor === "0") {
// for edit version
$flavor = "edit";
}
if ($flavor === "1" || $flavor === 1) {
// for play version
$flavor = null;
}
// when flavor is null, we will get a default flavor
if ($flavor == "edit") {
$flavorAsset = assetPeer::retrieveBestEditByEntryId($entry->getId());
} elseif (!is_null($flavor)) {
$flavorAsset = assetPeer::retrieveById($flavor);
// when specific asset was request, we don't validate its tags
if ($flavorAsset && ($flavorAsset->getEntryId() != $entry->getId() || $flavorAsset->getStatus() != flavorAsset::FLAVOR_ASSET_STATUS_READY)) {
$flavorAsset = null;
}
// we will throw an error later
} elseif (is_null($flavor) && !is_null($flavor_param_id)) {
$flavorAsset = assetPeer::retrieveByEntryIdAndParams($entry->getId(), $flavor_param_id);
if ($flavorAsset && $flavorAsset->getStatus() != flavorAsset::FLAVOR_ASSET_STATUS_READY) {
$flavorAsset = null;
}
// we will throw an error later
} else {
if ($entry->getSource() == entry::ENTRY_MEDIA_SOURCE_WEBCAM) {
$flavorAsset = assetPeer::retrieveOriginalByEntryId($entry->getId());
} else {
$flavorAsset = assetPeer::retrieveBestPlayByEntryId($entry->getId());
}
if (!$flavorAsset) {
$flavorAssets = assetPeer::retrieveReadyFlavorsByEntryIdAndTag($entry->getId(), flavorParams::TAG_WEB);
if (count($flavorAssets) > 0) {
$flavorAsset = $flavorAssets[0];
}
}
}
if (is_null($flavorAsset)) {
KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
}
$syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
if (kFileSyncUtils::file_exists($syncKey, false)) {
$path = kFileSyncUtils::getReadyLocalFilePathForKey($syncKey);