Flash Media Server Streaming: Content Protection
- by dbemerlin
Hi,
i have to implement flash streaming for the relaunch of our video-on-demand system but either because i haven't worked with flash-related systems before or because i'm too stupid i cannot get the system to work as it has to.
We need:
Per file & user access control with checks on a WebService every minute
if the lease time ran out mid-stream: cancelling the stream
rtmp streaming
dynamic bandwidth checking
Video Playback with Flowplayer (existing license)
I've got the streaming and bandwidth check working, i just can't seem to get the access control working. I have no idea how i know which file is played back or how i can play back a file depending on a key the user has entered.
Server-Side Code (main.asc):
application.onAppStart = function()
{
trace("Starting application");
this.payload = new Array();
for (var i=0; i < 1200; i++) {
this.payload[i] = Math.random(); //16K approx
}
}
application.onConnect = function( p_client, p_autoSenseBW )
{
p_client.writeAccess = "";
trace("client at : " + p_client.uri);
trace("client from : " + p_client.referrer);
trace("client page: " + p_client.pageUrl);
// try to get something from the query string: works
var i = 0;
for (i = 0; i < p_client.uri.length; ++i)
{
if (p_client.uri[i] == '?')
{
++i;
break;
}
}
var loadVars = new LoadVars();
loadVars.decode(p_client.uri.substr(i));
trace(loadVars.toString());
trace(loadVars['foo']);
// And accept the connection
this.acceptConnection(p_client);
trace("accepted!");
//this.rejectConnection(p_client);
// A connection from Flash 8 & 9 FLV Playback component based client
// requires the following code.
if (p_autoSenseBW)
{
p_client.checkBandwidth();
}
else
{
p_client.call("onBWDone");
}
trace("Done connecting");
}
application.onDisconnect = function(client)
{
trace("client disconnecting!");
}
Client.prototype.getStreamLength = function(p_streamName) {
trace("getStreamLength:" + p_streamName);
return Stream.length(p_streamName);
}
Client.prototype.checkBandwidth = function() {
application.calculateClientBw(this);
}
application.calculateClientBw = function(p_client)
{
/* lots of lines copied from an adobe sample, appear to work */
}
Client-Side Code:
<head>
<script type="text/javascript" src="flowplayer-3.1.4.min.js"></script>
</head>
<body>
<a
class="rtmp"
href="rtmp://xx.xx.xx.xx/vod_project/test_flv.flv"
style="display: block; width: 520px; height: 330px"
id="player">
</a>
<script>
$f(
"player",
"flowplayer-3.1.5.swf",
{
clip: {
provider: 'rtmp',
autoPlay: false,
url: 'test_flv'
},
plugins: {
rtmp: {
url: 'flowplayer.rtmp-3.1.3.swf',
netConnectionUrl: 'rtmp://xx.xx.xx.xx/vod_project?foo=bar'
}
}
}
);
</script>
</body>
My first Idea was to get a key from the Query String, ask the web service about which file and user that key is for and play the file but i can't seem to find out how to play a file from server side.
My second idea was to let flowplayer play a file, pass the key as query string and if the filename and key don't match then reject the connection but i can't seem to find out which file it's currently playing.
The only remaining idea i have is: create a list of all files the user is allowed to open and set allowReadAccess or however it was called to allow those files, but that would be clumsy due to the current infrastructure.
Any hints?
Thanks.