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

The following examples show how to use org.red5.io.utils.ObjectMap#get() . 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: StreamingProxy.java    From red5-client with Apache License 2.0 6 votes vote down vote up
@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 2
Source File: BaseRTMPClientHandler.java    From red5-client with Apache License 2.0 5 votes vote down vote up
@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 3
Source File: ClientTest.java    From red5-client with Apache License 2.0 5 votes vote down vote up
@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 4
Source File: RTMPTSClientTest.java    From red5-client with Apache License 2.0 5 votes vote down vote up
@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 5
Source File: RTMPTClientTest.java    From red5-client with Apache License 2.0 5 votes vote down vote up
@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 6
Source File: RTMPClientTest.java    From red5-client with Apache License 2.0 4 votes vote down vote up
@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");
}