1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU Lesser General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 3 requirements |
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
24 | ** |
25 | ** GNU General Public License Usage |
26 | ** Alternatively, this file may be used under the terms of the GNU |
27 | ** General Public License version 2.0 or (at your option) the GNU General |
28 | ** Public license version 3 or any later version approved by the KDE Free |
29 | ** Qt Foundation. The licenses are as published by the Free Software |
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
31 | ** included in the packaging of this file. Please review the following |
32 | ** information to ensure the GNU General Public License requirements will |
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
35 | ** |
36 | ** $QT_END_LICENSE$ |
37 | ** |
38 | ****************************************************************************/ |
39 | |
40 | #include "qgstreameraudiodecodercontrol.h" |
41 | #include "qgstreameraudiodecodersession.h" |
42 | |
43 | #include <QtCore/qdir.h> |
44 | #include <QtCore/qsocketnotifier.h> |
45 | #include <QtCore/qurl.h> |
46 | #include <QtCore/qdebug.h> |
47 | |
48 | #include <sys/types.h> |
49 | #include <sys/stat.h> |
50 | #include <fcntl.h> |
51 | |
52 | QT_BEGIN_NAMESPACE |
53 | |
54 | QGstreamerAudioDecoderControl::QGstreamerAudioDecoderControl(QGstreamerAudioDecoderSession *session, QObject *parent) |
55 | : QAudioDecoderControl(parent) |
56 | , m_session(session) |
57 | { |
58 | connect(sender: m_session, SIGNAL(bufferAvailableChanged(bool)), receiver: this, SIGNAL(bufferAvailableChanged(bool))); |
59 | connect(sender: m_session, SIGNAL(bufferReady()), receiver: this, SIGNAL(bufferReady())); |
60 | connect(sender: m_session, SIGNAL(error(int,QString)), receiver: this, SIGNAL(error(int,QString))); |
61 | connect(sender: m_session, SIGNAL(formatChanged(QAudioFormat)), receiver: this, SIGNAL(formatChanged(QAudioFormat))); |
62 | connect(sender: m_session, SIGNAL(sourceChanged()), receiver: this, SIGNAL(sourceChanged())); |
63 | connect(sender: m_session, SIGNAL(stateChanged(QAudioDecoder::State)), receiver: this, SIGNAL(stateChanged(QAudioDecoder::State))); |
64 | connect(sender: m_session, SIGNAL(finished()), receiver: this, SIGNAL(finished())); |
65 | connect(sender: m_session, SIGNAL(positionChanged(qint64)), receiver: this, SIGNAL(positionChanged(qint64))); |
66 | connect(sender: m_session, SIGNAL(durationChanged(qint64)), receiver: this, SIGNAL(durationChanged(qint64))); |
67 | } |
68 | |
69 | QGstreamerAudioDecoderControl::~QGstreamerAudioDecoderControl() |
70 | { |
71 | |
72 | } |
73 | |
74 | QAudioDecoder::State QGstreamerAudioDecoderControl::state() const |
75 | { |
76 | return m_session->pendingState(); |
77 | } |
78 | |
79 | QString QGstreamerAudioDecoderControl::sourceFilename() const |
80 | { |
81 | return m_session->sourceFilename(); |
82 | } |
83 | |
84 | void QGstreamerAudioDecoderControl::setSourceFilename(const QString &fileName) |
85 | { |
86 | m_session->setSourceFilename(fileName); |
87 | } |
88 | |
89 | QIODevice* QGstreamerAudioDecoderControl::sourceDevice() const |
90 | { |
91 | return m_session->sourceDevice(); |
92 | } |
93 | |
94 | void QGstreamerAudioDecoderControl::setSourceDevice(QIODevice *device) |
95 | { |
96 | m_session->setSourceDevice(device); |
97 | } |
98 | |
99 | void QGstreamerAudioDecoderControl::start() |
100 | { |
101 | m_session->start(); |
102 | } |
103 | |
104 | void QGstreamerAudioDecoderControl::stop() |
105 | { |
106 | m_session->stop(); |
107 | } |
108 | |
109 | QAudioFormat QGstreamerAudioDecoderControl::audioFormat() const |
110 | { |
111 | return m_session->audioFormat(); |
112 | } |
113 | |
114 | void QGstreamerAudioDecoderControl::setAudioFormat(const QAudioFormat &format) |
115 | { |
116 | m_session->setAudioFormat(format); |
117 | } |
118 | |
119 | QAudioBuffer QGstreamerAudioDecoderControl::read() |
120 | { |
121 | return m_session->read(); |
122 | } |
123 | |
124 | bool QGstreamerAudioDecoderControl::bufferAvailable() const |
125 | { |
126 | return m_session->bufferAvailable(); |
127 | } |
128 | |
129 | qint64 QGstreamerAudioDecoderControl::position() const |
130 | { |
131 | return m_session->position(); |
132 | } |
133 | |
134 | qint64 QGstreamerAudioDecoderControl::duration() const |
135 | { |
136 | return m_session->duration(); |
137 | } |
138 | |
139 | QT_END_NAMESPACE |
140 | |