summaryrefslogtreecommitdiffstats
path: root/vrplayer/demuxmedia.h
blob: ecb2546227f9f4d4afea1e80ef17c4cf43fe6a50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef DEMUXMEDIA_H
#define DEMUXMEDIA_H

#ifdef __cplusplus
#define __STDC_CONSTANT_MACROS
#ifdef _STDINT_H
#undef _STDINT_H
#endif
#include <stdint.h>
#endif

#include <QObject>
#include <QQueue>
#include <QThread>
#include <QMutex>
#include <QDebug>

#include "mediapacket.h"
#include "playaudio.h"
#include "playvideo.h"

/* ffmpeg related stuff */
extern "C"
{
    #include <libavformat/avformat.h>
    #include <libavcodec/avcodec.h>
}

#define VCR_PLAY        1
#define VCR_PAUSE       2
#define VCR_STOP        3
#define VCR_REWIND      4
#define VCR_POWER_OFF   5

class DemuxMedia : public QObject
{
    Q_OBJECT
public:
    explicit DemuxMedia(QObject *parent = 0, QQueue<MediaPacket *> *audioQueue = 0,
                        QQueue<MediaPacket *> *videoQueue = 0, void *channel = 0, int stream_id = 101);

    void setVcrOp(int op);

public slots:
    void       startDemuxing();
    PlayVideo *getPlayVideoInstance();

private:
    QQueue<MediaPacket *> *audioQueue;
    QQueue<MediaPacket *> *videoQueue;
    QMutex                 vcrMutex;
    int                    vcrFlag;
    void                  *channel;
    PlayVideo             *playVideo;
    QThread               *playVideoThread;
    PlayAudio             *playAudio;
    QThread               *playAudioThread;
    int                    stream_id;
    bool                   threadsStarted;
    QMutex                 sendMutex;

    void startAudioVideoThreads();
};

#endif // DEMUXMEDIA_H