File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed
Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -124,9 +124,15 @@ public MediaRecorder() {
124124 /**
125125 * Sets a Surface to show a preview of recorded media (video). Calls this
126126 * before prepare() to make sure that the desirable preview display is
127- * set.
127+ * set. If {@link #setCamera(Camera)} is used and the surface has been
128+ * already set to the camera, application do not need to call this. If
129+ * this is called with non-null surface, the preview surface of the camera
130+ * will be replaced by the new surface. If this method is called with null
131+ * surface or not called at all, media recorder will not change the preview
132+ * surface of the camera.
128133 *
129134 * @param sv the Surface to use for the preview
135+ * @see android.hardware.Camera#setPreviewDisplay(android.view.SurfaceHolder)
130136 */
131137 public void setPreviewDisplay (Surface sv ) {
132138 mSurface = sv ;
Original file line number Diff line number Diff line change @@ -515,9 +515,13 @@ status_t CameraSource::initWithCameraAccess(
515515 return err;
516516 }
517517
518- // This CHECK is good, since we just passed the lock/unlock
519- // check earlier by calling mCamera->setParameters().
520- CHECK_EQ ((status_t )OK, mCamera ->setPreviewDisplay (mSurface ));
518+ // Set the preview display. Skip this if mSurface is null because
519+ // applications may already set a surface to the camera.
520+ if (mSurface != NULL ) {
521+ // This CHECK is good, since we just passed the lock/unlock
522+ // check earlier by calling mCamera->setParameters().
523+ CHECK_EQ ((status_t )OK, mCamera ->setPreviewDisplay (mSurface ));
524+ }
521525
522526 // By default, do not store metadata in video buffers
523527 mIsMetaDataStoredInVideoBuffers = false ;
You can’t perform that action at this time.
0 commit comments