Reland of lease camera statistics after switching camera on CameraCapturer. (patchset #1 id:1 of https://codereview.webrtc.org/2353163003/ )

Reason for revert:
Fix bugs causing the new code to fail.

Original issue's description:
> Revert of Release camera statistics after switching camera on CameraCapturer. (patchset #1 id:1 of https://codereview.webrtc.org/2353263002/ )
>
> Reason for revert:
> Breaks bots.
>
> Original issue's description:
> > Release camera statistics after switching camera on CameraCapturer.
> >
> > BUG=webrtc:6397
> > TBR=magjed@webrtc.org
> > NOTRY=True
> >
> > Committed: https://crrev.com/d5e9237b303e5fe253dc6530fbcf939921f4eaed
> > Cr-Commit-Position: refs/heads/master@{#14323}
>
> TBR=magjed@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:6397
>
> Committed: https://crrev.com/ad5d65845f5c859d0564811a4eea68e1efdb8450
> Cr-Commit-Position: refs/heads/master@{#14324}

TBR=magjed@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:6397

Review-Url: https://codereview.webrtc.org/2357893002
Cr-Commit-Position: refs/heads/master@{#14330}
This commit is contained in:
sakal 2016-09-21 06:08:53 -07:00 committed by Commit bot
parent 7f40ba4414
commit 0cb8828bce

View File

@ -44,6 +44,8 @@ public abstract class CameraCapturer implements CameraVideoCapturer {
synchronized (stateLock) {
sessionOpening = false;
currentSession = session;
cameraStatistics = new CameraStatistics(surfaceHelper, eventsHandler);
firstFrameObserved = false;
stateLock.notifyAll();
if (switchState == SwitchState.IN_PROGRESS) {
@ -57,9 +59,6 @@ public abstract class CameraCapturer implements CameraVideoCapturer {
switchState = SwitchState.IDLE;
switchCameraInternal(switchEventsHandler);
}
cameraStatistics = new CameraStatistics(surfaceHelper, eventsHandler);
firstFrameObserved = false;
}
}
@ -379,6 +378,14 @@ public abstract class CameraCapturer implements CameraVideoCapturer {
return;
}
if (!sessionOpening && currentSession == null) {
Logging.d(TAG, "switchCamera: No session open");
if (switchEventsHandler != null) {
switchEventsHandler.onCameraSwitchError("Camera is not running.");
}
return;
}
this.switchEventsHandler = switchEventsHandler;
if (sessionOpening) {
switchState = SwitchState.PENDING;
@ -387,15 +394,9 @@ public abstract class CameraCapturer implements CameraVideoCapturer {
switchState = SwitchState.IN_PROGRESS;
}
if (currentSession == null) {
Logging.d(TAG, "switchCamera: No session open");
if (switchEventsHandler != null) {
switchEventsHandler.onCameraSwitchError("Camera is not running.");
}
return;
}
Logging.d(TAG, "switchCamera: Stopping session");
cameraStatistics.release();
cameraStatistics = null;
currentSession.stop();
currentSession = null;