/** * Creates the gStreamer pipeline and blocks until it starts successfully * * @param newRec The RecordingImpl of the capture we wish to perform. * @return The recording ID (equal to newRec.getID()) or null in the case of an error */ public void start(RecordingImpl newRec) { // Create the pipeline try { pipeline = create(newRec.getProperties(), false); } catch (UnsatisfiedLinkError e) { throw new UnableToStartCaptureException( e.getMessage() + " : please add libjv4linfo.so to /usr/lib to correct this issue."); } // Check if the pipeline came up ok if (pipeline == null) { // logger.error("Capture {} could not start, pipeline was null!", newRec.getID()); captureFailureHandler.resetOnFailure(newRec.getID()); throw new UnableToStartCaptureException( "Capture " + newRec.getID() + " could not start, pipeline was null!"); } logger.info("Initializing devices for capture."); hookUpBus(); // Grab time to wait for pipeline to start int wait; String waitProp = newRec.getProperty(CaptureParameters.CAPTURE_START_WAIT); if (waitProp != null) { wait = Integer.parseInt(waitProp); } else { wait = 5; // Default taken from gstreamer docs } pipeline.debugToDotFile(Pipeline.DEBUG_GRAPH_SHOW_ALL, pipeline.getName()); // Try and start the pipeline pipeline.play(); if (pipeline.getState(wait * GStreamerPipeline.GST_SECOND) != State.PLAYING) { // In case of an error call stop to clean up the pipeline. logger.debug("Pipeline was unable to start after " + wait + " seconds."); stop(GStreamerPipeline.DEFAULT_PIPELINE_SHUTDOWN_TIMEOUT); throw new UnableToStartCaptureException( "Unable to start pipeline after " + wait + " seconds. Aborting!"); } logger.info("{} started.", pipeline.getName()); }