Note that there are some explanatory texts on larger screens.

plurals
  1. POVideo Streaming not working over internet or local network
    primarykey
    data
    text
    <p>I'm working on a project that needs to implement live video streaming from webcam on server into applet on remote client.</p> <p>I have a code for capturing live stream from webcam through JMF on server &amp; deploy streaming on rtp &amp; an applet that receive streaming from the rtp address then play it into it.</p> <p>But the problem that it's only working within my own pc (server) &amp; doesn't work over local network (it loads applet but doesn't run the video player).</p> <p>Server Code:</p> <pre><code>public class Streaming_Server { /** * @param args the command line arguments */ private static String PORT = "10000"; private static InetAddress addr; static final Format[] FORMATS = { new VideoFormat("rgb") }; static final ContentDescriptor CONTENT_DESCRIPTOR = new ContentDescriptor("raw.rtp"); public static void main(String[] args) throws IOException, NoDataSourceException, NoProcessorException, CannotRealizeException, NoDataSinkException { // TODO code application logic here try { addr = InetAddress.getLocalHost(); String ipAddr = addr.getHostAddress(); String hostname = addr.getHostName(); System.out.println("Your IP is " + ipAddr); System.out.println("Your Host Name is " + hostname); } catch (UnknownHostException e){} CaptureDeviceInfo webcamInfooo = new CaptureDeviceInfo("Camera", new MediaLocator("vfw://0"), null); MediaLocator camDeviceMediaLocator = webcamInfooo.getLocator(); DataSource source = Manager.createDataSource(camDeviceMediaLocator); Processor mediaProcessor = Manager.createRealizedProcessor(new ProcessorModel(source, FORMATS, CONTENT_DESCRIPTOR)); //MediaLocator outputMediaLocator = new MediaLocator("rtp://" + addr.getHostAddress() + ":" + PORT + "/video"); MediaLocator outputMediaLocator = new MediaLocator("rtp://192.168.1.4:20000/video"); DataSink dataSink = Manager.createDataSink(mediaProcessor.getDataOutput(), outputMediaLocator); mediaProcessor.start(); dataSink.open(); dataSink.start(); } } </code></pre> <p>Client Code:</p> <pre><code>public class Streaming_Client extends Applet implements ControllerListener { /** * Initialization method that will be called after the applet is loaded into * the browser. */ Player player = null; private MediaLocator mediaLocator; private static String PORT = "10000"; private static InetAddress addr; public void init() { // TODO start asynchronous download of heavy resources //mediaLocator = new MediaLocator("rtp:/192.168.1.4:10000/video"); mediaLocator = new MediaLocator("rtp:/192.168.1.4:20000/video"); setLayout(new BorderLayout()); try { player = Manager.createPlayer(mediaLocator); player.addControllerListener(this); } catch (IOException | NoPlayerException ex) { Logger.getLogger(Streaming_Client.class.getName()).log(Level.SEVERE, null, ex); } } public void start(){ player.start(); } public void stop(){ player.stop(); player.deallocate(); } public void destroy(){ player.close(); } // TODO overwrite start(), stop() and destroy() methods @Override public void controllerUpdate(ControllerEvent ce) { if ((ce instanceof RealizeCompleteEvent)) { Component comp; if ((comp = this.player.getVisualComponent()) != null) add("Center", comp); if ((comp = this.player.getControlPanelComponent()) != null) add("South", comp); validate(); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload