2014-07-23 34 views
10

Qui, devo ottenere lo streaming video dal vivo da una fotocamera IP wireless a Android mobile tramite protocollo RTSP. La fotocamera è collegata al router wireless e mobile ha anche la stessa rete wifi. Ora ho bisogno di implementare lo streaming video live dalla telecamera.Streaming video in diretta da una telecamera IP wireless al cellulare Android

A tale scopo, cosa devo fare ?. questo è un nuovo concetto per me.Come collegare Android cellulare e fotocamera a livello di programmazione e ottenere lo streaming dal vivo.Qualsiasi aiuto sarebbe apprezzato.

+1

Seguire le istruzioni in questo [collegamento] (http://www.androidhive.info/2014/06/android-streaming-live-camera-video-to-web-page/) per farlo. –

risposta

2

è possibile accedere alle immagini live feed dal tuo IP Cam al PC, il mio era

String URL = "http://192.168.1.8/image/jpeg.cgi";

o una sorta. Dovresti controllare il tuo dispositivo se è incluso. È quindi possibile scaricare l'immagine e metterla sulla visualizzazione di immagini. non il file di immagine reale solo i suoi dettagli grafici. È possibile cercare MJpegInputStream per questo, ecco il codice di esempio per esso

public class MjpegInputStream extends DataInputStream { 
private final byte[] SOI_MARKER = { (byte) 0xFF, (byte) 0xD8 }; 
private final byte[] EOF_MARKER = { (byte) 0xFF, (byte) 0xD9 }; 
private final String CONTENT_LENGTH = "Content-Length"; 
private final static int HEADER_MAX_LENGTH = 100; 
private final static int FRAME_MAX_LENGTH = 40000 + HEADER_MAX_LENGTH; 
private int mContentLength = -1; 

public static MjpegInputStream read(Context context,String url) { 
    HttpResponse res; 
    MyHttpClient httpclient = new MyHttpClient(context);  
    try { 
     res = httpclient.execute(new HttpGet(URI.create(url))); 
     return new MjpegInputStream(res.getEntity().getContent());    
    } catch (ClientProtocolException e) { 
    } catch (IOException e) {} 
    return null; 
} 

public MjpegInputStream(InputStream in) { super(new BufferedInputStream(in, FRAME_MAX_LENGTH)); } 

private int getEndOfSeqeunce(DataInputStream in, byte[] sequence) throws IOException { 
    int seqIndex = 0; 
    byte c; 
    for(int i=0; i < FRAME_MAX_LENGTH; i++) { 
     c = (byte) in.readUnsignedByte(); 
     if(c == sequence[seqIndex]) { 
      seqIndex++; 
      if(seqIndex == sequence.length) return i + 1; 
     } else seqIndex = 0; 
    } 
    return -1; 
} 

private int getStartOfSequence(DataInputStream in, byte[] sequence) throws IOException { 
    int end = getEndOfSeqeunce(in, sequence); 
    return (end < 0) ? (-1) : (end - sequence.length); 
} 

private int parseContentLength(byte[] headerBytes) throws IOException, NumberFormatException { 
    ByteArrayInputStream headerIn = new ByteArrayInputStream(headerBytes); 
    Properties props = new Properties(); 
    props.load(headerIn); 
    return Integer.parseInt(props.getProperty(CONTENT_LENGTH)); 
} 

public Bitmap readMjpegFrame() throws IOException { 
    mark(FRAME_MAX_LENGTH); 
    int headerLen = getStartOfSequence(this, SOI_MARKER); 
    reset(); 
    byte[] header = new byte[headerLen]; 
    readFully(header); 
    try { 
     mContentLength = parseContentLength(header); 
    } catch (NumberFormatException nfe) { 
     mContentLength = getEndOfSeqeunce(this, EOF_MARKER); 
    } 
    reset(); 
    byte[] frameData = new byte[mContentLength]; 
    skipBytes(headerLen); 
    readFully(frameData); 
    return BitmapFactory.decodeStream(new ByteArrayInputStream(frameData)); 
} 

si può guardare più su MJpegInput flusso here e here

sperano i suoi utili, codifiche felici.