Search in sources :

Example 6 with R5VideoView

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

the class PublishTest 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);
    publish();
    return rootView;
}
Also used : R5VideoView(com.red5pro.streaming.view.R5VideoView) View(android.view.View)

Example 7 with R5VideoView

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

the class PublishABRTest method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.publish_test, container, false);
    // Create the configuration from the values.xml
    R5Configuration config = new R5Configuration(R5StreamProtocol.RTSP, TestContent.GetPropertyString("host"), TestContent.GetPropertyInt("port"), TestContent.GetPropertyString("context"), TestContent.GetPropertyFloat("publish_buffer_time"));
    config.setLicenseKey(TestContent.GetPropertyString("license_key"));
    config.setBundleID(getActivity().getPackageName());
    R5Connection connection = new R5Connection(config);
    // setup a new stream using the connection
    publish = new R5Stream(connection);
    publish.audioController.sampleRate = TestContent.GetPropertyInt("sample_rate");
    publish.setListener(this);
    // show all logging
    publish.setLogLevel(R5Stream.LOG_LEVEL_DEBUG);
    R5Camera camera = null;
    if (TestContent.GetPropertyBool("video_on")) {
        // attach a camera video source
        cam = openFrontFacingCameraGingerbread();
        cam.setDisplayOrientation((camOrientation + 180) % 360);
        camera = new R5Camera(cam, TestContent.GetPropertyInt("camera_width"), TestContent.GetPropertyInt("camera_height"));
        camera.setBitrate(TestContent.GetPropertyInt("bitrate"));
        camera.setOrientation(camOrientation);
    }
    R5AdaptiveBitrateController adaptor = new R5AdaptiveBitrateController();
    adaptor.AttachStream(publish);
    if (TestContent.GetPropertyBool("audio_on")) {
        // attach a microphone
        R5Microphone mic = new R5Microphone();
        publish.attachMic(mic);
    }
    preview = (R5VideoView) rootView.findViewById(R.id.videoPreview);
    preview.attachStream(publish);
    if (TestContent.GetPropertyBool("video_on"))
        publish.attachCamera(camera);
    preview.showDebugView(TestContent.GetPropertyBool("debug_view"));
    publish.publish(TestContent.GetPropertyString("stream1"), R5Stream.RecordType.Live);
    if (TestContent.GetPropertyBool("video_on"))
        cam.startPreview();
    return rootView;
}
Also used : R5Camera(com.red5pro.streaming.source.R5Camera) R5Microphone(com.red5pro.streaming.source.R5Microphone) R5Configuration(com.red5pro.streaming.config.R5Configuration) R5Connection(com.red5pro.streaming.R5Connection) R5Stream(com.red5pro.streaming.R5Stream) R5AdaptiveBitrateController(com.red5pro.streaming.source.R5AdaptiveBitrateController) SurfaceView(android.view.SurfaceView) R5VideoView(com.red5pro.streaming.view.R5VideoView) View(android.view.View)

Example 8 with R5VideoView

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

the class SubscribeTest 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);
    Subscribe();
    return view;
}
Also used : R5VideoView(com.red5pro.streaming.view.R5VideoView) View(android.view.View)

Example 9 with R5VideoView

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

the class SubscribeTwoStreamTest method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.double_view, container, false);
    // Create the configuration from the tests.xml
    R5Configuration config = new R5Configuration(R5StreamProtocol.RTSP, TestContent.GetPropertyString("host"), TestContent.GetPropertyInt("port"), TestContent.GetPropertyString("context"), TestContent.GetPropertyFloat("subscribe_buffer_time"));
    config.setLicenseKey(TestContent.GetPropertyString("license_key"));
    config.setBundleID(getActivity().getPackageName());
    R5Connection connection = new R5Connection(config);
    // setup a new stream using the connection
    subscribe = new R5Stream(connection);
    subscribe.setListener(this);
    subscribe.audioController = new R5AudioController();
    subscribe.audioController.sampleRate = TestContent.GetPropertyInt("sample_rate");
    // show all logging
    subscribe.setLogLevel(R5Stream.LOG_LEVEL_DEBUG);
    // find the view and attach the stream
    display = (R5VideoView) view.findViewById(R.id.videoView1);
    display.attachStream(subscribe);
    display.showDebugView(TestContent.GetPropertyString("debug_view").equals("true"));
    subscribe.play(TestContent.GetPropertyString("stream1"));
    secondDisplay = (R5VideoView) view.findViewById(R.id.videoView2);
    final R5ConnectionListener listener = this;
    final Handler root = new Handler(Looper.getMainLooper());
    new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                Thread.sleep(4000);
                Looper.prepare();
                root.post(new Runnable() {

                    @Override
                    public void run() {
                        R5Configuration config2 = new R5Configuration(R5StreamProtocol.RTSP, TestContent.GetPropertyString("host"), TestContent.GetPropertyInt("port"), TestContent.GetPropertyString("context"), TestContent.GetPropertyFloat("subscribe_buffer_time"));
                        config2.setLicenseKey(TestContent.GetPropertyString("license_key"));
                        config2.setBundleID(getActivity().getPackageName());
                        R5Connection secondConnection = new R5Connection(config2);
                        secondSubscribe = new R5Stream(secondConnection);
                        secondSubscribe.setListener(listener);
                        secondDisplay.attachStream(secondSubscribe);
                        secondDisplay.showDebugView(TestContent.GetPropertyString("debug_view").equals("true"));
                        secondSubscribe.audioController = new R5AudioController();
                        secondSubscribe.audioController.sampleRate = TestContent.GetPropertyInt("sample_rate");
                        secondSubscribe.play(TestContent.GetPropertyString("stream2"));
                    }
                });
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }).start();
    return view;
}
Also used : R5ConnectionListener(com.red5pro.streaming.event.R5ConnectionListener) R5Configuration(com.red5pro.streaming.config.R5Configuration) R5Connection(com.red5pro.streaming.R5Connection) R5Stream(com.red5pro.streaming.R5Stream) Handler(android.os.Handler) R5AudioController(com.red5pro.streaming.media.R5AudioController) R5VideoView(com.red5pro.streaming.view.R5VideoView) View(android.view.View)

Example 10 with R5VideoView

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

the class SubscribeStreamManagerTest 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 {
                // url format: https://{streammanagerhost}:{port}/streammanager/api/2.0/event/{scopeName}/{streamName}?action=subscribe
                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=subscribe";
                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() {
                                subscribeToManager(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 view;
}
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)

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