root/tags/release_0_0_6/libfreebob/src/libfreebobavc/avc_definitions.cpp

Revision 156, 3.0 kB (checked in by anonymous, 18 years ago)

This commit was manufactured by cvs2svn to create tag
'release_0_0_6'.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 /* avc_defintions.cpp
2  * Copyright (C) 2005 by Daniel Wagner
3  *
4  * This file is part of FreeBob.
5  *
6  * FreeBob is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * FreeBob is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with FreeBob; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
18  * MA 02111-1307 USA.
19  */
20
21 #include "avc_definitions.h"
22
23
24 int
25 convertESamplingFrequency(ESamplingFrequency freq)
26 {
27     int value = 0;
28
29     switch ( freq ) {
30     case eSF_22050Hz:
31         value = 22050;
32         break;
33     case eSF_24000Hz:
34         value = 24000;
35         break;
36     case eSF_32000Hz:
37         value = 32000;
38         break;
39     case eSF_44100Hz:
40         value = 44100;
41         break;
42     case eSF_48000Hz:
43         value = 48000;
44         break;
45     case eSF_88200Hz:
46         value = 88200;
47         break;
48     case eSF_96000Hz:
49         value = 96000;
50         break;
51     case eSF_176400Hz:
52         value = 176400;
53         break;
54     case eSF_192000Hz:
55         value = 192000;
56         break;
57     default:
58         value = 0;
59     }
60
61
62     return value;
63 }
64
65 ESamplingFrequency
66 parseSampleRate( int sampleRate )
67 {
68     ESamplingFrequency efreq;
69     switch ( sampleRate ) {
70     case 22050:
71         efreq = eSF_22050Hz;
72         break;
73     case 24000:
74         efreq = eSF_24000Hz;
75         break;
76     case 32000:
77         efreq = eSF_32000Hz;
78         break;
79     case 44100:
80         efreq = eSF_44100Hz;
81         break;
82     case 48000:
83         efreq = eSF_48000Hz;
84         break;
85     case 88200:
86         efreq = eSF_88200Hz;
87         break;
88     case 96000:
89         efreq = eSF_96000Hz;
90         break;
91     case 176400:
92         efreq = eSF_176400Hz;
93         break;
94     case 192000:
95         efreq = eSF_192000Hz;
96         break;
97     default:
98         efreq = eSF_DontCare;
99     }
100
101     return efreq;
102 }
103
104 std::ostream& operator<<( std::ostream& stream, ESamplingFrequency samplingFrequency )
105 {
106     char* str;
107     switch ( samplingFrequency ) {
108     case eSF_22050Hz:
109         str = "22050";
110         break;
111     case eSF_24000Hz:
112         str = "24000";
113         break;
114     case eSF_32000Hz:
115         str = "32000";
116         break;
117     case eSF_44100Hz:
118         str = "44100";
119         break;
120     case eSF_48000Hz:
121         str = "48000";
122         break;
123     case eSF_88200Hz:
124         str = "88200";
125         break;
126     case eSF_96000Hz:
127         str = "96000";
128         break;
129     case eSF_176400Hz:
130         str = "176400";
131         break;
132     case eSF_192000Hz:
133         str = "192000";
134         break;
135     case eSF_DontCare:
136     default:
137         str = "unknown";
138     }
139     return stream << str;
140 };
Note: See TracBrowser for help on using the browser.