51 lines
1.1 KiB
C++
51 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#if USE_VLC
|
|
#include <mutex>
|
|
#include <QObject>
|
|
#include <QImage>
|
|
|
|
|
|
class VlcMediaPlayer : public QObject {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
VlcMediaPlayer();
|
|
~VlcMediaPlayer();
|
|
|
|
static bool Init();
|
|
static void Uninit();
|
|
|
|
static struct libvlc_instance_t* GetVLCInstance();
|
|
|
|
bool Play(const QString& path);
|
|
void Stop();
|
|
bool IsPlaying() const;
|
|
|
|
signals:
|
|
void VideoDataOutput(QImage);
|
|
void Stopped();
|
|
void TimeChanged(qint64);
|
|
|
|
protected:
|
|
void OnPostionChangedCallback(float pos);
|
|
void OnTimeChangedCallback(qint64 pos);
|
|
|
|
private:
|
|
struct libvlc_media_player_t* vlcPlayer_{ nullptr };
|
|
|
|
QString moviePath_;
|
|
|
|
friend void* MediaCallbakLocak(void* opaque, void** planes);
|
|
friend void MediaCallbakUnLocak(void* opaque, void* picture, void* const* planes);
|
|
friend void OnVLCEvent(const struct libvlc_event_t* event, void* data);
|
|
//friend unsigned MediaSetup(void** opaque, char* chroma, unsigned* width, unsigned* height, unsigned* pitches, unsigned* lines);
|
|
|
|
std::mutex mutx_;
|
|
std::vector<uchar> pixels_;
|
|
|
|
int videoWidth_{ 0 };
|
|
int videoHeight_{ 0 };
|
|
};
|
|
#endif
|