org.red5.io.utils.ObjectMap Java Examples
The following examples show how to use
org.red5.io.utils.ObjectMap.
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: BaseRTMPClientHandler.java From red5-client with Apache License 2.0 | 6 votes |
/** * Creates the default connection parameters collection. Many implementations of this handler will create a tcUrl if not found, it is * created with the current server url. * * @param server * the server location * @param port * the port for the protocol * @param application * the application name at the given server * @return connection parameters map */ @Override public Map<String, Object> makeDefaultConnectionParams(String server, int port, String application) { Map<String, Object> params = new ObjectMap<>(); params.put("app", application); params.put("objectEncoding", Integer.valueOf(0)); params.put("fpad", Boolean.FALSE); params.put("flashVer", "WIN 11,2,202,235"); params.put("audioCodecs", Integer.valueOf(3575)); params.put("videoFunction", Integer.valueOf(1)); params.put("pageUrl", null); params.put("path", application); params.put("capabilities", Integer.valueOf(15)); params.put("swfUrl", null); params.put("videoCodecs", Integer.valueOf(252)); return params; }
Example #2
Source File: StreamingProxy.java From red5-client with Apache License 2.0 | 6 votes |
@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); } }
Example #3
Source File: RTMPTClientTest.java From red5-client with Apache License 2.0 | 5 votes |
@Override public void resultReceived(IPendingServiceCall call) { System.out.println("connectCallback"); ObjectMap<?, ?> map = (ObjectMap<?, ?>) call.getResult(); String code = (String) map.get("code"); System.out.printf("Response code: %s\n", code); if ("NetConnection.Connect.Rejected".equals(code)) { System.out.printf("Rejected: %s\n", map.get("description")); disconnect(); synchronized (RTMPTClientTest.class) { finished = true; RTMPTClientTest.class.notifyAll(); } } else if ("NetConnection.Connect.Failed".equals(code)) { System.out.printf("Failed: %s\n", map.get("description")); disconnect(); synchronized (RTMPTClientTest.class) { finished = true; RTMPTClientTest.class.notifyAll(); } } else if ("NetConnection.Connect.Success".equals(code)) { test(); createStream(createStreamCallback); } else { System.out.printf("Unhandled response code: %s\n", code); } }
Example #4
Source File: PlayEngine.java From red5-server-common with Apache License 2.0 | 5 votes |
/** * 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 #5
Source File: RTMPTSClientTest.java From red5-client with Apache License 2.0 | 5 votes |
@Override public void resultReceived(IPendingServiceCall call) { System.out.println("connectCallback"); ObjectMap<?, ?> map = (ObjectMap<?, ?>) call.getResult(); String code = (String) map.get("code"); System.out.printf("Response code: %s\n", code); if ("NetConnection.Connect.Rejected".equals(code)) { System.out.printf("Rejected: %s\n", map.get("description")); disconnect(); synchronized (RTMPTSClientTest.class) { finished = true; RTMPTSClientTest.class.notifyAll(); } } else if ("NetConnection.Connect.Failed".equals(code)) { System.out.printf("Failed: %s\n", map.get("description")); disconnect(); synchronized (RTMPTSClientTest.class) { finished = true; RTMPTSClientTest.class.notifyAll(); } } else if ("NetConnection.Connect.Success".equals(code)) { test(); createStream(createStreamCallback); } else { System.out.printf("Unhandled response code: %s\n", code); } }
Example #6
Source File: ClientMethodHander.java From red5-client with Apache License 2.0 | 5 votes |
public void onStatus(IConnection conn, ObjectMap<String, Object> status) { log.debug("onStatus: {}", status); String code = status.get("code").toString(); if ("NetStream.Play.Stop".equals(code)) { log.debug("Playback stopped"); conn.close(); } }
Example #7
Source File: SharedObjectClient.java From red5-client with Apache License 2.0 | 5 votes |
@Override public void resultReceived(IPendingServiceCall call) { log.debug("Received pending call: {}", call); Object result = call.getResult(); if (result instanceof ObjectMap) { obj = getSharedObject(soName, false); obj.connect(Red5.getConnectionLocal()); obj.addSharedObjectListener(this); } }
Example #8
Source File: ClientTest.java From red5-client with Apache License 2.0 | 5 votes |
@Override public void resultReceived(IPendingServiceCall call) { System.out.println("connectCallback"); ObjectMap<?, ?> map = (ObjectMap<?, ?>) call.getResult(); String code = (String) map.get("code"); System.out.printf("Response code: %s\n", code); if ("NetConnection.Connect.Rejected".equals(code)) { System.out.printf("Rejected: %s\n", map.get("description")); disconnect(); finished = true; } else if ("NetConnection.Connect.Success".equals(code)) { invoke("demoService.getListOfAvailableFLVs", new Object[] {}, methodCallCallback); createStream(createStreamCallback); } }
Example #9
Source File: BaseRTMPClientHandler.java From red5-client with Apache License 2.0 | 5 votes |
@Override public void resultReceived(IPendingServiceCall call) { log.debug("resultReceived", call); if (call.getResult() instanceof ObjectMap<?, ?>) { ObjectMap<?, ?> map = (ObjectMap<?, ?>) call.getResult(); if (map.containsKey("code")) { String code = (String) map.get("code"); log.debug("Code: {}", code); if (StatusCodes.NS_PLAY_START.equals(code)) { subscribed = true; } } } wrapped.resultReceived(call); }
Example #10
Source File: InputTest.java From red5-io with Apache License 2.0 | 5 votes |
@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); }
Example #11
Source File: InputTest.java From red5-io with Apache License 2.0 | 5 votes |
@Test public void testOnStreamSendMap() { // 02 = string // 08 = mixed array (map) max number = 0 IoBuffer data = IoBuffer.wrap(IOUtils.hexStringToByteArray("02 00 0c 6f 6e 53 74 72 65 61 6d 53 65 6e 64 08 00000000 00 05 76 616c7565 02 00 01 31 00 00 09")); Input in0 = new Input(data); assertEquals(DataTypes.CORE_STRING, in0.readDataType()); String method = in0.readString(); assertEquals("onStreamSend", method); assertEquals(DataTypes.CORE_MAP, in0.readDataType()); @SuppressWarnings("rawtypes") ObjectMap map = (ObjectMap) in0.readMap(); assertEquals(map.get("value"), "1"); }
Example #12
Source File: AMFIOTest.java From red5-io with Apache License 2.0 | 5 votes |
/** * Sample data from https://en.wikipedia.org/wiki/Action_Message_Format */ @Test public void testAMF0Wiki() { log.debug("\ntestAMF0Wiki"); IoBuffer data = IoBuffer.wrap(IOUtils.hexStringToByteArray("03 00 04 6e 61 6d 65 02 00 04 4d 69 6b 65 00 03 61 67 65 00 40 3e 00 00 00 00 00 00 00 05 61 6c 69 61 73 02 00 04 4d 69 6b 65 00 00 09")); Input in0 = new Input(data); // object assertEquals(DataTypes.CORE_OBJECT, in0.readDataType()); @SuppressWarnings("rawtypes") ObjectMap person = (ObjectMap) in0.readObject(); assertEquals(person.get("name"), "Mike"); assertEquals(person.get("alias"), "Mike"); assertEquals(person.get("age"), 30d); }
Example #13
Source File: Input.java From red5-io with Apache License 2.0 | 5 votes |
/** * Reads the input as a map and returns a Map * * @return Read map */ protected Map<String, Object> readSimpleObject() { log.debug("readSimpleObject"); Map<String, Object> result = new ObjectMap<>(); readKeyValues(result); storeReference(result); return result; }
Example #14
Source File: Input.java From red5-io with Apache License 2.0 | 5 votes |
@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 #15
Source File: Serializer.java From red5-io with Apache License 2.0 | 5 votes |
/** * Write typed object to the output * * @param out * Output writer * @param obj * Object type to write * @return true if the object has been written, otherwise false */ @SuppressWarnings("all") protected static boolean writeObjectType(Output out, Object obj) { if (obj instanceof ObjectMap || obj instanceof BeanMap) { out.writeObject((Map) obj); } else if (obj instanceof Map) { out.writeMap((Map) obj); } else if (obj instanceof RecordSet) { out.writeRecordSet((RecordSet) obj); } else { out.writeObject(obj); } return true; }
Example #16
Source File: BandwidthChecker.java From red5-rtsp-restreamer with Apache License 2.0 | 5 votes |
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 #17
Source File: StreamService.java From red5-server-common with Apache License 2.0 | 5 votes |
/** * Dynamic streaming play method. This is a convenience method. * * @param params * play parameters */ @SuppressWarnings("rawtypes") public void play2(ObjectMap params) { log.debug("play2 options: {}", params); Map<String, Object> playOptions = new HashMap<String, Object>(); for (Object key : params.keySet()) { String k = key.toString(); log.trace("Parameter: {}", k); playOptions.put(k, params.get(k)); } play2(playOptions); }
Example #18
Source File: RTMPClientTest.java From red5-client with Apache License 2.0 | 4 votes |
@Test public void test26() throws InterruptedException { client.setStreamEventHandler(new INetStreamEventHandler() { @Override public void onStreamEvent(Notify notify) { log.info("ClientStream.dispachEvent: {}", notify); } }); client.setServiceProvider(new ClientMethodHander()); client.setConnectionClosedHandler(new Runnable() { @Override public void run() { System.out.println("Connection closed"); } }); client.setExceptionHandler(new ClientExceptionHandler() { @Override public void handleException(Throwable throwable) { throwable.printStackTrace(); } }); IPendingServiceCallback connectCallback = new IPendingServiceCallback() { @Override public void resultReceived(IPendingServiceCall call) { log.info("connectCallback"); ObjectMap<?, ?> map = (ObjectMap<?, ?>) call.getResult(); String code = (String) map.get("code"); log.info("Response code: {}", code); if ("NetConnection.Connect.Rejected".equals(code)) { System.out.printf("Rejected: %s\n", map.get("description")); client.disconnect(); } else if ("NetConnection.Connect.Success".equals(code)) { // 1. Wait for onBWDone timer.schedule(new BandwidthStatusTask(), 2000L); } } }; /* * client.connect("localhost", 1935, "live/remote/0586e318-6277-11e3-adc2-22000a1d91fe", new IPendingServiceCallback() { * @Override public void resultReceived(IPendingServiceCall result) { System.out.println("resultReceived: " + result); ObjectMap<?, ?> map = (ObjectMap<?, ?>) result.getResult(); * String code = (String) map.get("code"); System.out.printf("Response code: %s\n", code); if ("NetConnection.Connect.Rejected".equals(code)) { System.out.printf("Rejected: %s\n", * map.get("description")); client.disconnect(); } else if ("NetConnection.Connect.Success".equals(code)) { System.out.println("success: " + result.isSuccess()); ArrayList<Object> * list = new ArrayList<>(); list.add(new Object[] { "fujifilm-x100s-video-test-1080p-full-hd-hdmp4_720.mp4" }); list.add(new Object[] { * "canon-500d-test-video-720-hd-30-fr-hdmp4_720.mp4" }); Object[] params = { "64", "cc-video-processed/", list }; //Object[] params = { "64", "cc-video-processed/" }; * client.invoke("loadPlaylist", params, new IPendingServiceCallback() { * @Override public void resultReceived(IPendingServiceCall result) { System.out.println(result); } }); } } }); */ client.connect("localhost", 1935, "vod", connectCallback); do { try { Thread.sleep(10000); } catch (InterruptedException e) { } } while (!client.conn.isClosed()); log.debug("Client not connected"); timer.cancel(); log.info("Exit"); }