function get_stream_cmml($inline=false, $force_track=null){ $dbr =& wfGetDB(DB_SLAVE); //set cmml name space if inline: $ns = ($inline)?'cmml:':''; $ns=''; $encap=false;//if we should have a parent cmml tag if(!$force_track){ //check the request to get trac set: $mvcp = new MV_Component(); $mvcp->procMVDReqSet(); $tracks = $mvcp->mvd_tracks; if(count($mvcp->mvd_tracks)>1)$encap=true; }else{ $tracks = $force_track; $encap=false; } //get the stream title $streamTitle = new MV_Title($this->stream_name.'/'.$this->req_time); $wgTitle = Title::newFromText($this->stream_name.'/'.$this->req_time, MV_NS_STREAM); //do mvd_index query: $mvd_res = MV_Index::getMVDInRange($streamTitle->getStreamId(), $streamTitle->getStartTimeSeconds(), $streamTitle->getEndTimeSeconds(), $tracks); //get the stream stream req if(!$inline)header('Content-Type: text/xml'); //print the header: if(!$inline)print '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'."\n"; //if(!$inline)print '<!DOCTYPE cmml SYSTEM "http://svn.annodex.net/standards/cmml_2_0.dtd">'."\n"; $tracks=array(); if(count($dbr->numRows($mvd_res))!=0){ global $wgOut; $MV_Overlay = new MV_Overlay(); while($mvd = $dbr->fetchObject($mvd_res)){ if(!isset($tracks[$mvd->mvd_type]))$tracks[$mvd->mvd_type]=''; $tracks[$mvd->mvd_type].=' <'.$ns.'clip id="mvd_'.$mvd->id.'" start="ntp:'.seconds2ntp($mvd->start_time).'" end="ntp:'.seconds2ntp($mvd->end_time).'"> <'.$ns.'img src="'.htmlentities($streamTitle->getFullStreamImageURL(null, seconds2ntp($mvd->start_time))).'"/> <'.$ns.'body><![CDATA[ '. $MV_Overlay->getMVDhtml($mvd, $absolute_links=true).' ]]></'.$ns.'body> </'.$ns.'clip>'; //clear wgOutput } } if($encap)print '<cmml_set>'; //based on: http://trac.annodex.net/wiki/CmmlChanges foreach($tracks as $role=>$body_string){ ?> <cmml lang="en" id="<?=$role?>" role="<?=wfMsg($role)?>" xmlns="http://svn.annodex.net/standards/cmml_2_0.dtd"> <<?=$ns?>head> <<?=$ns?>title><?=wfMsg($role)?></<?=$ns?>title> <<?=$ns?>description><?=htmlentities(wfMsg($role.'_desc'))?></<?=$ns?>description> </<?=$ns?>head> <?=$body_string?> </cmml> <? } if($encap)print '</cmml_set>'; }
function generate($take_duration) { global $mvgIP; require_once $mvgIP . '/includes/MV_Index.php'; $s = MV_Stream::newStreamByName($this->name); if (!$s->db_load_stream()) { return "An error occured while loading stream info please notify Administrator"; } $stream_duration = $s->getDuration(); if ($stream_duration === NULL) { return "Error: Stream Duration not set"; } $sitting_id = $s->getSittingId(); $editors = $this->getAssignedEditors($sitting_id); $readers = $this->getAssignedReaders($sitting_id); $reporters = $this->getAssignedReporters($sitting_id); $editors_count = count($editors); $readers_count = count($readers); $reporters_count = count($reporters); $html = ''; if ($editors_count == 0) { $html .= "No Editors Assigned"; return $html; } if ($readers_count == 0) { $html .= "No Readers Assigned"; return $html; } if ($reporters_count == 0) { $html .= "No Reporters Assigned"; return $html; } //delete all existing take transcripts $dbr =& wfGetDB(DB_SLAVE); $result =& MV_Index::getMVDInRange($s->getStreamId(), 0, $s->getDuration(), $this->mvd_tracks); while ($row = $dbr->fetchObject($result)) { $title = Title::newFromText($row->wiki_title, MV_NS_MVD); $art = new Article($title); if ($art->exists()) { $art->doDelete("new takes generated", true); } } $num_editor = 0; $num_reader = 0; $num_reporter = 0; for ($i = 0; $i < $stream_duration; $i = $i + $take_duration) { $start_time = $i; $end_time = $i + $take_duration; $title_text = 'Take_en:' . $this->name . '/' . seconds2ntp($start_time) . '/' . seconds2ntp($end_time); $title = Title::newFromText($title_text, MV_NS_MVD); $editor = User::newFromId($editors[$num_editor]); $editor_name = $editor->getRealName(); $reader = User::newFromId($readers[$num_editor]); $reader_name = $reader->getRealName(); $reporter = User::newFromId($reporters[$num_editor]); $reporter_name = $reporter->getRealName(); $article = new Article($title); $text = '[[Edited By::' . $editor_name . ']], ' . '[[Read By::' . $reader_name . ']], ' . '[[Reported By::' . $reporter_name . ']], ' . '[[Status::Incomplete]]'; $article->doEdit($text, 'Automatically Generated', EDIT_NEW); if ($num_editor < $editors_count - 1) { $num_editor++; } else { $num_editor = 0; } if ($num_reader < $readers_count - 1) { $num_reader++; } else { $num_reader = 0; } if ($num_reporter < $reporters_count - 1) { $num_reporter++; } else { $num_reporter = 0; } } $html .= 'Takes Successfully Generated'; return $html; }
function stream_paging_links($return_set = 'both') { global $wgUser, $mvDefaultStreamViewLength, $mvgScriptPath; $sk = $wgUser->getSkin(); $prev_link = $next_link = ''; //check if their is prev available: $mvTitle = $this->mv_interface->article->mvTitle; if ($return_set == 'both' || $return_set == 'prev') { if ($mvTitle->getStartTimeSeconds() > 0) { $prev_time_start = $mvTitle->getStartTimeSeconds() - $mvDefaultStreamViewLength; if ($prev_time_start < 0) { $prev_time_start = 0; } $prev_time_end = $mvTitle->getEndTimeSeconds() - $mvDefaultStreamViewLength; if ($prev_time_end < $mvDefaultStreamViewLength) { $prev_time_end = $mvDefaultStreamViewLength; } $newTitle = Title::MakeTitle(MV_NS_STREAM, $mvTitle->getStreamName() . '/' . seconds2ntp($prev_time_start) . '/' . seconds2ntp($prev_time_end)); $prev_link = $sk->makeKnownLinkObj($newTitle, '<img style="index:5" border="0" src="' . $mvgScriptPath . '/skins/images/results_previous.png">', $this->getStateReq()); } } if ($return_set == 'both' || $return_set == 'next') { if ($mvTitle->getDuration() != $mvTitle->getEndTimeSeconds()) { $next_time_start = $mvTitle->getStartTimeSeconds() + $mvDefaultStreamViewLength; if ($next_time_start > $mvTitle->getDuration() - $mvDefaultStreamViewLength) { $next_time_start = $mvTitle->getDuration() - $mvDefaultStreamViewLength; } $next_time_end = $mvTitle->getEndTimeSeconds() + $mvDefaultStreamViewLength; if ($next_time_end > $mvTitle->getDuration()) { $next_time_end = $mvTitle->getDuration(); } $newTitle = Title::MakeTitle(MV_NS_STREAM, $mvTitle->getStreamName() . '/' . seconds2ntp($next_time_start) . '/' . seconds2ntp($next_time_end)); $next_link = $sk->makeKnownLinkObj($newTitle, '<img style="index:5" border="0" src="' . $mvgScriptPath . '/skins/images/results_next.png">', $this->getStateReq()); } } if ($return_set == 'both') { return $prev_link . ' ' . $next_link; } if ($return_set == 'prev') { return $prev_link; } if ($return_set == 'next') { return $next_link; } }
function getNearStreamName($range = '', $length = '') { global $mvDefaultClipLength, $mvDefaultClipRange; $stream =& mvGetMVStream($this->stream_name); if ($range == '') { $range = $mvDefaultClipRange; } if ($length == '') { $length = $mvDefaultClipLength; } //subtract $range seconds from the start time: $start_t = $this->getStartTimeSeconds() - $range; if ($start_t < 0) { $start_t = 0; } $start_ntp = seconds2ntp($start_t); //add $range seconds to the end time: if (isset($this->end_time)) { $end_t = $this->getEndTimeSeconds() + $range; if ($end_t > $stream->getDuration()) { $end_t = $stream->getDuration(); } $end_ntp = '/' . seconds2ntp($this->getEndTimeSeconds() + $range); } else { //make the end time the default Clip length $end_ntp = '/' . seconds2ntp($this->getStartTimeSeconds() + $length + $range); } return $this->stream_name . '/' . $start_ntp . $end_ntp; }
function setupStreamView() { global $mvgIP, $mvDefaultStreamViewLength, $wgOut, $mvgScriptPath, $wgUser, $mvSittingsTable, $wgSkin; //set default time range if null time range request $this->article->mvTitle->setStartEndIfEmpty(); //grab relevent article semantic properties (so far playback_resolution) for user overwriting playback res $this->grabSemanticProp(); //set up the interface objects: foreach (array('MV_VideoPlayer', 'MV_Overlay', 'MV_Tools') as $cp_name) { $this->components[$cp_name] = new $cp_name(array('mv_interface' => &$this)); } //process track request: $this->components['MV_Overlay']->procMVDReqSet(); //add in title & tracks var: $wgOut->addScript('<script type="text/javascript">/*<![CDATA[*/' . " \t\t\n \t\tvar mvTitle = '{$this->article->mvTitle->getWikiTitle()}'; \n \t\tvar mvTracks = '" . $this->components['MV_Overlay']->getMVDReqString() . '\'; /*]]>*/</script>' . "\n"); //undesa $dbr =& wfGetDB(DB_SLAVE); $id = $this->article->mvTitle->getSittingId(); $result = $dbr->select($dbr->tableName($mvSittingsTable), '*', array('id' => $id)); $row = $dbr->fetchObject($result); $tit = Title::makeTitle(MV_NS_SITTING, $row->name); $text = $tit->getText(); $rlink = '<a href="' . $tit->getFullURL() . '">' . '<b>Sitting: ' . $text . '</a> ->Stream: </b>'; //undesa $this->page_header = $rlink; //also add prev next paging $this->page_header .= '<span class="mv_stream_title">' . $this->article->mvTitle->getStreamNameText() . $this->components['MV_Tools']->stream_paging_links('prev') . ' <span id="mv_stream_time">' . $this->article->mvTitle->getTimeDesc() . '</span>' . $this->components['MV_Tools']->stream_paging_links('next') . wfMsg('mv_of') . seconds2ntp($this->article->mvTitle->getDuration()) . '</span>'; //add export cmml icon $this->page_header .= '<span id="cmml_link"/>'; $sTitle = Title::makeTitle(NS_SPECIAL, 'MvExportStream'); $sk = $wgUser->getSkin(); $this->page_header .= $sk->makeKnownLinkObj($sTitle, '<img style="width:28px;height:28px;" src="' . $mvgScriptPath . '/skins/images/Feed-icon_cmml_28x28.png">', 'feed_format=roe&stream_name=' . $this->article->mvTitle->getStreamName() . '&t=' . $this->article->mvTitle->getTimeRequest(), '', '', 'title="' . wfMsg('mv_export_cmml') . '"'); $this->page_header .= '</span><div id="sitting_id" style="display:none;">' . $id . '</div>'; $this->page_title = $this->article->mvTitle->getStreamNameText() . ' ' . $this->article->mvTitle->getTimeDesc(); }
function do_edit_submit($titleKey, $mvd_id, $returnEncapsulated = false) { global $wgOut, $wgScriptPath, $wgUser, $wgTitle, $wgRequest; if ($mvd_id == 'new') { $titleKey = substr($_REQUEST['title'], 0, strpos($_REQUEST['title'], '/')) . '/' . $_REQUEST['mv_start_hr_new'] . '/' . $_REQUEST['mv_end_hr_new']; $pos2 = strpos($_REQUEST['title'], '/'); $pos1 = strpos($_REQUEST['title'], ':'); //$nameKey ='mp_names'.substr($_REQUEST['title'],$pos1,$pos2).$_REQUEST['mv_start_hr_new'].'/'.$_REQUEST['mv_end_hr_new']; $nameKey = 'mp_names:' . $_REQUEST['wgTitle'] . '/' . $_REQUEST['mv_start_hr_new'] . '/' . $_REQUEST['mv_end_hr_new']; } else { $nameKey = 'mp_names:' . $_REQUEST['wgTitle'] . '/' . $_REQUEST['mv_start_hr_' . $mvd_id] . '/' . $_REQUEST['mv_end_hr_' . $mvd_id]; } $type = substr($_REQUEST['title'], 0, strpos($_REQUEST['title'], ':')); //set up the title /article $wgTitle = Title::newFromText($titleKey, MV_NS_MVD); $Article = new Article($wgTitle); if ($type != 'Anno_en') { $tit = Title::newFromText($nameKey, MV_NS_MVD); $art = new Article($tit); if (!$art->exists()) { $art->doEdit($_REQUEST['smw_Spoken_By'], 'MP names DO NOT EDIT', EDIT_NEW); //$art->doPurge(); } else { $art->doEdit($_REQUEST['smw_Spoken_By'], 'MP names DO NOT EDIT', EDIT_UPDATE); //$art->doPurge(); } } //xxxx //add all semantic form based attributes/relations to the posted body text foreach ($_POST as $key => $val) { $do_swm_include = true; if (substr($key, 0, 4) == 'smw_') { //try attribute $swmTitle = Title::newFromText(substr($key, 4), SMW_NS_PROPERTY); if ($swmTitle->exists()) { //make sure the person is not empty: if (trim($val) != '') { //@@todo update for other smw types: //$wgRequest->data['wpTextbox1'] = trim($_REQUEST['wpTextbox1']); if ($key == 'smw_Spoken_By') { //update the request wpTextBox: $wgRequest->data['wpTextbox1'] .= "[[" . $swmTitle->getText() . ':=' . $val . ']]'; } else { if ($key == 'smw_Edited_By') { $user = User::newFromId($val); $user->addWatch($wgTitle); $wgRequest->data['wpTextbox1'] .= " [[" . $swmTitle->getText() . ':=' . $user->getRealName() . ']] '; } else { if ($key == 'smw_Read_By') { $user = User::newFromId($val); $user->addWatch($wgTitle); $wgRequest->data['wpTextbox1'] .= " [[" . $swmTitle->getText() . ':=' . $user->getRealName() . ']] '; } else { if ($key == 'smw_Reported_By') { $user = User::newFromId($val); $user->addWatch($wgTitle); $wgRequest->data['wpTextbox1'] .= " [[" . $swmTitle->getText() . ':=' . $user->getRealName() . ']] '; } else { if ($key == 'smw_Status') { $wgRequest->data['wpTextbox1'] .= " [[" . $swmTitle->getText() . ':=' . $val . ']] '; } } } } } } } } } /* global $reportersTable; if (isset($wgRequest->data['smw_Reported_By'])) { $name = $wgRequest->data['smw_Reported_By']; $sql = 'SELECT * FROM '.$reportersTable.' WHERE name="'.$name.'"'; $dbr =& wfGetDB(DB_SLAVE); $result = $dbr->query($sql); $row = $dbr->fetchObject($result); $number = $row->order_number; if ($row->next == 'next') { $dbw =& wfGetDB(DB_WRITE); $sql = 'UPDATE '.$reportersTable.' SET next="" WHERE name="'.$name.'"'; $result = $dbw->query($sql); $sql = 'SELECT * FROM '.$reportersTable.' WHERE order_number='."$number+1"; $result = $dbr->query($sql); $row = $dbr->numRows($result); if ($row > 0) { $sql = 'UPDATE '.$reportersTable.' SET next="next" WHERE order_number='."$number+1"; } else { $sql = 'UPDATE '.$reportersTable.' SET next="next" WHERE order_number=1'; } $result = $dbw->query($sql); } } */ $editPageAjax = new MV_EditPageAjax($Article); $editPageAjax->mvd_id = $mvd_id; //undesa global $mvgIP; $pages_start = array(); $pages_end = array(); $overlap = false; $start_hour = substr($_REQUEST['mv_start_hr_new'], 0, 1); $start_min = substr($_REQUEST['mv_start_hr_new'], 2, 2); $start_sec = substr($_REQUEST['mv_start_hr_new'], 5, 2); $start_time_in_sec = $start_hour * 3600 + $start_min * 60 + $start_sec; $end_hour = substr($_REQUEST['mv_end_hr_new'], 0, 1); $end_min = substr($_REQUEST['mv_end_hr_new'], 2, 2); $end_sec = substr($_REQUEST['mv_end_hr_new'], 5, 2); $end_time_in_sec = $end_hour * 3600 + $end_min * 60 + $end_sec; $streamTitle = new MV_Title($_REQUEST['title']); //$transcript_title = new MV_Title($titleKey); //$start = $transcript_title->getStartTimeSeconds(); //$end = $transcript_title->getEndTimeSeconds(); require_once $mvgIP . '/includes/MV_Index.php'; $dbr =& wfGetDB(DB_SLAVE); $result =& MV_Index::getMVDInRange($streamTitle->getStreamId(), $streamTitle->getStartTimeSeconds(), $streamTitle->getEndTimeSeconds(), 'Ht_en'); if ($dbr->numRows($result) == 0) { $pages_start = array(); $pages_end = array(); } else { while (($row = $dbr->fetchObject($result)) && $overlap == false) { $pages_start[$row->id] = $row->start_time; $pages_end[$row->id] = $row->end_time; if ($row->start_time <= $start_time_in_sec && $start_time_in_sec <= $row->end_time || $row->start_time <= $end_time_in_sec && $end_time_in_sec <= $row->end_time) { $overlap = true; } } } $val = $wgRequest->getVal('overlap'); if ($overlap == true && !isset($_POST['wpPreview']) && $val == 'no') { return "alert(\"The transcript you are trying to save" . $val . " overlaps with another\");" . $wgOut->getHTML(); } //undesa //if preview just return the parsed preview //@@todo refactor to use as much EditPage code as possible // use the "livePreview" functionality of Edit page. if (isset($_POST['wpPreview'])) { //$out = $editPageAjax->getPreviewText(); //$wgOut->addHTML($out); $mvTitle = new MV_Title($_REQUEST['title']); $parserOutput = $this->parse_format_text($wgRequest->data['wpTextbox1'], $mvTitle); $wgOut->addParserOutput($parserOutput); return $wgOut->getHTML() . '<div style="clear:both;"><hr></div>'; } if ($editPageAjax->edit($wgRequest->data['wpTextbox1']) == false) { if ($mvd_id == 'new') { //get context info to position timeline element: $rt = isset($_REQUEST['wgTitle']) ? $_REQUEST['wgTitle'] : null; $this->get_overlay_context_from_title($rt); //get updated mvd_id: $dbr =& wfGetDB(DB_SLAVE); $result =& MV_Index::getMVDbyTitle($titleKey, 'mv_page_id'); $mvd_id = $result->id; $result2 =& MV_Index::getMVDbyTitle($nameKey, 'mv_page_id'); //purge cache for parent stream MV_MVD::onEdit($this->mvd_pages, $mvd_id); //MV_MVD::onEdit($this->mvd_pages, $result2->id); //return Encapsulated (since its a new mvd) $returnEncapsulated = true; } else { //purge cache for parent stream MV_MVD::onEdit($this->mvd_pages, $mvd_id); } if ($returnEncapsulated) { if ($_REQUEST['saveandcreate'] == 'true') { $time_range = seconds2ntp($end_time_in_sec + 1) . '/' . seconds2ntp($end_time_in_sec + 600); $time_str = 'mv_disp_add_mvd("ht_en","' . $time_range . '")'; return php2jsObj(array('status' => 'ok', 'mvd_id' => $mvd_id, 'titleKey' => $titleKey, 'fd_mvd' => $this->get_fd_mvd_request($titleKey, $mvd_id, 'enclosed'), 'tl_mvd' => $this->get_tl_mvd_request($titleKey, $mvd_id), 'saveandcreate' => $time_str)); } else { return php2jsObj(array('status' => 'ok', 'mvd_id' => $mvd_id, 'titleKey' => $titleKey, 'fd_mvd' => $this->get_fd_mvd_request($titleKey, $mvd_id, 'enclosed'), 'tl_mvd' => $this->get_tl_mvd_request($titleKey, $mvd_id))); } } else { return $this->get_fd_mvd_request($titleKey, $mvd_id); } //return "page saved successfully?"; } else { //return "edit failed/ or preview? "; //$wgOut should have edit form with reported conflict, error or whatever return $wgOut->getHTML(); } }
function getHTMLResults() { global $mvgIP, $wgOut, $mvgScriptPath, $mvgContLang, $wgUser, $wgParser; //print_r($this->results); //for each stream range: $o = ''; //print_r($this->results ); require_once $mvgIP . '/includes/MV_Title.php'; require_once $mvgIP . '/includes/MV_MetavidInterface/MV_Overlay.php'; if (count($this->results) == 0) { return '<h3>' . wfMsg('mv_search_no_results') . '</h3>'; } foreach ($this->results as $stream_id => &$stream_set) { $matches = 0; $stream_out = $mvTitle = ''; $sk =& $wgUser->getSkin(); foreach ($stream_set as &$srange) { $cat_html = $mvd_out = ''; $range_match = 0; foreach ($srange['rows'] as &$mvd) { $matches++; if (isset($mvd->text)) { //@@todo parse category info if present //$cat_html = $mvd->text; //run via parser to add in Category info: $parserOptions = ParserOptions::newFromUser($wgUser); $parserOptions->setEditSection(false); $parserOptions->setTidy(true); $title = Title::MakeTitle(MV_NS_MVD, $mvd->wiki_title); $parserOutput = $wgParser->parse($mvd->text, $title, $parserOptions); $cats = $parserOutput->getCategories(); foreach ($cats as $catkey => $title_str) { $title = Title::MakeTitle(NS_CATEGORY, $catkey); $cat_html .= ' ' . $sk->makeKnownLinkObj($title, $catkey); } //add category pre-text: if ($cat_html != '') { $cat_html = wfMsg('Categories') . ':' . $cat_html; } //$wgOut->addCategoryLinks( $parserOutput->getCategories() ); //$cat_html = $sk->getCategories(); //empty out the categories //$wgOut->mCategoryLinks = array(); } $mvTitle = new MvTitle($mvd->wiki_title); //retive only the first article: //$title = Title::MakeTitle(MV_NS_MVD, $mvd->wiki_title); //$article = new Article($title); $bgcolor = MV_Overlay::getMvdBgColor($mvd); $mvd_out .= '<span style="background:#' . $bgcolor . '"> ' . $mvTitle->getTimeDesc() . ' </span>'; $mvd_out .= '<a title="' . wfMsg('mv_expand_play') . '" href="javascript:mv_ex(\'' . $mvd->id . '\')"><img id="mv_img_ex_' . $mvd->id . '" border="0" src="' . $mvgScriptPath . '/skins/images/closed.png"></a>' . ' '; //output control liniks: //make stream title link: $mvStreamTitle = Title::MakeTitle(MV_NS_STREAM, $mvTitle->getNearStreamName()); //$mvTitle->getStreamName() .'/'.$mvTitle->getStartTime() .'/'. $mvTitle->getEndTime() ); $mvd_out .= $sk->makeKnownLinkObj($mvStreamTitle, '<img border="0" src="' . $mvgScriptPath . '/skins/images/run_mv_stream.png">', '', '', '', '', ' title="' . wfMsg('mv_view_in_stream_interface') . '" '); //$title = MakeTitle::() $mvd_out .= ' '; $mvdTitle = Title::MakeTitle(MV_NS_MVD, $mvd->wiki_title); $mvd_out .= $sk->makeKnownLinkObj($mvdTitle, '<img border="0" src="' . $mvgScriptPath . '/skins/images/run_mediawiki.png">', '', '', '', '', ' title="' . wfMsg('mv_view_wiki_page') . '" '); $mvd_out .= '<div id="mvr_' . $mvd->id . '" style="display:none;background:#' . $bgcolor . ';" ></div>'; $mvd_out .= '<br>' . "\n"; } if (count($srange['rows']) != 1) { $stream_out .= ' ' . $cat_html . ' In range:' . seconds2ntp($srange['s']) . ' to ' . seconds2ntp($srange['e']) . wfMsg('mv_match_text', count($srange['rows'])) . '<br>' . "\n"; $stream_out .= $mvd_out; } else { $stream_out .= $mvd_out; } } $nsary = $mvgContLang->getNamespaceArray(); //output stream name and mach count /*$o.='<br><img class="mv_stream_play_button" name="'.$nsary[MV_NS_STREAM].':' . $mvTitle->getStreamName() . '" align="left" src="'.$mvgScriptPath.'/skins/mv_embed/images/vid_play_sm.png">'; */ $o .= '<h3>' . $mvTitle->getStreamNameText() . wfMsg('mv_match_text', $matches) . '</h3>'; $o .= '<div id="mv_stream_' . $stream_id . '">' . $stream_out . '</div>'; } return $o; }
function get_stream_info() { //@@todo recognize multiple streams //@@todo check cache (with name/file modification date) //( to pull meta data without reading the file) //get the stream size: $this->stream_size = filesize($this->file_name); //if not available in the cache compute: fseek($this->f, 0); //make sure we are the start of the file: $header = fread($this->f, 512); $this->magic = substr($header, 0, 4); //stream serial number: $this->serial = substr($header, 14, 4); //number of segments in the page $this->segments = ord($header[26]); $this->packet_length = 0; for ($i = 0; $i < $this->segments; $i++) { $this->packet_length += ord($header[27 + $i]); } $this->packet_magic = substr($header, 27 + $this->segments, 8); if (0 == strncmp($this->packet_magic, "vorbis", 7)) { $this->subtype = "audio/x-vorbis"; } elseif (0 == strncmp($this->packet_magic, "€theora", 7)) { $this->subtype = "video/x-theora"; } else { $this->subtype = "unknown"; } echo " type:<tt>" . $this->subtype . "</tt><br>"; if ($this->subtype == "audio/x-vorbis") { $this->channels = ord($header[27 + $this->segments + 11]); $this->rate = ord($header[27 + $this->segments + 15]); $this->rate = $this->rate << 8 | ord($header[27 + $this->segments + 14]); $this->rate = $this->rate << 8 | ord($header[27 + $this->segments + 13]); $this->rate = $this->rate << 8 | ord($header[27 + $this->segments + 12]); echo " " . $this->channels . " channel " . $this->rate . "Hz"; } elseif ($this->subtype == "video/x-theora") { //The width of the frame in macro blocks. 16 bits. $this->width = ord($header[27 + $this->segments + 14]); $this->width = $this->width << 8 | ord($header[27 + $this->segments + 15]); $this->width = $this->width << 8 | ord($header[27 + $this->segments + 16]); //The height of the frame in macro blocks. 16 bits. $this->height = ord($header[27 + $this->segments + 17]); $this->height = $this->height << 8 | ord($header[27 + $this->segments + 18]); $this->height = $this->height << 8 | ord($header[27 + $this->segments + 19]); //The frame-rate numerator. 32 bits. $this->fps_numerator = ord($header[27 + $this->segments + 22]); $this->fps_numerator = $this->fps_numerator << 8 | ord($header[27 + $this->segments + 23]); $this->fps_numerator = $this->fps_numerator << 8 | ord($header[27 + $this->segments + 24]); $this->fps_numerator = $this->fps_numerator << 8 | ord($header[27 + $this->segments + 25]); //The frame-rate denominator. 32 bits. $this->fps_denominator = ord($header[27 + $this->segments + 26]); $this->fps_denominator = $this->fps_denominator << 8 | ord($header[27 + $this->segments + 27]); $this->fps_denominator = $this->fps_denominator << 8 | ord($header[27 + $this->segments + 28]); $this->fps_denominator = $this->fps_denominator << 8 | ord($header[27 + $this->segments + 29]); /* (not currently used) //the pixel aspect-ratio numerator. 24 bits $parn = ord($header[27+$this->segments']+30]); $parn = ($parn << 8) | ord($header[27+$this->segments+31]); $parn = ($parn << 8) | ord($header[27+$this->segments+32]); //The pixel aspect-ratio denominator. 24 bits $pard = ord($header[27+$this->segments+33]); $pard = ($pard << 8) | ord($header[27+$this->segments+34]); $pard = ($pard << 8) | ord($header[27+$this->segments+35]); //The color space. 8 bits. $cs = ord($header[27+$this->segments+36]); //The pixel format. 2 bits.(skipped) //The nominal bitrate of the stream, in bits per second. 24 bits. $nombr=ord($header[27+$this->segments+37]); $nombr=($nombr << 8) | ord($header[27+$this->segments+38]); $nombr=($nombr << 8) | ord($header[27+$this->segments+39]); //The quality hint. 6 bits.</t> $qual = ord($header[27+$this->segments+40]); $qual = ($qual >> 2); //shave off the last two bits ? */ /* * The amount to shift the key frame number by in the granule position. 5 bits.</t> * (in oggz_auto.c) (we don't currently support theora < alpha3') keyframe_granule_shift = (char) ((header[40] & 0x03) << 3); keyframe_granule_shift |= (header[41] & 0xe0) >> 5; */ $this->kfgshfit = ord(($header[27 + $this->segments + 40] & 0x3) << 3); $this->kfgshfit = $this->kfgshfit | ord(($header[27 + $this->segments + 41] & 0xe0) >> 5); if ($this->fps_numerator == 0 || $this->fps_denominator == 0) { $this->rate = "unknown"; } else { $this->rate = $this->fps_numerator / $this->fps_denominator; } echo " " . $this->width . "x" . $this->height . "<br>"; echo " " . $this->rate . " fps <br>"; echo " serial: " . $this->serial . '<br>'; } echo " (" . $this->stream_size . " bytes)"; //now get the stream length (for educated page location guessing) print "stream length: " . $this->getStreamLength() . 's Or:' . seconds2ntp(floor($this->getStreamLength())); }
function do_proccess_images($stream, $force = false) { global $mvLocalImgLoc, $MVStreams, $wgDBname; $dbr =& wfGetDB(DB_SLAVE); $dbw =& wfGetDB(DB_MASTER); //get all images for the current stream: $sql = "SELECT * FROM `metavid`.`image_archive` \n\t\t\t\tWHERE `stream_fk`= {$stream->id}"; $image_res = $dbr->query($sql); $img_count = $dbr->numRows($image_res); print "Found " . $img_count . " images for stream " . $stream->name . "\n"; //grab from metavid and copy to local directory structure: $i = $j = 0; $mv_stream_id = $MVStreams[$stream->name]->getStreamId(); //if force we can clear out existing images: if ($force) { print "force update flag (remove all existing images)\n"; $local_img_dir = MV_StreamImage::getLocalImageDir($mv_stream_id); $res = $dbr->query("SELECT * FROM `{$wgDBname}`.`mv_stream_images` WHERE `stream_id`={$mv_stream_id}"); while ($row = $dbr->fetchObject($res)) { $local_img_file = $local_img_dir . '/' . $row->time . '*.jpg'; shell_exec('rm -f ' . $local_img_file); } //remove db entries: $dbw->query("DELETE FROM `{$wgDBname}`.`mv_stream_images` WHERE `stream_id`={$mv_stream_id}"); } while ($row = $dbr->fetchObject($image_res)) { //if(isset($row-> $relative_time = $row->time - $stream->adj_start_time; //status updates: if ($i == 10) { print "On image {$j} of {$img_count} time: " . seconds2ntp($relative_time) . " {$metavid_img_url}\n"; $i = 0; } $j++; $i++; //get streamImage obj: $local_img_dir = MV_StreamImage::getLocalImageDir($mv_stream_id); $metavid_img_url = 'http://metavid.ucsc.edu/image_media/' . $row->id . '.jpg'; $local_img_file = $local_img_dir . '/' . $relative_time . '.jpg'; //check if the image already exist in the new table $sql = "SELECT * FROM `{$wgDBname}`.`mv_stream_images` " . "WHERE `stream_id`={$mv_stream_id} " . "AND `time`={$relative_time}"; $img_check = $dbr->query($sql); $doInsert = true; if ($dbr->numRows($img_check) != 0) { //make sure its there and matches what it should be: if (is_file($local_img_file)) { $row = $dbr->fetchObject($img_check); //print "file $local_img_file skiped, stream_id:" . $mv_stream_id . " time: " . seconds2ntp($relative_time) . "\n"; continue; } else { //grab but don't insert: $doInsert = false; } } if ($doInsert) { //insert: $dbw->insert('mv_stream_images', array('stream_id' => $MVStreams[$stream->name]->getStreamId(), 'time' => $relative_time)); $img_id = $dbw->insertId(); //$grab = exec('cd ' . $img_path . '; wget ' . $im_url); } if (is_file($local_img_file)) { echo "skipped {$local_img_file} \n"; continue; } //print "run copy: $metavid_img_url, $local_img_file \n"; if (!copy($metavid_img_url, $local_img_file)) { echo "failed to copy {$metavid_img_url} to {$local_img_file}...\n"; } else { //all good don't report anything' //print "all good\n"; } } }