static void playIt (GtkWidget *widget, GstElement* pipeline)
{
    /*
     * sidenote: I find it completly stupid that you can detect the end of stream in
     * bus_call() with GST_MESSAGE_EOS, but cannot access and reset the state of the pipeline
     * throught the GMainLoop *loop. (If there is a way please, tell me about it)
     * So in order to detect the end of stream, you've got two options:
     *      _ create a second bus
     *      _ pass a struct to bus_call
     *      _ get the stream length and compare it to the current position....
     * I use the third option here, but I'm only skirting the problem to
     * keep the code simple and readable.
     * known issue: if you set the speeed too high (eg:*64), it won't detect the end of
     * the stream correctly, so you'll need to rewind the stream manually by pressing the stop button
     */
    // rewind stream if we're at the end of the stream
    gint64 streamPosition, streamLength;
    GstFormat format = GST_FORMAT_TIME;

    gst_element_query_position (pipeline, &format, &streamPosition);
    gst_element_query_duration (pipeline, &format, &streamLength);
    if (streamPosition==streamLength)
        stopIt(widget,pipeline);


    // setting the stream to the playing state
    g_print("Playing Video\n");
    gst_element_set_state (pipeline, GST_STATE_PLAYING);
}
AnalyzerRunControl::AnalyzerRunControl(const AnalyzerStartParameters &sp,
        ProjectExplorer::RunConfiguration *runConfiguration)
    : RunControl(runConfiguration, sp.runMode)
{
    setIcon(QLatin1String(":/images/analyzer_start_small.png"));

    m_runConfig = runConfiguration;
    m_sp = sp;

    connect(this, SIGNAL(finished()), SLOT(runControlFinished()));
    connect(AnalyzerManager::stopAction(), SIGNAL(triggered()), SLOT(stopIt()));
}
void VideoProcessor::run(){
	
	cv::Mat frame;
	cv::Mat output;

	if (!isOpened())		// if no capture device has been set
		return;
	stop= false;


	while (!isStopped()) {
		if (!readNextFrame(frame))				// read next frame if any
			break;

		if (windowNameInput.length()!=0)			// display input frame
			cv::imshow(windowNameInput,frame);
	
		if (callIt) {						// calling the process function or method
			if (process){					// process the frame
				process(frame, output);
			}
			else if (frameProcessor){
				frameProcessor->process(frame,output);
			}
			fnumber++;					// increment frame number
		} else {
			output= frame;
		}
		if (outputFile.length()!=0)
			writeNextFrame(output);

		if (windowNameOutput.length()!=0)			// display output frame
			cv::imshow(windowNameOutput,output);
		if (delay>=0 && cv::waitKey(delay)>=0)			// introduce a delay
			stopIt();

		if (frameToStop>=0 && getFrameNumber()==frameToStop)// check if we should stop
			stopIt();
	}
}
Esempio n. 4
0
static void startRemoteTool(IAnalyzerTool *tool)
{
    StartRemoteDialog dlg;
    if (dlg.exec() != QDialog::Accepted)
        return;

    AnalyzerStartParameters sp;
    sp.startMode = StartRemote;
    sp.connParams = dlg.sshParams();
    sp.debuggee = dlg.executable();
    sp.debuggeeArgs = dlg.arguments();
    sp.displayName = dlg.executable();
    sp.workingDirectory = dlg.workingDirectory();

    AnalyzerRunControl *rc = tool->createRunControl(sp, 0);
    QObject::connect(AnalyzerManager::stopAction(), SIGNAL(triggered()), rc, SLOT(stopIt()));

    ProjectExplorerPlugin::instance()->startRunControl(rc, tool->runMode());
}