Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowing to lock camera orientation on Android. In progress. #39

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.oney.WebRTCModule">
<uses-permission android:name="android.permission.CAMERA" />
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.facebook.react.bridge.UiThreadUtil;
import com.facebook.react.bridge.WritableArray;
import com.facebook.react.bridge.WritableMap;
import org.webrtc.DailyCamera2Enumerator;
import com.oney.WebRTCModule.videoEffects.ProcessorProvider;
import com.oney.WebRTCModule.videoEffects.VideoEffectProcessor;
import com.oney.WebRTCModule.videoEffects.VideoFrameProcessor;
Expand Down Expand Up @@ -71,7 +72,7 @@ class GetUserMediaImpl {

if (camera2supported) {
Log.d(TAG, "Creating video capturer using Camera2 API.");
cameraEnumerator = new Camera2Enumerator(reactContext);
cameraEnumerator = new DailyCamera2Enumerator(reactContext);
} else {
Log.d(TAG, "Creating video capturer using Camera1 API.");
cameraEnumerator = new Camera1Enumerator(false);
Expand Down
22 changes: 22 additions & 0 deletions android/src/main/java/org/webrtc/DailyCamera2Capturer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.webrtc;

import android.content.Context;
import android.hardware.camera2.CameraManager;

public class DailyCamera2Capturer extends Camera2Capturer {

private final CameraManager cameraManager;

private static final String TAG = "DailyCamera2Capturer";

public DailyCamera2Capturer(Context context, String cameraName, CameraEventsHandler eventsHandler) {
super(context, cameraName, eventsHandler);
this.cameraManager = (CameraManager)context.getSystemService(Context.CAMERA_SERVICE);
Logging.d(TAG, "CREATED DailyCamera2Capturer");
}

protected void createCameraSession(CameraSession.CreateSessionCallback createSessionCallback, CameraSession.Events events, Context applicationContext, SurfaceTextureHelper surfaceTextureHelper, String cameraName, int width, int height, int framerate) {
DailyCamera2Session.create(createSessionCallback, events, applicationContext, this.cameraManager, surfaceTextureHelper, cameraName, width, height, framerate);
}

}
18 changes: 18 additions & 0 deletions android/src/main/java/org/webrtc/DailyCamera2Enumerator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.webrtc;

import android.content.Context;

public class DailyCamera2Enumerator extends Camera2Enumerator {

final Context context;

public DailyCamera2Enumerator(Context context) {
super(context);
this.context = context;
}

public CameraVideoCapturer createCapturer(String deviceName, CameraVideoCapturer.CameraEventsHandler eventsHandler) {
return new DailyCamera2Capturer(this.context, deviceName, eventsHandler);
}

}
Loading