Reland of Support adding and removing MediaRecorder to camera 2 session. (patchset #1 id:1 of https://codereview.webrtc.org/2844233002/ )
Reason for revert: Revert "Revert of Support adding and removing MediaRecorder to camera 2 session. (patchset #5 id:80001 of https://codereview.webrtc.org/2833773003/ )" Will fix external bots by cherry picking this CL and updating external functions which depend on CameraVideoCapturer interface Original issue's description: > Revert of Support adding and removing MediaRecorder to camera 2 session. (patchset #5 id:80001 of https://codereview.webrtc.org/2833773003/ ) > > Reason for revert: > Breaks external bot > > Original issue's description: > > Support adding and removing MediaRecorder to camera 2 session. > > > > Camera 1 API is not supported. > > > > BUG=b/36684011 > > > > Review-Url: https://codereview.webrtc.org/2833773003 > > Cr-Commit-Position: refs/heads/master@{#17901} > > Committed:2fc04769fa> > TBR=sakal@webrtc.org,glaznev@webrtc.org > # Skipping CQ checks because original CL landed less than 1 days ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=b/36684011 > > Review-Url: https://codereview.webrtc.org/2844233002 > Cr-Commit-Position: refs/heads/master@{#17905} > Committed:6702739862TBR=sakal@webrtc.org,magjed@webrtc.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=b/36684011 Review-Url: https://codereview.webrtc.org/2844393002 Cr-Commit-Position: refs/heads/master@{#17915}
This commit is contained in:
@ -10,11 +10,8 @@
|
||||
|
||||
package org.webrtc;
|
||||
|
||||
import org.webrtc.CameraEnumerationAndroid.CaptureFormat;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import java.util.List;
|
||||
import android.media.MediaRecorder;
|
||||
|
||||
public class Camera1Capturer extends CameraCapturer {
|
||||
private final boolean captureToTexture;
|
||||
@ -29,8 +26,11 @@ public class Camera1Capturer extends CameraCapturer {
|
||||
@Override
|
||||
protected void createCameraSession(CameraSession.CreateSessionCallback createSessionCallback,
|
||||
CameraSession.Events events, Context applicationContext,
|
||||
SurfaceTextureHelper surfaceTextureHelper, String cameraName, int width, int height,
|
||||
int framerate) {
|
||||
SurfaceTextureHelper surfaceTextureHelper, MediaRecorder mediaRecorder, String cameraName,
|
||||
int width, int height, int framerate) {
|
||||
if (mediaRecorder != null) {
|
||||
throw new RuntimeException("MediaRecoder is not supported for camera 1.");
|
||||
}
|
||||
Camera1Session.create(createSessionCallback, events, captureToTexture, applicationContext,
|
||||
surfaceTextureHelper, Camera1Enumerator.getCameraIndex(cameraName), width, height,
|
||||
framerate);
|
||||
|
||||
@ -13,6 +13,7 @@ package org.webrtc;
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.hardware.camera2.CameraManager;
|
||||
import android.media.MediaRecorder;
|
||||
|
||||
@TargetApi(21)
|
||||
public class Camera2Capturer extends CameraCapturer {
|
||||
@ -29,9 +30,9 @@ public class Camera2Capturer extends CameraCapturer {
|
||||
@Override
|
||||
protected void createCameraSession(CameraSession.CreateSessionCallback createSessionCallback,
|
||||
CameraSession.Events events, Context applicationContext,
|
||||
SurfaceTextureHelper surfaceTextureHelper, String cameraName, int width, int height,
|
||||
int framerate) {
|
||||
SurfaceTextureHelper surfaceTextureHelper, MediaRecorder mediaRecoder, String cameraName,
|
||||
int width, int height, int framerate) {
|
||||
Camera2Session.create(createSessionCallback, events, applicationContext, cameraManager,
|
||||
surfaceTextureHelper, cameraName, width, height, framerate);
|
||||
surfaceTextureHelper, mediaRecoder, cameraName, width, height, framerate);
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,6 +10,8 @@
|
||||
|
||||
package org.webrtc;
|
||||
|
||||
import android.media.MediaRecorder;
|
||||
|
||||
/**
|
||||
* Base interface for camera1 and camera2 implementations. Extends VideoCapturer with a
|
||||
* switchCamera() function. Also provides subinterfaces for handling camera events, and a helper
|
||||
@ -59,6 +61,32 @@ public interface CameraVideoCapturer extends VideoCapturer {
|
||||
*/
|
||||
void switchCamera(CameraSwitchHandler switchEventsHandler);
|
||||
|
||||
/**
|
||||
* MediaRecorder add/remove handler - one of these functions are invoked with the result of
|
||||
* addMediaRecorderToCamera() or removeMediaRecorderFromCamera calls.
|
||||
* The callback may be called on an arbitrary thread.
|
||||
*/
|
||||
public interface MediaRecorderHandler {
|
||||
// Invoked on success.
|
||||
void onMediaRecorderSuccess();
|
||||
|
||||
// Invoked on failure, e.g. camera is stopped or any exception happens.
|
||||
void onMediaRecorderError(String errorDescription);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add MediaRecorder to camera pipeline. This can only be called while the camera is running.
|
||||
* Once MediaRecorder is added to camera pipeline camera switch is not allowed.
|
||||
* This function can be called from any thread.
|
||||
*/
|
||||
void addMediaRecorderToCamera(MediaRecorder mediaRecorder, MediaRecorderHandler resultHandler);
|
||||
|
||||
/**
|
||||
* Remove MediaRecorder from camera pipeline. This can only be called while the camera is running.
|
||||
* This function can be called from any thread.
|
||||
*/
|
||||
void removeMediaRecorderFromCamera(MediaRecorderHandler resultHandler);
|
||||
|
||||
/**
|
||||
* Helper class to log framerate and detect if the camera freezes. It will run periodic callbacks
|
||||
* on the SurfaceTextureHelper thread passed in the ctor, and should only be operated from that
|
||||
|
||||
Reference in New Issue
Block a user