Flash Media Server Streaming:内容保护

时间:2010-04-28 13:40:28

标签: flash streaming flash-media-server flowplayer

我必须实现flash流媒体以重新启动我们的视频点播系统,但要么因为我之前没有使用过闪存相关系统,要么因为我太傻了我无法使系统工作,因为它必须。

我们需要:

  • 每个档案&用户访问控制,每分钟检查一次WebService
  • 如果租用时间在流中出现:取消流
  • rtmp streaming
  • 动态带宽检查
  • 使用Flowplayer进行视频播放(现有许可证)

我已经进行了流媒体和带宽检查,我似乎无法使访问控制工作。我不知道我怎么知道播放哪个文件或者如何根据客户端发送的密钥播放文件。

服务器端代码(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 */
}

客户端代码:

<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>

我的第一个想法是从查询字符串中获取一个密钥,向Web服务询问该密钥所针对的文件和用户并播放该文件,但我似乎无法找到如何从服务器端播放文件

我的第二个想法是让流程玩家播放文件,将密钥作为查询字符串传递,如果文件名和密钥不匹配则拒绝连接,但我似乎无法找出它当前正在播放的文件。< / p>

我唯一剩下的想法是:创建允许用户打开的所有文件的列表并设置allowReadAccess,或者调用它来允许这些文件,但由于当前的基础结构,这将是笨拙的。

任何提示?

感谢。

1 个答案:

答案 0 :(得分:0)

我今天找到了FlowPlayers clip.connectionArgs ,现在我正在为它实现一个解决方案。

生成的代码将是:

服务器端main.asc onConnect:

application.onConnect( p_client, p_userid, p_streamname )
{
  if (p_client.check_access(p_userid, p_streamname))
  {
    p_client.readAccess = "streams/_definst_/" + p_streamname;
    this.acceptConnection(p_client);
  }
  else
  {
    this.rejectConnection(p_client);
  }
}

客户端:

$f(
  "player",
   "flowplayer-3.1.5.swf",
   {
     clip:  {
       provider: 'rtmp',
       autoPlay: false,
       url: 'test_flv',
       connectionArgs: ["12345", "test_flv"]
     },
     plugins: {
       rtmp: {
         url: 'flowplayer.rtmp-3.1.3.swf',
         netConnectionUrl: 'rtmp://xx.xx.xx.xx/vod_project?foo=bar'
       }
     }
   }
);
相关问题