aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes JMF-RTP audio. please help. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "JMF-RTP audio. please help." Watch "JMF-RTP audio. please help." New topic
Author

JMF-RTP audio. please help.

Stanley George
Ranch Hand

Joined: Dec 09, 2000
Posts: 55
hi
i am using JMF-RTP.
i have created an RTP session for transmission or audio (GSM_RTP).
the RTP session manager is set to "127.0.0.1:8998" ,ttl =1
the player is set to :
MediaLocator mrl = new MediaLocator("rtp://127.0.0.1:8998/audio/1")
Player player = Manager.createPlayer(mrl);
i run the transmitter first and then the player
but the player shows the following error message in th jmf-log file....
**************************************************
" XX Cannot create the RTP Session: Address in use: Cannot bind "
**************************************************
if i run the player first, then the transmitter gives the above message
i know that this may be because one of the applications is using the specified address (localhost) and port. but isn't this how
it is supposed to be? i mean we have to transmit to an address and play from the same address.
isn't that so?
i want to speak into the mike and hear my voice too (obviously after a delay)
my aim is to do audio conferencing. first i am trying only one-way voice chat
the same transmitter and player programs work perfectly if i am storing into a file or playing from a file, so i guess there is no problem with either the processor, player etc.
please correct me if i have gone wrong anywhere.
kindly help.
ps. i am using StateHelper.java and other pieces of code from the JMF user-guide
Stanley George
Ranch Hand

Joined: Dec 09, 2000
Posts: 55
hi
solved the problem myself
all u have to do is change the MediaLocator to "rtp:224.144.251.104:49151/audio/1" .
the change has to be done both in the transmitter(recorder) as well as the player
thanx to those who have at least looked.
[This message has been edited by Stanley George (edited February 23, 2001).]
gautham kasinath
Ranch Hand

Joined: Dec 01, 2000
Posts: 583
Hi! stan!
Well cud u r share u r knowledge abou thow to create a transmitter and a reciever??
I am new to JMF..
Thanks
Regds
Gautham Kasinath

"In the country of the blind, the one eyed man is the King"
Gautham Kasinath CV at : http://www.geocities.com/gkasinath
Stanley George
Ranch Hand

Joined: Dec 09, 2000
Posts: 55
you can implement the reciever in much the same way as
a simple player :
************************************************
MediaLocator mrl =
new MediaLocator("rtp://224.144.251.104:8998/audio/1");
// the parameters are :-
// rtp: protocol
// 224.144.251.104: IP address of server with streaming data
// 49150: port number
// audio: type of media
// 1: ttl (time to live)
player = Manager.createPlayer(mrl);

player.addControllerListener(this);

player.start ();
************************************************
the transmitter is a bit more tricky
1> you have to configure the Processor (this is for capturing
audio from the mic).
2> after that you need to transcode it
using audio codecs (GSM_RTP). this is done to reduce the
bandwidth requirement of your audio conferencing application
3> now u simply transmit the data that you have captured
this can be done using a DataSink (most simple), RTP Sessions,
or RTP Sockets.
i have successfully tried the DataSink approach. i am currently
working on RTPSessionManager.
i would highly reccomend that u STUDY the JMF user guide. it will
clear your concepts about Processors, Players, SessionManagers,
Managers and a host of other superbly interesting stuff.
try out the code fragments given in the user guide. any problems
and i will gladly help as much as i can.
regards
gautham kasinath
Ranch Hand

Joined: Dec 01, 2000
Posts: 583
Hi!
tanx a lot for the tip.. I guess I will study the JMF first before venturing into something solid..
Thanks again
Regds
gautham kasinath
gautham kasinath
Ranch Hand

Joined: Dec 01, 2000
Posts: 583
Hi!
Well i wud like to know were I can get hold of good tutorials for JMF the ones I have r no good..
I need ones with sample codes discribing how to code in them
Regds
Gautham Kasinath
Stanley George
Ranch Hand

Joined: Dec 09, 2000
Posts: 55
hi gautham
i have done all my audio conferencing coding using the code fragments available in JMF user guide. they work very well. of course u have to study the whole guide first to be able to even start understanding whats happening and do something substantial.
if you want i will send some specific code fragments from the java users guide. but i guess u can very well do that yourself.
if u want i will send u the code i myself have written (cut & paste from user guide). but i would reccomend u do it urself.
u'll get to know whats going on if u tinker around a bit.
regards

gautham kasinath
Ranch Hand

Joined: Dec 01, 2000
Posts: 583
Hi!
Well I really apprecaite u r offer for code help.. tanx.. but I guess I will tinker round as u suggested..
meanwile can u help me with getting a query generator for Endlish text to sql query.
I need desperately n I donn have time to do de same..
please temme if u can help me with that if u already have a simple sql query generator that u mite ve developed for ur self..
the reason i need it is to put in a meaning based smart search in my site.. the site I m dev as a project
Thanx.
Regds
Gautham Kasinath
gautham kasinath
Ranch Hand

Joined: Dec 01, 2000
Posts: 583
Hi! Stanley and all
Well I need to know where the JMF User guide is..
Regds
Gautham Kasinath
Stanley George
Ranch Hand

Joined: Dec 09, 2000
Posts: 55
http://java.sun.com/products/java-media/jmf/2.1.1/guide/
gautham kasinath
Ranch Hand

Joined: Dec 01, 2000
Posts: 583
Hi! Stan!
Tanx a lot I am now following the link..
One more thing do you know any algorithm for pseudo Random Number generation which repeats over a user defined time period??
Please tell me about the same asap if you know. I need it for a meeting this afternoon!
Regds
Gautham Kasinath
Stanley George
Ranch Hand

Joined: Dec 09, 2000
Posts: 55
class Random could be your answer.
if two instances of Random created from the same seed, and the same sequence of method calls is made for each, they will generate and return the same sequence of numbers.
for a detailed explanation pls refer api docs
enjoy
gautham kasinath
Ranch Hand

Joined: Dec 01, 2000
Posts: 583
tanx stan!!
Regds
Gautham Kasinath
Stanley George
Ranch Hand

Joined: Dec 09, 2000
Posts: 55
does anyone know how to link JMF-RTP with java telephony?
i mean if u have an audio-conferencing application , ann u use it as a telephony application using JTAPI?
crahul
Greenhorn

Joined: Sep 27, 2001
Posts: 1
Hi,
If you have developed the Audio Conference for multiple users,Can u share yur code of Audio Conference with me..
Thanks in advance
Regards
Rahul
Originally posted by Stanley George:
hi gautham
i have done all my audio conferencing coding using the code fragments available in JMF user guide. they work very well. of course u have to study the whole guide first to be able to even start understanding whats happening and do something substantial.
if you want i will send some specific code fragments from the java users guide. but i guess u can very well do that yourself.
if u want i will send u the code i myself have written (cut & paste from user guide). but i would reccomend u do it urself.
u'll get to know whats going on if u tinker around a bit.
regards

Hoang Hai
Greenhorn

Joined: Dec 02, 2001
Posts: 8

Hi Stan,
I got a trouble with JMF that seems similar to your 1st problem in http://www.javaranch.com/ubb/Forum45/HTML/000120.html
But after seeing your solution, I couldn't resolve my problem ;((
I'm a newbie to JMF, and studying the book Java How to program, 4th edition.
There're some sample programs that I'll atach :
- a RTPServer that stream media to a host with a port. (RTPServerTest to run it)
- a SimplePlayer program to play either a media file or a media locator in general.
As I understand (follow the book), I can user RTPServer to streams a mp3 file to the localhost : 127.0.0.1, port 4000
and use the SimplePlayer to play that stream (with the media locator : "rtp://127.0.0.1:4000/audio" )
But :
* When I run the 2 applications on the same machine :
- which applications that starts later will encounter the problem : Can't open local data port : 4000
* When I run them on 2 machines :
- Both run smoothly (i.e. no error messages displayed in the console ), but I can't hear any sound !!!
I tried to change the port to 49151 like your solution, but on the same machine, the " can't open port" error happens as usual (
I'm really confused.
Now I'll keep sudying JMF from the sun JMF'guide, but if you can give me some advice , or even test these programs for me, it'll help me much )
Many thanks in advance
-----
I submit my problem here : JMF - RTPServer n Player - port problem
I'm also trying to use the Darwin Streaming Server (an Apple opensource RTP/RTSP server : http://www.publicsource.apple.com/projects/streaming/)
with the intention to make it receive the audio streams from my future Java application, then distribute it (multicast/unicast). then I'll build another
application to connect and play those streams
Any idea or experience would be appreciated )
Thanks again, Stanley
Hoang Hai
Hoang Hai
Greenhorn

Joined: Dec 02, 2001
Posts: 8
For the examples AVReceive2 and AVTransmit2 from JMF Solutions page :
The conflict happens when a rtpmanager tries initializing a SessionAddress with a port that's already used in an initialized rtpManager.
So I think if the transmitter for example, transmit to port 4000, if could make the receiver listen (connect) to that port through another port (e.g., 5000), the conflict won't happen
And I tried this way :
- The AVTransmit2 code remains unchanged.
- AVReceive2 : because the RTPManager mgrs[ i] initialize the localAddr, so I fixed the port (5000) in its construction lines.
so, when I run :
- java AVTransmit2 file:./sound.mp3 127.0.0.1 4000
so, localAddr=destAddr=127.0.0.1,
DataPort=4000, ControlPort=4001 for both addresses
then
- java AVReceive2 127.0.0.1/4000
the port 4000 just exists in the SessionAddress destAddr that's transfered in to addTarget method of mgrs[ i] in AVReceive2.
i.e: localAddr=destAddr=127.0.0.1
local DataPort=5000
local ControlPort=5001
destination DataPort=4000,
destination ControlPort=4001
There's no more conflict , but... AVReceive2 can't regcognize any ReceiveStream or Participant ;((.
Anyone could tell me to connect to port 4000 indirectly though port 5000 like that, was I right or not ?
Thanks for reading
HH
note : I post this message also in http://forum1.java.sun.com/thread.jsp?forum=28&thread=142384
...hoping for some help while working around n around n around.... ;D
abhisek tripathi
Greenhorn

Joined: Oct 15, 2004
Posts: 1
hello stanley ,i m doing a project on developing a VoIP application using NIST's JAIN SIP stack and JMF.
I m new to JMF .can u give me a hint coz i don't know how to start frm scratch in capturing voice and transmitting it via RTP .
thx


i m one of 'those' who don't know who r 'those'.
Sergiu Voicu
Greenhorn

Joined: Oct 24, 2004
Posts: 1
Hi.
I tryed for over a month to find a java internet voicechat. But all I find on the sun examples works only on lan. Does anybody have any idea if an internet voicechat can be done ?
tanay dey
Greenhorn

Joined: Nov 03, 2004
Posts: 2
hi
Every body
i get a problem ,i program on AudioCoference + java
When i use the same port number in both AudioTransmit &
AudioReceive class then a got a problem
After running the AudioReceive class i got a Error mesage
for using the same port
How can i solve the problem Please help anyone dtanay2004@yahoo.com
Stanley George
Ranch Hand

Joined: Dec 09, 2000
Posts: 55
Hi guys,
Sorry for not being able to respond for a long time. Here are some answers. Hope you find them helpful.

abhisek tripathi:
> I m new to JMF .can u give me a hint

Ahishek,
I read the Programmer's Guide 3-4 times to understand the working of JMF. The JMF API is a good reference when you are reading the guide. You can view the Programmer's Guide at:
http://java.sun.com/products/java-media/jmf/1.0/guide/index.html

-------------------

Sergiu Voicu:
> Does anybody have any idea if an internet voicechat can be done ?

Sergiu,
It can be done. I have made a voicechat app in JMF and it works on dialup!

-------------------

tanay dey:
> When i use the same port number in both AudioTransmit &
> AudioReceive class then a got a problem

Tanay,
Sockets are endpoints to applications that are communicating over the network. If there are multiple applications listening on the same IP Address, they are differentiated by different ports. When you instantiate AudioTransmit & AudioReceive on the same port, it creates contention. The first one to be instantiated will bind the port. No other application/instance may use that port as long as it is bound. Try using different port numbers.

-------------------
Cheers to all
Stanley George
[ November 05, 2004: Message edited by: Stanley George ]
Gigi Kent
Ranch Hand

Joined: Nov 30, 2004
Posts: 40
Hello. I have made a an audio-video application using JMF and it works on dial up just fine, with 0.2 s delay and 10 fps.JMF it's amazing.
Good luck.
[ November 05, 2008: Message edited by: Corneliu Croitoru ]
raj saras
Greenhorn

Joined: Dec 16, 2004
Posts: 2
Hi Stanley,
I tried to run AVTransmit2 in LINUX. It is compiling and running well.But no RTP packets was sent out.

Do you know Why?
Please help me if U have answer.

Thanks in advance,
rajsaras(rajsaras16@yahoo.com)
Stanley George
Ranch Hand

Joined: Dec 09, 2000
Posts: 55
Raj,
I am not sure what the problem is. Maybe you can try and use the 'tcpdump' tool in Linux. It spits out information about all the packets that are handled by your system. You can see the source and destination of packets sent via the port used by your application.

Did you try running it on a different OS? I would also look if it is a firewall issue.

Cheers
raj saras
Greenhorn

Joined: Dec 16, 2004
Posts: 2
Hi Stanley,

Thanks for Ur guidance.

I am using two laptops running Aodv routing. I used ethereal to capture the packets sent out. Only the routing messages are being sent. No other data packets.

And also I tried the same program in Windows. It is working fine.

Regards,
Rajsaras.
Stanley George
Ranch Hand

Joined: Dec 09, 2000
Posts: 55
Raj,
As your code is working in Windows, I think it could be a firewall issue in Linux.

Generally a firewall prevents non-HTTP connections initialed by remote machines. Since JMF uses RTP, the firewall blocks it. This is true with mobile ad-hoc networks too.

You can try disabling the firewall using the following command in Linux as root:
service iptables stop

Cheers
[ January 05, 2005: Message edited by: Stanley George ]
Kee Kong Sim
Greenhorn

Joined: Jan 13, 2005
Posts: 5
Stanley,

Can u help me check what's wrong with my codes? I'm developing a text+voice chat but only the text chat is working but voice chat not working. here is the link:

http://www.coderanch.com/t/272598/java/java/Help-voice-chat-JMF

i'm trying to voice chat another computer in the same LAN, which is thru a router. no error message come out but seem the programme doesn't run all the code. is it possible my router firewall block it my voice chat function? how to disable firewall in windows environment?
Stanley George
Ranch Hand

Joined: Dec 09, 2000
Posts: 55
Kee,
Since you are on the same LAN, I don't think it is a firewall issue.

Try using this audio format : AudioFormat(AudioFormat.MPEG_RTP, 44100, 16, 2);
You may also want to try replacing MPEG_RTP with GSM_RTP.

Cheers
[ January 23, 2005: Message edited by: Stanley George ]
Kee Kong Sim
Greenhorn

Joined: Jan 13, 2005
Posts: 5
the compiler don't understand the AudioFormat.MPEG_RTP,

when i code:
AudioFormat audio = AudioFormat(AudioFormat.GSM_RTP, 44100, 16, 2);
Vector deviceList = CaptureDeviceManager.getDeviceList(audio);


the compile error:
D:\KKSIM\PFI\PFI Chat Prog\CaptureNSend.java:27: cannot resolve symbol
symbol : variable GSM_RTP
location: class javax.sound.sampled.AudioFormat
AudioFormat audio = AudioFormat(AudioFormat.GSM_RTP, 44100, 16, 2);
^
D:\KKSIM\PFI\PFI Chat Prog\CaptureNSend.java:30: getDeviceList(javax.media.Format) in javax.media.CaptureDeviceManager cannot be applied to (javax.sound.sampled.AudioFormat)
Vector deviceList = CaptureDeviceManager.getDeviceList(audio);
^
Note: D:\KKSIM\PFI\PFI Chat Prog\CaptureNSend.java uses or overrides a deprecated API.
Note: Recompile with -deprecation for details.
2 errors

Process completed.



did i miss import anything?
my import:
import java.io.*;
import java.util.Vector;
import javax.media.protocol.*;
import javax.media.*;
import javax.media.rtp.*;
import java.net.*;
import javax.sound.sampled.*;
Kee Kong Sim
Greenhorn

Joined: Jan 13, 2005
Posts: 5
oh i know what i have missed, javax.media.AudioFormat;
Basheer Bader
Greenhorn

Joined: Nov 03, 2008
Posts: 1
[ UD: Welcome to JavaRanch.

Please do not post unrelated questions into existing threads. That's called "hijacking" and is frowned upon. Start a new thread instead. ]
[ November 03, 2008: Message edited by: Ulf Dittmer ]
Thud Dissa
Greenhorn

Joined: Feb 06, 2011
Posts: 1
Hi guys..

For my undergraduate project im going to implement an internet radio. What it does is simply broadcast audios from a streaming server to internet. In JMF i saw some codes to stream a single audio file via RTP but I need to stream more than that. Would i b able to do that thing using JMF and what are the things i should know to build my streaming server. Thank you in advance.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JMF-RTP audio. please help.