Java Code Examples for org.red5.server.stream.message.RTMPMessage#build()

The following examples show how to use org.red5.server.stream.message.RTMPMessage#build() . 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: PlayEngine.java    From red5-server-common with Apache License 2.0 6 votes vote down vote up
/**
 * Send reset message
 */
private void sendReset() {
    if (pullMode) {
        Ping recorded = new Ping();
        recorded.setEventType(Ping.RECORDED_STREAM);
        recorded.setValue2(streamId);
        // recorded 
        RTMPMessage recordedMsg = RTMPMessage.build(recorded);
        doPushMessage(recordedMsg);
    }
    Ping begin = new Ping();
    begin.setEventType(Ping.STREAM_BEGIN);
    begin.setValue2(streamId);
    // begin 
    RTMPMessage beginMsg = RTMPMessage.build(begin);
    doPushMessage(beginMsg);
    // reset
    ResetMessage reset = new ResetMessage();
    doPushMessage(reset);
}
 
Example 2
Source File: Application.java    From red5-rtsp-restreamer with Apache License 2.0 6 votes vote down vote up
@Override
public void packetReceived(IBroadcastStream stream, IStreamPacket packet) {

	RTMPMessage m = RTMPMessage.build((IRTMPEvent) packet, packet.getTimestamp());

	try {

		limiter--;
		if (limiter > 1) {
			streamer.pushMessage(null, m);
		} else {
			if (streamer != null) {
				stream.removeStreamListener(this);
				streamer.stop();
				streamer = null;
			}
		}

	} catch (IOException e) {

		e.printStackTrace();
	}

}
 
Example 3
Source File: PlayEngine.java    From red5-server-common with Apache License 2.0 5 votes vote down vote up
/**
 * Send clear ping. Lets client know that stream has no more data to send.
 */
private void sendClearPing() {
    Ping eof = new Ping();
    eof.setEventType(Ping.STREAM_PLAYBUFFER_CLEAR);
    eof.setValue2(streamId);
    // eos 
    RTMPMessage eofMsg = RTMPMessage.build(eof);
    doPushMessage(eofMsg);
}
 
Example 4
Source File: PlayEngine.java    From red5-server-common with Apache License 2.0 5 votes vote down vote up
/**
 * Sends an onPlayStatus message.
 * 
 * http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/NetDataEvent.html
 * 
 * @param code
 * @param duration
 * @param bytes
 */
private void sendOnPlayStatus(String code, int duration, long bytes) {
    if (log.isDebugEnabled()) {
        log.debug("Sending onPlayStatus - code: {} duration: {} bytes: {}", code, duration, bytes);
    }
    // create the buffer
    IoBuffer buf = IoBuffer.allocate(102);
    buf.setAutoExpand(true);
    Output out = new Output(buf);
    out.writeString("onPlayStatus");
    ObjectMap<Object, Object> args = new ObjectMap<>();
    args.put("code", code);
    args.put("level", Status.STATUS);
    args.put("duration", duration);
    args.put("bytes", bytes);
    String name = currentItem.get().getName();
    if (StatusCodes.NS_PLAY_TRANSITION_COMPLETE.equals(code)) {
        args.put("clientId", streamId);
        args.put("details", name);
        args.put("description", String.format("Transitioned to %s", name));
        args.put("isFastPlay", false);
    }
    out.writeObject(args);
    buf.flip();
    Notify event = new Notify(buf, "onPlayStatus");
    if (lastMessageTs > 0) {
        event.setTimestamp(lastMessageTs);
    } else {
        event.setTimestamp(0);
    }
    RTMPMessage msg = RTMPMessage.build(event);
    doPushMessage(msg);
}