Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Avalon with AMS Instructions

NOTE: This document is a work in progress. It is incomplete and untested.

This documentation is for Release 3.0.0.

These instructions provide a recipe for configuring Avalon to use Adobe Media Server (AMS) for content streaming.These instructions assume that the Apache server used is the one installed with AMS. If a separate Apache is used, make changes accordingly.

This example uses the default AMS installation location: /opt/adobe/ams

Configuration changes AMS:

1. /opt/adobe/ams/Apache2.2/conf/httpd.conf

Include avalon.conf by adding this line at the end:

Include conf/avalon.conf

2. /opt/adobe/ams/Apache2.2/conf/avalon.conf

<IfModule mod_disk_cache.c>
   CacheEnable disk /avalon 

RewriteEngine on
RewriteLock /tmp/avalon_rewrite_lock
RewriteMap avalon_auth prg:/opt/adobe/ams/Apache2.2/bin/avalon_auth
RewriteCond %{QUERY_STRING} audio-only=true
RewriteCond %{QUERY_STRING} codec=aac
RewriteCond %{QUERY_STRING} token=([^&]+)
RewriteRule ^/avalon/(.+).m3u8$ /avalon/audio-only-aac/$1.m3u8?token=%1 [R=301,L]

RewriteCond %{QUERY_STRING} audio-only=true
RewriteCond %{QUERY_STRING} token=([^&]+)
RewriteRule ^/avalon/(.+).m3u8$ /avalon/audio-only/$1.m3u8?token=%1 [R=301,L]

RewriteCond %{QUERY_STRING} token=([^&]+)
RewriteRule ^/avalon ${avalon_auth:%{REQUEST_URI}?token=%1}
RewriteCond %{REQUEST_URI} !(.+).ts$
RewriteCond %{QUERY_STRING} !token=
RewriteRule ^/avalon - [F]
RewriteRule ^/avalon/forbidden - [F]

<Location /avalon>
   HLSHttpStreamingEnabled true
   HLSMediaFileDuration 2000
   HttpStreamingContentPath "../webroot/avalon"
   HLSFmsDirPath ".."
   HLSJITConfAllowed true
   HLSM3U8MaxAge 86400
   HLSTSSegmentMaxAge 86400
   HLSMetaMaxAge 3600
   Options -Indexes FollowSymLinks
4. /opt/adobe/ams/Apache2.2/bin/avalon_auth

auth_url=`grep AVALON.AUTH_URL /opt/adobe/ams/conf/ams.ini | cut -d '=' -f 2 | sed 's/^ *//g'` 

while read uri; do
   raw=`curl -s "${auth_url}.txt?token=${parm[1]}"`
   valid=`echo ${parm[1]} | grep ^${resp}`
   if [ -n "${valid}" ] && [ -n "${resp}" ]; then
      	echo $uri
      echo '/avalon/forbidden'

5. /opt/adobe/ams/conf/ams.ini

Add avalon substitution variables at the end:

AVALON.STREAM_PATH = /opt/adobe/ams/webroot/avalon
AVALON.AUTH_URL = http://localhost/authorize

6. Create /opt/adobe/ams/applications/avalon/Application.xml

			<!-- Specifies application specific virtual directory mapping for recorded streams. -->

	<!-- Settings specific to runtime script engine memory -->
		<!-- This specifies the max size (Kb.) the runtime can grow to before -->
		<!-- garbage collection is performed. -->

			<!-- Specified in bytes/sec -->
			<!-- Specified in bytes/sec -->
				<!-- Drop live audio if audio q exceeds time specified. time in milliseconds -->
				<!-- Default buffer length in millisecond for live audio and video queue. -->
				<!-- Default buffer length in millisecond for live audio and video, value cannot be set below this by Flash player. -->
				<!-- Ratio of the buffer length used by server side stream -->
				<!-- to live buffer. The value is between 0 and 1. To -->
				<!-- avoid break up of audio, the ratio should not be more -->
				<!-- than 0.5 of the live buffer. -->
7. Create /opt/adobe/ams/applications/avalon/main.asc:
 * Avalon Media System authenticated RTMP streaming application for
 * Adobe Media Server.
 * Add the following keys to your <ams_install_home>/conf/ams.ini:
 *		AVALON.AUTH_URL = http://localhost/authorize
 *		AVALON.STREAM_PATH = /opt/adobe/ams/webroot/avalon
application.onAppStart = function()
   // Logging
   trace("Starting Avalon Streaming app...");
   this.avalonAuthUrl = application.config.avalonAuthUrl;
   trace("Requests will be authenticated against " + this.avalonAuthUrl);
   trace("...loading completed.");
application.onConnect = function( p_client, p_autoSenseBW )
   //Add security here
   p_client.writeAccess = ""; // prevents creating shared object or live streams.
   p_client.readAccess = "";  // no access by default
   var xhttp = new LoadVars();
   if (!xhttp.hasOwnProperty('token')) {
      trace('Missing token in request.');
      return false;
   var authed = false;
   xhttp.onHTTPStatus = function(status) {
   trace('Received ' + status);
   switch (status) {
      case 202: 
         authed = true;
      case 403: 
         authed = false;
   xhttp.onLoad = function() {
   if (authed) {
      // grant access to the specific mediapackage directories authorized
      p_client.readAccess = xhttp['authorized']; 
   // Accept the connection no matter what; the denial will happen when the stream is requested
   if (p_client.readAccess.length > 0) {
      trace("Client can read " + p_client.readAccess);
   } else {
      trace("Client cannot read anything");
   if (p_autoSenseBW)
   var authUrl = application.avalonAuthUrl;
   trace('Authorizing against ' + authUrl);
   return null;

Configure Matterhorn

1. /usr/local/matterhorn/current/etc/

Configure Avalon


Other Resources

Install Adobe Media Server


  • No labels