rock_widget_collection  0.1
Functions
main.cpp File Reference
#include <iostream>
#include <stdlib.h>
#include <QtCore>
#include <QtGui>
#include <QtOpenGL/QGLWidget>
#include "ImageView.h"

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 22 of file main.cpp.

23 {
24  QApplication qapp(argc, argv);
25 
26 #if 0
27  QGst::init(&argc, &argv);
28 
29  QGst::ElementPtr videoSrc = QGst::ElementFactory::make("videotestsrc");
30  QGst::ElementPtr fallbackVideoSink = QGst::ElementFactory::make("qtvideosink");
31  QGst::PipelinePtr pipeline = QGst::Pipeline::create("mypipeline");
32  QGst::PipelinePtr fallbackPipeline = QGst::Pipeline::create("fallbackPipeline");
33 
34  QGraphicsScene *scene = new QGraphicsScene;
35  QGraphicsView *view = new QGraphicsView(scene);
36  view->setViewport(new QGLWidget); // indicator to use qtglvideosink (hardware rendering!)
37 
38  QGst::Ui::GraphicsVideoSurface *surface = new QGst::Ui::GraphicsVideoSurface(view);
39  QGst::Ui::GraphicsVideoWidget *widget = new QGst::Ui::GraphicsVideoWidget;
40  widget->setSurface(surface);
41 
42  scene->addItem(widget);
43  view->show();
44  view->resize(400,400);
45  widget->resize(300,300);
46 
47  pipeline->add(videoSrc, surface->videoSink());
48  videoSrc->link(surface->videoSink());
49 
50  std::cout << "Video source name: " << surface->videoSink()->property("name").toString().toStdString() << std::endl;
51 
52  /* start playing */
53  if(!pipeline->setState(QGst::StatePlaying)) {
54  /* There seems to be an opengl problem. Fall back to software rendering using qtvideosink. */
55  std::cout << "Could not play pipeline with opengl video sink. Trying to fall back to qtvideosink." << std::endl;
56 // pipeline->remove(surface->videoSink());
57 // delete pipeline; pipeline = 0;
58 // //videoSrc->unparent();
59 // //fallbackPipeline->add(videoSrc, fallbackVideoSink);
60 // //videoSrc->link(fallbackVideoSink);
61 // delete surface; surface = 0;
62 // delete widget; widget = 0;
63 //
64 // view = new QGraphicsView(scene);
65 //
66 // surface = new QGst::Ui::GraphicsVideoSurface(view);
67 // widget = new QGst::Ui::GraphicsVideoWidget;
68 // widget->setSurface(surface);
69 // std::cout << "Video source name: " << surface->videoSink()->property("name").toString().toStdString() << std::endl;
70 //
71 // view->show();
72 // view->resize(400,400);
73 // widget->resize(300,300);
74 //
75 // fallbackPipeline->add(surface->videoSink());
76 // videoSrc->link(surface->videoSink());
77 //
78 // std::cout << "before second play call" << std::endl;
79 //
80 // if(!fallbackPipeline->setState(QGst::StatePlaying)) {
81 // /* Still unable to play pipeline */
82 // std::cout << "Falling back to software rendering also did not help. Exit." << std::endl;
83 // exit(EXIT_FAILURE);
84 // }
85 // std::cout << "Everything worked. Playing the pipeline." << std::endl;
86  }
87 
88 #endif
89 
90 #if 0
91 
92  QGst::ElementPtr videoSrc = QGst::ElementFactory::make("videotestsrc");
93  QGst::ElementPtr videoSink = QGst::ElementFactory::make("qtglvideosink");
94 
95  QGLWidget *glwidget = new QGLWidget;
96  glwidget->makeCurrent();
97  videoSink->setProperty("glcontext", (void*) QGLContext::currentContext());
98  glwidget->doneCurrent();
99 
100  if (videoSink->setState(QGst::StateReady) != QGst::StateChangeSuccess) {
101  // fall back to qtvideosink
102  videoSink = QGst::ElementFactory::make("qtvideosink");
103  }
104 
105  QGst::PipelinePtr pipeline = QGst::Pipeline::create("mypipeline");
106  pipeline->add(videoSrc, videoSink);
107  videoSrc->link(videoSink);
108 
109 
110 #endif
111 
112 #if 1
113  ImageView gstImageView;
114  gstImageView.show();
115 #endif
116 
117  qapp.exec();
118 }
Image viewer with optional text and geometry overlay functionality.
Definition: ImageView.h:47