Link to home
Start Free TrialLog in
Avatar of appleminii
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.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();
           }
}
}
ASKER CERTIFIED SOLUTION
Avatar of Tommy Braas
Tommy Braas
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of maheshexp
maheshexp

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