red5检测流量

@Override
    public void streamSubscriberStart(ISubscriberStream stream) {
     print(”streamSubscriberStart”);
     IConnection conn = Red5.getConnectionLocal();
     conn.setAttribute(”data”, conn.getWrittenBytes());
     conn.setAttribute(”time”, System.currentTimeMillis());
     super.streamSubscriberStart(stream);
    }

    @Override
    public void streamSubscriberClose(ISubscriberStream arg0) {
     IConnection conn = Red5.getConnectionLocal();
     long data = conn.getWrittenBytes() - (Long) conn.getAttribute(”data”);
     long time = System.currentTimeMillis() - (Long) conn.getAttribute(”time”);
     print(”bytes per second:” + data * 1000 / time);
     print(”streamSubscriberClose”);
     super.streamSubscriberClose(arg0);
    }

你可能感兴趣的:(流)