本文整理汇总了Java中org.red5.server.net.rtmp.event.Notify.setTimestamp方法的典型用法代码示例。如果您正苦于以下问题:Java Notify.setTimestamp方法的具体用法?Java Notify.setTimestamp怎么用?Java Notify.setTimestamp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.red5.server.net.rtmp.event.Notify
的用法示例。
在下文中一共展示了Notify.setTimestamp方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: notifyBroadcastStart
import org.red5.server.net.rtmp.event.Notify; //导入方法依赖的package包/类
/**
* Notifies handler on stream broadcast start
*/
private void notifyBroadcastStart() {
IStreamAwareScopeHandler handler = getStreamAwareHandler();
if (handler != null) {
try {
handler.streamBroadcastStart(this);
} catch (Throwable t) {
log.error("Error in notifyBroadcastStart", t);
}
}
// send metadata for creation and start dates
IoBuffer buf = IoBuffer.allocate(256);
buf.setAutoExpand(true);
Output out = new Output(buf);
out.writeString("onMetaData");
Map<Object, Object> params = new HashMap<>();
Calendar cal = GregorianCalendar.getInstance();
cal.setTimeInMillis(creationTime);
params.put("creationdate", ZonedDateTime.ofInstant(cal.toInstant(), ZoneId.of("UTC")).format(DateTimeFormatter.ISO_INSTANT));
cal.setTimeInMillis(startTime);
params.put("startdate", ZonedDateTime.ofInstant(cal.toInstant(), ZoneId.of("UTC")).format(DateTimeFormatter.ISO_INSTANT));
if (log.isDebugEnabled()) {
log.debug("Params: {}", params);
}
out.writeMap(params);
buf.flip();
Notify notify = new Notify(buf);
notify.setAction("onMetaData");
notify.setHeader(new Header());
notify.getHeader().setDataType(Notify.TYPE_STREAM_METADATA);
notify.getHeader().setStreamId(0);
notify.setTimestamp(0);
dispatchEvent(notify);
}
示例2: sendOnPlayStatus
import org.red5.server.net.rtmp.event.Notify; //导入方法依赖的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);
}