{=include-block:Y_Blocks.txt;head=}
<script type="text/javascript" src="/Y_Baselib.js"></script>
<script type="text/javascript">
//<![CDATA[
/*0=normal, 1=record*/
function setControls(state)
{
	switch(state)
	{
		case 1:
			document.v.record_filename.disabled=true;
			document.v.tdisplay.disabled=true;
			document.v.transon.disabled=true;
			break;
	
		default:
			document.v.record_filename.disabled=false;
			document.v.tdisplay.disabled=false;
			document.v.transon.disabled=false;
			break;
	}
}
/*0=custom, 1=off*/
function setControlsCustom(state)
{
	switch(state)
	{
		case 1:
		{=if-equal:{=mode=}~tv~
			document.v.twidth.disabled=true;
			document.v.theight.disabled=true;
			document.v.vcodec.disabled=true;
			document.v.vb.disabled=true;
			document.v.scale.disabled=true;
		=}
			document.v.acodec.disabled=true;
			document.v.ab.disabled=true;
			document.v.channels.disabled=true;
			document.v.tmux.disabled=true;
			break;

		default:
		{=if-equal:{=mode=}~tv~
			document.v.twidth.disabled=false;
			document.v.theight.disabled=false;
			document.v.vcodec.disabled=false;
			document.v.vb.disabled=false;
			document.v.scale.disabled=false;
		=}
			document.v.acodec.disabled=false;
			document.v.ab.disabled=false;
			document.v.channels.disabled=false;
			document.v.tmux.disabled=false;
			break;
	}
}
function on_profile_change()
{
	if(document.v.profile.value == "custom")
		setControlsCustom(0);
	else
		setControlsCustom(1);
}
function on_transon_change()
{
	if(document.v.transon.checked)
	{
		document.v.profile.disabled=false;
		on_profile_change();
	}
	else
	{
		document.v.profile.disabled=true;
		setControlsCustom(1);
	}
}
function doRecord()
{
	var _live = parent.live;
	if(document.v.record.value == "Record")
	{
		var transcode = "";
		var stream = "";
		if(document.v.transon.checked)
		{
			switch(document.v.profile.value)
			{
				case "custom":
					transcode = "transcode{"+
	{=if-equal:{=mode=}~tv~
					"width="	+document.v.twidth.value+
					",height="	+document.v.theight.value+
					",vcodec="	+document.v.vcodec.value+
					",vb="		+document.v.vb.value+
					",scale="	+document.v.scale.value+
					","+
	=}				
					"acodec="	+document.v.acodec.value+
					",ab="		+document.v.ab.value+
					",channels="	+document.v.channels.value+
					",deinterlace}:";
					break;

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

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

				case "ipoda":
					transcode = "transcode{acodec=mp4a,ab=192}:";
					break;
			}
		}
		switch(document.v.profile.value)
		{
			case "mp3":
				stream = "dst=std{"+
				"access=file"+
				",mux=raw"+
				",url="+document.v.record_filename.value+
				"}";
				break;

			case "mp4":
				stream = "dst=std{"+
				"access=file"+
				",mux=mp4"+
				",url="+document.v.record_filename.value+
				"}";
				break;

			default:
				stream = "dst=std{"+
				"access=file"+
				",mux="+document.v.tmux.value+
				",url="+document.v.record_filename.value+
				"}";
				break;
		}
		if(document.v.tdisplay.checked)
			stream = stream+",dst=display";

		var __vlc_cmd = ":sout=#"+transcode+"duplicate{"+stream+"}";
/*		var sel = document.v.tmux.selectedIndex;
		var ymux = (sel != -1) ? document.v.tmux[sel].value : "ts";
		var __vlc_cmd = ":sout=#duplicate{dst=display,dst=std{access=file,mux="+ymux+",url="+document.v.record_filename.value+"}}";
*/
		var options = new Array(__vlc_cmd,":input-repeat=1");
		document.v.record.value = "Stop Record";
		setControls(1);
		_live.do_play_state(1, options);
	}
	else
	{
		document.v.record.value = "Record";
		setControls(0);
		_live.do_play();
	}
}
//]]>
</script>
</head>
<body>
	<form name="v" action="" method="get">
		<table class="y_live_table" cellspacing="0" width="100%">
		<tr><td class="y_form_header" colspan="5">Record Mode</td></tr>
		<tr>
			<td>&nbsp;</td>
			<td>Filename:</td>
			<td colspan="3"><input type="text" name="record_filename" value="{=ini-get:/var/tuxbox/config/Y-Web.conf;vlc_record_path=}"/></td>
		</tr>
		<tr>
			<td>&nbsp;</td>
			<td colspan="4">
				<input type="checkbox" name="tdisplay" value="1" title="Display on while transcoding" checked="checked"/>Display on&nbsp;
				<input type="checkbox" name="transon" value="1" title="use transcoding" onclick="on_transon_change()"/>Transcoding on
			</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
			<td colspan="4">
			<br/>
				<button class="y_live_button" type="button" value="r" title="record stream to file" name="record" onclick="doRecord()">Record</button> 
			</td>
		</tr>
		<tr><td class="y_form_header" colspan="5"><br/>Record Transcode</td></tr>
		<tr>
			<td>&nbsp;</td>
			<td>Profile:</td>
			<td>
				<select name="profile" class="y_live_button" onchange="on_profile_change()">
	{=if-equal:{=mode=}~tv~
				<option value="ipod" selected>iPod Video</option>
	=}
				<option value="custom">custom</option>
				<option value="ipoda">iPod Audio</option>
				<option value="mp3">mp3 Audio</option>
				</select>
			</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
		</tr>
	{=if-equal:{=mode=}~tv~
		<tr><td class="y_form_section"><br/>Video</td><td class="y_form_section" colspan="4">&nbsp;</td></tr>
		<tr>
			<td>&nbsp;</td>
			<td>Breite:</td>
			<td><input type="text" name="twidth" size="4" value="384" class="y_live_button"/></td>
			<td>H&ouml;he:</td>
			<td><input type="text" name="theight" size="4" value="288" class="y_live_button"/></td>
		</tr>
		<tr>
			<td>&nbsp;</td>
			<td>Codec:</td>
			<td>
				<select name="vcodec" class="y_live_button">
				<option value="mp4v" selected>mp4v</option>
				<option value="mp2v">mp2v</option>
				<option value="DIV3">DIV3</option>
				<option value="h264">h264</option>
				</select>
			</td>
			<td>Bitrate:</td>
			<td> 
				<select name="vb" class="y_live_button">
				<option value="1024">1024</option>
				<option value="786">786</option>
				<option value="512">512</option>
				<option value="384" 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>&nbsp;</td>
			<td>Scale:</td>
			<td>
				<select name="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>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">Audio</td><td class="y_form_section" colspan="4">&nbsp;</td></tr>
		<tr>
			<td>&nbsp;</td>
			<td>Codec:</td>
			<td>
				<select name="acodec" class="y_live_button">
				<option value="mp4a" selected>mp4a</option>
				<option value="mp3">mp3</option>
				<option value="mp2a">mp2a</option>
				<option value="a52">a52</option>
				</select>
			</td>
			<td>Bitrate:</td>
			<td>
				<select name="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>32</option>
				<option value="16">16</option>
				</select>
			</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
			<td>Channels:</td>
			<td>
				<select name="channels" class="y_live_button">
				<option value="1">1</option>
				<option value="2 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="4">&nbsp;</td></tr>
		<tr>
			<td>&nbsp;</td>
			<td>Mux:</td>
			<td>
				<select name="tmux" class="y_live_button">
	{=if-equal:{=mode=}~tv~
				<option value="ts" selected>ts</option>
				<option value="ps">ps</option>
				<option value="mp4">mp4</option>
				<option value="mov">mov</option>
				<option value="raw">raw</option>
	~
				<option value="raw" selected>raw</option>
				<option value="mp4">mp4</option>
	=}
				</select>
			</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
		</tr>
		</table>
	</form>
<script type="text/javascript">
//<![CDATA[
	on_transon_change();
//]]>
</script>
</body>
</html>
