Tizen 2.0 Release
[framework/multimedia/gst-plugins-good0.10.git] / gst / isomp4 / qtdemux_lang.c
1 /* GStreamer Quicktime/ISO demuxer language utility functions
2  * Copyright (C) 2010 Tim-Philipp Müller <tim centricular net>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #include "qtdemux.h"
21 #include "qtdemux_lang.h"
22
23 #include <string.h>
24
25 /* http://developer.apple.com/mac/library/documentation/QuickTime/QTFF/QTFFChap4/qtff4.html */
26
27 static const gchar qt_lang_map[][4] = {
28
29 /* 000 English
30  * 001 French
31  * 002 German
32  * 003 Italian
33  * 004 Dutch
34  * 005 Swedish
35  * 006 Spanish
36  * 007 Danish
37  * 008 Portuguese
38  * 009 Norwegian
39  */
40   "eng", "fre", "deu", "ita", "nld", "swe", "spa", "dan", "por", "nor",
41
42 /* 010 Hebrew
43  * 011 Japanese
44  * 012 Arabic
45  * 013 Finnish
46  * 014 Greek
47  * 015 Icelandic
48  * 016 Maltese
49  * 017 Turkish
50  * 018 Croatian
51  * 019 Traditional Chinese (ISO 639-2 can't express script differences, so zho)
52  */
53   "heb", "jpn", "ara", "fin", "ell", "isl", "mlt", "tur", "hrv", "zho",
54
55 /* 020 Urdu
56  * 021 Hindi
57  * 022 Thai
58  * 023 Korean
59  * 024 Lithuanian
60  * 025 Polish
61  * 026 Hungarian
62  * 027 Estonian
63  * 028 Latvian / Lettish
64  * 029 Lappish / Saamish (used code for Nothern Sami)
65  */
66   "urd", "hin", "tha", "kor", "lit", "pol", "hun", "est", "lav", "sme",
67
68 /* 030 Faeroese
69  * 031 Farsi
70  * 032 Russian
71  * 033 Simplified Chinese (ISO 639-2 can't express script differences, so zho)
72  * 034 Flemish (no ISO 639-2 code, used Dutch code)
73  * 035 Irish
74  * 036 Albanian
75  * 037 Romanian
76  * 038 Czech
77  * 039 Slovak
78  */
79   "fao", "fas", "rus", "zho", "nld", "gle", "sqi", "ron", "ces", "slk",
80
81 /* 040 Slovenian
82  * 041 Yiddish
83  * 042 Serbian
84  * 043 Macedonian
85  * 044 Bulgarian
86  * 045 Ukrainian
87  * 046 Byelorussian
88  * 047 Uzbek
89  * 048 Kazakh
90  * 049 Azerbaijani
91  */
92   "slv", "yid", "srp", "mkd", "bul", "ukr", "bel", "uzb", "kaz", "aze",
93
94 /* 050 AzerbaijanAr (presumably script difference? used aze here)
95  * 051 Armenian
96  * 052 Georgian
97  * 053 Moldavian
98  * 054 Kirghiz
99  * 055 Tajiki
100  * 056 Turkmen
101  * 057 Mongolian
102  * 058 MongolianCyr (presumably script difference? used mon here)
103  * 059 Pashto
104  */
105
106   "aze", "hye", "kat", "mol", "kir", "tgk", "tuk", "mon", "mon", "pus",
107
108
109 /* 060 Kurdish
110  * 061 Kashmiri
111  * 062 Sindhi
112  * 063 Tibetan
113  * 064 Nepali
114  * 065 Sanskrit
115  * 066 Marathi
116  * 067 Bengali
117  * 068 Assamese
118  * 069 Gujarati
119  */
120   "kur", "kas", "snd", "bod", "nep", "san", "mar", "ben", "asm", "guj",
121
122 /* 070 Punjabi
123  * 071 Oriya
124  * 072 Malayalam
125  * 073 Kannada
126  * 074 Tamil
127  * 075 Telugu
128  * 076 Sinhalese
129  * 077 Burmese
130  * 078 Khmer
131  * 079 Lao
132  */
133   "pan", "ori", "mal", "kan", "tam", "tel", "sin", "mya", "khm", "lao",
134
135 /* 080 Vietnamese
136  * 081 Indonesian
137  * 082 Tagalog
138  * 083 MalayRoman
139  * 084 MalayArabic
140  * 085 Amharic
141  * 087 Galla (same as Oromo?)
142  * 087 Oromo
143  * 088 Somali
144  * 089 Swahili
145  */
146   "vie", "ind", "tgl", "msa", "msa", "amh", "orm", "orm", "som", "swa",
147
148 /* 090 Ruanda
149  * 091 Rundi
150  * 092 Chewa
151  * 093 Malagasy
152  * 094 Esperanto
153  * 095 ---
154  * 096 ---
155  * 097 ---
156  * 098 ---
157  * 099 ---
158  */
159   "kin", "run", "nya", "mlg", "ep", "und", "und", "und", "und", "und",
160
161 /* 100-109 ---
162  * 110-119 ---
163  */
164   "und", "und", "und", "und", "und", "und", "und", "und", "und", "und",
165   "und", "und", "und", "und", "und", "und", "und", "und", "und", "und",
166
167 /* 120-127 ---
168  * 128 Welsh
169  * 129 Basque
170  */
171   "und", "und", "und", "und", "und", "und", "und", "und", "cym", "eus",
172
173 /* 130 Catalan
174  * 131 Latin
175  * 132 Quechua
176  * 133 Guarani
177  * 134 Aymara
178  * 135 Tatar
179  * 136 Uighur
180  * 137 Dzongkha
181  * 138 JavaneseRom
182  */
183   "cat", "lat", "que", "grn", "aym", "tat", "uig", "dzo", "jav"
184 };
185
186 /* map quicktime language code to ISO-639-2T id, returns "und" if unknown */
187 void
188 qtdemux_lang_map_qt_code_to_iso (gchar id[4], guint16 qt_lang_code)
189 {
190   const gchar *iso_code;
191
192   g_assert (qt_lang_code < 0x800);
193
194   if (qt_lang_code < G_N_ELEMENTS (qt_lang_map))
195     iso_code = qt_lang_map[qt_lang_code];
196   else
197     iso_code = "und";
198
199   GST_DEBUG ("mapped quicktime language code %u to ISO 639-2T code '%s'",
200       qt_lang_code, iso_code);
201
202   memcpy (id, iso_code, 4);
203
204   g_assert (id[3] == '\0');
205 }