GstreamerPlayer(ElphelVision parent) {
    this.Parent = parent;

    args = new String[2];
    args[1] = "";
    args[0] = "";

    try {
      args = Gst.init("ElphelVision", args);
    } catch (GstException e) {
      Parent.WriteErrortoConsole("Gst.init error: " + e);
    }

    //        Playbin = new PlayBin2("VideoPlayer");
    //        rtspsource = "rtspsrc location=rtsp://" + Parent.Camera.GetIP()[0] + ":554
    // protocols=0x00000001 latency=50 ! rtpjpegdepay ! jpegdec ! queue ! jp462bayer ! queue !
    // bayer2rgb2 method=0 ! ffmpegcolorspace  name=elphelstream";
    // Playbin.setInputFile(new File("test.avi"));
    /*java.net.URI uri = null;
    try {
    uri = new URI("rtsp://" + Parent.Camera.GetIP()[0] + ":554");
    } catch (URISyntaxException ex) {
    Logger.getLogger(GstreamerPlayer.class.getName()).log(Level.SEVERE, null, ex);
    }
    Playbin.setURI(uri);*/

    videoComponent = new VideoComponent();
    videoComponent.setPreferredSize(new Dimension(850, 480));
    //     Playbin.setVideoSink(videoComponent.getElement());

    /*
    Playbin.getBus().connect(new Bus.EOS() {

    public void endOfStream(GstObject source) {
    System.out.println("Finished playing file");
    Gst.quit();
    }
    });
    Playbin.getBus().connect(new Bus.ERROR() {

    public void errorMessage(GstObject source, int code, String message) {
    System.out.println("Error occurred: " + message);
    Gst.quit();
    }
    });
    Playbin.getBus().connect(new Bus.STATE_CHANGED() {

    public void stateChanged(GstObject source, State old, State current, State pending) {
    if (source == Playbin) {
    System.out.println("Pipeline state changed from " + old + " to " + current);
    }
    }
    });
     */
  }
示例#2
0
  public static void handleRequest(VideoComponent vc, String settings, JTextArea log, String addr)
      throws UnknownHostException, IOException {
    textArea = log;

    String[] s = settings.split(" ");
    attribute = s[0]; // Passive/Active
    request = s[2];

    if (clientPipe == null) {
      // Play -> connect and play
      // Pause -> nothing
      // Stop -> Nothing
      if (request.equalsIgnoreCase("play")) {
        connectAndPlay(vc, settings, addr);
        videoQ = new LinkedList<FrameInfo>();
        audioQ = new LinkedList<FrameInfo>();
        jointQ = new LinkedList<CompareInfo>();
      }
    } else {
      // Play -> if playing then nothing || if paused then resume
      // Pause -> if playing then pause || if  paused then nothing
      // Stop -> Signal kill and purge pipes
      if (request.equalsIgnoreCase("play")) {
        commandResume();
        videoQ = new LinkedList<FrameInfo>();
        audioQ = new LinkedList<FrameInfo>();
        jointQ = new LinkedList<CompareInfo>();
      } else if (request.equalsIgnoreCase("pause")) {
        commandPause();
      } else if (request.equalsIgnoreCase("rewind")) {
        commandRewind();
        videoQ = new LinkedList<FrameInfo>();
        audioQ = new LinkedList<FrameInfo>();
        jointQ = new LinkedList<CompareInfo>();
      } else if (request.equalsIgnoreCase("forward")) {
        commandForward();
        videoQ = new LinkedList<FrameInfo>();
        audioQ = new LinkedList<FrameInfo>();
        jointQ = new LinkedList<CompareInfo>();
      } else { // request = stop
        commandStop(vc);
      }
    }
    vc.setPreferredSize(new Dimension(1200, 640));
  }