Android Open Source - phone-monitor Video Capture






From Project

Back to project page phone-monitor.

License

The source code is released under:

Copyright (c) 2014, bbdolly All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redi...

If you think the Android project phone-monitor listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.ivideoi;
//from ww  w .j  ava2s . c om
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

import com.thetransactioncompany.jsonrpc2.JSONRPC2Request;
import com.thetransactioncompany.jsonrpc2.JSONRPC2Response;
import com.thetransactioncompany.jsonrpc2.client.JSONRPC2Session;
import com.thetransactioncompany.jsonrpc2.client.JSONRPC2SessionException;

import android.hardware.Camera;
import android.media.AudioFormat;
import android.media.AudioRecord;
import android.media.MediaRecorder;

public class VideoCapture implements Camera.PictureCallback 
{
  public static VideoCapture Instance()
  {
    if(_this == null)
    {
      _this = new VideoCapture();
    }
    return _this;
  }
  
  public VideoCapture()
  {
    _lock = new ReentrantLock(true);
        Thread th = new Thread(
        new Runnable()
    {
      public void run()
      {
        while (true)
        {
          MainActivity.sleep(8000);
          _lock.lock();
              _mycamera = Camera.open();
              Camera.Parameters parameters = _mycamera.getParameters();
              parameters.setPictureFormat(android.graphics.ImageFormat.JPEG);
              _mycamera.startPreview();
              MainActivity.sleep(1000);
          _mycamera.takePicture(null, null, VideoCapture.this);
          _lock.unlock();
        }
      }
    }
        );
        th.start();
  }
  
    @Override
    public void onPictureTaken(byte[] data, Camera camera) 
    {
      _lock.lock();
      _mycamera.release();
      DataIO.getInstance().uploadbyte(MainActivity.getTimeString()+".jpg", data);
    MainActivity.updateView(1,_count++);
    _lock.unlock();
    }
  
    Lock _lock;
  Camera _mycamera;
    private int _count = 0;
    private static VideoCapture _this = null;
}




Java Source Code List

com.ivideoi.AudioCapture.java
com.ivideoi.DataIO.java
com.ivideoi.MainActivity.java
com.ivideoi.VideoCapture.java