diff options
author | Gerald Combs <gerald@wireshark.org> | 2016-12-02 15:52:02 -0800 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2016-12-06 22:36:55 +0000 |
commit | d59653f8d52efbf3ab32f95043cd718965e57406 (patch) | |
tree | 14e868a73180a3eccbed1d3715bb64a2c92f6928 /ui/qt/rtp_player_dialog.cpp | |
parent | 263fea9723ea3487c0d98b0720ab2d656f780fe1 (diff) | |
download | wireshark-d59653f8d52efbf3ab32f95043cd718965e57406.tar.gz |
Qt: Make the RTP player output device selectable.
Add a combobox for selecting the output device and populate it with our
available devices. Let the user know if our output format isn't
supported.
Ping-Bug: 13105
Change-Id: I299c7d0f191bb66d93896338036000e2c377781f
Reviewed-on: https://code.wireshark.org/review/19046
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'ui/qt/rtp_player_dialog.cpp')
-rw-r--r-- | ui/qt/rtp_player_dialog.cpp | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/ui/qt/rtp_player_dialog.cpp b/ui/qt/rtp_player_dialog.cpp index 743685c307..35274cb3f0 100644 --- a/ui/qt/rtp_player_dialog.cpp +++ b/ui/qt/rtp_player_dialog.cpp @@ -35,6 +35,7 @@ #include "tango_colors.h" #include <QAudio> +#include <QAudioDeviceInfo> #include <QFrame> #include <QMenu> #include <QVBoxLayout> @@ -134,7 +135,7 @@ RtpPlayerDialog::RtpPlayerDialog(QWidget &parent, CaptureFile &cf) : ctx_menu_->addAction(ui->actionCrosshairs); connect(ui->audioPlot, SIGNAL(mouseMove(QMouseEvent*)), - this, SLOT(mouseMoved(QMouseEvent*))); + this, SLOT(updateHintLabel())); connect(ui->audioPlot, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(graphClicked(QMouseEvent*))); @@ -150,6 +151,21 @@ RtpPlayerDialog::RtpPlayerDialog(QWidget &parent, CaptureFile &cf) : ui->playButton->setIcon(StockIcon("media-playback-start")); ui->stopButton->setIcon(StockIcon("media-playback-stop")); + QString default_out_name = QAudioDeviceInfo::defaultOutputDevice().deviceName(); + foreach (QAudioDeviceInfo out_device, QAudioDeviceInfo::availableDevices(QAudio::AudioOutput)) { + QString out_name = out_device.deviceName(); + ui->outputDeviceComboBox->addItem(out_name); + if (out_name == default_out_name) { + ui->outputDeviceComboBox->setCurrentText(out_name); + } + } + if (ui->outputDeviceComboBox->count() < 1) { + ui->outputDeviceComboBox->setEnabled(false); + ui->playButton->setEnabled(false); + ui->stopButton->setEnabled(false); + ui->outputDeviceComboBox->addItem(tr("No devices available")); + } + ui->audioPlot->setMouseTracking(true); ui->audioPlot->setEnabled(true); ui->audioPlot->setInteractions( @@ -379,6 +395,7 @@ void RtpPlayerDialog::addRtpStream(struct _rtp_stream_info *rtp_stream) connect(audio_stream, SIGNAL(startedPlaying()), this, SLOT(updateWidgets())); connect(audio_stream, SIGNAL(finishedPlaying()), this, SLOT(updateWidgets())); + connect(audio_stream, SIGNAL(playbackError(QString)), this, SLOT(setPlaybackError(QString))); connect(audio_stream, SIGNAL(processedSecs(double)), this, SLOT(setPlayPosition(double))); } audio_stream->addRtpStream(rtp_stream); @@ -473,6 +490,7 @@ void RtpPlayerDialog::updateWidgets() } ui->playButton->setEnabled(enable_play); + ui->outputDeviceComboBox->setEnabled(enable_play); ui->stopButton->setEnabled(enable_stop); cur_play_pos_->setVisible(enable_stop); @@ -480,6 +498,7 @@ void RtpPlayerDialog::updateWidgets() ui->timingComboBox->setEnabled(enable_timing); ui->todCheckBox->setEnabled(enable_timing); + updateHintLabel(); ui->audioPlot->replot(); } @@ -492,7 +511,7 @@ void RtpPlayerDialog::graphClicked(QMouseEvent *event) ui->audioPlot->setFocus(); } -void RtpPlayerDialog::mouseMoved(QMouseEvent *) +void RtpPlayerDialog::updateHintLabel() { int packet_num = getHoveredPacket(); QString hint = "<small><i>"; @@ -501,6 +520,8 @@ void RtpPlayerDialog::mouseMoved(QMouseEvent *) hint += tr("%1. Press \"G\" to go to packet %2") .arg(getHoveredTime()) .arg(packet_num); + } else if (!playback_error_.isEmpty()) { + hint += playback_error_; } hint += "</i></small>"; @@ -603,6 +624,7 @@ void RtpPlayerDialog::on_playButton_clicked() cur_play_pos_->point1->setCoords(left, 0.0); cur_play_pos_->point2->setCoords(left, 1.0); cur_play_pos_->setVisible(true); + playback_error_.clear(); ui->audioPlot->replot(); } @@ -709,6 +731,13 @@ int RtpPlayerDialog::getHoveredPacket() return audio_stream->nearestPacket(ts, !ui->todCheckBox->isChecked()); } +// Used by RtpAudioStreams to initialize QAudioOutput. We could alternatively +// pass the corresponding QAudioDeviceInfo directly. +const QString RtpPlayerDialog::currentOutputDeviceName() +{ + return ui->outputDeviceComboBox->currentText(); +} + void RtpPlayerDialog::on_jitterSpinBox_valueChanged(double) { rescanPackets(); |