Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 784
  • Last Modified:

Problem with receiving an RTP stream

Hey guys,
  I'm attempting to write a program to receive an RTP stream and play the content (a video file) however when I run the program I get an error message :-

java.net.MalformedURLException: unknown protocol: rtp
        at java.net.URL.<init>(URL.java:544)
        at java.net.URL.<init>(URL.java:434)
        at java.net.URL.<init>(URL.java:383)
        at MyPlayer.<init>(MyPlayer.java:27)
        at MyPlayer.main(MyPlayer.java:97)

This is probably a very straightforward problem to solve but i've searched the net to no avail. Any help would be hugely appreciated. Please see below for my code.

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.media.*;
import java.net.*;


public class MyPlayer extends JFrame
      implements ControllerListener
{
    private MediaLocator mloc;
    private String vidFile;
    private Player p = null;
    private URL mediaURL;
    //private JPanel jp;
    private boolean realized = false;
   
    public MyPlayer()
    {
      try
      {
            setSize(300,300);
            getContentPane().setLayout(new BorderLayout());
            vidFile = "file://c:/GreenScreen.mov";
            mediaURL = new URL("rtp://127.0.0.1:10000/video/1");
           
          //mloc = new MediaLocator(vidFile);
          mloc = new MediaLocator(mediaURL);
          p = Manager.createPlayer(mloc);
          p.addControllerListener(this);
            //jp = new JPanel();
            wrapRealize();
            p.prefetch();
           
            //getContentPane().add(jp, BorderLayout.CENTER);
           
            addWindowListener(new WindowAdapter()
            {
                public void windowClosing(WindowEvent we)
                {
                        p.deallocate();
                        p.close();
                  System.gc();
                  System.exit(0);
                }
            });

            setVisible(true);
      }
      catch(Exception e)
      {
          e.printStackTrace();
      }
    }
   
    public synchronized void wrapRealize()
    {
        p.realize();
        while(!realized)
        {
            try
            {
                wait();
            }
            catch(InterruptedException ie)
            {
            }
        }
    }        

    public synchronized void controllerUpdate(ControllerEvent ce)
    {
        if(ce instanceof RealizeCompleteEvent)
        {
            realized = true;
            Component display = p.getVisualComponent();
            getContentPane().add(display, BorderLayout.CENTER);
            Component controller = p.getControlPanelComponent();
            getContentPane().add(controller, BorderLayout.SOUTH);
            notify();  
        }
        else if(ce instanceof PrefetchCompleteEvent)
        {
            p.start();
        }
        else if(ce instanceof EndOfMediaEvent)
        {
            p.stop();
        }
               
    }
   
    public static void main(String[] args)
    {
        MyPlayer player = new MyPlayer();
    }
}
0
MrChartWars
Asked:
MrChartWars
  • 8
  • 5
1 Solution
 
CEHJCommented:
>>mediaURL = new URL("rtp://127.0.0.1:10000/video/1");

Are you sure this protocol is supported?
0
 
CEHJCommented:
This is guesswork, but try importing:


import javax.media.*;
import javax.media.format.*;
import javax.media.protocol.*;
import javax.media.control.*;
import javax.media.rtp.*;
import javax.media.rtp.rtcp.*;
import com.sun.media.rtp.*;
0
 
MrChartWarsAuthor Commented:
Thanks for your feedback so far, i've just tried importing those classes but it made no difference :o(

I'm not certain the protocol is supported, i'm only going on tutorials etc i've found on the internet, if anyone out there knows of an easier/better way to create a receiver then please let me know :o)

Thanks
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
CEHJCommented:
Try

mloc = new MediaLocator("rtp://127.0.0.1:10000/video/1");
0
 
MrChartWarsAuthor Commented:
Ok,thanks for that, think you may be on the right track, i just tried that but now i get :-

Could not find error.connectionerror
java.io.IOException: Connection refused: connect
Could not find error.connectionerror
java.io.IOException: Connection refused: connect
javax.media.NoPlayerException: Error instantiating class: com.sun.media.protocol
.ftp.DataSource : java.io.IOException: Connection refused: connect
        at javax.media.Manager.createPlayerForContent(Manager.java:1362)
        at javax.media.Manager.createPlayer(Manager.java:417)
        at MyPlayer.<init>(MyPlayer.java:38)
        at MyPlayer.main(MyPlayer.java:104)

Any ideas?

Thanks for the help so far :o)
0
 
CEHJCommented:
>>java.io.IOException: Connection refused: connect

Suggests there's no rtp service running on local port 10000
0
 
CEHJCommented:
(Assuming Windows) no output from

netstat -a | find "10000"

means there isn't
0
 
MrChartWarsAuthor Commented:
Apologies for asking so many stupid questions (i'm really new at this stuff.) When i type the above command i get the following output :-

TCP    Computer:4490          port32.ds1-sl.adsl.cybercity.dk:10000  ESTABLISHED

Thanks
0
 
CEHJCommented:
That looks like you've a connection to that host on port 10000 in Denmark, but you're trying to connect to one on the localhost
0
 
MrChartWarsAuthor Commented:
Ok, right, I think I understand now. I just tried netstat on port 10,001 and it didn't produce any output which presumably means there is nothing using the port. I ran the RTP sender on port 10,001 and ran netstat again but again there was no output. Does this mean that the sender isn't working properly? The reason i ask is because I only have the class for the sender (it is presumed to be working correctly) and I must write the receiver side.

Thanks
0
 
CEHJCommented:
>>Does this mean that the sender isn't working properly?

It means that there's no service running on that port to connect to in the first place. 'Connection refused' is misleading - there's nothing there
0
 
MrChartWarsAuthor Commented:
Ok, I just wanted to post to say i've worked out the answer. It was the loopback address (127.0.0.1) - I think beecause the system I was on resides on a local network (with a local IP address) it didn't like it. I changed the IP address to 10.0.0.1 (the address given via ipconfig) and all is well :o)

Thanks
0
 
CEHJCommented:
:-)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 8
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now