Java Code Examples for org.red5.server.messaging.OOBControlMessage#setTarget()

The following examples show how to use org.red5.server.messaging.OOBControlMessage#setTarget() . 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: 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 2
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 3
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 4
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 5
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 6
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());
        }
    }
}