How to Identify Publishers and Consumers using Red5 API

醉酒当歌 提交于 2019-12-11 23:00:35

问题


public boolean connect(IConnection conn, IScope scope, Object[] params)
    {
            IClient client = conn.getClient();
            log.info( "app connect " + conn.getClient().getId() );
            client.setAttribute( "stamp", new Long( 0 ) );
        return true;
    }

This is the method which is being called every time Client is connected at my Custom Application in Red5 Server ,so is there a way to identify if a Client is Subscriber (Consumer ,Viewer) or Publisher (User which streams at my server).

Bests


回答1:


To disallow or allow publish or subscribe a user, you can use those methods inside appStart callback method:

  • registerStreamPlaybackSecurity
  • registerStreamPublishSecurity

For more, look to the:

http://dl.fancycode.com/red5/api/org/red5/server/adapter/MultiThreadedApplicationAdapter.html

I'm using jRuby, and it's very easy to do so:

registerStreamPlaybackSecurity do |scope, name, start, len, flush|
  false # no playback allowed
end
registerStreamPublishSecurity do |scope, name, mode|
  rand(1) % 1 == 0 # publishing (recording) sometimes allowed, sometimes no
end


来源:https://stackoverflow.com/questions/6775239/how-to-identify-publishers-and-consumers-using-red5-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!