Package projekt.lab

Source Code of projekt.lab.NetworkStream

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package projekt.lab;

import com.sun.jna.Native;
import com.sun.jna.NativeLibrary;
import java.awt.Canvas;
import java.io.File;
import uk.co.caprica.vlcj.binding.LibVlc;
import uk.co.caprica.vlcj.player.MediaPlayerFactory;
import uk.co.caprica.vlcj.player.embedded.EmbeddedMediaPlayer;
import uk.co.caprica.vlcj.player.embedded.videosurface.CanvasVideoSurface;
import uk.co.caprica.vlcj.runtime.RuntimeUtil;

/**
*
* @author Perom
*/
public class NetworkStream extends Thread
{
   
    NetworkStream(Canvas canvas, int cache,int port)
    {
   //  NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), "C:\\Users\\Perom\\Documents\\NetBeansProjects\\AstroServerSide\\VLC\\");
   // Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class);
  NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), "C:\\VLC\\");
  Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class);

      running = false;
 
      networkCache = cache;
     
      streamPort = port;
      factory = new MediaPlayerFactory("--no-video-title-show");

      stream = factory.newEmbeddedMediaPlayer();      

      videoSurface = factory.newVideoSurface(canvas);

      stream.setVideoSurface(videoSurface);

      String[] options = {" :network-caching=500"};

      //stream.prepareMedia("http://localhost:"+streamPort+"/stream.webm", options);
      stream.prepareMedia("http://localhost:8080", options);
    }
   
    public void startStream()
    {
 
   stream.start();
    }
   
    public void pauseStream()
    {
   stream.pause();
 
 
    }
   
    public String takePicture(String path)
    {
  String fullFileName = path;
  if(stream.isPlaying())
  {
      long epoch = System.currentTimeMillis()/1000;
     
      fullFileName += epoch +".png";
      File file = new File(fullFileName);
      stream.saveSnapshot(file);
      System.out.print(file);
      return fullFileName;
  }
  return null;
    }
   
    @Override
    public void run()
    {
  running = true;
  startStream();
    }
   
   
    private MediaPlayerFactory factory;
    private EmbeddedMediaPlayer stream;
    private CanvasVideoSurface videoSurface;
    private int networkCache;
    private int streamPort;
    public boolean running;
}
TOP

Related Classes of projekt.lab.NetworkStream

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.