[113] | 1 | /* smplayer, GUI front-end for mplayer.
|
---|
[188] | 2 | Copyright (C) 2006-2017 Ricardo Villalba <rvm@users.sourceforge.net>
|
---|
[113] | 3 |
|
---|
| 4 | This program is free software; you can redistribute it and/or modify
|
---|
| 5 | it under the terms of the GNU General Public License as published by
|
---|
| 6 | the Free Software Foundation; either version 2 of the License, or
|
---|
| 7 | (at your option) any later version.
|
---|
| 8 |
|
---|
| 9 | This program is distributed in the hope that it will be useful,
|
---|
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 12 | GNU General Public License for more details.
|
---|
| 13 |
|
---|
| 14 | You should have received a copy of the GNU General Public License
|
---|
| 15 | along with this program; if not, write to the Free Software
|
---|
| 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
| 17 | */
|
---|
| 18 |
|
---|
[176] | 19 | #ifndef VIDEOPREVIEW_H
|
---|
| 20 | #define VIDEOPREVIEW_H
|
---|
[113] | 21 |
|
---|
| 22 | #include <QWidget>
|
---|
| 23 | #include <QString>
|
---|
| 24 | #include <QList>
|
---|
| 25 |
|
---|
| 26 | class QProgressDialog;
|
---|
| 27 | class QGridLayout;
|
---|
| 28 | class QLabel;
|
---|
| 29 | class QScrollArea;
|
---|
| 30 | class QDialogButtonBox;
|
---|
| 31 | class QSettings;
|
---|
| 32 | class QAction;
|
---|
| 33 |
|
---|
| 34 | class VideoInfo
|
---|
| 35 | {
|
---|
| 36 | public:
|
---|
| 37 | VideoInfo() { filename.clear(); width = 0; height = 0; length = 0;
|
---|
| 38 | size = 0; fps = 0; aspect = 0; video_bitrate = 0;
|
---|
| 39 | audio_bitrate = 0; audio_rate = 0; video_format.clear(); };
|
---|
| 40 | ~VideoInfo() {};
|
---|
| 41 |
|
---|
| 42 | QString filename;
|
---|
| 43 | int width;
|
---|
| 44 | int height;
|
---|
| 45 | int length;
|
---|
| 46 | qint64 size;
|
---|
| 47 | double fps;
|
---|
| 48 | double aspect;
|
---|
| 49 | int video_bitrate;
|
---|
| 50 | int audio_bitrate;
|
---|
| 51 | int audio_rate;
|
---|
| 52 | QString video_format;
|
---|
| 53 | };
|
---|
| 54 |
|
---|
| 55 | class VideoPreview : public QWidget
|
---|
| 56 | {
|
---|
| 57 | Q_OBJECT
|
---|
| 58 |
|
---|
| 59 | public:
|
---|
| 60 | enum ExtractFormat { JPEG = 1, PNG = 2 };
|
---|
| 61 |
|
---|
| 62 | VideoPreview(QString mplayer_path, QWidget * parent = 0);
|
---|
| 63 | ~VideoPreview();
|
---|
| 64 |
|
---|
| 65 | void setMplayerPath(QString mplayer_path);
|
---|
| 66 | QString mplayerPath() { return mplayer_bin; };
|
---|
| 67 |
|
---|
| 68 | void setVideoFile(QString file) { prop.input_video = file; };
|
---|
| 69 | QString videoFile() { return prop.input_video; };
|
---|
| 70 |
|
---|
| 71 | void setDVDDevice(const QString & dvd_device) { prop.dvd_device = dvd_device; };
|
---|
| 72 | QString DVDDevice() { return prop.dvd_device; };
|
---|
| 73 |
|
---|
| 74 | void setCols(int cols) { prop.n_cols = cols; };
|
---|
| 75 | int cols() { return prop.n_cols; };
|
---|
| 76 |
|
---|
| 77 | void setRows(int rows) { prop.n_rows = rows; };
|
---|
| 78 | int rows() { return prop.n_rows; };
|
---|
| 79 |
|
---|
| 80 | void setGrid(int cols, int rows) { prop.n_cols = cols; prop.n_rows = rows; };
|
---|
| 81 |
|
---|
| 82 | void setInitialStep(int step) { prop.initial_step = step; };
|
---|
| 83 | int initialStep() { return prop.initial_step; };
|
---|
| 84 |
|
---|
| 85 | void setMaxWidth(int w) { prop.max_width = w; };
|
---|
| 86 | int maxWidth() { return prop.max_width; };
|
---|
| 87 |
|
---|
| 88 | void setDisplayOSD(bool b) { prop.display_osd = b; };
|
---|
| 89 | bool displayOSD() { return prop.display_osd; };
|
---|
| 90 |
|
---|
| 91 | void setAspectRatio(double asp) { prop.aspect_ratio = asp; };
|
---|
| 92 | double aspectRatio() { return prop.aspect_ratio; };
|
---|
| 93 |
|
---|
| 94 | void setExtractFormat( ExtractFormat format ) { prop.extract_format = format; };
|
---|
| 95 | ExtractFormat extractFormat() { return prop.extract_format; };
|
---|
| 96 |
|
---|
| 97 | bool createThumbnails();
|
---|
| 98 |
|
---|
| 99 | bool showConfigDialog(QWidget * parent);
|
---|
| 100 |
|
---|
| 101 | void setSettings(QSettings * settings);
|
---|
| 102 | QSettings * settings() { return set; };
|
---|
| 103 |
|
---|
| 104 | VideoInfo getInfo(const QString & mplayer_path, const QString & filename);
|
---|
| 105 | QString errorMessage() { return error_message; };
|
---|
| 106 |
|
---|
| 107 | void adjustWindowSize();
|
---|
| 108 |
|
---|
| 109 | protected slots:
|
---|
| 110 | void cancelPressed();
|
---|
| 111 | void saveImage();
|
---|
| 112 | void showInfo(bool visible);
|
---|
| 113 |
|
---|
| 114 | protected:
|
---|
| 115 | virtual void retranslateStrings();
|
---|
| 116 | virtual void changeEvent( QEvent * event );
|
---|
| 117 |
|
---|
| 118 | protected:
|
---|
| 119 | bool extractImages();
|
---|
[176] | 120 | bool runPlayer(int seek, double aspect_ratio);
|
---|
[113] | 121 | bool addPicture(const QString & filename, int num, int time);
|
---|
| 122 | void displayVideoInfo(const VideoInfo & i);
|
---|
| 123 | void cleanDir(QString directory);
|
---|
| 124 | void clearThumbnails();
|
---|
| 125 | QString framePicture();
|
---|
| 126 | void saveSettings();
|
---|
| 127 | void loadSettings();
|
---|
| 128 |
|
---|
| 129 | QList <QLabel *> label_list;
|
---|
| 130 |
|
---|
| 131 | QGridLayout * grid_layout;
|
---|
| 132 | QLabel * info;
|
---|
| 133 | QLabel * foot;
|
---|
| 134 | QWidget * w_contents;
|
---|
| 135 | QScrollArea * scroll_area;
|
---|
| 136 | QDialogButtonBox * button_box;
|
---|
| 137 |
|
---|
| 138 | QString mplayer_bin;
|
---|
| 139 |
|
---|
| 140 | QString output_dir;
|
---|
| 141 | QString full_output_dir;
|
---|
| 142 |
|
---|
| 143 | QProgressDialog * progress;
|
---|
| 144 | bool canceled;
|
---|
| 145 |
|
---|
| 146 | QSettings * set;
|
---|
| 147 |
|
---|
| 148 | QAction * toggleInfoAct;
|
---|
| 149 |
|
---|
| 150 | struct Properties {
|
---|
| 151 | QString input_video;
|
---|
| 152 | QString dvd_device;
|
---|
| 153 | int n_cols, n_rows, initial_step, max_width;
|
---|
| 154 | double aspect_ratio;
|
---|
| 155 | bool display_osd;
|
---|
| 156 | ExtractFormat extract_format;
|
---|
| 157 | } prop;
|
---|
| 158 |
|
---|
| 159 | struct {
|
---|
| 160 | int thumbnail_width;
|
---|
| 161 | } run;
|
---|
| 162 |
|
---|
| 163 | QString last_directory;
|
---|
| 164 | bool save_last_directory;
|
---|
| 165 | QString error_message;
|
---|
| 166 | };
|
---|
| 167 |
|
---|
| 168 | #endif
|
---|