|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #ifndef QGSTREAMERCAPTURESESSION_MAEMO_H |
|
43 #define QGSTREAMERCAPTURESESSION_MAEMO_H |
|
44 |
|
45 #include <qmediarecordercontrol.h> |
|
46 |
|
47 #include <QtCore/qurl.h> |
|
48 |
|
49 #include <gst/gst.h> |
|
50 |
|
51 #include "qgstreamerbushelper.h" |
|
52 |
|
53 QT_USE_NAMESPACE |
|
54 |
|
55 class QGstreamerMessage; |
|
56 class QGstreamerBusHelper; |
|
57 class QGstreamerAudioEncode; |
|
58 class QGstreamerVideoEncode; |
|
59 class QGstreamerImageEncode; |
|
60 class QGstreamerRecorderControl; |
|
61 class QGstreamerMediaContainerControl; |
|
62 class QGstreamerCameraExposureControl; |
|
63 class QGstreamerCameraFocusControl; |
|
64 class QGstreamerImageProcessingControl; |
|
65 |
|
66 class QGstreamerElementFactory |
|
67 { |
|
68 public: |
|
69 virtual GstElement *buildElement() = 0; |
|
70 virtual void prepareWinId() {} |
|
71 }; |
|
72 |
|
73 class QGstreamerVideoInput : public QGstreamerElementFactory |
|
74 { |
|
75 public: |
|
76 virtual QList<qreal> supportedFrameRates(const QSize &frameSize = QSize()) const = 0; |
|
77 virtual QList<QSize> supportedResolutions(qreal frameRate = -1) const = 0; |
|
78 }; |
|
79 |
|
80 class QGstreamerCaptureSession : public QObject, public QGstreamerSyncEventFilter |
|
81 { |
|
82 Q_OBJECT |
|
83 Q_PROPERTY(qint64 duration READ duration NOTIFY durationChanged) |
|
84 Q_ENUMS(State) |
|
85 Q_ENUMS(CaptureMode) |
|
86 |
|
87 public: |
|
88 enum CaptureMode { Audio = 1, Video = 2, AudioAndVideo = Audio | Video }; |
|
89 enum State { StoppedState, PreviewState, PausedState, RecordingState }; |
|
90 |
|
91 QGstreamerCaptureSession(CaptureMode captureMode, QObject *parent); |
|
92 ~QGstreamerCaptureSession(); |
|
93 |
|
94 CaptureMode captureMode() const { return m_captureMode; } |
|
95 |
|
96 QUrl outputLocation() const; |
|
97 bool setOutputLocation(const QUrl& sink); |
|
98 |
|
99 QGstreamerAudioEncode *audioEncodeControl() const { return m_audioEncodeControl; } |
|
100 QGstreamerVideoEncode *videoEncodeControl() const { return m_videoEncodeControl; } |
|
101 QGstreamerImageEncode *imageEncodeControl() const { return m_imageEncodeControl; } |
|
102 |
|
103 QGstreamerRecorderControl *recorderControl() const { return m_recorderControl; } |
|
104 QGstreamerMediaContainerControl *mediaContainerControl() const { return m_mediaContainerControl; } |
|
105 |
|
106 QGstreamerElementFactory *audioInput() const { return m_audioInputFactory; } |
|
107 void setAudioInput(QGstreamerElementFactory *audioInput); |
|
108 |
|
109 QGstreamerElementFactory *audioPreview() const { return m_audioPreviewFactory; } |
|
110 void setAudioPreview(QGstreamerElementFactory *audioPreview); |
|
111 |
|
112 QGstreamerVideoInput *videoInput() const { return m_videoInputFactory; } |
|
113 void setVideoInput(QGstreamerVideoInput *videoInput); |
|
114 |
|
115 QGstreamerElementFactory *videoPreview() const { return m_videoPreviewFactory; } |
|
116 void setVideoPreview(QGstreamerElementFactory *videoPreview); |
|
117 |
|
118 State state() const; |
|
119 qint64 duration() const; |
|
120 |
|
121 bool processSyncMessage(const QGstreamerMessage &message); |
|
122 |
|
123 signals: |
|
124 void stateChanged(QGstreamerCaptureSession::State state); |
|
125 void durationChanged(qint64 duration); |
|
126 void error(int error, const QString &errorString); |
|
127 |
|
128 public slots: |
|
129 void setState(QGstreamerCaptureSession::State); |
|
130 void setCaptureDevice(const QString &deviceName); |
|
131 void setMetaData(const QMap<QByteArray, QVariant>&); |
|
132 |
|
133 private slots: |
|
134 void busMessage(const QGstreamerMessage &message); |
|
135 |
|
136 private: |
|
137 enum PipelineMode { EmptyPipeline, PreviewPipeline, RecordingPipeline, PreviewAndRecordingPipeline }; |
|
138 |
|
139 void setupCameraBin(); |
|
140 GstElement *buildVideoSrc(); |
|
141 void buildAudioEncodeBin(); |
|
142 |
|
143 QUrl m_sink; |
|
144 QString m_captureDevice; |
|
145 State m_state; |
|
146 State m_pendingState; |
|
147 bool m_waitingForEos; |
|
148 PipelineMode m_pipelineMode; |
|
149 QGstreamerCaptureSession::CaptureMode m_captureMode; |
|
150 QMap<QByteArray, QVariant> m_metaData; |
|
151 |
|
152 QGstreamerElementFactory *m_audioInputFactory; |
|
153 QGstreamerElementFactory *m_audioPreviewFactory; |
|
154 QGstreamerVideoInput *m_videoInputFactory; |
|
155 QGstreamerElementFactory *m_videoPreviewFactory; |
|
156 |
|
157 QGstreamerAudioEncode *m_audioEncodeControl; |
|
158 QGstreamerVideoEncode *m_videoEncodeControl; |
|
159 QGstreamerImageEncode *m_imageEncodeControl; |
|
160 QGstreamerRecorderControl *m_recorderControl; |
|
161 QGstreamerMediaContainerControl *m_mediaContainerControl; |
|
162 QGstreamerCameraExposureControl *m_cameraExposureControl; |
|
163 QGstreamerCameraFocusControl *m_cameraFocusControl; |
|
164 QGstreamerImageProcessingControl *m_imageProcessingControl; |
|
165 |
|
166 QGstreamerBusHelper *m_busHelper; |
|
167 GstBus* m_bus; |
|
168 GstElement *m_pipeline; |
|
169 GstElement *m_videoSrc; |
|
170 bool m_videoPreviewFactoryHasChanged; |
|
171 |
|
172 GstElement *m_audioSrc; |
|
173 GstElement *m_audioConvert; |
|
174 GstElement *m_capsFilter; |
|
175 GstElement *m_fileSink; |
|
176 GstElement *m_audioEncoder; |
|
177 GstElement *m_muxer; |
|
178 public: |
|
179 QString m_imageFileName; |
|
180 }; |
|
181 |
|
182 #endif // QGSTREAMERCAPTURESESSION_MAEMO_H |