~ubuntu-branches/ubuntu/trusty/phonon/trusty-updates

« back to all changes in this revision

Viewing changes to phonon/experimental/tests/avcaptureapptest/capture_test.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Modestas Vainius
  • Date: 2011-03-11 21:39:20 UTC
  • mfrom: (6.1.4 experimental)
  • Revision ID: james.westby@ubuntu.com-20110311213920-pvkmqc1gdpy88uzx
Tags: 4:4.6.0really4.4.4-2
* Drop phonon-backends-dbg from phonon-dbg Recommends/Breaks. No longer
  needed.
* Readd packaging copyright/licensing to debian/copyright.
* Bump libphonon-dev Breaks/Replaces to << 4:4.6.0really4.4.4 for
  libphononexperimental-dev. experimental/avcaptureinterface.h header which
  used to be there up to 4.4.4 (see changelog below).
* Switch debian/rules build engine to dhmk (qt-kde-team/2/*):
  - build-depend on pkg-kde-tools >= 0.11;
  - port debian/rules to dhmk keeping it dh compatible as much as possible.
* Drop unused ${shlibs:Depends} from libphonon-dev and
  libphononexperimental-dev packages.
* Add README.Debian to phonon-backend-null package.
* Remove phonon-backend-null.lintian-overrides: phonon-backend-null is no
  longer and empty package due to README.Debian (see above).
* Release to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*  This file is part of the KDE project
 
2
 *  Copyright (C) 2010 Casian Andrei <skeletk13@gmail.com>
 
3
 *
 
4
 *  This library is free software; you can redistribute it and/or
 
5
 *  modify it under the terms of the GNU Lesser General Public
 
6
 *  License as published by the Free Software Foundation; either
 
7
 *  version 2.1 of the License, or (at your option) version 3, or any
 
8
 *  later version accepted by the membership of KDE e.V. (or its
 
9
 *  successor approved by the membership of KDE e.V.), Nokia Corporation
 
10
 *  (or its successors, if any) and the KDE Free Qt Foundation, which shall
 
11
 *  act as a proxy defined in Section 6 of version 3 of the license.
 
12
 *
 
13
 *  This library is distributed in the hope that it will be useful,
 
14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
16
 *  Lesser General Public License for more details.
 
17
 *
 
18
 *  You should have received a copy of the GNU Lesser General Public
 
19
 *  License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 
20
 *
 
21
 */
 
22
 
 
23
#include "capture_test.h"
 
24
 
 
25
MediaPlayer::MediaPlayer(QWidget *parent)
 
26
: QWidget(parent)
 
27
{
 
28
    m_videoDeviceModel = NULL;
 
29
    m_audioDeviceModel = NULL;
 
30
 
 
31
    QVBoxLayout *layout = new QVBoxLayout(this);
 
32
 
 
33
    m_vwidget = new Phonon::VideoWidget(this);
 
34
    m_vwidget->setMinimumSize(QSize(400, 300));
 
35
    m_vwidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
 
36
    layout->addWidget(m_vwidget);
 
37
 
 
38
    m_aoutput = new Phonon::AudioOutput();
 
39
 
 
40
    m_avcapture = new Phonon::Experimental::AvCapture();
 
41
 
 
42
    Phonon::createPath(m_avcapture, m_aoutput);
 
43
    Phonon::createPath(m_avcapture, m_vwidget);
 
44
 
 
45
    QHBoxLayout *deviceNameLayout = new QHBoxLayout(this);
 
46
 
 
47
    m_videoDeviceCombo = new QComboBox(this);
 
48
    m_videoDeviceCombo->setEditable(false);
 
49
    m_audioDeviceCombo = new QComboBox(this);
 
50
    m_audioDeviceCombo->setEditable(false);
 
51
    deviceNameLayout->addWidget(m_videoDeviceCombo);
 
52
    deviceNameLayout->addWidget(m_audioDeviceCombo);
 
53
    connect(m_videoDeviceCombo, SIGNAL(activated(int)), this, SLOT(setVideoDeviceIndex(int)));
 
54
    connect(m_audioDeviceCombo, SIGNAL(activated(int)), this, SLOT(setAudioDeviceIndex(int)));
 
55
    updateDeviceList();
 
56
 
 
57
    layout->addItem(deviceNameLayout);
 
58
 
 
59
    m_playButton = new QPushButton(this);
 
60
    m_playButton->setText("Start");
 
61
    connect(m_playButton, SIGNAL(clicked()), m_avcapture, SLOT(start()));
 
62
 
 
63
    m_stopButton = new QPushButton(this);
 
64
    m_stopButton->setText("Stop");
 
65
    connect(m_stopButton, SIGNAL(clicked()), m_avcapture, SLOT(stop()));
 
66
 
 
67
    QHBoxLayout *buttonsLayout = new QHBoxLayout(this);
 
68
    buttonsLayout->addWidget(m_playButton);
 
69
    buttonsLayout->addWidget(m_stopButton);
 
70
    layout->addItem(buttonsLayout);
 
71
 
 
72
    m_volumeSlider = new Phonon::VolumeSlider(this);
 
73
    layout->addWidget(m_volumeSlider);
 
74
    m_volumeSlider->setAudioOutput(m_aoutput);
 
75
 
 
76
    setLayout(layout);
 
77
}
 
78
 
 
79
MediaPlayer::~MediaPlayer()
 
80
{
 
81
    delete m_aoutput;
 
82
    delete m_avcapture;
 
83
}
 
84
 
 
85
void MediaPlayer::setVideoDeviceIndex(int index)
 
86
{
 
87
#ifndef QT_NO_PHONON_VIDEOCAPTURE
 
88
    QModelIndex mi = m_videoDeviceModel->index(index, 0, QModelIndex());
 
89
    Q_ASSERT(mi.isValid());
 
90
 
 
91
    Phonon::VideoCaptureDevice vc = m_videoDeviceModel->modelData(mi);
 
92
    Q_ASSERT(vc.isValid());
 
93
 
 
94
    m_avcapture->setVideoCaptureDevice(vc);
 
95
#endif
 
96
}
 
97
 
 
98
void MediaPlayer::setAudioDeviceIndex(int index)
 
99
{
 
100
#ifndef QT_NO_PHONON_AUDIOCAPTURE
 
101
    QModelIndex mi = m_audioDeviceModel->index(index, 0, QModelIndex());
 
102
    Q_ASSERT(mi.isValid());
 
103
 
 
104
    Phonon::AudioCaptureDevice ac = m_audioDeviceModel->modelData(mi);
 
105
    Q_ASSERT(ac.isValid());
 
106
 
 
107
    m_avcapture->setAudioCaptureDevice(ac);
 
108
#endif // QT_NO_PHONON_AUDIOCAPTURE
 
109
}
 
110
 
 
111
void MediaPlayer::updateDeviceList()
 
112
{
 
113
#ifndef QT_NO_PHONON_VIDEOCAPTURE
 
114
    QList<Phonon::VideoCaptureDevice> vl = Phonon::BackendCapabilities::availableVideoCaptureDevices();
 
115
 
 
116
    if (!m_videoDeviceModel)
 
117
        m_videoDeviceModel = new Phonon::VideoCaptureDeviceModel(vl, 0);
 
118
    m_videoDeviceCombo->setModel(m_videoDeviceModel);
 
119
 
 
120
    Q_ASSERT(m_videoDeviceModel->rowCount() >= 0);
 
121
 
 
122
    if (m_videoDeviceModel->rowCount() == 0)
 
123
        QMessageBox::critical(this, "Error", "No video capture devices found.");
 
124
#else
 
125
    QMessageBox::critical(this, "Error", "Video capture is disabled.");
 
126
#endif
 
127
 
 
128
#ifndef QT_NO_PHONON_AUDIOCAPTURE
 
129
    QList<Phonon::AudioCaptureDevice> al = Phonon::BackendCapabilities::availableAudioCaptureDevices();
 
130
 
 
131
    if (!m_audioDeviceModel)
 
132
        m_audioDeviceModel = new Phonon::AudioCaptureDeviceModel(al, 0);
 
133
    m_audioDeviceCombo->setModel(m_audioDeviceModel);
 
134
 
 
135
    Q_ASSERT(m_audioDeviceModel->rowCount() >= 0);
 
136
 
 
137
    if (m_audioDeviceModel->rowCount() == 0)
 
138
        QMessageBox::critical(this, "Error", "No audio capture devices found.");
 
139
#else
 
140
    QMessageBox::critical(this, "Error", "Audio capture is disabled.");
 
141
#endif
 
142
}
 
143