Java Code Examples for org.red5.io.utils.ObjectMap#put()

The following examples show how to use org.red5.io.utils.ObjectMap#put() . 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 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);
}
 
Example 2
Source File: BandwidthChecker.java    From red5-rtsp-restreamer with Apache License 2.0 5 votes vote down vote up
public void run() {

		done = false;

		connection.ping();
		deltaDown = connection.getWrittenBytes();
		deltaUp = connection.getReadBytes();
		endpoint().invoke("onBWStart");

		try {
			Thread.sleep(duration);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		done = true;

		connection.removeAttribute("bwChecker");

		ObjectMap<Object, Object> map = new ObjectMap<Object, Object>();
		map.put("bytesDown", bytesDown);
		map.put("bytesUp", bytesUp);
		map.put("messages", messages);
		map.put("chunks", messages);
		map.put("ping", connection.getLastPingTime());

		endpoint().invoke("onBWDone", new Object[] { map });

	}
 
Example 3
Source File: Input.java    From red5-io with Apache License 2.0 5 votes vote down vote up
@Override
public Object readMap() {
    // the maximum number used in this mixed array
    int maxNumber = buf.getInt();
    log.debug("Read start mixed array: {}", maxNumber);
    ObjectMap<Object, Object> result = new ObjectMap<Object, Object>();
    // we must store the reference before we deserialize any items in it to
    // ensure that reference IDs are correct
    int reference = storeReference(result);
    while (hasMoreProperties()) {
        String key = getString();
        Object item = Deserializer.deserialize(this, Object.class);
        //log.info("key: {} item: {}", key, item);
        if (!NumberUtils.isParsable(key)) {
            result.put(key, item);
        } else {
            // map keys are either integers or strings, none will be doubles
            if (key.contains(".")) {
                result.put(key, item);
            } else {
                result.put(Integer.valueOf(key), item);
            }
        }
    }
    result.remove("length");
    // replace the original reference with the final result
    storeReference(reference, result);
    return result;
}
 
Example 4
Source File: InputTest.java    From red5-io with Apache License 2.0 5 votes vote down vote up
@Test
public void testZeroBasedEcmaArray() {
    // { '0': 'hello', '1': 'world' }
    byte[] stream = new byte[] { 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0x30, 0x02, 0x00, 0x05, 'h', 'e', 'l', 'l', 'o', 0x00, 0x01, 0x31, 0x02, 0x00, 0x05, 'w', 'o', 'r', 'l', 'd', 0x00, 0x00, 0x09 };
    Input input = new Input(IoBuffer.wrap(stream));
    Object actual = input.readMap();

    ObjectMap<Object, Object> expected = new ObjectMap<>();
    expected.put(0, "hello");
    expected.put(1, "world");

    assertEquals(expected, actual);
}