2012-12-09 04:36:41 +04:00
|
|
|
#ifndef DECODERTHREAD_H
|
|
|
|
#define DECODERTHREAD_H
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
#define __STDC_CONSTANT_MACROS
|
|
|
|
#ifdef _STDINT_H
|
|
|
|
#undef _STDINT_H
|
|
|
|
#endif
|
|
|
|
#include <stdint.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <QThread>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QString>
|
|
|
|
#include <QRect>
|
|
|
|
#include <QMutex>
|
2012-12-27 06:48:17 +04:00
|
|
|
#include <QTimer>
|
|
|
|
#include <QQueue>
|
2012-12-09 04:36:41 +04:00
|
|
|
|
|
|
|
#include <xrdpapi.h>
|
|
|
|
#include <xrdpvr.h>
|
2012-12-27 06:48:17 +04:00
|
|
|
#include <mediapacket.h>
|
|
|
|
#include <playvideo.h>
|
|
|
|
#include <playaudio.h>
|
2012-12-09 04:36:41 +04:00
|
|
|
|
|
|
|
/* ffmpeg related stuff */
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#include <libavformat/avformat.h>
|
|
|
|
#include <libavcodec/avcodec.h>
|
|
|
|
}
|
|
|
|
|
2012-12-27 06:48:17 +04:00
|
|
|
class DecoderThread : public QObject
|
2012-12-09 04:36:41 +04:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2012-12-27 06:48:17 +04:00
|
|
|
/* public methods */
|
2012-12-09 04:36:41 +04:00
|
|
|
DecoderThread();
|
2012-12-27 06:48:17 +04:00
|
|
|
|
2012-12-09 04:36:41 +04:00
|
|
|
void setFilename(QString filename);
|
2012-12-27 06:48:17 +04:00
|
|
|
void stopPlayer();
|
|
|
|
void pausePlayer();
|
|
|
|
void resumePlayer();
|
|
|
|
void oneTimeDeinit();
|
|
|
|
void close();
|
|
|
|
void run();
|
|
|
|
void startMediaPlay();
|
2012-12-09 04:36:41 +04:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void on_mediaSeek(int value);
|
|
|
|
|
|
|
|
private:
|
2012-12-27 06:48:17 +04:00
|
|
|
/* private variables */
|
|
|
|
QQueue<MediaPacket *> audioQueue;
|
|
|
|
QQueue<MediaPacket *> videoQueue;
|
2012-12-09 04:36:41 +04:00
|
|
|
|
2012-12-27 06:48:17 +04:00
|
|
|
QTimer *videoTimer;
|
|
|
|
QTimer *audioTimer;
|
|
|
|
QTimer *pktTimer;
|
2012-12-09 04:36:41 +04:00
|
|
|
QString filename;
|
|
|
|
void *channel;
|
|
|
|
int stream_id;
|
|
|
|
QRect geometry;
|
|
|
|
int64_t elapsedTime; /* elapsed time in usecs since play started */
|
|
|
|
QMutex mutex;
|
|
|
|
int64_t la_seekPos; /* locked access; must hold mutex */
|
|
|
|
|
2012-12-27 06:48:17 +04:00
|
|
|
PlayVideo *playVideo;
|
|
|
|
QThread *playVideoThread;
|
|
|
|
PlayAudio *playAudio;
|
|
|
|
QThread *playAudioThread;
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
int sendMetadataFile();
|
|
|
|
int sendAudioFormat();
|
|
|
|
int sendVideoFormat();
|
|
|
|
int sendGeometry();
|
|
|
|
void updateSlider();
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
/* private slots */
|
|
|
|
void audioTimerCallback();
|
|
|
|
void videoTimerCallback();
|
|
|
|
void pktTimerCallback();
|
2012-12-09 04:36:41 +04:00
|
|
|
|
|
|
|
signals:
|
2012-12-27 06:48:17 +04:00
|
|
|
/* private signals */
|
2012-12-09 04:36:41 +04:00
|
|
|
void on_progressUpdate(int percent);
|
|
|
|
void on_decoderErrorMsg(QString title, QString msg);
|
|
|
|
void on_mediaDurationInSeconds(int duration);
|
|
|
|
void on_elapsedtime(int val); /* in hundredth of a sec */
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // DECODERTHREAD_H
|