Skip to content
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