0.1
This commit is contained in:
parent
875bdfd460
commit
bf9e74a147
2 changed files with 128 additions and 0 deletions
117
main.cpp
Normal file
117
main.cpp
Normal file
|
@ -0,0 +1,117 @@
|
|||
#include <iostream>
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include <vlc/vlc.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QMainWindow>
|
||||
#include <QFrame>
|
||||
#include <QLabel>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class Player{
|
||||
public:
|
||||
Player();
|
||||
~Player();
|
||||
|
||||
CURL *curl;
|
||||
CURLcode res;
|
||||
|
||||
QMainWindow *window;
|
||||
QFrame *videoWidget;
|
||||
QLabel *label;
|
||||
|
||||
libvlc_instance_t * inst;
|
||||
libvlc_media_player_t *mp;
|
||||
libvlc_media_t *m;
|
||||
private:
|
||||
sender_holen();
|
||||
play(void);
|
||||
};
|
||||
Player::Player(){
|
||||
cout << "starte..." << endl;
|
||||
this->sender_holen();
|
||||
|
||||
window = new QMainWindow;
|
||||
videoWidget = new QFrame;
|
||||
label = new QLabel("Hello World");
|
||||
window->resize(1024,576);
|
||||
window->setWindowTitle("vlc-vdr");
|
||||
window->setCentralWidget(videoWidget);
|
||||
window->setCentralWidget(label);
|
||||
window->show();
|
||||
|
||||
this->play();
|
||||
}
|
||||
Player::~Player(){
|
||||
cout << "beende..." << endl;
|
||||
}
|
||||
Player::sender_holen(){
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "http://192.168.101.9:3000/channels.m3u");
|
||||
/* example.com is redirected, so we tell libcurl to follow redirection */
|
||||
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
|
||||
|
||||
/* Perform the request, res will get the return code */
|
||||
res = curl_easy_perform(curl);
|
||||
/* Check for errors */
|
||||
if(res != CURLE_OK)
|
||||
fprintf(stderr, "curl_easy_perform() failed: %s\n",
|
||||
curl_easy_strerror(res));
|
||||
|
||||
/* always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Player::play(void){
|
||||
cout << "play..." << endl;
|
||||
/* Load the VLC engine */
|
||||
inst = libvlc_new (0, NULL);
|
||||
|
||||
/* Create a new item */
|
||||
m = libvlc_media_new_location (inst, "http://192.168.101.9:3000/S19.2E-133-33-51");
|
||||
//m = libvlc_media_new_path (inst, "/path/to/test.mov");
|
||||
|
||||
/* Create a media player playing environement */
|
||||
mp = libvlc_media_player_new_from_media (m);
|
||||
|
||||
/* No need to keep the media now */
|
||||
libvlc_media_release (m);
|
||||
|
||||
#if defined(Q_OS_WIN) // Windows
|
||||
// libvlc_media_player_set_hwnd(mp, (void *)videoWidget->winId());
|
||||
#elif defined(Q_OS_MAC) // Mac
|
||||
libvlc_media_player_set_nsobject(mp, (void *)videoWidget->winId());
|
||||
#else //Linux
|
||||
int windid = _videoWidget->winId();
|
||||
libvlc_media_player_set_xwindow (mp, windid );
|
||||
#endif
|
||||
|
||||
/* play the media_player */
|
||||
libvlc_media_player_play (mp);
|
||||
|
||||
Sleep(10000); /* Let it play a bit */
|
||||
|
||||
/* Stop playing */
|
||||
libvlc_media_player_stop (mp);
|
||||
|
||||
/* Free the media_player */
|
||||
libvlc_media_player_release (mp);
|
||||
|
||||
libvlc_release (inst);
|
||||
cout << "play...stop" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
QApplication app(argc, argv);
|
||||
Player a;
|
||||
return app.exec();
|
||||
}
|
11
vlc-vdr.pro
Normal file
11
vlc-vdr.pro
Normal file
|
@ -0,0 +1,11 @@
|
|||
|
||||
QT += core gui
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4) : QT += widgets
|
||||
|
||||
SOURCES += \
|
||||
main.cpp
|
||||
|
||||
INCLUDEPATH += "."
|
||||
win32:LIBS += -L"." -lcurl -llibvlc
|
||||
DEFINES += CURL_STATICLIB VLC_STATICLIB
|
Loading…
Add table
Reference in a new issue