cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements
2354
Views
0
Helpful
54
Replies
Highlighted
Rising star

G.711 streamer example

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.

Enjoy

54 REPLIES 54
Highlighted
Beginner

Re: G.711 streamer example

So I downloaded Java DK, Java WMF, compiled AVTransmit2.java using javac and got AVTransmit2.class. What do I do with it now?

Best regards,

Victor

Highlighted
Rising star

Re: G.711 streamer example

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:

Usage: AVTransmit2 , where sourceURL is a path on your local harddisk where you have a wave file to be streamed, destIP is the destination IP address (this can be either unicast or multicast, and finally you indicate the port on which the sending ocurrs). Or here's a complete valid example (taken directly from the source code comments)

java AVTransmit2 file:/C:/media/test.mov 129.130.131.132 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 129.130.131.132 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.

Highlighted
Beginner

Re: G.711 streamer example

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,

Cheers,

Victor

Highlighted
Rising star

Re: G.711 streamer example

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.

Highlighted
Beginner

Re: G.711 streamer example

Can I use .wma or .mp3 files?

Highlighted
Rising star

Re: G.711 streamer example

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).

Highlighted
Beginner

Re: G.711 streamer example

I am going to try and do this with java in a moment.

Any idea if this is posisble using .Net.

Highlighted
Beginner

Re: G.711 streamer example

Could only hear wav files. mp3 did not work.

Highlighted
Beginner

Re: G.711 streamer example

Hello Stephan:

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(239.1.1.1), no RTP streams were sent out.

From the sniffer, only one DNS query for 239.1.1.1,

no any RTP packages were found.

Do you have any idea what is wrong?

Highlighted
Beginner

Re: G.711 streamer example

Hello lyf20040507,

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?

Regards,

Ashish.

Highlighted
Beginner

Re: G.711 streamer example

I've got JDK 1.5.0.4 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

me: JMFTest/AVTransmit2)

at java.lang.ClassLoader.defineClass1(Native Method)

at java.lang.ClassLoader.defineClass(ClassLoader.java:620)

at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12

4)

at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)

at java.net.URLClassLoader.access$100(URLClassLoader.java:56)

at java.net.URLClassLoader$1.run(URLClassLoader.java:195)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:188)

at java.lang.ClassLoader.loadClass(ClassLoader.java:306)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)

at java.lang.ClassLoader.loadClass(ClassLoader.java:251)

at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

Do I have a problem with the classpath ??

Highlighted
Beginner

Re: G.711 streamer example

Let me try the java emthod

Highlighted
Rising star

Re: G.711 streamer example

@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.

Highlighted
Beginner

Re: G.711 streamer example

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...

CreatePlease to create content
Content for Community-Ad

Cisco COVID-19 Survey