Search in sources :

Example 11 with R5VideoView

use of com.red5pro.streaming.view.R5VideoView in project streaming-android by red5pro.

the class TwoWayTest method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.twoway_test, container, false);
    preview = (R5VideoView) rootView.findViewById(R.id.videoPreview);
    publish();
    publish.client = this;
    final R5ConnectionListener additionalListener = this;
    publish.setListener(new R5ConnectionListener() {

        @Override
        public void onConnectionEvent(R5ConnectionEvent r5ConnectionEvent) {
            additionalListener.onConnectionEvent(r5ConnectionEvent);
            if (r5ConnectionEvent == R5ConnectionEvent.START_STREAMING) {
                isPublishing = true;
                sendRemoteCall();
            }
            if (r5ConnectionEvent == R5ConnectionEvent.DISCONNECTED) {
                if (isSubscribing) {
                    isSubscribing = false;
                    subscribe.stop();
                    subscribe = null;
                }
                isPublishing = false;
            }
        }
    });
    display = (R5VideoView) rootView.findViewById(R.id.videoView);
    return rootView;
}
Also used : R5ConnectionListener(com.red5pro.streaming.event.R5ConnectionListener) R5ConnectionEvent(com.red5pro.streaming.event.R5ConnectionEvent) R5VideoView(com.red5pro.streaming.view.R5VideoView) View(android.view.View)

Example 12 with R5VideoView

use of com.red5pro.streaming.view.R5VideoView in project streaming-android by red5pro.

the class PublishStreamManagerTest method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.publish_test, container, false);
    preview = (R5VideoView) rootView.findViewById(R.id.videoPreview);
    new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                // url format: https://{streammanagerhost}:{port}/streammanager/api/2.0/event/{scopeName}/{streamName}?action=broadcast
                String port = TestContent.getFormattedPortSetting(TestContent.GetPropertyString("server_port"));
                String url = "http://" + TestContent.GetPropertyString("host") + port + "/streammanager/api/2.0/event/" + TestContent.GetPropertyString("context") + "/" + TestContent.GetPropertyString("stream1") + "?action=broadcast";
                HttpClient httpClient = new DefaultHttpClient();
                HttpResponse response = httpClient.execute(new HttpGet(url));
                StatusLine statusLine = response.getStatusLine();
                if (statusLine.getStatusCode() == HttpStatus.SC_OK) {
                    ByteArrayOutputStream out = new ByteArrayOutputStream();
                    response.getEntity().writeTo(out);
                    String responseString = out.toString();
                    out.close();
                    JSONObject data = new JSONObject(responseString);
                    final String outURL = data.getString("serverAddress");
                    if (!outURL.isEmpty()) {
                        getActivity().runOnUiThread(new Runnable() {

                            @Override
                            public void run() {
                                publishToManager(outURL);
                            }
                        });
                    } else {
                        System.out.println("Server address not returned");
                    }
                } else {
                    response.getEntity().getContent().close();
                    throw new IOException(statusLine.getReasonPhrase());
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }).start();
    return rootView;
}
Also used : HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) R5VideoView(com.red5pro.streaming.view.R5VideoView) View(android.view.View) TextView(android.widget.TextView) DefaultHttpClient(org.apache.http.impl.client.DefaultHttpClient) IOException(java.io.IOException) StatusLine(org.apache.http.StatusLine) JSONObject(org.json.JSONObject) DefaultHttpClient(org.apache.http.impl.client.DefaultHttpClient) HttpClient(org.apache.http.client.HttpClient)

Example 13 with R5VideoView

use of com.red5pro.streaming.view.R5VideoView in project streaming-android by red5pro.

the class SubscribeCluster method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.subscribe_test, container, false);
    display = (R5VideoView) view.findViewById(R.id.videoView);
    new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                HttpClient httpClient = new DefaultHttpClient();
                String port = TestContent.getFormattedPortSetting(TestContent.GetPropertyString("server_port"));
                HttpResponse response = httpClient.execute(new HttpGet("http://" + TestContent.GetPropertyString("host") + port + "/cluster"));
                StatusLine statusLine = response.getStatusLine();
                if (statusLine.getStatusCode() == HttpStatus.SC_OK) {
                    ByteArrayOutputStream out = new ByteArrayOutputStream();
                    response.getEntity().writeTo(out);
                    String responseString = out.toString();
                    out.close();
                    // the return is the host ip and rtmp port. we are only interested in the host ip.
                    String[] bits = responseString.split(":");
                    edgeIP = bits[0];
                    Log.i("cluster", "round robin ip: " + edgeIP);
                    getActivity().runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            beginSubscribe();
                        }
                    });
                } else {
                    // Closes the connection.
                    response.getEntity().getContent().close();
                    throw new IOException(statusLine.getReasonPhrase());
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }).start();
    return view;
}
Also used : HttpGet(org.apache.http.client.methods.HttpGet) BasicHttpResponse(org.apache.http.message.BasicHttpResponse) HttpResponse(org.apache.http.HttpResponse) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) R5VideoView(com.red5pro.streaming.view.R5VideoView) View(android.view.View) TextView(android.widget.TextView) DefaultHttpClient(org.apache.http.impl.client.DefaultHttpClient) IOException(java.io.IOException) StatusLine(org.apache.http.StatusLine) DefaultHttpClient(org.apache.http.impl.client.DefaultHttpClient) HttpClient(org.apache.http.client.HttpClient)

Example 14 with R5VideoView

use of com.red5pro.streaming.view.R5VideoView in project streaming-android by red5pro.

the class SubscribeReconnectTest method SetupListener.

public void SetupListener() {
    final R5ConnectionListener additionalListener = this;
    final SubscribeReconnectTest subscribeTest = this;
    final R5Stream subscriber = this.subscribe;
    final R5VideoView view = this.display;
    subscribe.setListener(new R5ConnectionListener() {

        @Override
        public void onConnectionEvent(R5ConnectionEvent r5ConnectionEvent) {
            final R5ConnectionListener me = this;
            additionalListener.onConnectionEvent(r5ConnectionEvent);
            if (r5ConnectionEvent == R5ConnectionEvent.CLOSE && !SubscribeReconnectTest.this.stopped) {
                Handler h = new Handler(Looper.getMainLooper());
                h.postDelayed(new Runnable() {

                    @Override
                    public void run() {
                        if (!stopped) {
                            subscribeTest.findStreams();
                        }
                    }
                }, reconnectDelay);
            } else if (r5ConnectionEvent == R5ConnectionEvent.NET_STATUS && r5ConnectionEvent.message.equals("NetStream.Play.UnpublishNotify")) {
                Handler h = new Handler(Looper.getMainLooper());
                h.postDelayed(new Runnable() {

                    @Override
                    public void run() {
                        subscriber.setListener(null);
                        subscriber.stop();
                        view.attachStream(null);
                        subscribeTest.delayReconnect(reconnectDelay);
                    }
                }, reconnectDelay);
            }
        }
    });
}
Also used : R5ConnectionListener(com.red5pro.streaming.event.R5ConnectionListener) R5VideoView(com.red5pro.streaming.view.R5VideoView) R5Stream(com.red5pro.streaming.R5Stream) R5ConnectionEvent(com.red5pro.streaming.event.R5ConnectionEvent) Handler(android.os.Handler)

Example 15 with R5VideoView

use of com.red5pro.streaming.view.R5VideoView in project streaming-android by red5pro.

the class SubscribeReconnectTest method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.subscribe_test, container, false);
    // find the view and attach the stream
    display = (R5VideoView) view.findViewById(R.id.videoView);
    findStreams();
    return view;
}
Also used : R5VideoView(com.red5pro.streaming.view.R5VideoView) View(android.view.View)

Aggregations

R5VideoView (com.red5pro.streaming.view.R5VideoView)17 View (android.view.View)16 R5Stream (com.red5pro.streaming.R5Stream)8 R5Connection (com.red5pro.streaming.R5Connection)7 R5Configuration (com.red5pro.streaming.config.R5Configuration)7 R5Microphone (com.red5pro.streaming.source.R5Microphone)6 TextView (android.widget.TextView)4 R5Camera (com.red5pro.streaming.source.R5Camera)4 R5ConnectionListener (com.red5pro.streaming.event.R5ConnectionListener)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 IOException (java.io.IOException)3 HttpResponse (org.apache.http.HttpResponse)3 StatusLine (org.apache.http.StatusLine)3 HttpClient (org.apache.http.client.HttpClient)3 HttpGet (org.apache.http.client.methods.HttpGet)3 DefaultHttpClient (org.apache.http.impl.client.DefaultHttpClient)3 Handler (android.os.Handler)2 SurfaceView (android.view.SurfaceView)2 R5ConnectionEvent (com.red5pro.streaming.event.R5ConnectionEvent)2 JSONObject (org.json.JSONObject)2