52 AudioRecorder::AudioRecorder() |
52 AudioRecorder::AudioRecorder() |
53 { |
53 { |
54 audiosource = new QAudioCaptureSource; |
54 audiosource = new QAudioCaptureSource; |
55 capture = new QMediaRecorder(audiosource); |
55 capture = new QMediaRecorder(audiosource); |
56 |
56 |
57 QAudioEncoderSettings audioSettings; |
57 if (capture->supportedAudioCodecs().size() > 0) { |
58 audioSettings.setQuality(QtMedia::LowQuality); |
58 QAudioEncoderSettings audioSettings; |
59 audioSettings.setEncodingMode(QtMedia::ConstantQualityEncoding); |
59 audioSettings.setQuality(QtMedia::LowQuality); |
60 audioSettings.setCodec(capture->supportedAudioCodecs().first()); |
60 audioSettings.setEncodingMode(QtMedia::ConstantQualityEncoding); |
61 capture->setEncodingSettings(audioSettings,QVideoEncoderSettings(),capture->supportedContainers().first()); |
61 audioSettings.setCodec(capture->supportedAudioCodecs().first()); |
|
62 capture->setEncodingSettings(audioSettings,QVideoEncoderSettings(), |
|
63 capture->supportedContainers().first()); |
|
64 } |
62 |
65 |
63 // set a default file |
66 // set a default file |
64 #ifdef Q_OS_SYMBIAN |
67 #ifdef Q_OS_SYMBIAN |
65 capture->setOutputLocation(QUrl("c:\\data\\test.wav")); |
68 capture->setOutputLocation(QUrl("c:\\data\\test.wav")); |
66 #else |
69 #else |
67 capture->setOutputLocation(QUrl("test.raw")); |
70 capture->setOutputLocation(QUrl("test.raw")); |
68 #endif |
71 #endif |
69 |
72 |
70 QWidget *window = new QWidget; |
73 QWidget *window = new QWidget; |
|
74 window->setMinimumSize(320,240); |
|
75 window->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum); |
|
76 |
71 QGridLayout* layout = new QGridLayout; |
77 QGridLayout* layout = new QGridLayout; |
72 |
78 |
73 QLabel* deviceLabel = new QLabel; |
79 QLabel* deviceLabel = new QLabel; |
74 deviceLabel->setText("Devices"); |
80 deviceLabel->setText(tr("Audio Device")); |
75 deviceBox = new QComboBox(this); |
81 deviceBox = new QComboBox(this); |
76 deviceBox->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed); |
82 deviceBox->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Fixed); |
|
83 deviceBox->setMinimumSize(200,10); |
77 |
84 |
78 QLabel* containerLabel = new QLabel; |
85 QLabel* containerLabel = new QLabel; |
79 containerLabel->setText("Container"); |
86 containerLabel->setText(tr("File Container")); |
80 containersBox = new QComboBox(this); |
87 containersBox = new QComboBox(this); |
81 containersBox->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed); |
88 containersBox->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Fixed); |
|
89 containersBox->setMinimumSize(200,10); |
82 |
90 |
83 QLabel* codecLabel = new QLabel; |
91 QLabel* codecLabel = new QLabel; |
84 codecLabel->setText("Codec"); |
92 codecLabel->setText(tr("Audio Codec")); |
85 codecsBox = new QComboBox(this); |
93 codecsBox = new QComboBox(this); |
86 codecsBox->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed); |
94 codecsBox->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Fixed); |
|
95 codecsBox->setMinimumSize(200,10); |
87 |
96 |
88 QLabel* qualityLabel = new QLabel; |
97 QLabel* qualityLabel = new QLabel; |
89 qualityLabel->setText("Quality"); |
98 qualityLabel->setText(tr("Audio Quality")); |
90 qualityBox = new QComboBox(this); |
99 qualityBox = new QComboBox(this); |
91 qualityBox->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed); |
100 qualityBox->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Fixed); |
|
101 qualityBox->setMinimumSize(200,10); |
92 |
102 |
93 QList<QString> inputs = audiosource->audioInputs(); |
103 QList<QString> inputs = audiosource->audioInputs(); |
94 for(int i = 0; i < inputs.size(); i++) |
104 for(int i = 0; i < inputs.size(); i++) |
95 deviceBox->addItem(inputs.at(i)); |
105 deviceBox->addItem(inputs.at(i)); |
96 |
106 |
100 |
110 |
101 QStringList containers = capture->supportedContainers(); |
111 QStringList containers = capture->supportedContainers(); |
102 for(int i = 0; i < containers.count(); i++) |
112 for(int i = 0; i < containers.count(); i++) |
103 containersBox->addItem(containers.at(i)); |
113 containersBox->addItem(containers.at(i)); |
104 |
114 |
105 qualityBox->addItem("Low"); |
115 qualityBox->addItem(tr("Low")); |
106 qualityBox->addItem("Medium"); |
116 qualityBox->addItem(tr("Medium")); |
107 qualityBox->addItem("High"); |
117 qualityBox->addItem(tr("High")); |
108 |
118 |
109 connect(capture, SIGNAL(durationChanged(qint64)), this, SLOT(updateProgress(qint64))); |
119 connect(capture, SIGNAL(durationChanged(qint64)), this, SLOT(updateProgress(qint64))); |
110 connect(capture, SIGNAL(stateChanged(QMediaRecorder::State)), this, SLOT(stateChanged(QMediaRecorder::State))); |
120 connect(capture, SIGNAL(stateChanged(QMediaRecorder::State)), this, SLOT(stateChanged(QMediaRecorder::State))); |
|
121 connect(capture, SIGNAL(error(QMediaRecorder::Error)), this, SLOT(errorChanged(QMediaRecorder::Error))); |
111 |
122 |
112 layout->addWidget(deviceLabel,0,0,Qt::AlignHCenter); |
123 layout->addWidget(deviceLabel,0,0,Qt::AlignHCenter); |
113 connect(deviceBox,SIGNAL(activated(int)),SLOT(deviceChanged(int))); |
124 connect(deviceBox,SIGNAL(activated(int)),SLOT(deviceChanged(int))); |
114 layout->addWidget(deviceBox,0,1,1,3,Qt::AlignLeft); |
125 layout->addWidget(deviceBox,0,1,1,3,Qt::AlignLeft); |
115 |
126 |
116 layout->addWidget(containerLabel,1,0,Qt::AlignHCenter); |
127 layout->addWidget(containerLabel,1,0,Qt::AlignHCenter); |
117 connect(containersBox,SIGNAL(activated(int)),SLOT(containerChanged(int))); |
128 connect(containersBox,SIGNAL(activated(int)),SLOT(containerChanged(int))); |
118 layout->addWidget(containersBox,1,1,Qt::AlignLeft); |
129 layout->addWidget(containersBox,1,1,1,3,Qt::AlignLeft); |
119 |
130 |
120 layout->addWidget(codecLabel,1,2,Qt::AlignHCenter); |
131 layout->addWidget(codecLabel,2,0,Qt::AlignHCenter); |
121 connect(codecsBox,SIGNAL(activated(int)),SLOT(codecChanged(int))); |
132 connect(codecsBox,SIGNAL(activated(int)),SLOT(codecChanged(int))); |
122 layout->addWidget(codecsBox,1,3,Qt::AlignLeft); |
133 layout->addWidget(codecsBox,2,1,1,3,Qt::AlignLeft); |
123 |
134 |
124 layout->addWidget(qualityLabel,2,0,Qt::AlignHCenter); |
135 layout->addWidget(qualityLabel,3,0,Qt::AlignHCenter); |
125 connect(qualityBox,SIGNAL(activated(int)),SLOT(qualityChanged(int))); |
136 connect(qualityBox,SIGNAL(activated(int)),SLOT(qualityChanged(int))); |
126 layout->addWidget(qualityBox,2,1,Qt::AlignLeft); |
137 layout->addWidget(qualityBox,3,1,1,3,Qt::AlignLeft); |
127 |
138 |
128 fileButton = new QPushButton(this); |
139 fileButton = new QPushButton(this); |
129 fileButton->setText(tr("Output File")); |
140 fileButton->setText(tr("Output File")); |
130 connect(fileButton,SIGNAL(clicked()),SLOT(selectOutputFile())); |
141 connect(fileButton,SIGNAL(clicked()),SLOT(selectOutputFile())); |
131 layout->addWidget(fileButton,3,0,Qt::AlignHCenter); |
142 layout->addWidget(fileButton,4,0,Qt::AlignHCenter); |
132 |
143 |
133 button = new QPushButton(this); |
144 button = new QPushButton(this); |
134 button->setText(tr("Record")); |
145 button->setText(tr("Record")); |
135 connect(button,SIGNAL(clicked()),SLOT(toggleRecord())); |
146 connect(button,SIGNAL(clicked()),SLOT(toggleRecord())); |
136 layout->addWidget(button,3,1,Qt::AlignHCenter); |
147 layout->addWidget(button,4,1,Qt::AlignHCenter); |
|
148 |
|
149 QLabel* durationLabel = new QLabel; |
|
150 durationLabel->setText(tr("Duration")); |
|
151 layout->addWidget(durationLabel,4,2,Qt::AlignRight); |
137 |
152 |
138 recTime = new QLabel; |
153 recTime = new QLabel; |
139 recTime->setText("0 sec"); |
154 layout->addWidget(recTime,4,3,Qt::AlignLeft); |
140 layout->addWidget(recTime,4,0,Qt::AlignHCenter); |
155 |
|
156 statusLabel = new QLabel; |
|
157 statusLabel->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Fixed); |
|
158 statusLabel->setMinimumSize(270,10); |
|
159 statusLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken); |
|
160 statusLabel->setLineWidth(1); |
|
161 layout->addWidget(statusLabel,5,0,1,4,Qt::AlignHCenter); |
141 |
162 |
142 window->setLayout(layout); |
163 window->setLayout(layout); |
143 setCentralWidget(window); |
164 setCentralWidget(window); |
144 window->show(); |
165 window->show(); |
145 |
166 |