diff --git a/app/app.iml b/app/app.iml index 736aa2d..07c52b7 100644 --- a/app/app.iml +++ b/app/app.iml @@ -49,13 +49,6 @@ - - - - - - - @@ -63,6 +56,13 @@ + + + + + + + @@ -70,13 +70,6 @@ - - - - - - - @@ -84,31 +77,25 @@ + + + + + + + - - - - - - - - - - - - - @@ -119,10 +106,10 @@ + - diff --git a/app/src/main/java/red5pro/org/testandroidproject/tests/PublishCameraSwapTest/PublishCameraSwapTest.java b/app/src/main/java/red5pro/org/testandroidproject/tests/PublishCameraSwapTest/PublishCameraSwapTest.java index 25b64fd..e01db25 100644 --- a/app/src/main/java/red5pro/org/testandroidproject/tests/PublishCameraSwapTest/PublishCameraSwapTest.java +++ b/app/src/main/java/red5pro/org/testandroidproject/tests/PublishCameraSwapTest/PublishCameraSwapTest.java @@ -6,14 +6,21 @@ import android.view.Surface; import android.view.View; +import com.red5pro.streaming.R5Connection; +import com.red5pro.streaming.R5Stream; +import com.red5pro.streaming.R5StreamProtocol; +import com.red5pro.streaming.config.R5Configuration; import com.red5pro.streaming.source.R5Camera; +import com.red5pro.streaming.source.R5Microphone; import red5pro.org.testandroidproject.tests.PublishTest.PublishTest; +import red5pro.org.testandroidproject.tests.TestContent; /** * Created by davidHeimann on 2/10/16. */ public class PublishCameraSwapTest extends PublishTest { + private int currentCamMode = Camera.CameraInfo.CAMERA_FACING_FRONT; public void onActivityCreated(Bundle savedInstanceState) { @@ -27,6 +34,64 @@ public boolean onTouch(View v, MotionEvent event) { }); } + @Override + protected void publish(){ + 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("video_on")) { + //attach a camera video source + int rotate = (currentCamMode == Camera.CameraInfo.CAMERA_FACING_FRONT) ? 180 : 0; + cam = (currentCamMode == Camera.CameraInfo.CAMERA_FACING_FRONT) ? + openFrontFacingCameraGingerbread() : openBackFacingCameraGingerbread(); + cam.setDisplayOrientation((camOrientation + rotate) % 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.setListener(this); + publish.publish(TestContent.GetPropertyString("stream1"), R5Stream.RecordType.Live); + + if(TestContent.GetPropertyBool("video_on")) { + cam.startPreview(); + } + + } + private boolean onPublishTouch( MotionEvent e ) { if( e.getAction() == MotionEvent.ACTION_UP && publish != null) { diff --git a/app/src/main/java/red5pro/org/testandroidproject/tests/PublishTest/PublishTest.java b/app/src/main/java/red5pro/org/testandroidproject/tests/PublishTest/PublishTest.java index 9cc1478..bd846de 100644 --- a/app/src/main/java/red5pro/org/testandroidproject/tests/PublishTest/PublishTest.java +++ b/app/src/main/java/red5pro/org/testandroidproject/tests/PublishTest/PublishTest.java @@ -108,6 +108,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa return rootView; } + protected void publish(){ String b = getActivity().getPackageName();