aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJirka Novak <j.novak@netsystem.cz>2019-12-28 19:17:43 +0100
committerAnders Broman <a.broman58@gmail.com>2020-01-07 09:18:59 +0000
commitc1f5b4d2d91d7a1113d0206237fff55669b87727 (patch)
tree00f660c962c80593cbb7b4ce03f9beeca5967dfe
parentc283cf37c5e962ccd679e23c6aaa821dc16e559a (diff)
rtp_analysis_dialog: Improved codec recognition during saving of audio to .au
I found that when codec is negotiated to nonstandard payload id, it was reported as unsupported even was supported. Patch fixes it. Change-Id: I4eb14fc22f83eb42300fc67baee8456dff65d191 Reviewed-on: https://code.wireshark.org/review/35575 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rw-r--r--ui/qt/rtp_analysis_dialog.cpp54
-rw-r--r--ui/qt/rtp_analysis_dialog.h6
2 files changed, 34 insertions, 26 deletions
diff --git a/ui/qt/rtp_analysis_dialog.cpp b/ui/qt/rtp_analysis_dialog.cpp
index 4ca20b6e3d..19ed25e4dc 100644
--- a/ui/qt/rtp_analysis_dialog.cpp
+++ b/ui/qt/rtp_analysis_dialog.cpp
@@ -1043,7 +1043,7 @@ void RtpAnalysisDialog::showPlayer()
/* Convert one packet payload to samples in row */
/* It supports G.711 now, but can be extended to any other codecs */
-size_t RtpAnalysisDialog::convert_payload_to_samples(unsigned int payload_type, QTemporaryFile *tempfile, uint8_t *pd_out, size_t payload_len, struct _GHashTable *decoders_hash)
+size_t RtpAnalysisDialog::convert_payload_to_samples(unsigned int payload_type, const gchar *payload_type_names[256], QTemporaryFile *tempfile, uint8_t *pd_out, size_t payload_len, struct _GHashTable *decoders_hash)
{
unsigned int channels = 0;
unsigned int sample_rate = 0;
@@ -1053,6 +1053,7 @@ size_t RtpAnalysisDialog::convert_payload_to_samples(unsigned int payload_type,
/* Decoded audio is in samples (2 bytes) */
SAMPLE *decode_buff = Q_NULLPTR;
size_t decoded_samples;
+ const gchar *payload_type_str = Q_NULLPTR;
tempfile->read((char *)payload_data, payload_len);
if (PT_UNDF_123 == payload_type) {
@@ -1060,26 +1061,33 @@ size_t RtpAnalysisDialog::convert_payload_to_samples(unsigned int payload_type,
return 0;
}
+ if (payload_type_names[payload_type] != NULL) {
+ payload_type_str = payload_type_names[payload_type];
+ }
+
/* Decoder returns count of bytes, but data are samples */
- decoded_bytes = decode_rtp_packet_payload(payload_type, Q_NULLPTR, payload_data, payload_len, &decode_buff, decoders_hash, &channels, &sample_rate);
+ decoded_bytes = decode_rtp_packet_payload(payload_type, payload_type_str, payload_data, payload_len, &decode_buff, decoders_hash, &channels, &sample_rate);
decoded_samples = decoded_bytes/2;
- if (sample_rate != 8000) {
- sae_unsupported_codec_ = true;
- decoded_samples = 0;
- } else if (decoded_samples > 0) {
- /* Change byte order to network order */
- for(size_t i = 0; i < decoded_samples; i++) {
- SAMPLE sample;
- uint8_t pd[4];
-
- sample = decode_buff[i];
- phton16(pd, sample);
- pd_out[2*i] = pd[0];
- pd_out[2*i+1] = pd[1];
+ if (decoded_samples > 0) {
+ if (sample_rate == 8000) {
+ /* Change byte order to network order */
+ for(size_t i = 0; i < decoded_samples; i++) {
+ SAMPLE sample;
+ uint8_t pd[4];
+
+ sample = decode_buff[i];
+ phton16(pd, sample);
+ pd_out[2*i] = pd[0];
+ pd_out[2*i+1] = pd[1];
+ }
+ } else {
+ sae_unsupported_rate_ = true;
+ decoded_samples = 0;
}
} else {
sae_unsupported_codec_ = true;
+ decoded_samples = 0;
}
g_free(decode_buff);
@@ -1113,7 +1121,7 @@ bool RtpAnalysisDialog::saveAudioAUSilence(size_t total_len, QFile *save_file, g
return true;
}
-bool RtpAnalysisDialog::saveAudioAUUnidir(tap_rtp_stat_t &statinfo, QTemporaryFile *tempfile, QFile *save_file, int64_t header_end, gboolean *stop_flag, gboolean interleave, size_t prefix_silence)
+bool RtpAnalysisDialog::saveAudioAUUnidir(tap_rtp_stat_t &statinfo, const gchar *payload_type_names[256], QTemporaryFile *tempfile, QFile *save_file, int64_t header_end, gboolean *stop_flag, gboolean interleave, size_t prefix_silence)
{
int64_t nchars;
uint8_t pd_out[2*4000];
@@ -1131,7 +1139,7 @@ bool RtpAnalysisDialog::saveAudioAUUnidir(tap_rtp_stat_t &statinfo, QTemporaryFi
ui->progressFrame->setValue(int(tempfile->pos() * 100 / tempfile->size()));
- sample_count=convert_payload_to_samples(save_data.payload_type, tempfile , pd_out, save_data.payload_len, decoders_hash);
+ sample_count=convert_payload_to_samples(save_data.payload_type, payload_type_names, tempfile, pd_out, save_data.payload_len, decoders_hash);
if (!isSAEOK()) {
return false;
@@ -1160,13 +1168,13 @@ bool RtpAnalysisDialog::saveAudioAUUnidir(tap_rtp_stat_t &statinfo, QTemporaryFi
return true;
}
-bool RtpAnalysisDialog::saveAudioAUBidir(tap_rtp_stat_t &fwd_statinfo, tap_rtp_stat_t &rev_statinfo, QTemporaryFile *fwd_tempfile, QTemporaryFile *rev_tempfile, QFile *save_file, int64_t header_end, gboolean *stop_flag, size_t prefix_silence_fwd, size_t prefix_silence_rev)
+bool RtpAnalysisDialog::saveAudioAUBidir(tap_rtp_stat_t &fwd_statinfo, tap_rtp_stat_t &rev_statinfo, const gchar *fwd_payload_type_names[256], const gchar *rev_payload_type_names[256], QTemporaryFile *fwd_tempfile, QTemporaryFile *rev_tempfile, QFile *save_file, int64_t header_end, gboolean *stop_flag, size_t prefix_silence_fwd, size_t prefix_silence_rev)
{
- if (!saveAudioAUUnidir(fwd_statinfo, fwd_tempfile, save_file, header_end, stop_flag, true, prefix_silence_fwd)) {
+ if (!saveAudioAUUnidir(fwd_statinfo, fwd_payload_type_names, fwd_tempfile, save_file, header_end, stop_flag, true, prefix_silence_fwd)) {
return false;
}
- if (!saveAudioAUUnidir(rev_statinfo, rev_tempfile, save_file, header_end+2, stop_flag, true, prefix_silence_rev)) {
+ if (!saveAudioAUUnidir(rev_statinfo, rev_payload_type_names, rev_tempfile, save_file, header_end+2, stop_flag, true, prefix_silence_rev)) {
return false;
}
@@ -1299,7 +1307,7 @@ bool RtpAnalysisDialog::saveAudioAU(StreamDirection direction, QFile *save_file,
if (!saveAudioAUSilence(fwd_total_len + fwd_samples_diff + bidir_samples_diff, save_file, stop_flag)) {
return false;
}
- if (!saveAudioAUUnidir(fwd_statinfo_.rtp_stats, fwd_tempfile_, save_file, header_end, stop_flag, false, fwd_samples_diff + bidir_samples_diff)) {
+ if (!saveAudioAUUnidir(fwd_statinfo_.rtp_stats, fwd_statinfo_.payload_type_names, fwd_tempfile_, save_file, header_end, stop_flag, false, fwd_samples_diff + bidir_samples_diff)) {
return false;
}
break;
@@ -1311,7 +1319,7 @@ bool RtpAnalysisDialog::saveAudioAU(StreamDirection direction, QFile *save_file,
return false;
}
- if (!saveAudioAUUnidir(rev_statinfo_.rtp_stats, rev_tempfile_, save_file, header_end, stop_flag, false, rev_samples_diff + bidir_samples_diff)) {
+ if (!saveAudioAUUnidir(rev_statinfo_.rtp_stats, rev_statinfo_.payload_type_names, rev_tempfile_, save_file, header_end, stop_flag, false, rev_samples_diff + bidir_samples_diff)) {
return false;
}
break;
@@ -1324,7 +1332,7 @@ bool RtpAnalysisDialog::saveAudioAU(StreamDirection direction, QFile *save_file,
if (!saveAudioAUSilence((total_len + bidir_samples_diff) * 2, save_file, stop_flag)) {
return false;
}
- if (!saveAudioAUBidir(fwd_statinfo_.rtp_stats, rev_statinfo_.rtp_stats, fwd_tempfile_, rev_tempfile_, save_file, header_end, stop_flag, fwd_samples_diff + bidir_samples_diff, rev_samples_diff + bidir_samples_diff)) {
+ if (!saveAudioAUBidir(fwd_statinfo_.rtp_stats, rev_statinfo_.rtp_stats, fwd_statinfo_.payload_type_names, rev_statinfo_.payload_type_names, fwd_tempfile_, rev_tempfile_, save_file, header_end, stop_flag, fwd_samples_diff + bidir_samples_diff, rev_samples_diff + bidir_samples_diff)) {
return false;
}
}
diff --git a/ui/qt/rtp_analysis_dialog.h b/ui/qt/rtp_analysis_dialog.h
index 903574162f..20c3f9f80a 100644
--- a/ui/qt/rtp_analysis_dialog.h
+++ b/ui/qt/rtp_analysis_dialog.h
@@ -133,10 +133,10 @@ private:
void showPlayer();
- size_t convert_payload_to_samples(unsigned int payload_type, QTemporaryFile *tempfile, uint8_t *pd_out, size_t expected_nchars, struct _GHashTable *decoders_hash);
+ size_t convert_payload_to_samples(unsigned int payload_type, const gchar *payload_type_names[256], QTemporaryFile *tempfile, uint8_t *pd_out, size_t expected_nchars, struct _GHashTable *decoders_hash);
bool saveAudioAUSilence(size_t total_len, QFile *save_file, gboolean *stop_flag);
- bool saveAudioAUUnidir(tap_rtp_stat_t &statinfo, QTemporaryFile *tempfile, QFile *save_file, int64_t header_end, gboolean *stop_flag, gboolean interleave, size_t prefix_silence);
- bool saveAudioAUBidir(tap_rtp_stat_t &fwd_statinfo, tap_rtp_stat_t &rev_statinfo, QTemporaryFile *fwd_tempfile, QTemporaryFile *rev_tempfile, QFile *save_file, int64_t header_end, gboolean *stop_flag, size_t prefix_silence_fwd, size_t prefix_silence_rev);
+ bool saveAudioAUUnidir(tap_rtp_stat_t &statinfo, const gchar *payload_type_names[256], QTemporaryFile *tempfile, QFile *save_file, int64_t header_end, gboolean *stop_flag, gboolean interleave, size_t prefix_silence);
+ bool saveAudioAUBidir(tap_rtp_stat_t &fwd_statinfo, tap_rtp_stat_t &rev_statinfo, const gchar *fwd_payload_type_names[256], const gchar *rev_payload_type_names[256], QTemporaryFile *fwd_tempfile, QTemporaryFile *rev_tempfile, QFile *save_file, int64_t header_end, gboolean *stop_flag, size_t prefix_silence_fwd, size_t prefix_silence_rev);
bool saveAudioAU(StreamDirection direction, QFile *save_file, gboolean *stop_flag, RtpAnalysisDialog::SyncType sync);
bool saveAudioRAW(StreamDirection direction, QFile *save_file, gboolean *stop_flag);
void saveAudio(StreamDirection direction, RtpAnalysisDialog::SyncType sync);