@Override
 public String run(Properties parms) {
   int degree = Integer.parseInt(parms.getProperty("degree"));
   Log.d(TAG, ">>>>>>>run in doRotate degree = " + degree);
   cameraView_.StopPreview();
   cameraView_.Rotate(degree);
   cameraView_.setupCamera(cameraView_.Width(), cameraView_.Height(), previewCb_);
   cameraView_.StartPreview();
   return "OK";
 }
 @Override
 public String run(Properties parms) {
   int wid = Integer.parseInt(parms.getProperty("wid"));
   int hei = Integer.parseInt(parms.getProperty("hei"));
   Log.d(TAG, ">>>>>>>run in doSetup wid = " + wid + " hei=" + hei);
   cameraView_.StopPreview();
   cameraView_.setupCamera(wid, hei, previewCb_);
   cameraView_.StartPreview();
   return "OK";
 }
 @Override
 public String run(Properties parms) {
   try {
     int quality = Integer.parseInt(parms.getProperty("quality"));
     Log.d(TAG, ">>>>>>>run in doChangeQuality quality = " + quality);
     mQuality = quality;
     return "OK";
   } catch (Exception e) {
     e.printStackTrace();
   }
   return "ERROR";
 }
        @Override
        public InputStream streaming(Properties parms) {
          VideoFrame targetFrame = null;
          for (int i = 0; i < maxVideoNumber; i++) {
            if (videoFrames[i].acquire()) {
              targetFrame = videoFrames[i];
              break;
            }
          }
          // return 503 internal error
          if (targetFrame == null) {
            Log.d(TAG, "No free videoFrame found!");
            return null;
          }

          // compress yuv to jpeg
          int picWidth = cameraView_.Width();
          int picHeight = cameraView_.Height();
          YuvImage newImage = new YuvImage(preFrame, ImageFormat.NV21, picWidth, picHeight, null);
          targetFrame.reset();
          boolean ret;
          inProcessing = true;
          try {
            ret =
                newImage.compressToJpeg(new Rect(0, 0, picWidth, picHeight), mQuality, targetFrame);
          } catch (Exception ex) {
            ret = false;
          }
          inProcessing = false;

          // compress success, return ok
          if (ret == true) {
            parms.setProperty("mime", "image/jpeg");
            InputStream ins = targetFrame.getInputStream();
            return ins;
          }
          // send 503 error
          targetFrame.release();

          return null;
        }