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