org.red5.server.messaging.OOBControlMessage Java Examples

The following examples show how to use org.red5.server.messaging.OOBControlMessage. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConnectionConsumer.java    From red5-server-common with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
public void onOOBControlMessage(IMessageComponent source, IPipe pipe, OOBControlMessage oobCtrlMsg) {
    if ("ConnectionConsumer".equals(oobCtrlMsg.getTarget())) {
        String serviceName = oobCtrlMsg.getServiceName();
        log.trace("Service name: {}", serviceName);
        if ("pendingCount".equals(serviceName)) {
            oobCtrlMsg.setResult(conn.getPendingMessages());
        } else if ("pendingVideoCount".equals(serviceName)) {
            IClientStream stream = conn.getStreamByChannelId(video.getId());
            if (stream != null) {
                oobCtrlMsg.setResult(conn.getPendingVideoMessages(stream.getStreamId()));
            } else {
                oobCtrlMsg.setResult(0L);
            }
        } else if ("writeDelta".equals(serviceName)) {
            //TODO: Revisit the max stream value later
            long maxStream = 120 * 1024;
            // Return the current delta between sent bytes and bytes the client
            // reported to have received, and the interval the client should use
            // for generating BytesRead messages (half of the allowed bandwidth).
            oobCtrlMsg.setResult(new Long[] { conn.getWrittenBytes() - conn.getClientBytesRead(), maxStream / 2 });
        } else if ("chunkSize".equals(serviceName)) {
            int newSize = (Integer) oobCtrlMsg.getServiceParamMap().get("chunkSize");
            if (newSize != chunkSize) {
                chunkSize = newSize;
                chunkSizeSent.set(false);
                sendChunkSize();
            }
        }
    }
}
 
Example #2
Source File: ClientBroadcastStream.java    From red5-server-common with Apache License 2.0 5 votes vote down vote up
/**
 * Send OOB control message with chunk size
 */
private void notifyChunkSize() {
    if (chunkSize > 0 && livePipe != null) {
        OOBControlMessage setChunkSize = new OOBControlMessage();
        setChunkSize.setTarget("ConnectionConsumer");
        setChunkSize.setServiceName("chunkSize");
        if (setChunkSize.getServiceParamMap() == null) {
            setChunkSize.setServiceParamMap(new HashMap<String, Object>());
        }
        setChunkSize.getServiceParamMap().put("chunkSize", chunkSize);
        livePipe.sendOOBControlMessage(getProvider(), setChunkSize);
    }
}
 
Example #3
Source File: ClientBroadcastStream.java    From red5-server-common with Apache License 2.0 5 votes vote down vote up
/**
 * Out-of-band control message handler
 *
 * @param source
 *            OOB message source
 * @param pipe
 *            Pipe that used to send OOB message
 * @param oobCtrlMsg
 *            Out-of-band control message
 */
public void onOOBControlMessage(IMessageComponent source, IPipe pipe, OOBControlMessage oobCtrlMsg) {
    String target = oobCtrlMsg.getTarget();
    if ("ClientBroadcastStream".equals(target)) {
        String serviceName = oobCtrlMsg.getServiceName();
        if ("chunkSize".equals(serviceName)) {
            chunkSize = (Integer) oobCtrlMsg.getServiceParamMap().get("chunkSize");
            notifyChunkSize();
        } else {
            log.debug("Unhandled OOB control message for service: {}", serviceName);
        }
    } else {
        log.debug("Unhandled OOB control message to target: {}", target);
    }
}
 
Example #4
Source File: PlayEngine.java    From red5-server-common with Apache License 2.0 5 votes vote down vote up
/**
 * Send VOD init control message
 * 
 * @param item
 *            Playlist item
 */
private void sendVODInitCM(IPlayItem item) {
    OOBControlMessage oobCtrlMsg = new OOBControlMessage();
    oobCtrlMsg.setTarget(IPassive.KEY);
    oobCtrlMsg.setServiceName("init");
    Map<String, Object> paramMap = new HashMap<String, Object>(1);
    paramMap.put("startTS", (int) item.getStart());
    oobCtrlMsg.setServiceParamMap(paramMap);
    msgInReference.get().sendOOBControlMessage(this, oobCtrlMsg);
}
 
Example #5
Source File: PlayEngine.java    From red5-server-common with Apache License 2.0 5 votes vote down vote up
/**
 * Send VOD seek control message
 * 
 * @param msgIn
 *            Message input
 * @param position
 *            Playlist item
 * @return Out-of-band control message call result or -1 on failure
 */
private int sendVODSeekCM(int position) {
    OOBControlMessage oobCtrlMsg = new OOBControlMessage();
    oobCtrlMsg.setTarget(ISeekableProvider.KEY);
    oobCtrlMsg.setServiceName("seek");
    Map<String, Object> paramMap = new HashMap<String, Object>(1);
    paramMap.put("position", position);
    oobCtrlMsg.setServiceParamMap(paramMap);
    msgInReference.get().sendOOBControlMessage(this, oobCtrlMsg);
    if (oobCtrlMsg.getResult() instanceof Integer) {
        return (Integer) oobCtrlMsg.getResult();
    } else {
        return -1;
    }
}
 
Example #6
Source File: PlayEngine.java    From red5-server-common with Apache License 2.0 5 votes vote down vote up
/**
 * Send VOD check video control message
 * 
 * @return result of oob control message
 */
private boolean sendCheckVideoCM() {
    OOBControlMessage oobCtrlMsg = new OOBControlMessage();
    oobCtrlMsg.setTarget(IStreamTypeAwareProvider.KEY);
    oobCtrlMsg.setServiceName("hasVideo");
    msgInReference.get().sendOOBControlMessage(this, oobCtrlMsg);
    if (oobCtrlMsg.getResult() instanceof Boolean) {
        return (Boolean) oobCtrlMsg.getResult();
    } else {
        return false;
    }
}
 
Example #7
Source File: PlayEngine.java    From red5-server-common with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
public void onOOBControlMessage(IMessageComponent source, IPipe pipe, OOBControlMessage oobCtrlMsg) {
    if ("ConnectionConsumer".equals(oobCtrlMsg.getTarget())) {
        if (source instanceof IProvider) {
            IMessageOutput out = msgOutReference.get();
            if (out != null) {
                out.sendOOBControlMessage((IProvider) source, oobCtrlMsg);
            } else {
                // this may occur when a client attempts to play and then disconnects
                log.warn("Output is not available, message cannot be sent");
                close();
            }
        }
    }
}
 
Example #8
Source File: PlayEngine.java    From red5-server-common with Apache License 2.0 5 votes vote down vote up
/**
 * Get number of pending video messages
 * 
 * @return Number of pending video messages
 */
private long pendingVideoMessages() {
    IMessageOutput out = msgOutReference.get();
    if (out != null) {
        OOBControlMessage pendingRequest = new OOBControlMessage();
        pendingRequest.setTarget("ConnectionConsumer");
        pendingRequest.setServiceName("pendingVideoCount");
        out.sendOOBControlMessage(this, pendingRequest);
        if (pendingRequest.getResult() != null) {
            return (Long) pendingRequest.getResult();
        }
    }
    return 0;
}
 
Example #9
Source File: RTMPHandler.java    From red5-server-common with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
protected void onChunkSize(RTMPConnection conn, Channel channel, Header source, ChunkSize chunkSize) {
    int requestedChunkSize = chunkSize.getSize();
    log.debug("Chunk size: {}", requestedChunkSize);
    // set chunk size on the connection
    RTMP state = conn.getState();
    // set only the read chunk size since it came from the client
    state.setReadChunkSize(requestedChunkSize);
    //state.setWriteChunkSize(requestedChunkSize);
    // set on each of the streams
    for (IClientStream stream : conn.getStreams()) {
        if (stream instanceof IClientBroadcastStream) {
            IClientBroadcastStream bs = (IClientBroadcastStream) stream;
            IBroadcastScope scope = bs.getScope().getBroadcastScope(bs.getPublishedName());
            if (scope == null) {
                continue;
            }
            OOBControlMessage setChunkSize = new OOBControlMessage();
            setChunkSize.setTarget("ClientBroadcastStream");
            setChunkSize.setServiceName("chunkSize");
            if (setChunkSize.getServiceParamMap() == null) {
                setChunkSize.setServiceParamMap(new HashMap<String, Object>());
            }
            setChunkSize.getServiceParamMap().put("chunkSize", requestedChunkSize);
            scope.sendOOBControlMessage((IConsumer) null, setChunkSize);
            log.debug("Sending chunksize {} to {}", chunkSize, bs.getProvider());
        }
    }
}
 
Example #10
Source File: StreamingProxy.java    From red5-client with Apache License 2.0 4 votes vote down vote up
@Override
public void onOOBControlMessage(IMessageComponent source, IPipe pipe, OOBControlMessage oobCtrlMsg) {
    log.debug("onOOBControlMessage: {}", oobCtrlMsg);
}
 
Example #11
Source File: SlicedFileConsumer.java    From red5-server-common with Apache License 2.0 2 votes vote down vote up
/**
 * Out-of-band control message handler
 * 
 * @param source
 *            Source of message
 * @param pipe
 *            Pipe that is used to transmit OOB message
 * @param oobCtrlMsg
 *            OOB control message
 */
public void onOOBControlMessage(IMessageComponent source, IPipe pipe, OOBControlMessage oobCtrlMsg) {
}
 
Example #12
Source File: FileConsumer.java    From red5-server-common with Apache License 2.0 2 votes vote down vote up
/**
 * Out-of-band control message handler
 *
 * @param source
 *            Source of message
 * @param pipe
 *            Pipe that is used to transmit OOB message
 * @param oobCtrlMsg
 *            OOB control message
 */
public void onOOBControlMessage(IMessageComponent source, IPipe pipe, OOBControlMessage oobCtrlMsg) {
}
 
Example #13
Source File: ICYStream.java    From red5-rtsp-restreamer with Apache License 2.0 2 votes vote down vote up
@Override
public void onOOBControlMessage(IMessageComponent arg0, IPipe arg1, OOBControlMessage arg2) {

}