examples/m-jpeg-streamer/server.js
function() {
    appsink.pull(function(buf, caps) {
    	if (caps) {
    		//console.log("CAPS", caps);
    		mimeType = caps['name'];
    	}
        if (buf) {
            //console.log("BUFFER size",buf.length);
			for( c in clients ) {
			    // write header contained in caps
			    clients[c].write('--'+boundary+'\r\n');
			    clients[c].write('Content-Type: ' + mimeType + '\r\n' +
                    'Content-Length: ' + buf.length + '\r\n');
			    clients[c].write('\r\n');
			    /* debug to ensure the jpeg is good
			    if(bOnce == 1) {
    			    fs.writeFile("buffer.jpeg", buf);
    				bOnce = 0;
			    }
			    */
			    
				clients[c].write(buf, 'binary');
				clients[c].write('\r\n');
			}
			pull();
        } else {
            setTimeout(pull, 500);
        }
    });
}
function() {
    appsink.pull(function(buf, caps) {
    	if (caps) {
    		//console.log("CAPS", caps);
    		mimeType = caps['name'];
    	}
        if (buf) {
            //console.log("BUFFER size",buf.length);
			for( c in clients ) {
			    // write header contained in caps
			    clients[c].write('--'+boundary+'\r\n');
			    clients[c].write('Content-Type: ' + mimeType + '\r\n' +
                    'Content-Length: ' + buf.length + '\r\n');
			    clients[c].write('\r\n');
			    /* debug to ensure the jpeg is good
			    if(bOnce == 1) {
    			    fs.writeFile("buffer.jpeg", buf);
    				bOnce = 0;
			    }
			    */
			    
				clients[c].write(buf, 'binary');
				clients[c].write('\r\n');
			}
			pull();
        } else {
            setTimeout(pull, 500);
        }
    });
}
function ( ) { appsink . pull ( function ( buf , caps ) { if ( caps ) { //console.log("CAPS", caps); mimeType = caps [ 'name' ] ; } if ( buf ) { //console.log("BUFFER size",buf.length); for ( c in clients ) { // write header contained in caps clients [ c ] . write ( '--' + boundary + '\r\n' ) ; clients [ c ] . write ( 'Content-Type: ' + mimeType + '\r\n' + 'Content-Length: ' + buf . length + '\r\n' ) ; clients [ c ] . write ( '\r\n' ) ; /* debug to ensure the jpeg is good
			    if(bOnce == 1) {
    			    fs.writeFile("buffer.jpeg", buf);
    				bOnce = 0;
			    }
			    */ clients [ c ] . write ( buf , 'binary' ) ; clients [ c ] . write ( '\r\n' ) ; } pull ( ) ; } else { setTimeout ( pull , 500 ) ; } } ) ; }
var bOnce = 1;
var bOnce = 1 ;