appleminii
asked on
JMF Receiving media by RTP
I'm working on program for transmitting and receiving audio through RTP in local machine, but the program doesn't receive the data. It never goes into update(ReceiveStreamEvent event). The following is the portion of the code. is there any problem? Thx a lot
public class ReceiveMeida implements ReceiveStreamListener, ControllerListener {
public ReceiveMeida() {
RTPManager rtpManager;
SessionAddress localAddr;
int port = 5000;
try {
localAddr = new SessionAddress(InetAddress .getLocalH ost(),port );
rtpManager = RTPManager.newInstance();
rtpManager.initialize(loca lAddr);
rtpManager.addReceiveStrea mListener( this);
}
catch (Exception e) {
}
}
public void update(ReceiveStreamEvent event) {
if (event instanceof NewReceiveStreamEvent) {
Player newplayer;
try {
ReceiveStream receiveStream = event.getReceiveStream();
DataSource dsource = receiveStream.getDataSourc e();
newplayer = Manager.createPlayer(dsour ce);
}
catch (Exception e) {
}
if (newplayer == null) return;
newplayer.addControllerLis tener(this );
newplayer.realize();
}
}
public synchronized void controllerUpdate (ControllerEvent e) {
if (e instanceof RealizeCompleteEvent) {
newplayer.start();
}
}
}
public class ReceiveMeida implements ReceiveStreamListener, ControllerListener {
public ReceiveMeida() {
RTPManager rtpManager;
SessionAddress localAddr;
int port = 5000;
try {
localAddr = new SessionAddress(InetAddress
rtpManager = RTPManager.newInstance();
rtpManager.initialize(loca
rtpManager.addReceiveStrea
}
catch (Exception e) {
}
}
public void update(ReceiveStreamEvent event) {
if (event instanceof NewReceiveStreamEvent) {
Player newplayer;
try {
ReceiveStream receiveStream = event.getReceiveStream();
DataSource dsource = receiveStream.getDataSourc
newplayer = Manager.createPlayer(dsour
}
catch (Exception e) {
}
if (newplayer == null) return;
newplayer.addControllerLis
newplayer.realize();
}
}
public synchronized void controllerUpdate (ControllerEvent e) {
if (e instanceof RealizeCompleteEvent) {
newplayer.start();
}
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
do u get any runtime error()....where did u call update(...) function
Try changing your codes to like this to get any possible errors :
public class ReceiveMeida implements ReceiveStreamListener, ControllerListener {
public ReceiveMeida() {
RTPManager rtpManager;
SessionAddress localAddr;
int port = 5000;
try {
localAddr = new SessionAddress(InetAddress .getLocalH ost(),port );
rtpManager = RTPManager.newInstance();
rtpManager.initialize(loca lAddr);
rtpManager.addReceiveStrea mListener( this);
}
catch (Exception e) {
System.err.println(""+ e);
}
}
public void update(ReceiveStreamEvent event) {
if (event instanceof NewReceiveStreamEvent) {
Player newplayer;
try {
ReceiveStream receiveStream = event.getReceiveStream();
DataSource dsource = receiveStream.getDataSourc e();
newplayer = Manager.createPlayer(dsour ce);
}
catch (Exception e) {
System.err.println(""+ e);
}
if (newplayer == null) return;
newplayer.addControllerLis tener(this );
newplayer.realize();
}
}
public synchronized void controllerUpdate (ControllerEvent e) {
if (e instanceof RealizeCompleteEvent) {
newplayer.start();
}
}
}
Here is a sweet tutorial for that :
http://java.sun.com/docs/books/tutorial/essential/exceptions/handling.html
Hope that helps . . .
Javatm
public class ReceiveMeida implements ReceiveStreamListener, ControllerListener {
public ReceiveMeida() {
RTPManager rtpManager;
SessionAddress localAddr;
int port = 5000;
try {
localAddr = new SessionAddress(InetAddress
rtpManager = RTPManager.newInstance();
rtpManager.initialize(loca
rtpManager.addReceiveStrea
}
catch (Exception e) {
System.err.println(""+ e);
}
}
public void update(ReceiveStreamEvent event) {
if (event instanceof NewReceiveStreamEvent) {
Player newplayer;
try {
ReceiveStream receiveStream = event.getReceiveStream();
DataSource dsource = receiveStream.getDataSourc
newplayer = Manager.createPlayer(dsour
}
catch (Exception e) {
System.err.println(""+ e);
}
if (newplayer == null) return;
newplayer.addControllerLis
newplayer.realize();
}
}
public synchronized void controllerUpdate (ControllerEvent e) {
if (e instanceof RealizeCompleteEvent) {
newplayer.start();
}
}
}
Here is a sweet tutorial for that :
http://java.sun.com/docs/books/tutorial/essential/exceptions/handling.html
Hope that helps . . .
Javatm
=-)