aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes How to attach metadata with AudioOutputStream Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "How to attach metadata with AudioOutputStream " Watch "How to attach metadata with AudioOutputStream " New topic
Author

How to attach metadata with AudioOutputStream

Ackshat Sharma
Greenhorn

Joined: Sep 03, 2011
Posts: 22
I am working with an application in which the client captures audio in java and send it to server(which waits for the connection and recieve the inputStream) , when it comes to sending metadata with AudioInputStream it creates a problem. i.e since AudioInputStream cannot be serialized with other attributes attached to make a serialized object, I am not able to send the name of audio file which is to be recieved at Server,

Is there any way to send name with the AudioStream, I tried signal based approach where first server waits for byte stream to get a name and then acknowledge client to send the AudioInputStream but tht doesnt work

and got the error message "Software caused connection abort" may be because second time when the client send the AudioStream the connection is closed by .... (is it JVM?)
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Ackshat Sharma wrote:I am working with an application in which the client captures audio in java and send it to server(which waits for the connection and recieve the inputStream) , when it comes to sending metadata with AudioInputStream it creates a problem. i.e since AudioInputStream cannot be serialized with other attributes attached to make a serialized object, I am not able to send the name of audio file which is to be recieved at Server,


But that isn't really a problem, you're just trying to do the wrong thing. Sending the name of a file on the client system would be useless, since the server system doesn't have access to those files. And likewise sending an input stream to the server would be useless, since the server can't read from it. (That's why AudioInputStream isn't serializable.) Am I correct in assuming that the AudioInputStream is your method of capturing the audio on the client? If so, then what you should do is to read the bytes from that stream and send them to the server. When you have finished capturing the audio then you should close your connection to the server. The server will see that you are finished because it will come to the end of its SocketInputStream, so it can then deal with the whole of your captured audio clip.

and got the error message "Software caused connection abort" may be because second time when the client send the AudioStream the connection is closed by .... (is it JVM?)


If you follow my suggestions, that means that you need to make a separate connection to your server for each audio clip that you capture.
Ackshat Sharma
Greenhorn

Joined: Sep 03, 2011
Posts: 22
What i am doing is "Capturing audio using java applet and sending it to a server what server has to do is to recieve the audio and write it to the disk with a name specified to the server" since every time a new audio is sent to server , i want server to save it with a new name which is sent by the client applet. I guess its clear to you Paul,
Since i can not store the entire captured data to some temporary buffer(if so please tell how) on client machine, cannot sent the whole data to server at once getting it blended with some object(in form of attribute along with name and other netadata), i streamed it to server , the server is recieving it.

The concern is fixing metadata with any bufferedStream/OutputStream and receiving it at server side,
The server will see that you are finished because it will come to the end of its SocketInputStream, so it can then deal with the whole of your captured audio clip.


please tell me how can server extract the name of audioinputstream( my context of metadata is what is generic i.e format,framesize,length and also the explicitly attached metadata i.e name, id etc).
the generic metadata can be extracted from the data stored in buffer since its JVM's personal matter but when it comes to extra information , i have not found any way yet to bind it to stream and extract it at server .

@Paul
Thanks a lot for the concern.
 
 
subject: How to attach metadata with AudioOutputStream