Search in sources :

Example 1 with R5Microphone

use of com.red5pro.streaming.source.R5Microphone in project streaming-android by red5pro.

the class RecordedTest method onCreateView.

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("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.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);
    }
    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.Record);
    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) R5VideoView(com.red5pro.streaming.view.R5VideoView) View(android.view.View)

Example 2 with R5Microphone

use of com.red5pro.streaming.source.R5Microphone in project streaming-android by red5pro.

the class PublishCamera2Test 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);
    String b = getActivity().getPackageName();
    // 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(b);
    R5Connection connection = new R5Connection(config);
    // setup a new stream using the connection
    publish = new R5Stream(connection);
    publish.audioController.sampleRate = TestContent.GetPropertyInt("sample_rate");
    // show all logging
    publish.setLogLevel(R5Stream.LOG_LEVEL_DEBUG);
    if (TestContent.GetPropertyBool("audio_on")) {
        // attach a microphone
        R5Microphone mic = new R5Microphone();
        publish.attachMic(mic);
    }
    preview.attachStream(publish);
    CameraManager manager = (CameraManager) getActivity().getSystemService(Context.CAMERA_SERVICE);
    try {
        String[] camList = manager.getCameraIdList();
        for (String id : camList) {
            CameraCharacteristics info = manager.getCameraCharacteristics(id);
            if (info.get(CameraCharacteristics.LENS_FACING) == CameraCharacteristics.LENS_FACING_FRONT) {
                camOrientation = info.get(CameraCharacteristics.SENSOR_ORIENTATION);
                camInfo = info;
                manager.openCamera(id, new CameraDevice.StateCallback() {

                    @Override
                    public void onOpened(@NonNull CameraDevice camera) {
                        if (preview == null)
                            return;
                        startPublish(camera);
                    }

                    @Override
                    public void onDisconnected(@NonNull CameraDevice camera) {
                    }

                    @Override
                    public void onError(@NonNull CameraDevice camera, int error) {
                    }
                }, null);
                break;
            }
        }
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
    return rootView;
}
Also used : R5Microphone(com.red5pro.streaming.source.R5Microphone) CameraDevice(android.hardware.camera2.CameraDevice) R5Stream(com.red5pro.streaming.R5Stream) CameraManager(android.hardware.camera2.CameraManager) ImageView(android.widget.ImageView) R5VideoView(com.red5pro.streaming.view.R5VideoView) View(android.view.View) CameraAccessException(android.hardware.camera2.CameraAccessException) R5Configuration(com.red5pro.streaming.config.R5Configuration) R5Connection(com.red5pro.streaming.R5Connection) CameraCharacteristics(android.hardware.camera2.CameraCharacteristics)

Example 3 with R5Microphone

use of com.red5pro.streaming.source.R5Microphone in project streaming-android by red5pro.

the class PublishCustomSourceTest 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);
    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);
    CustomVideoSource source = new CustomVideoSource();
    source.setBitrate(TestContent.GetPropertyInt("bitrate"));
    publish.attachCamera(source);
    preview.showDebugView(TestContent.GetPropertyBool("debug_view"));
    publish.publish(TestContent.GetPropertyString("stream1"), R5Stream.RecordType.Live);
    return rootView;
}
Also used : R5Microphone(com.red5pro.streaming.source.R5Microphone) R5Configuration(com.red5pro.streaming.config.R5Configuration) R5Connection(com.red5pro.streaming.R5Connection) R5Stream(com.red5pro.streaming.R5Stream) R5VideoView(com.red5pro.streaming.view.R5VideoView) View(android.view.View)

Example 4 with R5Microphone

use of com.red5pro.streaming.source.R5Microphone in project streaming-android by red5pro.

the class PublishSendTest 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);
        camera.setFramerate(TestContent.GetPropertyInt("fps"));
    }
    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();
    preview.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Map<String, String> parms = new HashMap<String, String>();
            parms.put("value", "1");
            publish.send("onStreamSend", parms);
        }
    });
    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) SurfaceView(android.view.SurfaceView) R5VideoView(com.red5pro.streaming.view.R5VideoView) View(android.view.View) HashMap(java.util.HashMap) Map(java.util.Map)

Example 5 with R5Microphone

use of com.red5pro.streaming.source.R5Microphone in project streaming-android by red5pro.

the class PublishStreamManagerTest method publishToManager.

private void publishToManager(String url) {
    R5Configuration config = new R5Configuration(R5StreamProtocol.RTSP, url, 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);
        camera.setFramerate(TestContent.GetPropertyInt("fps"));
    }
    if (TestContent.GetPropertyBool("audio_on")) {
        // attach a microphone
        R5Microphone mic = new R5Microphone();
        publish.attachMic(mic);
    }
    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();
    edgeShow = new TextView(preview.getContext());
    FrameLayout.LayoutParams position = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM);
    edgeShow.setLayoutParams(position);
    ((FrameLayout) preview.getParent()).addView(edgeShow);
    edgeShow.setText("Connected to: " + url, TextView.BufferType.NORMAL);
    edgeShow.setBackgroundColor(Color.LTGRAY);
}
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) FrameLayout(android.widget.FrameLayout) TextView(android.widget.TextView)

Aggregations

R5Connection (com.red5pro.streaming.R5Connection)9 R5Stream (com.red5pro.streaming.R5Stream)9 R5Configuration (com.red5pro.streaming.config.R5Configuration)9 R5Microphone (com.red5pro.streaming.source.R5Microphone)9 R5Camera (com.red5pro.streaming.source.R5Camera)7 View (android.view.View)6 R5VideoView (com.red5pro.streaming.view.R5VideoView)6 SurfaceView (android.view.SurfaceView)2 CameraAccessException (android.hardware.camera2.CameraAccessException)1 CameraCharacteristics (android.hardware.camera2.CameraCharacteristics)1 CameraDevice (android.hardware.camera2.CameraDevice)1 CameraManager (android.hardware.camera2.CameraManager)1 FrameLayout (android.widget.FrameLayout)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 R5AdaptiveBitrateController (com.red5pro.streaming.source.R5AdaptiveBitrateController)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1