I am trying to get raw audio data from a live stream routed through Red5.
I can use netstream.attachAudio(mic) with no issues but understand getting the raw data is not supported.
I have code that sends the audio data via ByteArray using netstream.send. I can verify the data is being sent to the Red5 server, and is being sent from the Red5 server back to the client (viewing network traffic). The client function I have setup to receive the data is never tried. I have found many examples and implemented a solution that per the examples should work .. But obviously missing something. The code is below:
protected function ncStatus(event:NetStatusEvent):void {
trace("rtmp connection status: " + event.info.code );
if ( event.info.code == "NetConnection.Connect.Success" ) {
upStream = new NetStream( netc );
upStream.client = this;
upStream.attachCamera(_camera);
upStream.addEventListener(NetStatusEvent.NET_STATUS, netStatus);
//this.upStream.attachAudio(this._mic);
_mic.addEventListener( SampleDataEvent.SAMPLE_DATA, micSampleDataHandler, false, 0, false );
upStream.publish("Seat1","live");
}
}
public function micSampleDataHandler( event:SampleDataEvent ):void {
upStream.send("audiodata", event.data as ByteArray );
if ( txnum==7 ) {
downStream.play("Seat1");
}
txnum++;
}
public function audiodata( data ):void {
var buf2:ByteArray = newBuffer();
var res:Boolean = ane.processEngine( data as ByteArray, buf2, true, true );
if ( res )
processBuffer.push( buf2 );
if ( processBuffer.length > 8 )
_sound.play();
}
protected function netStatus( event:NetStatusEvent):void {
trace("netstream status: " + event.info.code + " " + event.target );
if ( event.info.code == "NetStream.Publish.Start" ) {
downStream = new NetStream( netc );
downStream.client = this;
video = new Video();
video.attachNetStream( downStream );
mediaContainer.addChild(video);
downStream.addEventListener(NetStatusEvent.NET_STATUS, netStatus );
}
}
The video comes through no problem, the appropriate amount of data is sent to and from the server, no errors are indicated, but the function 'audiodata' is never called. Any ideas?