How to play videos

How to play videos

Ritratto di kusumat
Hi, I want to play videos on Meego netbook programatically. Can any one plz provide a sample. When i use #include No such file or directory. So Does Meego supports Video playback. If so plz assist. Thanks, kusumat
7 post / 0 new
Ultimo contenuto
Per informazioni complete sulle ottimizzazioni del compilatore, consultare l'Avviso sull'ottimizzazione
Ritratto di vyau

Hi Kusumat:

Just responded to your other thread of the same topic.

I will try to post some source code here but I am having trouble currently. Check your msg and I can email them to you.

--v

Ritratto di vyau

Hi Kusumat:

This sample program below should play video for you. There is one problem. The Wndowing part in terms of geometry/size, only works on meego netbook and I am still investigating the problem on meego tablet. With this as is, it will run on tablet in fullscreen mode.

Hope this helps.

#include
#include
#include
#include
#include
#include

#define DEFAULT_VIDEOSINK "xvimagesink"

/**
* work with video sink
*/
static GstElement *
find_video_sink (void)
{
GstStateChangeReturn sret;
GstElement *sink;

if ((sink = gst_element_factory_make("xvimagesink", NULL))) {
sret = gst_element_set_state (sink, GST_STATE_READY);
if (sret == GST_STATE_CHANGE_SUCCESS) {
return sink;
}
gst_element_set_state (sink, GST_STATE_NULL);
}
gst_object_unref (sink);

if ((sink = gst_element_factory_make("ximagesink", NULL))) {
sret = gst_element_set_state(sink, GST_STATE_READY);
if (sret == GST_STATE_CHANGE_SUCCESS) {
return sink;
}

gst_element_set_state(sink, GST_STATE_NULL);
}
gst_object_unref (sink);

if (strcmp(DEFAULT_VIDEOSINK, "xvimagesink") == 0 ||
strcmp(DEFAULT_VIDEOSINK, "ximagesink") == 0) {
return NULL;
}

if ((sink = gst_element_factory_make (DEFAULT_VIDEOSINK, NULL))) {
if (GST_IS_BIN (sink)) {
gst_object_unref (sink);
return NULL;
}

sret = gst_element_set_state (sink, GST_STATE_READY);
if (sret == GST_STATE_CHANGE_SUCCESS) {
return sink;
}

gst_element_set_state (sink, GST_STATE_NULL);
}
gst_object_unref (sink);
return NULL;
}

int main(int argc, char *argv[])
{
if (!g_thread_supported ()) {
g_thread_init (NULL);
}

gst_init (&argc, &argv);
QApplication app(argc, argv);
app.setOrganizationName("sample");

// lastWindowClosed() -- QApplication signal
// quit() -- QCoreApplication slot
app.connect(&app, SIGNAL(lastWindowClosed()),
&app, SLOT(quit ()));

/* prepare the pipeline */
GstElement *pipeline = gst_pipeline_new ("xvoverlay");
GstElement *src = gst_element_factory_make ("videotestsrc",
NULL);
GstElement *sink = find_video_sink ();

if (sink == NULL) {
g_error ("Couldn't find a working video sink.");
}

gst_bin_add_many (GST_BIN (pipeline), src,
sink, NULL);
gst_element_link (src, sink);

/* prepare the ui */

QWidget window;
window.resize(800, 480);
window.setWindowTitle("GstXOverlay Qt demo");
window.show();
WId xwinid = window.winId();
gst_x_overlay_set_xwindow_id(GST_X_OVERLAY (sink),
xwinid);

/* 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()));
}
int ret = app.exec();

//window.hide();
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (pipeline);

return ret;
}

Ritratto di vyau

Hi Kusumat:

I used the wrong formatting and as you can see the previous version does not come out legibly...Hope this will work.

This sample program below should play video for you. There is one problem. The Wndowing part in terms of geometry/size, only works on meego netbook and I am still investigating the problem on meego tablet. With this as is, it will run on tablet in fullscreen mode. Hope this helps.

#include
#include
#include
#include
#include
#include

#define DEFAULT_VIDEOSINK "xvimagesink"

/**
* slightly convoluted way to find a working video sink that's not a bin,
* one could use autovideosink from gst-plugins-good instead
*/
static GstElement *
find_video_sink (void)
{
GstStateChangeReturn sret;
GstElement *sink;

if ((sink = gst_element_factory_make("xvimagesink", NULL))) {
sret = gst_element_set_state (sink, GST_STATE_READY);
if (sret == GST_STATE_CHANGE_SUCCESS) {
return sink;
}
gst_element_set_state (sink, GST_STATE_NULL);
}
gst_object_unref (sink);

if ((sink = gst_element_factory_make("ximagesink", NULL))) {
sret = gst_element_set_state(sink, GST_STATE_READY);
if (sret == GST_STATE_CHANGE_SUCCESS) {
return sink;
}

gst_element_set_state(sink, GST_STATE_NULL);
}
gst_object_unref (sink);

if (strcmp(DEFAULT_VIDEOSINK, "xvimagesink") == 0 ||
strcmp(DEFAULT_VIDEOSINK, "ximagesink") == 0) {
return NULL;
}

if ((sink = gst_element_factory_make (DEFAULT_VIDEOSINK, NULL))) {
if (GST_IS_BIN (sink)) {
gst_object_unref (sink);
return NULL;
}

sret = gst_element_set_state (sink, GST_STATE_READY);
if (sret == GST_STATE_CHANGE_SUCCESS) {
return sink;
}

gst_element_set_state (sink, GST_STATE_NULL);
}
gst_object_unref (sink);
return NULL;
}

int main(int argc, char *argv[])
{
if (!g_thread_supported ()) {
g_thread_init (NULL);
}

gst_init (&argc, &argv);
QApplication app(argc, argv);
app.setOrganizationName("sample");

// lastWindowClosed() -- QApplication signal
// quit() -- QCoreApplication slot
app.connect(&app, SIGNAL(lastWindowClosed()),
&app, SLOT(quit ()));

/* prepare the pipeline */
GstElement *pipeline = gst_pipeline_new ("xvoverlay");
GstElement *src = gst_element_factory_make ("videotestsrc",
NULL);
GstElement *sink = find_video_sink ();

if (sink == NULL) {
g_error ("Couldn't find a working video sink.");
}

gst_bin_add_many (GST_BIN (pipeline), src,
sink, NULL);
gst_element_link (src, sink);

/* prepare the ui */

QWidget window;
window.resize(800, 480);
window.setWindowTitle("GstXOverlay Qt demo");
window.show();
WId xwinid = window.winId();
gst_x_overlay_set_xwindow_id(GST_X_OVERLAY (sink),
xwinid);

/* 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()));
}
int ret = app.exec();

//window.hide();
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (pipeline);

return ret;
}

Ritratto di vyau

Ok, the #include parts are all missing from the cut/paste and formatting.

The previous code is good. Please replace the top parts with this:

#include
#include
#include
#include
#include
#include

Ritratto di vyau

ok, I hope 3rd try will work. Looks like the formatting does not like the open bracket.

"#include "
"#include "
"#include "
"#include "
"#include "
"#include "

Ritratto di vyau

ok, I feel so stupid now...

These are the includes, please add the usually angle brackets. :)

gst/gst.h
gst/interfaces/xoverlay.h
QDebug
QApplication
QTimer
QWidget

Accedere per lasciare un commento.