Solved

JMF Receiving media by RTP

Posted on 2004-04-24
4
3,485 Views
Last Modified: 2013-11-23
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.getLocalHost(),port);
            rtpManager = RTPManager.newInstance();
            rtpManager.initialize(localAddr);
            
            rtpManager.addReceiveStreamListener(this);
            
            
      }
      catch (Exception  e) {
      }
}


public void update(ReceiveStreamEvent event) {
               
        if (event instanceof NewReceiveStreamEvent) {
             Player newplayer;
             
             try {
                 ReceiveStream receiveStream = event.getReceiveStream();
                 DataSource dsource = receiveStream.getDataSource();
                 
                 newplayer = Manager.createPlayer(dsource);

             }
             catch (Exception e) {
             }
 
             if (newplayer == null) return;
 

             newplayer.addControllerListener(this);
             newplayer.realize();
           
             

         }
         
}
public synchronized void controllerUpdate (ControllerEvent e) {
           if (e instanceof RealizeCompleteEvent) {
                 newplayer.start();
           }
}
}
0
Comment
Question by:appleminii
  • 2
4 Comments
 
LVL 14

Accepted Solution

by:
Tommy Braas earned 125 total points
ID: 10910624
One problem is that you have try - catch clauses where you do nothing with the exception! BAD!!! Add a e.printStackTrace() to each of your catch clauses. I am sure you will find a clue to what the problem is.
0
 
LVL 7

Expert Comment

by:maheshexp
ID: 10910866
do u get any runtime error()....where did u call update(...) function
0
 
LVL 15

Expert Comment

by:Javatm
ID: 10910974
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.getLocalHost(),port);
          rtpManager = RTPManager.newInstance();
          rtpManager.initialize(localAddr);
          rtpManager.addReceiveStreamListener(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.getDataSource();
                 
                 newplayer = Manager.createPlayer(dsource);

             }
             catch (Exception e) {
             System.err.println(""+ e);
             }
 
             if (newplayer == null) return;
             newplayer.addControllerListener(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
0
 
LVL 14

Expert Comment

by:Tommy Braas
ID: 10912949
=-)
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to implement Singleton Design Pattern in Java.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now