Building video player using Qt and gstreamer at the backend
-
hi! i am unable to display the gstreamer video window at central window of the dock window
this my code
videowindow.cpp
@videoWindow::videoWindow(QWidget *parent) :
QWidget(parent)
{
gst_init(NULL,NULL);pipeline=gst_pipeline_new("my_pipeline"); bin=gst_bin_new("my_bin"); src=gst_element_factory_make("v4l2src","source"); sink=gst_element_factory_make("xvimagesink",NULL); QLabel *label=new QLabel; /*First add the elements to the bin */ gst_bin_add_many(GST_BIN(bin),src,sink,NULL); /* add bin to the pipeline*/ gst_bin_add(GST_BIN(pipeline),bin); /*link the elemnets */ gst_element_link(src,sink); gst_element_set_state(sink,GST_STATE_READY); QApplication::syncX(); //GstXOverlayClass::gst_x_overlay_set_window_handle(GST_X_OVERLAY(sink),window.winId()); gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(sink),label->winId()); //run the pipeline GstStateChangeReturn sret=gst_element_set_state(pipeline,GST_STATE_PLAYING); if(sret==GST_STATE_CHANGE_FAILURE) { gst_element_set_state(pipeline,GST_STATE_NULL); gst_object_unref(pipeline); //Exit application // QTimer::singleShot(0,QApplication::activeWindow(),SLOT(quit())); } // label->hide();
}
videoWindow::~videoWindow()
{
gst_element_set_state(pipeline,GST_STATE_NULL);
gst_object_unref(pipeline);}@
mainwindow.cpp
@MainWindow::MainWindow()
{
//textEdit= new QTextEdit;
videoWindow *videowindow=new videoWindow;
setCentralWidget(videowindow);createActions(); createMenus(); createToolBars(); createStatusBar(); createDockWindows(); setWindowTitle(tr("Dock Widgets"));
}
void MainWindow::newLetter()
{
}void MainWindow::print()
{}
void MainWindow::save()
{}
void MainWindow::undo()
{void MainWindow::about()
{}
void MainWindow::createActions()
{}
void MainWindow::createMenus()
{}
void MainWindow::createToolBars()
{
fileToolBar = addToolBar(tr("File"));
fileToolBar->addAction(newLetterAct);
fileToolBar->addAction(saveAct);
fileToolBar->addAction(printAct);editToolBar = addToolBar(tr("Edit")); editToolBar->addAction(undoAct);
}
void MainWindow::createStatusBar()
{
statusBar()->showMessage(tr("Ready"));
}void MainWindow::createDockWindows()
{
QDockWidget *dock = new QDockWidget(tr("Thumbnails"), this);
QMainWindow::setCorner(Qt::BottomRightCorner,Qt::RightDockWidgetArea);
dock->setAllowedAreas(Qt::BottomDockWidgetArea);QString myDir="/home/sayantan/Qt_project/images"; QFileSystemModel *model = new QFileSystemModel; model->setRootPath(myDir); QListView *Thumbnails = new QListView(dock); Thumbnails->setMaximumSize(800,200); Thumbnails->setModel(model); Thumbnails->setRootIndex(model->index(myDir)); dock->setWidget(Thumbnails); addDockWidget(Qt::RightDockWidgetArea, dock); viewMenu->addAction(dock->toggleViewAction()); dock = new QDockWidget(tr("Paragraphs"), this); paragraphsList = new QListWidget(dock); paragraphsList->addItems(QStringList()"); dock->setWidget(paragraphsList); addDockWidget(Qt::RightDockWidgetArea, dock); viewMenu->addAction(dock->toggleViewAction());
}
@main.cpp
@int main(int argc, char *argv[])
{
QApplication app(argc, argv);
MainWindow w;
w.resize(800,600);
w.show();return app.exec();
}@
code is compiling and running without any error but it is unable to display any frame..........Please help me
-
Would you wrap the code in @ (just before it and right after it), please :)