{=include-block:Y_Blocks.txt;head=}
<script type="text/javascript" src="/Y_Baselib.js"></script>
<script type="text/javascript" src="/prototype.js"></script>
<script type="text/javascript">
//<![CDATA[
/*0=normal, 1=record*/
var isRecord=false;
function setControls(state)
{
	switch(state)	{
		case 1:
			$('record_filename','tdisplay', 'transon').invoke('disable');
			break;

		default:
			$('record_filename','tdisplay', 'transon').invoke('enable');
			break;
	}
}
/*0=custom, 1=off*/
function setControlsCustom(state)
{
	switch(state){
		case 1:
		{=if-equal:{=mode=}~tv~
			$('twidth','theight', 'vcodec', 'vb', 'scale').invoke('disable');
		=}
			$('acodec','ab', 'channels', 'tmux').invoke('disable');
			break;

		default:
		{=if-equal:{=mode=}~tv~
			$('twidth','theight', 'vcodec', 'vb', 'scale').invoke('enable');
		=}
			$('acodec','ab', 'channels', 'tmux').invoke('enable');
			break;
	}
}
function on_profile_change()
{
	if($F('profile') == "custom")
		setControlsCustom(0);
	else
		setControlsCustom(1);
}
function on_transon_change()
{
	if($('transon').checked){
		$('profile').enable();
		on_profile_change();
	}
	else	{
		$('profile').disable();
		setControlsCustom(1);
	}
}
function doRecord()
{
	var _live = parent.live;
	if(!isRecord)
	{
		var transcode = "";
		var stream = "";
		if($('transon').checked)
		{
			switch($F('profile'))
			{
				case "custom":
					transcode = "transcode{"+
	{=if-equal:{=mode=}~tv~
					"width="	+$F('twidth')+
					",height="	+$F('theight')+
					",vcodec="	+$F('vcodec')+
					",vb="		+$F('vb')+
					",scale="	+$F('scale')+
					","+
	=}
					"acodec="	+$F('acodec')+
					",ab="		+$F('ab')+
					",channels="	+$F('channels')+
					",deinterlace}:";
					break;

				case "ipod":
					transcode = "transcode{width=320,height=240,vcodec=mp4v,vb=768,acodec=mp4a,ab=128}:";
					break;

				case "divx3":
					transcode = "transcode{vcodec=DIV3,vb=1024,scale=1,acodec=mp3,ab=192,channels=2}:";
					break;

				case "mp3":
					transcode = "transcode{acodec=mp3,ab=192}:";
					break;

				case "ipoda":
					transcode = "transcode{acodec=mp4a,ab=192}:";
					break;
			}
		}
		switch($F('profile'))
		{
			case "mp3":
				stream = "dst=std{"+
				"access=file"+
				",mux=raw"+
				",url=\""+$F('record_filename')+"\""+
				"}";
				break;

			case "mp4":
				stream = "dst=std{"+
				"access=file"+
				",mux=mp4"+
				",url=\""+$F('record_filename')+"\""+
				"}";
				break;

			case "divx3":
				stream = "dst=std{"+
				"access=file"+
				",mux=asf"+
				",url=\""+$F('record_filename')+"\""+
				"}";
				break;

			default:
				stream = "dst=std{"+
				"access=file"+
				",mux="+$F('tmux')+
				",url=\""+$F('record_filename')+"\""+
				"}";
				break;
		}
		if($('tdisplay').checked)
			stream = stream+",dst=display";

		var __vlc_cmd = ":sout=#"+transcode+"duplicate{"+stream+"}";
		setControls(1);
		_live.do_play_bystring(__vlc_cmd);
	}
	else
	{
		setControls(0);
		_live.do_play();
	}
	isRecord=!isRecord;
	$('record').update( (isRecord)? "{=L:live.rec.stop_record=}": "{=L:live.rec.record=}");
}
//]]>
</script>
</head>
<body>
	<form id="v" class="y_form" action="" method="get">
		<table cellspacing="0" width="100%">
		<tr><td class="y_form_header" colspan="4">{=L:live.rec.record_mode=}</td></tr>
		<tr>
			<td>{=L:live.rec.filename=}:</td>
			<td colspan="3"><input type="text" id="record_filename" value="{=ini-get:%(CONFIGDIR)/Y-Web.conf;vlc_record_path=}"/></td>
		</tr>
		<tr>
			<td colspan="4">
				<input type="checkbox" id="tdisplay" value="1" title="Display on while transcoding" checked="checked"/>{=L:live.rec.display_on=}&nbsp;
				<input type="checkbox" id="transon" value="1" title="use transcoding" onclick="on_transon_change()"/>{=L:live.rec.transcoding_on=}
			</td>
		</tr>
		<tr>
			<td colspan="4">
			<br/>
				<button class="y_live_button" type="button" value="Record" title="record stream to file" onclick="doRecord()">
					<img src="/images/record.png"/>&nbsp;<span id="record">{=L:live.rec.record=}</span></button>
			</td>
		</tr>
		<tr><td class="y_form_header" colspan="4"><br/>{=L:live.rec.tanscode=}</td></tr>
		<tr>
			<td>{=L:live.rec.profile=}:</td>
			<td colspan="3">
				<select id="profile" class="y_live_button" onchange="on_profile_change()">
	{=if-equal:{=mode=}~tv~
				<option value="ipod" selected="selected">iPod Video</option>
				<option value="divx3">DivX</option>
	=}
				<option value="custom">custom</option>
				<option value="ipoda">iPod Audio</option>
				<option value="mp3">mp3 Audio</option>
				</select>
			</td>
		</tr>
	{=if-equal:{=mode=}~tv~
		<tr><td class="y_form_section"><br/>{=L:live.rec.video=}</td><td class="y_form_section" colspan="3">&nbsp;</td></tr>
		<tr>
			<td>{=L:live.rec.width=}:</td>
			<td><input type="text" id="twidth" size="4" value="720" class="y_live_button"/></td>
			<td>{=L:live.rec.height=}:</td>
			<td><input type="text" id="theight" size="4" value="576" class="y_live_button"/></td>
		</tr>
		<tr>
			<td>{=L:live.rec.codec=}:</td>
			<td>
				<select id="vcodec" class="y_live_button">
				<option value="mp4v" selected="selected">mp4v</option>
				<option value="mp1v">mp1v</option>
				<option value="mp2v">mp2v</option>
				<option value="DIV3">DIV3</option>
				<option value="h264">h264</option>
				<option value="H263">h263</option>
				<option value="h264">h264</option>
				<option value="WMV1">WMV1</option>
				<option value="WMV1">WMV2</option>
				</select>
			</td>
			<td>{=L:live.rec.bitrate=}:</td>
			<td>
				<select id="vb" class="y_live_button">
				<option value="1024">1024</option>
				<option value="786">786</option>
				<option value="512">512</option>
				<option value="384" selected="selected">384</option>
				<option value="256">256</option>
				<option value="128">128</option>
				<option value="96">96</option>
				<option value="64">64</option>
				</select>
			</td>
		</tr>
		<tr>
			<td>{=L:live.rec.scale=}:</td>
			<td>
				<select id="scale" class="y_live_button">
				<option value="0.25">0.25</option>
				<option value="0.50">0.50</option>
				<option value="0.75">0.75</option>
				<option value="1.00" selected="selected">1.00</option>
				<option value="1.25">1.25</option>
				<option value="1.50">1.50</option>
				<option value="1.75">1.75</option>
				<option value="2.00">2.00</option>
				</select>
			</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
		</tr>
	=}
		<tr><td class="y_form_section">{=L:live.rec.audio=}</td><td class="y_form_section" colspan="3">&nbsp;</td></tr>
		<tr>
			<td>{=L:live.rec.codec=}:</td>
			<td>
				<select id="acodec" class="y_live_button">
				<option value="mp4a" selected="selected">mp4a</option>
				<option value="mp3">mp3</option>
				<option value="mp2a">mp2a</option>
				<option value="a52">a52</option>
				<option value="vorb">vorb</option>
				<option value="flac">flac</option>
				<option value="fl32">fl32</option>
				</select>
			</td>
			<td>{=L:live.rec.bitrate=}:</td>
			<td>
				<select id="ab" class="y_live_button">
				<option value="192">192</option>
				<option value="128">128</option>
				<option value="96">96</option>
				<option value="64">64</option>
				<option value="32" selected="selected">32</option>
				<option value="16">16</option>
				</select>
			</td>
		</tr>
		<tr>
			<td>{=L:live.rec.channels=}:</td>
			<td>
				<select id="channels" class="y_live_button">
				<option value="1">1</option>
				<option value="2 selected="selected"">2</option>
				<option value="6">6</option>
				</select>
			</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
		</tr>
		<tr><td class="y_form_section">Mux</td><td class="y_form_section" colspan="3">&nbsp;</td></tr>
		<tr>
			<td>Mux:</td>
			<td>
				<select id="tmux" class="y_live_button">
	{=if-equal:{=mode=}~tv~
				<option value="ts" selected="selected">ts</option>
				<option value="ps">ps</option>
				<option value="mp4">mp4</option>
				<option value="mov">mov</option>
				<option value="ogg">ogg</option>
				<option value="asf">asf</option>
				<option value="mpeg1">mpeg1</option>
				<option value="wav">wav</option>
	~
				<option value="raw" selected>raw</option>
				<option value="mp4">mp4</option>
				<option value="ogg">ogg</option>
	=}
				</select>
			</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
		</tr>
		</table>
	</form>
<script type="text/javascript">
//<![CDATA[
	on_transon_change();
//]]>
</script>
</body>
</html>
