summaryrefslogtreecommitdiff
path: root/ui/qt/rtp_audio_stream.h
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2014-12-12 16:51:40 -0800
committerGerald Combs <gerald@wireshark.org>2015-10-02 18:26:05 +0000
commit3687d393040a40655d84e3e03417a474032bad86 (patch)
tree55f208b60abb59c5812bae2407a9b36dfdd2f09a /ui/qt/rtp_audio_stream.h
parentfd5eafa50a77bc319a240727600be38307e54f86 (diff)
downloadwireshark-3687d393040a40655d84e3e03417a474032bad86.tar.gz
Qt: Initial RTP playback.
Note the "initial". This is woefully incomplete. See the "to do" lists below and in the code. This differs a bit from the GTK+ version in that you specify one or more streams to be decoded. Instead of showing waveforms in individual widgets, add them all to a single QCustomPlot. This conserves screen real estate and lets us more easily take advantage of the QCP API. It also looks better IMHO. Change a bunch of checks for QtMultimediaWidgets to QtMultimedia. We probably won't use the widgets until we make 5.0 our minimum Qt version and plain old QtMultimedia lets us support Qt 4 more easily (in theory at least). Add resampling code from libspeex. I initially used this to resample each packet to match the preferred rate of our output device, but this resulted in poorer audio quality than expected. Leave it in and use to create visual samples for QCP and to match rates any time the rate changes. The latter is currently untested. Add some debugging macros. Note that both the RTP player and RTP analysis dialogs decode audio data using different code. Note that voip_calls_packet and voip_calls_init_tap appear to be dead code. To do: - Add silence frames where needed. - Implement the jitter buffer. - Implement the playback timing controls. - Tapping / scanning streams might be too slow. Change-Id: I20dd3b66d3df53c9b1f3501262dc01458849f6b4 Bug: 9007 Reviewed-on: https://code.wireshark.org/review/10458 Petri-Dish: Gerald Combs <gerald@wireshark.org> Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'ui/qt/rtp_audio_stream.h')
-rw-r--r--ui/qt/rtp_audio_stream.h151
1 files changed, 151 insertions, 0 deletions
diff --git a/ui/qt/rtp_audio_stream.h b/ui/qt/rtp_audio_stream.h
new file mode 100644
index 0000000000..b2842aad37
--- /dev/null
+++ b/ui/qt/rtp_audio_stream.h
@@ -0,0 +1,151 @@
+/* rtp_audio_stream.h
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef RTPAUDIOSTREAM_H
+#define RTPAUDIOSTREAM_H
+
+#include "config.h"
+
+#ifdef QT_MULTIMEDIA_LIB
+
+#include <glib.h>
+
+#include <epan/address.h>
+
+#include <QAudio>
+#include <QColor>
+#include <QMap>
+#include <QObject>
+#include <QSet>
+#include <QVector>
+
+class QAudioOutput;
+class QTemporaryFile;
+
+struct _rtp_stream_info;
+struct _rtp_sample;
+
+class RtpAudioStream : public QObject
+{
+ Q_OBJECT
+public:
+ explicit RtpAudioStream(QObject *parent, struct _rtp_stream_info *rtp_stream);
+ ~RtpAudioStream();
+ bool isMatch(const struct _rtp_stream_info *rtp_stream) const;
+ bool isMatch(const struct _packet_info *pinfo, const struct _rtp_info *rtp_info) const;
+ void addRtpStream(const struct _rtp_stream_info *rtp_stream);
+ void addRtpPacket(const struct _packet_info *pinfo, const struct _rtp_info *rtp_info);
+ void reset(double start_rel_time);
+
+ double startRelTime() const { return start_rel_time_; }
+ double stopRelTime() const { return stop_rel_time_; }
+ unsigned sampleRate() const { return audio_out_rate_; }
+ const QStringList payloadNames() const;
+
+ /**
+ * @brief Return a list of visual timestamps.
+ * @return A set of timestamps suitable for passing to QCPGraph::setData.
+ */
+ const QVector<double> visualTimestamps(bool relative = true);
+ /**
+ * @brief Return a list of visual samples. There will be fewer visual samples
+ * per second (1000) than the actual audio.
+ * @param y_offset Y axis offset to be used for stacking graphs.
+ * @return A set of values suitable for passing to QCPGraph::setData.
+ */
+ const QVector<double> visualSamples(int y_offset = 0);
+
+ /**
+ * @brief Return a list of out-of-sequence timestamps.
+ * @return A set of timestamps suitable for passing to QCPGraph::setData.
+ */
+ const QVector<double> outOfSequenceTimestamps(bool relative = true);
+ int outOfSequence() { return out_of_seq_timestamps_.length(); }
+ /**
+ * @brief Return a list of out-of-sequence samples. Y value is constant.
+ * @param y_offset Y axis offset to be used for stacking graphs.
+ * @return A set of values suitable for passing to QCPGraph::setData.
+ */
+ const QVector<double> outOfSequenceSamples(int y_offset = 0);
+
+ quint32 nearestPacket(double timestamp, bool is_relative = true);
+
+ QRgb color() { return color_; }
+ void setColor(QRgb color) { color_ = color; }
+
+ QAudio::State outputState() const;
+
+signals:
+ void startedPlaying();
+ void processedSecs(double secs);
+ void finishedPlaying();
+
+public slots:
+ void startPlaying();
+ void stopPlaying();
+
+private:
+ address src_addr_;
+ quint16 src_port_;
+ address dst_addr_;
+ quint16 dst_port_;
+ quint32 ssrc_;
+ int last_sequence_;
+ QTemporaryFile *tempfile_;
+ struct _GHashTable *decoders_hash_;
+ QList<const struct _rtp_stream_info *>rtp_streams_;
+ double global_start_rel_time_;
+ double start_abs_offset_;
+ double start_rel_time_;
+ double stop_rel_time_;
+ quint32 audio_out_rate_;
+ QSet<QString> payload_names_;
+ struct SpeexResamplerState_ *audio_resampler_;
+ struct SpeexResamplerState_ *visual_resampler_;
+ QAudioOutput *audio_output_;
+ QMap<double, quint32> packet_timestamps_;
+ QVector<qint16> visual_samples_;
+ QVector<double> out_of_seq_timestamps_;
+ qint16 max_sample_val_;
+ QRgb color_;
+
+private slots:
+ void outputStateChanged();
+ void outputNotify();
+
+};
+
+#endif // QT_MULTIMEDIA_LIB
+
+#endif // RTPAUDIOSTREAM_H
+
+/*
+ * Editor modelines
+ *
+ * Local Variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * ex: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */