Home NanoHttpd (android) streaming voice over local network (http)
Reply: 0

NanoHttpd (android) streaming voice over local network (http)

user1649 Published in April 20, 2018, 10:39 am

I'm trying to stream voice over nanohttp from an android device to another ( on the same local network ).

I've been trying few things and I got something to work but i have the feeling I'm doing it wrong somewhat.


ParcelFileDescriptor[] fdPair = new ParcelFileDescriptor[0];
    try {
        fdPair = ParcelFileDescriptor.createPipe();
    } catch (IOException e) {
    //get a handle to your read and write fd objects
    m_readFd = fdPair[0];
    m_writeFd = fdPair[1];

    // m_writer is given send do the microphoneHandler
    // m_reader is given to the webServ part
    m_reader = new FileInputStream( m_readFd.getFileDescriptor());
    m_writer = new FileOutputStream( m_writeFd.getFileDescriptor());


and for the server part

// not sure why but if i don't put this 
// I have to keep refreshing the page to 
// get the full record

return newChunkedResponse(Response.Status.OK,"audio/aac", m_fileInputStream );

It is quite working and i can hear my voice on the second device BUT If I try to refresh the page or I want to open a second one on another device I get an error :

E/fi.iki.elonen.NanoHTTPD: Could not send response to the client
java.net.SocketException: sendto failed: EPIPE (Broken pipe)

I will need it to work with multiple device.

Did I get something wrong with the pipes ? Is it about the server Response ? Or maybe I am totally in the wrong way... Any advices or tips would be appreciated.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.312129 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO