<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:util="http://www.springframework.org/schema/util"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd" >

	<!-- This configuration file contains some common definitions used by service configurations.
		 For example, it defines some static parameters like HTTP Content Type and ffmpeg encoding parameters. 
	-->

	<!-- Define static parameters; this can be referenced inside a paramBuilders list. -->
	<bean id="staticParams" class="vodserver.parambuilder.StaticParamBuilder">
		<property name="order" value="10"/>
		<property name="staticParams">
			<map>
				<!-- Define the default HTTP Content Type for streaming transcoded video content-->
				<entry key="httpContentType" value="video/mp2t"/>
				
				<!-- Define the ffmpeg encoding and output parameters. The video output should match
				     with the HTTP Content Type defined above. It should also instruct ffmpeg to
				     output the stream to stdout. -->
				<entry key="ffmpegOutputParams" value="-vcodec mpeg2video -s 720x576 -r 24 -flags cgop+ilme -sc_threshold 1000000000 -b:v 64K -maxrate:v 2M -bufsize:v 1.4M -acodec mp2 -ac 2 -b:a 128k -f mpegts -"/>
				
				<!-- Define the rtmpdump base parameters for downloading a stream. The default definition will check which parameters are 
				     defined (rtmpToken, rtmpStreamer, ...) and add the corresponding command line argument.
				     For parameters that are not defined, no command line argument will be added. -->
				<entry key="rtmpDumpBaseParams">
					<value>
				 		!!build('-T "', rtmpToken,'"')!!
				 		!!build('-r "', rtmpStreamer, '"')!! 
				 		!!build('-a "', rtmpApp, '"')!! 
				 		!!build('-f "', rtmpFlashVer, '"')!! 
				 		!!build('-W "', rtmpFlashPlayer, '"')!! 
				 		!!build('-p "', rtmpPageUrl, '"')!! 
				 		!!build('-y "', rtmpFile, '"')!!
				 	</value>
				</entry>
				
				<entry key="ffmpegRtmpInputParams">
					<value>
						"!!rtmpStreamer!!
				 		!!build("token='", rtmpToken, "'")!!
				 		!!build("app='", rtmpApp, "'")!! 
				 		!!build("flashVer='", rtmpFlashVer, "'")!! 
				 		!!build("swfUrl='", rtmpFlashPlayer, "'")!! 
				 		!!build("pageUrl='", rtmpPageUrl, "'")!! 
				 		!!build("playpath='", rtmpFile, "'")!!"
				 	</value>
				</entry>
				
				<entry key="rtmpDump" value="rtmpdump -v !!rtmpDumpBaseParams!!"/>
				
				<entry key="urlRegEx">
					<value><![CDATA[[A-Za-z0-9\-._~:/?#\[\]@!$&'()*+,;=]+]]></value>
				</entry>
				
				<entry key="header.Accept" value="text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"/>
				<entry key="header.Accept-Encoding" value="gzip,deflate,sdch"/>
				<entry key="header.Accept-Language" value="en-US,en;q=0.8"/>
				<entry key="header.Cache-Control" value="max-age=0"/>
				<entry key="header.Connection" value="keep-alive"/>
				<entry key="header.User-Agent" value="Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.76 Safari/537.36"/>
				
				<entry key="jsonHeader.Accept" value="application/json, text/javascript, */*; q=0.01"/>
				<entry key="jsonHeader.Accept-Encoding" value="gzip,deflate,sdch"/>
				<entry key="jsonHeader.Accept-Language" value="en-US,en;q=0.8"/>
				<entry key="jsonHeader.Cache-Control" value="max-age=0"/>
				<entry key="jsonHeader.Connection" value="keep-alive"/>
				<entry key="jsonHeader.User-Agent" value="Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.76 Safari/537.36"/>
				<entry key="jsonHeader.X-Requested-With" value="XMLHttpRequest"/>
			</map>
		</property>
	</bean>
	
	<!-- Map the request parameters to VODServer parameters; this can be referenced inside a paramBuilders list. -->
	<bean id="requestParamBuilder" class="vodserver.parambuilder.RequestParamBuilder">
		<property name="order" value="20"/>
	</bean>
	
	<!-- Utility bean for retrieving HTML content from a URL, setting the right headers -->
	<bean id="baseWebContentParamBuilder" class="vodserver.parambuilder.WebContentParamBuilder" abstract="true">
		<!-- Parameter name defining the URL to retrieve -->
		<property name="contentUrlParam" value="url"/>
		
		<!-- Parameter name used to store the output -->
		<property name="contentOutputParam" value="baseContent"/>
		
		<!-- Parameter prefix to find HTTP headers  -->
		<property name="headerParamPrefix" value="header"/>
	</bean>
	
	<!-- Utility bean for retrieving JSON content from a URL, setting the right headers.
		 Usually you will still need to add a Referer header. -->
	<bean id="baseJsonContentParamBuilder" class="vodserver.parambuilder.WebContentParamBuilder" abstract="true">
		<!-- Parameter name defining the URL to retrieve -->
		<property name="contentUrlParam" value="jsonUrl"/>
		
		<!-- Parameter name used to store the JSON content -->
		<property name="contentOutputParam" value="jsonContent"/>
		
		<!-- Parameter prefix to find HTTP headers  -->
		<property name="headerParamPrefix" value="jsonHeader"/>
	</bean>
	
	<bean id="paramBuilderServiceBase" abstract="true">
		<property name="paramBuilders">
			<list>
				<!-- Include static parameters from common -->
				<ref bean="staticParams"/>
				
				<!-- Include request parameter builder from common -->
				<ref bean="requestParamBuilder"/>
			</list>
		</property>
	</bean>
</beans>
