| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.media; | 5 package org.chromium.media; |
| 6 | 6 |
| 7 import android.annotation.TargetApi; | 7 import android.annotation.TargetApi; |
| 8 import android.content.Context; | 8 import android.content.Context; |
| 9 import android.graphics.ImageFormat; | 9 import android.graphics.ImageFormat; |
| 10 import android.graphics.Rect; | 10 import android.graphics.Rect; |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 @Override | 391 @Override |
| 392 public boolean startCapture() { | 392 public boolean startCapture() { |
| 393 if (mCamera == null) { | 393 if (mCamera == null) { |
| 394 Log.e(TAG, "startCapture: mCamera is null"); | 394 Log.e(TAG, "startCapture: mCamera is null"); |
| 395 return false; | 395 return false; |
| 396 } | 396 } |
| 397 | 397 |
| 398 mPreviewBufferLock.lock(); | 398 mPreviewBufferLock.lock(); |
| 399 try { | 399 try { |
| 400 if (mIsRunning) { | 400 if (mIsRunning) { |
| 401 nativeOnStarted(mNativeVideoCaptureDeviceAndroid); |
| 401 return true; | 402 return true; |
| 402 } | 403 } |
| 403 mIsRunning = true; | 404 mIsRunning = true; |
| 404 } finally { | 405 } finally { |
| 405 mPreviewBufferLock.unlock(); | 406 mPreviewBufferLock.unlock(); |
| 406 } | 407 } |
| 407 setPreviewCallback(this); | 408 setPreviewCallback(this); |
| 408 try { | 409 try { |
| 409 mCamera.startPreview(); | 410 mCamera.startPreview(); |
| 410 } catch (RuntimeException ex) { | 411 } catch (RuntimeException ex) { |
| 411 Log.e(TAG, "startCapture: Camera.startPreview: " + ex); | 412 Log.e(TAG, "startCapture: Camera.startPreview: " + ex); |
| 412 return false; | 413 return false; |
| 413 } | 414 } |
| 415 nativeOnStarted(mNativeVideoCaptureDeviceAndroid); |
| 414 return true; | 416 return true; |
| 415 } | 417 } |
| 416 | 418 |
| 417 @Override | 419 @Override |
| 418 public boolean stopCapture() { | 420 public boolean stopCapture() { |
| 419 if (mCamera == null) { | 421 if (mCamera == null) { |
| 420 Log.e(TAG, "stopCapture: mCamera is null"); | 422 Log.e(TAG, "stopCapture: mCamera is null"); |
| 421 return true; | 423 return true; |
| 422 } | 424 } |
| 423 | 425 |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 getCameraRotation()); | 786 getCameraRotation()); |
| 785 } | 787 } |
| 786 } finally { | 788 } finally { |
| 787 mPreviewBufferLock.unlock(); | 789 mPreviewBufferLock.unlock(); |
| 788 if (camera != null) { | 790 if (camera != null) { |
| 789 camera.addCallbackBuffer(data); | 791 camera.addCallbackBuffer(data); |
| 790 } | 792 } |
| 791 } | 793 } |
| 792 } | 794 } |
| 793 } | 795 } |
| OLD | NEW |