本文整理汇总了Java中org.red5.server.net.rtmp.event.Notify类的典型用法代码示例。如果您正苦于以下问题:Java Notify类的具体用法?Java Notify怎么用?Java Notify使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Notify类属于org.red5.server.net.rtmp.event包,在下文中一共展示了Notify类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCommand
import org.red5.server.net.rtmp.event.Notify; //导入依赖的package包/类
/**
* @param command - command to be processed
*/
protected void onCommand(ICommand command) {
if (!(command instanceof Notify)) {
return;
}
Notify invoke = (Notify)command;
if (invoke.getType() == IEvent.Type.STREAM_DATA) {
return;
}
String method = invoke.getCall().getServiceMethodName();
if ("screenSharerAction".equals(method)) {
Object[] args = invoke.getCall().getArguments();
if (args != null && args.length > 0) {
@SuppressWarnings("unchecked")
Map<String, Object> params = (Map<String, Object>)args[0];
if (bool(params.get("stopPublishing"))) {
stopPublishing();
}
if (params.containsKey("error")) {
frame.setStatus("" + params.get("error"));
}
}
}
}
示例2: handleParameters
import org.red5.server.net.rtmp.event.Notify; //导入依赖的package包/类
/**
* Sets incoming connection parameters and / or returns encoded parameters for use in a call.
*
* @param in
* @param notify
* @param input
* @return parameters array
*/
private Object[] handleParameters(IoBuffer in, Notify notify, Input input) {
Object[] params = new Object[] {};
List<Object> paramList = new ArrayList<>();
final Object obj = Deserializer.deserialize(input, Object.class);
if (obj instanceof Map) {
// Before the actual parameters we sometimes (connect) get a map of parameters, this is usually null, but if set should be
// passed to the connection object.
@SuppressWarnings("unchecked")
final Map<String, Object> connParams = (Map<String, Object>) obj;
notify.setConnectionParams(connParams);
} else if (obj != null) {
paramList.add(obj);
}
while (in.hasRemaining()) {
paramList.add(Deserializer.deserialize(input, Object.class));
}
params = paramList.toArray();
if (log.isDebugEnabled()) {
log.debug("Num params: {}", paramList.size());
for (int i = 0; i < params.length; i++) {
log.debug(" > {}: {}", i, params[i]);
}
}
return params;
}
示例3: packetReceived
import org.red5.server.net.rtmp.event.Notify; //导入依赖的package包/类
public void packetReceived(IBroadcastStream arg0, IStreamPacket packet) {
if (done) {
arg0.removeStreamListener(this);
return;
}
messages = Red5.getConnectionLocal().getWrittenMessages() + Red5.getConnectionLocal().getReadMessages();
bytesUp = Red5.getConnectionLocal().getReadBytes();
bytesDown = Red5.getConnectionLocal().getWrittenBytes();
if (packet instanceof Notify) {
endpoint().invoke("onBWChunk", new Object[] { chunk });
chunks++;
// Input reader = new Input(((Notify)packet).getData());
// reader.readDataType();//string
// String method=reader.readString(null);
// reader.readDataType();//object
// Map invokeData= (Map) reader.readMap(new Deserializer(), null);
// System.out.println(method+""+invokeData.get("data").toString());
}
}
示例4: getMetaDataEvent
import org.red5.server.net.rtmp.event.Notify; //导入依赖的package包/类
public Notify getMetaDataEvent() {
IoBuffer buf = IoBuffer.allocate(1024);
buf.setAutoExpand(true);
Output out = new Output(buf);
out.writeString("onMetaData");
Map<Object, Object> props = new HashMap<Object, Object>();
props.put("width", 160);
props.put("height", 120);
props.put("framerate", 15);
props.put("videocodecid", 7);
props.put("canSeekToEnd", false);
out.writeMap(props);
buf.flip();
return new Notify(buf);
}
示例5: onStreamEvent
import org.red5.server.net.rtmp.event.Notify; //导入依赖的package包/类
@Override
public void onStreamEvent(Notify notify) {
log.debug("onStreamEvent: {}", notify);
ObjectMap<?, ?> map = (ObjectMap<?, ?>) notify.getCall().getArguments()[0];
String code = (String) map.get("code");
log.debug("<:{}", code);
if (StatusCodes.NS_PUBLISH_START.equals(code)) {
setState(StreamState.PUBLISHED);
IMessage message = null;
while ((message = frameBuffer.poll()) != null) {
rtmpClient.publishStreamData(streamId, message);
}
} else if (StatusCodes.NS_UNPUBLISHED_SUCCESS.equals(code)) {
setState(StreamState.UNPUBLISHED);
}
}
示例6: testDecodeBufferExTS
import org.red5.server.net.rtmp.event.Notify; //导入依赖的package包/类
@Test
public void testDecodeBufferExTS() {
//log.debug("\testDecodeBufferExTS");
RTMPProtocolDecoder dec = new RTMPProtocolDecoder();
RTMPConnection conn = new RTMPMinaConnection();
Red5.setConnectionLocal(conn);
RTMP rtmp = conn.getState();
rtmp.setState(RTMP.STATE_CONNECTED);
// lastHeader: Header [streamId=1, channelId=4, dataType=18, timerBase=0, timerDelta=0, size=309, extended=false]
// get the local decode state
RTMPDecodeState state = conn.getDecoderState();
// meta and audio 4x chunks
IoBuffer in = IoBuffer.wrap(IOUtils.hexStringToByteArray("04000000000135120100000002000d40736574446174614672616d6502000a6f6e4d65746144617461080000000d00086475726174696f6e0040d518000000000000057769647468004064000000000000000668656967687400405e000000000000000d766964656f64617461726174650040686a000000000000096672616d657261746500403900000000c40000000c766964656f636f6465636964004000000000000000000d617564696f6461746172617465000000000000000000000f617564696f73616d706c65726174650040d5888000000000000f617564696f73616d706c6573697a65004030000000000000000673746572656f0100000c617564696f636f6465636964004000c40000000000000007656e636f64657202000d4c61766635362e31352e313032000866696c6573697a650000000000000000000000090400000000006908010000002afff340c400104002e62d4110009080200830107ea04cfa810710e0987f820ec130fc401897c1c0c70ff502008020eea04c1f0fe7fcb9fc10ff90d107c1f82008021feb07c1c04010041c20f89c1fff6b6edad93d99d8da6cd42a08e459095589d4b5fb9a4e679a1f4400001a00006a082afff342c41a19c91f225d89300055a47640c62cee7ccc85c08c42cadb6b56daebe65989f78c3ef3cfbd694ac0c34aa855ee0598a031f0a0686212d43631a4c59a926383c2d5201c5e9b7377"));
Packet packet = null;
do {
packet = dec.decodePacket(conn, state, in);
} while (packet == null);
assertNotNull(packet);
assertTrue(packet.getMessage() instanceof Notify);
do {
packet = dec.decodePacket(conn, state, in);
} while (packet == null);
assertNotNull(packet);
assertTrue(packet.getMessage() instanceof AudioData);
}
示例7: onCommand
import org.red5.server.net.rtmp.event.Notify; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected void onCommand(RTMPConnection conn, Channel channel, Header header, Notify notify) {
super.onCommand(conn, channel, header, notify);
System.out.println("onInvoke, header = " + header.toString());
System.out.println("onInvoke, notify = " + notify.toString());
Object obj = notify.getCall().getArguments().length > 0 ? notify.getCall().getArguments()[0] : null;
if (obj instanceof Map) {
Map<String, String> map = (Map<String, String>) obj;
String code = map.get("code");
if (StatusCodes.NS_PLAY_STOP.equals(code)) {
synchronized (RTMPTSClientTest.class) {
finished = true;
RTMPTSClientTest.class.notifyAll();
}
disconnect();
System.out.println("Disconnected");
}
}
}
示例8: onCommand
import org.red5.server.net.rtmp.event.Notify; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected void onCommand(RTMPConnection conn, Channel channel, Header header, Notify notify) {
super.onCommand(conn, channel, header, notify);
System.out.println("onInvoke, header = " + header.toString());
System.out.println("onInvoke, notify = " + notify.toString());
Object obj = notify.getCall().getArguments().length > 0 ? notify.getCall().getArguments()[0] : null;
if (obj instanceof Map) {
Map<String, String> map = (Map<String, String>) obj;
String code = map.get("code");
if (StatusCodes.NS_PLAY_STOP.equals(code)) {
synchronized (RTMPTClientTest.class) {
finished = true;
RTMPTClientTest.class.notifyAll();
}
disconnect();
System.out.println("Disconnected");
}
}
}
示例9: handlePendingCallResult
import org.red5.server.net.rtmp.event.Notify; //导入依赖的package包/类
/**
* Handler for pending call result. Dispatches results to all pending call
* handlers.
*
* @param conn
* Connection
* @param invoke
* Pending call result event context
*/
protected void handlePendingCallResult(RTMPConnection conn, Notify invoke) {
final IServiceCall call = invoke.getCall();
final IPendingServiceCall pendingCall = conn.retrievePendingCall(invoke.getInvokeId());
if (pendingCall != null) {
// The client sent a response to a previously made call.
Object[] args = call.getArguments();
if (args != null && args.length > 0) {
// TODO: can a client return multiple results?
pendingCall.setResult(args[0]);
}
Set<IPendingServiceCallback> callbacks = pendingCall.getCallbacks();
if (!callbacks.isEmpty()) {
HashSet<IPendingServiceCallback> tmp = new HashSet<IPendingServiceCallback>();
tmp.addAll(callbacks);
for (IPendingServiceCallback callback : tmp) {
try {
callback.resultReceived(pendingCall);
} catch (Exception e) {
log.error("Error while executing callback {}", callback, e);
}
}
}
}
}
示例10: encodeNotifyOrInvoke
import org.red5.server.net.rtmp.event.Notify; //导入依赖的package包/类
@Override
protected void encodeNotifyOrInvoke(IoBuffer out, Notify invoke, RTMP rtmp) {
// if we get an InsufficientBW message for the client, we'll reduce the
// base tolerance and set drop live to true
final IServiceCall call = invoke.getCall();
if ("onStatus".equals(call.getServiceMethodName()) && call.getArguments().length >= 1) {
Object arg0 = call.getArguments()[0];
if ("NetStream.Play.InsufficientBW".equals(((Status) arg0).getCode())) {
long baseT = getBaseTolerance();
try {
// drop the tolerances by half but not less than 500
setBaseTolerance(Math.max(baseT / 2, 500));
} catch (Exception e) {
log.debug("Problem setting base tolerance: {}", e.getMessage());
}
setDropLiveFuture(true);
}
}
super.encodeNotifyOrInvoke(out, invoke, rtmp);
}
示例11: onStreamEvent
import org.red5.server.net.rtmp.event.Notify; //导入依赖的package包/类
@Override
public void onStreamEvent(Notify notify) {
log.debug( "onStreamEvent " + notify );
@SuppressWarnings("rawtypes")
ObjectMap map = (ObjectMap) notify.getCall().getArguments()[0];
String code = (String) map.get("code");
if (StatusCodes.NS_PUBLISH_START.equals(code)) {
log.debug( "onStreamEvent Publish start" );
getCapture().setStartPublish(true);
setReadyToRecord(true);
}
}
示例12: 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);
}
示例13: 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);
}
示例14: getMetaData
import org.red5.server.net.rtmp.event.Notify; //导入依赖的package包/类
/**
* Returns a copy of the metadata for the associated stream, if it exists.
*
* @return stream meta data
*/
public Notify getMetaData() {
Notify md = metaData.get();
if (md != null) {
try {
return md.duplicate();
} catch (Exception e) {
}
}
return md;
}
示例15: getMetaData
import org.red5.server.net.rtmp.event.Notify; //导入依赖的package包/类
public Notify getMetaData() {
if (_metaDataEvent != null) {
return _metaDataEvent;
}
return null;
}