当前位置: 首页>>代码示例>>Java>>正文


Java RTMPMessage类代码示例

本文整理汇总了Java中org.red5.server.stream.message.RTMPMessage的典型用法代码示例。如果您正苦于以下问题:Java RTMPMessage类的具体用法?Java RTMPMessage怎么用?Java RTMPMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RTMPMessage类属于org.red5.server.stream.message包,在下文中一共展示了RTMPMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doPushMessage

import org.red5.server.stream.message.RTMPMessage; //导入依赖的package包/类
/**
 * Send message to output stream and handle exceptions.
 * 
 * @param message
 *            The message to send.
 */
private void doPushMessage(AbstractMessage message) {
    if (log.isTraceEnabled()) {
        String msgType = message.getMessageType();
        log.trace("doPushMessage: {}", msgType);
    }
    IMessageOutput out = msgOutReference.get();
    if (out != null) {
        try {
            out.pushMessage(message);
            if (message instanceof RTMPMessage) {
                IRTMPEvent body = ((RTMPMessage) message).getBody();
                // update the last message sent's timestamp
                lastMessageTs = body.getTimestamp();
                IoBuffer streamData = null;
                if (body instanceof IStreamData && (streamData = ((IStreamData<?>) body).getData()) != null) {
                    bytesSent.addAndGet(streamData.limit());
                }
            }
        } catch (IOException err) {
            log.error("Error while pushing message", err);
        }
    } else {
        log.warn("Push message failed due to null output pipe");
    }
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:32,代码来源:PlayEngine.java

示例2: sendReset

import org.red5.server.stream.message.RTMPMessage; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:23,代码来源:PlayEngine.java

示例3: packetReceived

import org.red5.server.stream.message.RTMPMessage; //导入依赖的package包/类
@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();
	}

}
 
开发者ID:Red5,项目名称:red5-rtsp-restreamer,代码行数:25,代码来源:Application.java

示例4: pushMessage

import org.red5.server.stream.message.RTMPMessage; //导入依赖的package包/类
/**
 * Push message
 * 
 * @param message
 *            Message
 */
private void pushMessage(IMessage message) throws IOException {
    if (msgOut != null) {
        msgOut.pushMessage(message);
    }
    // Notify listeners about received packet
    if (message instanceof RTMPMessage) {
        final IRTMPEvent rtmpEvent = ((RTMPMessage) message).getBody();
        if (rtmpEvent instanceof IStreamPacket) {
            for (IStreamListener listener : getStreamListeners()) {
                try {
                    listener.packetReceived(this, (IStreamPacket) rtmpEvent);
                } catch (Exception e) {
                    log.error("Error while notifying listener " + listener, e);
                }
            }
        }
    }
}
 
开发者ID:Red5,项目名称:red5-server,代码行数:25,代码来源:ServerStream.java

示例5: getNextRTMPMessage

import org.red5.server.stream.message.RTMPMessage; //导入依赖的package包/类
/**
 * Getter for next RTMP message.
 *
 * @return Next RTMP message
 */
protected RTMPMessage getNextRTMPMessage() {
    IMessage message;
    do {
        // Pull message from message input object...
        try {
            message = msgIn.pullMessage();
        } catch (Exception err) {
            log.error("Error while pulling message.", err);
            message = null;
        }
        // If message is null then return null
        if (message == null) {
            return null;
        }
    } while (!(message instanceof RTMPMessage));
    // Cast and return
    return (RTMPMessage) message;
}
 
开发者ID:Red5,项目名称:red5-server,代码行数:24,代码来源:ServerStream.java

示例6: doPushMessage

import org.red5.server.stream.message.RTMPMessage; //导入依赖的package包/类
/**
 * Send message to output stream and handle exceptions.
 * 
 * @param message The message to send.
 */
private void doPushMessage(AbstractMessage message) {
	log.trace("doPushMessage: {}", message.getMessageType());
	try {
		msgOut.pushMessage(message);
		if (message instanceof RTMPMessage) {
			IRTMPEvent body = ((RTMPMessage) message).getBody();
			//update the last message sent's timestamp
			lastMessageTs = body.getTimestamp();
			IoBuffer streamData = null;
			if (body instanceof IStreamData && (streamData = ((IStreamData<?>) body).getData()) != null) {
				bytesSent.addAndGet(streamData.limit());
			}
		}
	} catch (IOException err) {
		log.error("Error while pushing message", err);
	}
}
 
开发者ID:cwpenhale,项目名称:red5-mobileconsole,代码行数:23,代码来源:PlayEngine.java

示例7: sendReset

import org.red5.server.stream.message.RTMPMessage; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:cwpenhale,项目名称:red5-mobileconsole,代码行数:24,代码来源:PlayEngine.java

示例8: pushMessage

import org.red5.server.stream.message.RTMPMessage; //导入依赖的package包/类
/**
 * Push message
 * @param message     Message
 */
private void pushMessage(IMessage message) throws IOException {
	if (msgOut != null) {
		msgOut.pushMessage(message);
	}
	if (recordPipe != null) {
		recordPipe.pushMessage(message);
	}
	// Notify listeners about received packet
	if (message instanceof RTMPMessage) {
		final IRTMPEvent rtmpEvent = ((RTMPMessage) message).getBody();
		if (rtmpEvent instanceof IStreamPacket) {
			for (IStreamListener listener : getStreamListeners()) {
				try {
					listener.packetReceived(this, (IStreamPacket) rtmpEvent);
				} catch (Exception e) {
					log.error("Error while notifying listener " + listener, e);
				}
			}
		}
	}
}
 
开发者ID:cwpenhale,项目名称:red5-mobileconsole,代码行数:26,代码来源:ServerStream.java

示例9: getNextRTMPMessage

import org.red5.server.stream.message.RTMPMessage; //导入依赖的package包/类
/**
 * Getter for next RTMP message.
 *
 * @return  Next RTMP message
 */
protected RTMPMessage getNextRTMPMessage() {
	IMessage message;
	do {
		// Pull message from message input object...
		try {
			message = msgIn.pullMessage();
		} catch (Exception err) {
			log.error("Error while pulling message.", err);
			message = null;
		}
		// If message is null then return null
		if (message == null) {
			return null;
		}
	} while (!(message instanceof RTMPMessage));
	// Cast and return
	return (RTMPMessage) message;
}
 
开发者ID:cwpenhale,项目名称:red5-mobileconsole,代码行数:24,代码来源:ServerStream.java

示例10: getNextRTMPMessage

import org.red5.server.stream.message.RTMPMessage; //导入依赖的package包/类
/**
 * Getter for next RTMP message.
 * 
 * @return Next RTMP message
 */
private RTMPMessage getNextRTMPMessage() {
	IMessage message;
	do {
		// Pull message from message input object...
		try {
			message = msgIn.pullMessage();
		} catch (IOException err) {
			log.error("Error while pulling message.", err);
			message = null;
		}
		// If message is null then return null
		if (message == null) {
			return null;
		}
	} while (!(message instanceof RTMPMessage));
	// Cast and return
	return (RTMPMessage) message;
}
 
开发者ID:cwpenhale,项目名称:red5-mobileconsole,代码行数:24,代码来源:NoSyncServerStream.java

示例11: pushMessage

import org.red5.server.stream.message.RTMPMessage; //导入依赖的package包/类
/**
 * Push message
 * 
 * @param message
 *                Message
 */
private void pushMessage(IMessage message) throws IOException {
	msgOut.pushMessage(message);
	recordPipe.pushMessage(message);

	// Notify listeners about received packet
	if (message instanceof RTMPMessage) {
		final IRTMPEvent rtmpEvent = ((RTMPMessage) message).getBody();
		if (rtmpEvent instanceof IStreamPacket) {
			for (IStreamListener listener : getStreamListeners()) {
				try {
					listener.packetReceived(this, (IStreamPacket) rtmpEvent);
				} catch (Exception e) {
					log.error("Error while notifying listener " + listener, e);
				}
			}
		}
	}
}
 
开发者ID:cwpenhale,项目名称:red5-mobileconsole,代码行数:25,代码来源:NoSyncServerStream.java

示例12: pushVideo

import org.red5.server.stream.message.RTMPMessage; //导入依赖的package包/类
public void pushVideo(VideoData data, int ts) {
	if (startPublish) {
		if (Red5.getConnectionLocal() == null) {
			Red5.setConnectionLocal(client.getConnection());
		}
		RTMPMessage rtmpMsg = RTMPMessage.build(data, ts);
		client.publishStreamData(streamId, rtmpMsg);
	}
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:10,代码来源:CaptureScreen.java

示例13: playVOD

import org.red5.server.stream.message.RTMPMessage; //导入依赖的package包/类
/**
 * Performs the processes needed for VOD / pre-recorded streams.
 * 
 * @param withReset
 *            whether or not to perform reset on the stream
 * @param itemLength
 *            length of the item to be played
 * @return message for the consumer
 * @throws IOException
 */
private final IMessage playVOD(boolean withReset, long itemLength) throws IOException {
    IMessage msg = null;
    // change state
    subscriberStream.setState(StreamState.PLAYING);
    if (withReset) {
        releasePendingMessage();
    }
    sendVODInitCM(currentItem);
    // Don't use pullAndPush to detect IOExceptions prior to sending NetStream.Play.Start
    if (currentItem.getStart() > 0) {
        streamOffset = sendVODSeekCM((int) currentItem.getStart());
        // We seeked to the nearest keyframe so use real timestamp now
        if (streamOffset == -1) {
            streamOffset = (int) currentItem.getStart();
        }
    }
    IMessageInput in = msgInReference.get();
    msg = in.pullMessage();
    if (msg instanceof RTMPMessage) {
        // Only send first video frame
        IRTMPEvent body = ((RTMPMessage) msg).getBody();
        if (itemLength == 0) {
            while (body != null && !(body instanceof VideoData)) {
                msg = in.pullMessage();
                if (msg != null && msg instanceof RTMPMessage) {
                    body = ((RTMPMessage) msg).getBody();
                } else {
                    break;
                }
            }
        }
        if (body != null) {
            // Adjust timestamp when playing lists
            body.setTimestamp(body.getTimestamp() + timestampOffset);
        }
    }
    return msg;
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:49,代码来源:PlayEngine.java

示例14: sendClearPing

import org.red5.server.stream.message.RTMPMessage; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:12,代码来源:PlayEngine.java

示例15: sendOnPlayStatus

import org.red5.server.stream.message.RTMPMessage; //导入依赖的package包/类
/**
 * 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);
    if (StatusCodes.NS_PLAY_TRANSITION_COMPLETE.equals(code)) {
        args.put("clientId", streamId);
        args.put("details", currentItem.getName());
        args.put("description", String.format("Transitioned to %s", currentItem.getName()));
        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);
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:41,代码来源:PlayEngine.java


注:本文中的org.red5.server.stream.message.RTMPMessage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。