Re: [nodejs] use nodejs as streaming server

386 views
Skip to first unread message

Tim Caswell

unread,
Sep 20, 2012, 11:54:05 AM9/20/12
to nod...@googlegroups.com
I would start by reading up on audio encoding formats. This alone is
a pretty complex topic. Also, what is you client, what capabilities
does it have? If the client is a browser that's very different than
say a native mobile client on iOS. As far as the node part, building
a simple data proxy is easy, but usually you want to do more.

On Wed, Sep 19, 2012 at 11:19 PM, Chi Linh Le <lcli...@gmail.com> wrote:
> Hi All
>
> I am building a app with push-to-talk (conference call) function.
> Model of app as below.
>
> client A--(voice data)--->server (nodejs)--(voice data)--->client B
>
> I have some question.
>
> 1. How do get voice data from client?
> 2. How do send voice data to all connected client?
>
> Anyhelp is appreciated!
>
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+un...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

Chi Linh Le

unread,
Sep 21, 2012, 3:27:11 AM9/21/12
to nod...@googlegroups.com
Thank for responding.
Assume that client is android.
I can reading voice data from device, and sent to nodejs server.
nodejs server use datagram library to receive voice data which is sent from device.
Now, i can't find solution to send received voice data to all connected clients.

Here is some code on server side
///////////////////////////////////////////////////////////////////////////////////////////
var http = require('http'),
    dgram = require('dgram'),
    socketio = require('socket.io');

var app = http.createServer(handleRequest),
    io = socketio.listen(app),
    socket = dgram.createSocket('udp4');

socket.on('message', function(content, rinfo) {
    console.log('got message', content, 'from', rinfo.address, 'port ',rinfo.port);
    
io.sockets.emit('udp_message', 'test',rinfo.port);
socket.send(content, 0, content.length, 50006, rinfo.address, function(err, bytes) {
//socket.close();
});
});

function handleRequest(req, res) {

    res.writeHead(200, {'content-type': 'text/html'});
    res.end("<!doctype html> \
        <html><head> \
        <script src='/socket.io/socket.io.js'></script> \
        <script> \
            var socket = io.connect('localhost', {port: 8000}); \
            socket.on('udp message', function(message) { console.log(message) }); \
        </script></head></html>");

}

socket.bind(50005);
app.listen(8000);
///////////////////////////////////////////////////////////////////////////////////////////

I am waiting for your respons.

2012年9月20日木曜日 22時54分17秒 UTC+7 Tim Caswell:
Reply all
Reply to author
Forward
0 new messages