Bonjour,
Je cherche à développer une petite application permettant de visualiser un flux vidéo. J'ai trouvé un code sur internet qui donne ceci :
/*********tuto_vlc.cpp**********/
#include <iostream>
#include <qapplication.h>
#include <qtextedit.h>
#include <vlc/libvlc.h> //pour utiliser les fonction haut-niveu de VLC
class player : public QWidget
{
Q_OBJECT
QFrame *Webcam;
//variables propres a VLC
libvlc_exception_t _vlcexcep;
libvlc_instance_t *_vlcinstance;
public:
player();
~player();
public slots:
void playFile(QString file);
};
player::player() : QWidget(0)
{
//mise en place des widgets
Webcam = new QFrame(this);
Webcam->resize(500,400);// dimensionne l'image.
//et maintenant on peut initialiser le backend VLC
char *optionDeVlc[] = {(char*)""};
_vlcinstance = libvlc_new(1,optionDeVlc,&_vlcexcep); //param1=argc,param2=otionDeVlc=argv mais ici on n'en a pas besoin
// on indique ici a vlc sur quel widget afficher sa video
// VLC se chargera d'apdater la video a la taille du widget
// et dans son infinie bonte, VLC se chargera aussi de resizer la video
// si la taille du widget venait a changer pendant la lecture
libvlc_video_set_parent(_vlcinstance ,Webcam->winId(),&_vlcexcep);
}
player::~player()
{
}
/***************************************/
void player::playFile(QString file)
{
//l'api de VLC permet de gerer des playlist
//ici on n'utilise pas ce mecanisme
libvlc_playlist_add (_vlcinstance,file,NULL,&_vlcexcep);
//a ce niveau, le fichier est pret a etre jouer, reste a demarrer la lecture
libvlc_playlist_play(_vlcinstance,-1,0,NULL, &_vlcexcep); //-1 -> choisir le prochain item dans la playlist
}
/***************************************/
int main(int argc,char **argv)
{
QApplication app(argc,argv);
player p;
p.resize(500,400);
p.playFile("http://hamburgcam.axiscam.net:80/mjpg/video/mjpg");
app.setMainWidget(&p);
p.show();
return app.exec();
}
#include "tuto_vlc.moc"
ce code nessecite egalement d'utilisé (je n'ai pas compris à quoi sert se point pro????)
/********* tuto_vlc.pro ********************/
SOURCES += tuto_vlc.cpp
LIBS += -lvlc
jusque la sa marche mais la ou je bloque c'est pour intégrer ceci a mon programme créé avec Kdevelop
/******* player.cpp *********/
#include <iostream>
#include <qapplication.h>
#include <qtextedit.h>
#include <vlc/libvlc.h>
#include "player.h"
player::player(QWidget* parent, const char* name, WFlags fl)
: Form1(parent,name,fl)
{
char *optionDeVlc[] = {(char*)""};
instance = libvlc_new(1,optionDeVlc,&excep);
libvlc_video_set_parent(instance ,Webcam->winId(),&excep);
}
player::~player()
{
}
/*$SPECIALIZATION$*/
void player::playFile(QString file)
{
libvlc_playlist_add (instance,file,NULL,&excep);
libvlc_playlist_play(instance,-1,0,NULL, &excep); //-1 -> choisir le prochain item dans la playlist
}
#include "player.moc"
/************** projet.h******************/
#ifndef PLAYER_H
#define PLAYER_H
#include "Webcam.h"
class player : public Form1
{
Q_OBJECT
libvlc_exception_t excep;
libvlc_instance_t *instance;
public:
player(QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
~player();
/*$PUBLIC_FUNCTIONS$*/
public slots:
/*$PUBLIC_SLOTS$*/
void playFile(QString file);
};
#endif
Mais la j'ai les 3 erreurs suivante :
/home/rom/player/src/player.h:10: error: 'libvlc_exception_t' does not name a type
/home/rom/player/src/player.h:11: error: ISO C++ forbids declaration of 'libvlc_instance_t' with no type
/home/rom/player/src/player.h:11: error: expected ';' before '*' token
Quelqu'un a une idée pour corriger les erreurs ?