update epan/dissectors/pidl/drsuapi/drsuapi.idl from samba
[wireshark-sm.git] / ui / qt / utils / rtp_audio_routing.cpp
blob04ced435e344efdf1c687d3e63131b558ff416ea
1 /* rtp_audio_routing.cpp
3 * Wireshark - Network traffic analyzer
4 * By Gerald Combs <gerald@wireshark.org>
5 * Copyright 1998 Gerald Combs
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 */
10 #include "rtp_audio_routing.h"
12 AudioRouting::AudioRouting(bool muted, audio_routing_channel_t channel):
13 muted_(muted),
14 channel_(channel)
18 char const *AudioRouting::formatAudioRoutingToString()
20 if (muted_) {
21 return "Muted";
22 } else {
23 switch (channel_) {
24 case channel_any:
25 // Should not happen ever
26 return "ERR";
27 case channel_mono:
28 return "Play";
29 case channel_stereo_left:
30 return "L";
31 case channel_stereo_right:
32 return "R";
33 case channel_stereo_both:
34 return "L+R";
38 // Should not happen ever
39 return "ERR";
42 AudioRouting AudioRouting::getNextChannel(bool stereo_available)
44 if (stereo_available) {
45 // Stereo
46 if (muted_) {
47 return AudioRouting(AUDIO_UNMUTED, channel_stereo_left);
48 } else {
49 switch (channel_) {
50 case channel_stereo_left:
51 return AudioRouting(AUDIO_UNMUTED, channel_stereo_both);
52 case channel_stereo_both:
53 return AudioRouting(AUDIO_UNMUTED, channel_stereo_right);
54 case channel_stereo_right:
55 return AudioRouting(AUDIO_MUTED, channel_stereo_right);
56 default:
57 return AudioRouting(AUDIO_UNMUTED, channel_stereo_left);
60 } else {
61 // Mono
62 if (muted_) {
63 return AudioRouting(AUDIO_UNMUTED, channel_mono);
64 } else {
65 return AudioRouting(AUDIO_MUTED, channel_mono);
70 AudioRouting AudioRouting::convert(bool stereo_available)
72 // Muting is not touched by conversion
74 if (stereo_available) {
75 switch (channel_) {
76 case channel_mono:
77 // Mono -> Stereo
78 return AudioRouting(muted_, channel_stereo_both);
79 case channel_any:
80 // Unknown -> Unknown
81 return AudioRouting(muted_, channel_any);
82 default:
83 // Stereo -> Stereo
84 return AudioRouting(muted_, channel_);
86 } else {
87 switch (channel_) {
88 case channel_mono:
89 // Mono -> Mono
90 return AudioRouting(muted_, channel_mono);
91 case channel_any:
92 // Unknown -> Unknown
93 return AudioRouting(muted_, channel_any);
94 default:
95 // Stereo -> Mono
96 return AudioRouting(muted_, channel_mono);
101 void AudioRouting::mergeAudioRouting(AudioRouting new_audio_routing)
103 if (new_audio_routing.getChannel() == channel_any) {
104 muted_ = new_audio_routing.isMuted();
105 } else {
106 muted_ = new_audio_routing.isMuted();
107 channel_ = new_audio_routing.getChannel();