1 | use ffi::AVAudioServiceType::*; |
2 | use ffi::*; |
3 | |
4 | #[derive (Eq, PartialEq, Clone, Copy, Debug)] |
5 | pub enum AudioService { |
6 | Main, |
7 | Effects, |
8 | VisuallyImpaired, |
9 | HearingImpaired, |
10 | Dialogue, |
11 | Commentary, |
12 | Emergency, |
13 | VoiceOver, |
14 | Karaoke, |
15 | } |
16 | |
17 | impl From<AVAudioServiceType> for AudioService { |
18 | fn from(value: AVAudioServiceType) -> Self { |
19 | match value { |
20 | AV_AUDIO_SERVICE_TYPE_MAIN => AudioService::Main, |
21 | AV_AUDIO_SERVICE_TYPE_EFFECTS => AudioService::Effects, |
22 | AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED => AudioService::VisuallyImpaired, |
23 | AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED => AudioService::HearingImpaired, |
24 | AV_AUDIO_SERVICE_TYPE_DIALOGUE => AudioService::Dialogue, |
25 | AV_AUDIO_SERVICE_TYPE_COMMENTARY => AudioService::Commentary, |
26 | AV_AUDIO_SERVICE_TYPE_EMERGENCY => AudioService::Emergency, |
27 | AV_AUDIO_SERVICE_TYPE_VOICE_OVER => AudioService::VoiceOver, |
28 | AV_AUDIO_SERVICE_TYPE_KARAOKE => AudioService::Karaoke, |
29 | AV_AUDIO_SERVICE_TYPE_NB => AudioService::Main, |
30 | } |
31 | } |
32 | } |
33 | |
34 | impl From<AudioService> for AVAudioServiceType { |
35 | fn from(value: AudioService) -> AVAudioServiceType { |
36 | match value { |
37 | AudioService::Main => AV_AUDIO_SERVICE_TYPE_MAIN, |
38 | AudioService::Effects => AV_AUDIO_SERVICE_TYPE_EFFECTS, |
39 | AudioService::VisuallyImpaired => AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED, |
40 | AudioService::HearingImpaired => AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED, |
41 | AudioService::Dialogue => AV_AUDIO_SERVICE_TYPE_DIALOGUE, |
42 | AudioService::Commentary => AV_AUDIO_SERVICE_TYPE_COMMENTARY, |
43 | AudioService::Emergency => AV_AUDIO_SERVICE_TYPE_EMERGENCY, |
44 | AudioService::VoiceOver => AV_AUDIO_SERVICE_TYPE_VOICE_OVER, |
45 | AudioService::Karaoke => AV_AUDIO_SERVICE_TYPE_KARAOKE, |
46 | } |
47 | } |
48 | } |
49 | |