Solved

JMF Receiving media by RTP

Posted on 2004-04-24
4
3,510 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
difference of if loops 23 62
jsp login check 12 42
Chrome and Firefox Java 5 50
Need help aligning JRadioButton that put in a box using GridBagLayout 2 16
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

840 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