Android - Video Stream to server -


hello android geniuses!

i need app, have class wich records in background, , takes gps location.

now problem need stream video in real-time server secured (later..), local computer awesome now.

how should make happend? links or appreciated!

background recorder class:

public class recorderservice extends service {     private static final string tag = "recorderservice";     private surfaceview msurfaceview;     private surfaceholder msurfaceholder;     private static camera mservicecamera;     private boolean mrecordingstatus;     private mediarecorder mmediarecorder;      // gpstracker class     gpstracker gps;     geocoder geocoder;     string addressstring;      @override     public void oncreate() {         mrecordingstatus = false;         //mservicecamera = camerarecorder.mcamera;         mservicecamera = camera.open();         msurfaceview = mainactivity.msurfaceview;         msurfaceholder = mainactivity.msurfaceholder;          super.oncreate();         if (mrecordingstatus == false)             startrecording();     }      @override     public ibinder onbind(intent intent) {         // todo auto-generated method stub         return null;     }      @override     public void ondestroy() {         stoprecording();         mrecordingstatus = false;          super.ondestroy();     }          //start recording class.     public boolean startrecording(){          // create class object         gps = new gpstracker(recorderservice.this);          // check if gps enabled              if(gps.cangetlocation()){              double latitude = gps.getlatitude();             double longitude = gps.getlongitude();               toast.maketext(getbasecontext(),"latitude: " + latitude + "  longitude: "+ longitude, toast.length_short).show();               toast.maketext(getbasecontext(),getaddress(latitude,longitude), toast.length_short).show();            }else{              // can't location             // gps or network not enabled             // ask user enable gps/network in settings             gps.showsettingsalert(); }          gps.stopusinggps();            //try start backgroun recording         try {             toast.maketext(getbasecontext(), "recording started", toast.length_short).show();              //mservicecamera = camera.open();             camera.parameters params = mservicecamera.getparameters();             mservicecamera.setparameters(params);             camera.parameters p = mservicecamera.getparameters();              final list<size> listsize = p.getsupportedpreviewsizes();             size mpreviewsize = listsize.get(2);             log.v(tag, "use: width = " + mpreviewsize.width                          + " height = " + mpreviewsize.height);             p.setpreviewsize(mpreviewsize.width, mpreviewsize.height);             p.setpreviewformat(pixelformat.ycbcr_420_sp);             mservicecamera.setparameters(p);              try {                 mservicecamera.setpreviewdisplay(msurfaceholder);                 mservicecamera.startpreview();             }             catch (ioexception e) {                 log.e(tag, e.getmessage());                 e.printstacktrace();             }              mservicecamera.unlock();              mmediarecorder = new mediarecorder();             mmediarecorder.setcamera(mservicecamera);             mmediarecorder.setaudiosource(mediarecorder.audiosource.mic);             mmediarecorder.setvideosource(mediarecorder.videosource.camera);             mmediarecorder.setoutputformat(mediarecorder.outputformat.mpeg_4);             mmediarecorder.setaudioencoder(mediarecorder.audioencoder.default);             mmediarecorder.setvideoencoder(mediarecorder.videoencoder.default);             mmediarecorder.setoutputfile("/sdcard/video.mp4");             mmediarecorder.setvideoframerate(30);             mmediarecorder.setvideosize(mpreviewsize.width, mpreviewsize.height);             mmediarecorder.setpreviewdisplay(msurfaceholder.getsurface());              mmediarecorder.prepare();             mmediarecorder.start();               mrecordingstatus = true;              return true;         } catch (illegalstateexception e) {             log.d(tag, e.getmessage());             e.printstacktrace();             return false;         } catch (ioexception e) {             log.d(tag, e.getmessage());             e.printstacktrace();             return false;         }     }      //stops recording     public void stoprecording() {          toast.maketext(getbasecontext(), "recording stopped", toast.length_short).show();         try {             mservicecamera.reconnect();         } catch (ioexception e) {             // todo auto-generated catch block             e.printstacktrace();         }         mmediarecorder.stop();         mmediarecorder.reset();          mservicecamera.stoppreview();         mmediarecorder.release();          mservicecamera.release();         mservicecamera = null;     }      //gets adress, if not return nothing.      public string getaddress(double lat, double lon)     {         geocoder geocoder = new geocoder(this, locale.english);         string ret = "";         try {             list<address> addresses = geocoder.getfromlocation(lat, lon, 1);             if(addresses != null) {                 address returnedaddress = addresses.get(0);                 stringbuilder strreturnedaddress = new stringbuilder("address:\n");                 for(int i=0; i<returnedaddress.getmaxaddresslineindex(); i++) {                     strreturnedaddress.append(returnedaddress.getaddressline(i)).append("\n");                 }                  try{                     //createas file gps location.                     fileoutputstream fos = openfileoutput("/sdcard/adress.txt", getbasecontext().mode_world_readable);                     fos.write(strreturnedaddress.tostring().getbytes());                     fos.close();                     }                     catch (exception e){                      }                  ret = strreturnedaddress.tostring();             }             else{                 ret = "no address returned!";             }         } catch (ioexception e) {             // todo auto-generated catch block             e.printstacktrace();             ret = "can't address!";         }         return ret;     } } 

thank , have awesome day!

this link shows how can stream video device server: http://www.mattakis.com/blog/kisg/20090708/broadcasting-video-with-android-without-writing-to-the-file-system


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -