@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;
        }
 public synchronized void load(
     byte majorTypeHint,
     byte minorTypeHint,
     String encodingHint,
     java.io.File file,
     String hostname,
     boolean timeshifted,
     long bufferSize)
     throws PlaybackException {
   if (cdi == null) throw new PlaybackException();
   CaptureDevice capDev = cdi.getCaptureDevice();
   setVideoHWND0(
       capDev.getNativeVideoPreviewConfigHandle(),
       VideoFrame.getVideoFrameForPlayer(this).getVideoHandle());
   videoDimensions = null;
   getVideoDimensions();
   currFile = file;
   currState = LOADED_STATE;
   audioPreviewPtr = openAudioPreview0(capDev.getName());
 }
示例#3
0
 void setVideoFrame(VideoFrame f) {
   setImage(f.getBufferedImage());
 }