summaryrefslogtreecommitdiffstats
path: root/vrplayer/mainwindow.h
blob: ceddb683dab62890337933dc6e303b81416b75f1 (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

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

#include <QMainWindow>
#include <QFileDialog>
#include <QDebug>
#include <QMessageBox>
#include <QCloseEvent>
#include <QMoveEvent>
#include <QPoint>
#include <QRect>
#include <QLabel>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QPushButton>
#include <QSlider>
#include <QTimer>
#include <QPixmap>
#include <QPainter>

#include "xrdpapi.h"
#include "xrdpvr.h"
#include "decoder.h"
#include "ourinterface.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

namespace Ui
{
    class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

signals:
    void onGeometryChanged(int x, int y, int widht, int height);

public slots:
    void onSliderValueChanged(int value);

private slots:
    void on_actionOpen_Media_File_triggered();
    void on_actionExit_triggered();

    void onBtnPlayClicked(bool flag);
    void onBtnRewindClicked(bool flag);
    void onBtnStopClicked(bool flag);

    void onMediaDurationInSeconds(int duration);
    void onElapsedTime(int secs);
    void onSliderActionTriggered(int value);

protected:
    void resizeEvent(QResizeEvent *e);
    void closeEvent(QCloseEvent *e);
    void moveEvent(QMoveEvent *e);
    void mouseMoveEvent(QMouseEvent *e);

private:
    Ui::MainWindow *ui;

    /* for UI */
    QLabel        *lblCurrentPos;
    QLabel        *lblDuration;
    QLabel        *lblVideo;
    QHBoxLayout   *hboxLayoutTop;
    QHBoxLayout   *hboxLayoutMiddle;
    QHBoxLayout   *hboxLayoutBottom;
    QVBoxLayout   *vboxLayout;
    QPushButton   *btnPlay;
    QPushButton   *btnStop;
    QPushButton   *btnRewind;
    QSlider       *slider;
    QWidget       *window;
    bool           acceptSliderMove;

    /* private stuff */
    OurInterface  *interface;
    PlayVideo     *playVideo;
    QString        filename;
    bool           oneTimeInitSuccess;
    bool           remoteClientInited;
    void          *channel;
    int            stream_id;
    int64_t        elapsedTime; /* elapsed time in usecs since play started */
    int            vcrFlag;

    /* private methods */
    void setupUI();
    void openMediaFile();
    void getVdoGeometry(QRect *rect);
    void clearDisplay();
};

#endif // MAINWINDOW_H