I guess I'm not the only one to ever have tried it (I found a number of messages concerning this on the JMF newsgroups, but never a satisfactory solution spelled out), so my attachment could be useful.
Install JMF, put the JMF jar files into the classpath, and compile the source code. Then you have a commandline based G.711 capable streamer. It is not a very streamlined example as it's based on a streamer for video (in fact it still streams video as well as audio), but it is good enough for basic audio streaming.. just use a wav file as input (make sure it's not already ylaw as this program will transcode the content no matter what), specify destination port and address and you're all set.
There's no repeat, play until the end of file, use other input ports (like line in or microphone) but it's a working piece of code, which is more when I got when I started out doing this.
So I downloaded Java DK, Java WMF, compiled AVTransmit2.java using javac and got AVTransmit2.class. What do I do with it now?
Java WMF? Do you mean JMF?
Now you run the program via "java AVTransmit2" as you would run any other java program ;)
The program accepts 3 commandline parameters:
java AVTransmit2 file:/C:/media/test.mov 126.96.36.199 42050
Now obviously, streaming movies is no good for Cisco IP phones, but if you stream a .wav file, you get what you want. This example would stream a Quicktime movie to IP address 188.8.131.52 on port 42050 (be careful, the program always uses two consecutive ports so 42051 will also be blocked). If using a wave file, gave your phone listen to the IP address of the PC you're running this on and the port you specified and you should hear the audio. Alternatively, stream to an IP multicast address, so multiple phones can receive the stream simultaneously.
Hope this helps.
The thing is that I'm new to Java technology, and when I tried to run the compiled class I got some stupid error, but when I rebooted the PC it worked! :)
By the way, I know that the Phone can only play u-Law format audio, so I have to convert the audio first, right?
And is it possible to stream audio from the internet to the phone?
Thank you for your help,
Actually, the audio format conversion is done automatically.. you can take a CD quality WAV file and stream it.. the output of the streamer is in a format that the IP phone understands. In fact, you should not use wav files already in the proper format, because the code does not contain any checking of the source format and automatically downsamples and converts the input to the proper format.. if you use a .raw file (for instance a ringtone for IP phones), streaming will no longer work as the streamer mutilates the source. I'm sure that could be catched easily, but so far I had no need to do that.
I have to admit to never having tested that. You can easily convert WMA and MP3 to WAV using the Filewriter plugin of Winamp (as an example), but why not give it a shot without the conversion and let us know if it works. Actually, I very much doubt WMA will work, since JMF does not know this format, but MP3 should be supported by the framework. Ogg Vorbis is also supported, but you need to install some additional packages as the Vorbis en/decoder is not included into JMF.
Do not use G.711 .raw files (as for ringtimes, I've tried that and it did not work). However, that could easily be solved by looking up the source format and adjust the repackaging accordingly to the source format (if the source already has the proper format, all you need to do is make packets of the proper size).
With the "AVTransmit2" provided by you, I have sent
a pre-recorded wave file to a Cisco 7960 IP Phone.
But when I tried to send a wave file with multicast
address(184.108.40.206), no RTP streams were sent out.
From the sniffer, only one DNS query for 220.127.116.11,
no any RTP packages were found.
Do you have any idea what is wrong?
I have send the wav file to a Cisco 7905 Phone.
When I send that file from my PC it does not shows any error.
But at recieving end there is no response.
I use this syntax:
java AVTransmit2 file://c://song.wav 192.168.1.20 20500
where 192.168.1.20 is the IP address of the phone.
and 20500 is port number.
Can you tell me how can I accomplish this?
I've got JDK 18.104.22.168 installed and Java Media Framework 2.1.1e. I complied the AVTransmit2.java using javac AVTransmit2.java command and it outputted AVTransmit.class file, when i run Java AVTransmit I get
Exception in thread "main" java.lang.NoClassDefFoundError: AVTransmit2 (wrong na
at java.lang.ClassLoader.defineClass1(Native Method)
at java.security.AccessController.doPrivileged(Native Method)
Do I have a problem with the classpath ??
@Nishen: Java and .NET are not really compatible, and I doubt that JMF is compatible with J#.. but you can always try. And perhaps here's a G.711 streaming library for .NET somewhere (but searching google for G.711 stuff is hell, you get a lot of crap and I haven't found any good search string to really give me what I needed). What certainly will work is using WinRTP as it is COM and .NET (at least Microsoft's implementation) comes with COM interop. Though WinRTP has some inheritent disadvantages that I've described in another streaming thread last Friday: it's bound to the microphone filter, so you need to have a mic in, plus I could never managed to stream wav files.
So I've been trying your demo code all morning with a 7970 phone and getting nothing. Thought it was either a codec issue or something. Came back here to see if I missed a crucial piece of information on the thread. Everything looked good so I finally try again on a 7940...works perfectly.
Does anybody know why a 7940 will play the stream correctly and a 7970 won't? I have a paging app setup where the phones transmit multicast and the 7970 picks that up okay, but it doesn't like what's coming from the JMF transmission...goofy...