1 /* Webcamoid, webcam capture application.
2  * Copyright (C) 2017  Gonzalo Exequiel Pedone
3  *
4  * Webcamoid 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 3 of the License, or
7  * (at your option) any later version.
8  *
9  * Webcamoid 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 Webcamoid. If not, see <http://www.gnu.org/licenses/>.
16  *
17  * Web-Site: http://webcamoid.github.io/
18  */
19 
20 #ifndef AVFOUNDATIONSCREENDEV_H
21 #define AVFOUNDATIONSCREENDEV_H
22 
23 #include <CoreGraphics/CGDirectDisplay.h>
24 
25 #include "screendev.h"
26 
27 class AVFoundationScreenDevPrivate;
28 class QScreen;
29 
30 class AVFoundationScreenDev: public ScreenDev
31 {
32     Q_OBJECT
33     Q_PROPERTY(QStringList medias
34                READ medias
35                NOTIFY mediasChanged)
36     Q_PROPERTY(QString media
37                READ media
38                WRITE setMedia
39                RESET resetMedia
40                NOTIFY mediaChanged)
41     Q_PROPERTY(QList<int> streams
42                READ streams
43                WRITE setStreams
44                RESET resetStreams
45                NOTIFY streamsChanged)
46     Q_PROPERTY(AkFrac fps
47                READ fps
48                WRITE setFps
49                RESET resetFps
50                NOTIFY fpsChanged)
51 
52     public:
53         AVFoundationScreenDev();
54         ~AVFoundationScreenDev();
55 
56         Q_INVOKABLE AkFrac fps() const;
57         Q_INVOKABLE QStringList medias();
58         Q_INVOKABLE QString media() const;
59         Q_INVOKABLE QList<int> streams() const;
60         Q_INVOKABLE int defaultStream(const QString &mimeType);
61         Q_INVOKABLE QString description(const QString &media);
62         Q_INVOKABLE AkCaps caps(int stream);
63 
64         void frameReceived(CGDirectDisplayID screen,
65                            const QByteArray &buffer,
66                            qint64 pts,
67                            const AkFrac &fps,
68                            qint64 id);
69 
70     private:
71         AVFoundationScreenDevPrivate *d;
72 
73         void sendPacket(const AkPacket &packet);
74 
75     signals:
76         void mediasChanged(const QStringList &medias);
77         void mediaChanged(const QString &media);
78         void streamsChanged(const QList<int> &streams);
79         void loopChanged(bool loop);
80         void fpsChanged(const AkFrac &fps);
81         void sizeChanged(const QString &media, const QSize &size);
82         void error(const QString &message);
83 
84     public slots:
85         void setFps(const AkFrac &fps);
86         void resetFps();
87         void setMedia(const QString &media);
88         void resetMedia();
89         void setStreams(const QList<int> &streams);
90         void resetStreams();
91         bool init();
92         bool uninit();
93 
94     private slots:
95         void screenAdded(QScreen *screen);
96         void screenRemoved(QScreen *screen);
97         void srceenResized(int screen);
98 };
99 
100 #endif // AVFOUNDATIONSCREENDEV_H
101