private String startLivePreview(
     final LiveCamera liveCamera, final Integer width, final Integer height) {
   synchronized (mLockObj) {
     if (mServer == null) {
       mServer = new MixedReplaceMediaServer();
       mServer.setServerName("Live Preview Server");
       mServer.start();
     }
     final String segment = SEGMENT_LIVE_PREVIEW;
     if (mLivePreviewTask == null) {
       mLivePreviewTask =
           new LivePreviewTask(liveCamera) {
             @Override
             protected void onFrame(final byte[] frame) {
               byte[] b;
               if (width != null || height != null) {
                 b = resizeFrame(frame, width, height);
               } else {
                 b = frame;
               }
               offerFrame(segment, b);
             }
           };
       mExecutor.execute(mLivePreviewTask);
     }
     return mServer.getUrl() + "/" + segment;
   }
 }
 private void offerFrame(final String segment, final byte[] frame) {
   synchronized (mLockObj) {
     if (mServer != null) {
       mServer.offerMedia(segment, frame);
     }
   }
 }
 private void stopLivePreview() {
   synchronized (mLockObj) {
     if (mLivePreviewTask != null) {
       mLivePreviewTask.stop();
       mLivePreviewTask = null;
     }
     if (mServer != null) {
       mServer.stop();
       mServer = null;
     }
   }
 }