Flash Media Server 流式传输:内容保护

发布于 2024-08-30 18:58:52 字数 3940 浏览 10 评论 0原文

我必须实现 Flash 流来重新启动我们的视频点播系统,但要么是因为我以前没有使用过 Flash 相关的系统,要么是因为我太愚蠢了,我无法让系统正常工作。

我们需要:

  • 每个文件 & 每分钟检查一次 Web 服务
  • 用户访问控制,如果租用时间在中途耗尽,则
  • :取消流rtmp 流
  • 动态带宽检查
  • 使用 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 服务该密钥适用于哪个文件和用户并播放该文件,但我不能似乎找到了如何从服务器端播放文件。

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

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

有什么提示吗?

谢谢。

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 sent by the client.

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不疑不惑不回忆 2024-09-06 18:58:52

我今天发现了 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'
       }
     }
   }
);

I found the FlowPlayers clip.connectionArgs today and i'm implementing a solution for it now.

the resulting Code will be something along the lines of:

Server-Side 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);
  }
}

Client Side:

$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'
       }
     }
   }
);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文