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 outPutItem($wikiTitle, $desc_html = '')
    {
        global $wgOut, $wgUser;
        $sk = $wgUser->getSkin();
        $mvTitle = new MV_Title($wikiTitle);
        $mStreamTitle = Title::makeTitle(MV_NS_STREAM, ucfirst($mvTitle->getStreamName()) . '/' . $mvTitle->getTimeRequest());
        // only output media RSS item if its valid media:
        if (!$mvTitle->doesStreamExist()) {
            return;
        }
        // @@todo this should be cached
        $thumb_ref = $mvTitle->getFullStreamImageURL('320x240', null, '', true);
        if ($desc_html == '') {
            $article = new Article($wikiTitle);
            $wgOut->clearHTML();
            $wgOut->addWikiText($article->getContent());
            $desc_html = $wgOut->getHTML();
            $wgOut->clearHTML();
        }
        //get the parent meta if allowed:
        global $mvGetParentMeta;
        $pmvd = false;
        if ($mvGetParentMeta && strtolower($mvTitle->getMvdTypeKey()) == 'ht_en') {
            $pmvd = MV_Index::getParentAnnotativeLayers($mvTitle);
            if ($pmvd->wiki_title) {
                $pMvTitle = new MV_Title($pmvd->wiki_title);
                $pAnnoStreamTitle = Title::MakeTitle(MV_NS_STREAM, $pMvTitle->getNearStreamName(0));
            }
        }
        $desc_xml = '<![CDATA[
			<center class="mv_rss_view_only">
				<a href="' . htmlspecialchars($mStreamTitle->getFullUrl()) . '"><img src="' . $thumb_ref . '" border="0" /></a>
			</center>
			<br />' . $desc_html . ']]>';
        $stream_url = $mvTitle->getWebStreamURL();
        $talkpage = $wikiTitle->getTalkPage();
        $type_desc = $mvTitle->getMvdTypeKey() ? wfMsg($mvTitle->getMvdTypeKey()) : '';
        $time_desc = $mvTitle->getTimeDesc() ? $mvTitle->getTimeDesc() : '';
        ?>
<item>
<link>
		<?php 
        echo mvRSSFeed::xmlEncode($mStreamTitle->getFullUrl());
        ?>
</link>
<title><?php 
        echo mvRSSFeed::xmlEncode($mvTitle->getStreamNameText() . ' ' . $time_desc);
        ?>
</title>
<description>
<?php 
        echo $desc_xml;
        ?>
</description>
<?php 
        global $mvDefaultVideoQualityKey, $mvVidQualityMsgKeyType, $mvDefaultVideoHighQualityKey, $mvDefaultFlashQualityKey;
        //check a few different types in order of prefrence:
        if ($stream_url = $mvTitle->getWebStreamURL($mvDefaultVideoHighQualityKey)) {
            $mk = $mvDefaultVideoHighQualityKey;
        } elseif ($stream_url = $mvTitle->getWebStreamURL($mvDefaultVideoQualityKey)) {
            $mk = $mvDefaultVideoQualityKey;
        } elseif ($stream_url = $mvTitle->getWebStreamURL($mvDefaultFlashQualityKey)) {
            $mk = $mvDefaultFlashQualityKey;
        }
        if ($stream_url) {
            echo '<enclosure name="' . wfMsg($mk) . '" type="video/ogg" ' . 'url="' . mvRSSFeed::xmlEncode($stream_url) . '"/>';
        }
        ?>

<comments>
<?php 
        echo mvRSSFeed::xmlEncode($talkpage->getFullUrl());
        ?>
</comments>
<?php 
        $person = '';
        if ($pmvd && $pmvd->Speech_by) {
            $personTitle = Title::newFromText($pmvd->Speech_by);
            ?>
<media:person label="<?php 
            echo $personTitle->getText();
            ?>
" url="<?php 
            echo mvRSSFeed::xmlEncode($personTitle->getFullURL());
            ?>
" />
<?php 
        }
        //handle any parent clip tag info:
        if ($pmvd) {
            ?>
<media:parent_clip url="<?php 
            echo mvRSSFeed::xmlEncode($pAnnoStreamTitle->getFullUrl());
            ?>
" />
<?php 
            if ($pmvd->Bill) {
                $bTitle = Title::newFromText($pmvd->Bill);
                ?>
<media:bill label="<?php 
                echo $bTitle->getText();
                ?>
" url="<?php 
                echo mvRSSFeed::xmlEncode($bTitle->getFullURL());
                ?>
" />
<?php 
            }
            if ($pmvd->category) {
                foreach ($pmvd->category as $cat_titlekey) {
                    $cTitle = $cTitle = Title::MakeTitle(NS_CATEGORY, $cat_titlekey);
                    ?>
<media:category label="<?php 
                    echo $cTitle->getText();
                    ?>
" url="<?php 
                    echo mvRSSFeed::xmlEncode($cTitle->getFullUrl());
                    ?>
" />
<?php 
                }
            }
        }
        ?>
<media:thumbnail
	url="<?php 
        echo mvRSSFeed::xmlEncode($thumb_ref);
        ?>
" />
<media:roe_embed
	url="<?php 
        echo mvRSSFeed::xmlEncode($mvTitle->getROEURL());
        ?>
" />
<media:group>
<?php 
        global $mvDefaultFlashQualityKey, $mvVidQualityMsgKeyType, $mvDefaultFlashQualityKey;
        //add in media group:
        $vid_types = array($mvDefaultVideoQualityKey, 'mv_ogg_high_quality', $mvDefaultFlashQualityKey);
        foreach ($vid_types as $vid_key) {
            $stream_url = $mvTitle->getWebStreamURL($vid_key);
            if ($stream_url !== false && isset($mvVidQualityMsgKeyType[$vid_key])) {
                ?>
	<media:content
		blip:role="<?php 
                echo mvRSSFeed::xmlEncode($vid_key);
                ?>
"
		expression="full"
		type="<?php 
                echo mvRSSFeed::xmlEncode($mvVidQualityMsgKeyType[$vid_key]);
                ?>
"
		url="<?php 
                echo htmlentities($stream_url);
                ?>
"></media:content>
		<?php 
            }
        }
        ?>
</media:group>
</item>
<?
	}
 function parsePlaylist()
 {
     global $wgParser, $wgOut;
     //valid playlist in-line-attributes:
     $mvInlineAttr = array('wClip', 'mvClip', 'title', 'linkback', 'desc', 'desc', 'image');
     //build a associative array of "clips"
     $seq_text = $this->getSequenceText();
     $seq_lines = explode("\n", $seq_text);
     $parseBucket = $cur_attr = '';
     $clip_inx = -1;
     foreach ($seq_lines as $line) {
         //actions start with |
         $e = strpos($line, '=');
         if ($e !== false) {
             $cur_attr = substr($line, 1, $e - 1);
         }
         if (in_array($cur_attr, $mvInlineAttr)) {
             if ($cur_attr == 'mvClip') {
                 $clip_inx++;
             }
             //close the parse bucket (found a valid inline attr)
             if ($parseBucket != '' && $cur_attr != 'desc') {
                 $output = $wgParser->parse($parseBucket, $parser->mTitle, $parser->mOptions, true, false);
                 $parseBucket = '';
             }
         }
         $start_pos = $e !== false ? $e + 1 : 0;
         if ($clip_inx != -1) {
             if (!isset($this->clips[$clip_inx])) {
                 $this->clips[$clip_inx] = array();
             }
             if (!isset($this->clips[$clip_inx][$cur_attr])) {
                 $this->clips[$clip_inx][$cur_attr] = '';
             }
             $this->clips[$clip_inx][$cur_attr] .= substr($line, $start_pos);
         }
     }
     //poluate data (this could go here or somewhere else)
     foreach ($this->clips as $inx => &$clip) {
         if (trim($clip['mvClip']) == '') {
             unset($this->clips[$inx]);
             continue;
         }
         if ($clip['mvClip']) {
             $sn = str_replace('?t=', '/', $clip['mvClip']);
             $streamTitle = new MV_Title($sn);
             $wgStreamTitle = Title::newFromText($sn, MV_NS_STREAM);
             if ($streamTitle->doesStreamExist()) {
                 //mvClip is a substitue for src so assume its there:
                 $clip['src'] = $streamTitle->getWebStreamURL();
                 //title
                 if (!isset($clip['title'])) {
                     $clip['title'] = '';
                 }
                 if ($clip['title'] == '') {
                     $clip['title'] = $streamTitle->getTitleDesc();
                 }
                 if (!isset($clip['info'])) {
                     $clip['info'] = '';
                 }
                 if ($clip['info'] == '') {
                     $clip['info'] = $wgStreamTitle->getFullURL();
                 }
             }
             //check if we should look up the image:
             if (!isset($clip['image'])) {
                 $clip['image'] == '';
             }
             if ($clip['image'] == '') {
                 $clip['image'] = $streamTitle->getFullStreamImageURL();
             }
             //check if desc was present:
             if (!isset($clip['desc'])) {
                 $clip['desc'] = '';
             }
             //for now just lookup all ... @@todo future expose diffrent language tracks
             if ($clip['desc'] == '') {
                 $dbr =& wfGetDB(DB_SLAVE);
                 $mvd_res = MV_Index::getMVDInRange($streamTitle->getStreamId(), $streamTitle->getStartTimeSeconds(), $streamTitle->getEndTimeSeconds());
                 if (count($dbr->numRows($mvd_res)) != 0) {
                     $MV_Overlay = new MV_Overlay();
                     $wgOut->clearHTML();
                     while ($mvd = $dbr->fetchObject($mvd_res)) {
                         //output a link /line break
                         $MV_Overlay->outputMVD($mvd);
                         $wgOut->addHTML('<br>');
                     }
                     $clip['desc'] = $wgOut->getHTML();
                     $wgOut->clearHTML();
                 }
             }
         }
     }
     //print_r($this->clips);
 }