Miam-Player  0.8.0
A nice music player
VideoCapture.h
Go to the documentation of this file.
1 /******************************************************************************
2  VideoCapture.h: description
3  Copyright (C) 2012-2016 Wang Bin <wbsecg1@gmail.com>
4 
5 * This file is part of QtAV
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Lesser General Public
9  License as published by the Free Software Foundation; either
10  version 2.1 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public
18  License along with this library; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 ******************************************************************************/
21 
22 
23 #ifndef QTAV_VIDEOCAPTURE_H
24 #define QTAV_VIDEOCAPTURE_H
25 
26 #include <QtCore/QObject>
27 #include <QtGui/QImage>
28 #include <QtAV/QtAV_Global.h>
29 #include <QtAV/VideoFrame.h>
30 
31 namespace QtAV {
32 
33 //on capture per thread or all in one thread?
34 class Q_AV_EXPORT VideoCapture : public QObject
35 {
36  Q_OBJECT
37  Q_PROPERTY(bool async READ isAsync WRITE setAsync NOTIFY asyncChanged)
38  Q_PROPERTY(bool autoSave READ autoSave WRITE setAutoSave NOTIFY autoSaveChanged)
39  Q_PROPERTY(bool originalFormat READ isOriginalFormat WRITE setOriginalFormat NOTIFY originalFormatChanged)
40  Q_PROPERTY(QString saveFormat READ saveFormat WRITE setSaveFormat NOTIFY saveFormatChanged)
41  Q_PROPERTY(int quality READ quality WRITE setQuality NOTIFY qualityChanged)
42  Q_PROPERTY(QString captureName READ captureName WRITE setCaptureName NOTIFY captureNameChanged)
43  Q_PROPERTY(QString captureDir READ captureDir WRITE setCaptureDir NOTIFY captureDirChanged)
44 public:
45  explicit VideoCapture(QObject *parent = 0);
46  // TODO: if async is true, the cloned hw frame shares the same interop object with original frame, so interop obj may do 2 map() at the same time. It's not safe
47  void setAsync(bool value = true);
48  bool isAsync() const;
54  void setAutoSave(bool value = true);
55  bool autoSave() const;
62  void setOriginalFormat(bool value = true);
63  bool isOriginalFormat() const;
69  void setSaveFormat(const QString& format);
70  QString saveFormat() const;
76  void setQuality(int value);
77  int quality() const;
84  void setCaptureName(const QString& value);
85  QString captureName() const;
86  void setCaptureDir(const QString& value);
87  QString captureDir() const;
88 public Q_SLOTS:
89  void capture();
90 Q_SIGNALS:
91  void requested();
92  /*use it to popup a dialog for selecting dir, name etc. TODO: block avthread if not async*/
97  void frameAvailable(const QtAV::VideoFrame& frame);
103  void imageCaptured(const QImage& image); //TODO: emit only if not original format is set?
104  void failed();
110  void saved(const QString& path);
111 
112  void asyncChanged();
113  void autoSaveChanged();
114  void originalFormatChanged();
115  void saveFormatChanged();
116  void qualityChanged();
117  void captureNameChanged();
118  void captureDirChanged();
119 private slots:
120  void handleAppQuit();
121 private:
122  void setVideoFrame(const VideoFrame& frame);
123  // It's called by VideoThread after immediatly setVideoFrame(). Will emit ready()
124  void start();
125 
126  friend class CaptureTask;
127  friend class VideoThread;
128  bool async;
129  bool auto_save;
130  bool original_fmt;
131  //TODO: use blocking queue? If not, the parameters will change when thre previous is not finished
132  //or use a capture event that wrapper all these parameters
133  int qual;
134  QImage::Format qfmt;
135  QString fmt;
136  QString name, dir;
137  VideoFrame frame;
138 };
139 
140 } //namespace QtAV
141 #endif // QTAV_VIDEOCAPTURE_H
#define Q_AV_EXPORT
Definition: QtAV_Global.h:40
Definition: VideoCapture.h:34
Definition: VideoFrame.h:32
AudioOutput ao; ao.setAudioFormat(fmt); ao.open(); while (has_data) { data = read_data(ao->bufferSize...
Definition: AudioDecoder.h:31