]> git.sesse.net Git - vlc/blob - src/misc/mime.c
Opus decoder.
[vlc] / src / misc / mime.c
1 /*****************************************************************************
2  * mime.c
3  *****************************************************************************
4  * Copyright © 2004-2012 VLC authors and VideoLAN
5  * Copyright © 2004-2007 Rémi Denis-Courmont
6  *
7  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
8  *          Rémi Denis-Courmont <rem # videolan.org>
9  *
10  * This program is free software; you can redistribute it and/or modify it
11  * under the terms of the GNU Lesser General Public License as published by
12  * the Free Software Foundation; either version 2.1 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with this program; if not, write to the Free Software Foundation,
22  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 #ifdef HAVE_CONFIG_H
26 # include "config.h"
27 #endif
28
29 #include <vlc_common.h>
30 #include <vlc_mime.h>
31
32 #include <string.h>
33
34 static const struct
35 {
36     const char psz_ext[8];
37     const char *psz_mime;
38 } ext_mime[] =
39 {
40     { ".htm",   "text/html" },
41     { ".html",  "text/html" },
42     { ".txt",   "text/plain" },
43     { ".xml",   "text/xml" },
44     { ".dtd",   "text/dtd" },
45
46     { ".css",   "text/css" },
47
48     /* image mime */
49     { ".gif",   "image/gif" },
50     { ".jpe",   "image/jpeg" },
51     { ".jpg",   "image/jpeg" },
52     { ".jpeg",  "image/jpeg" },
53     { ".png",   "image/png" },
54     /* same as modules/mux/mpjpeg.c here: */
55     { ".mpjpeg","multipart/x-mixed-replace; boundary=7b3cc56e5f51db803f790dad720ed50a" },
56
57     /* media mime */
58     { ".avi",   "video/avi" },
59     { ".asf",   "video/x-ms-asf" },
60     { ".m1a",   "audio/mpeg" },
61     { ".m2a",   "audio/mpeg" },
62     { ".m1v",   "video/mpeg" },
63     { ".m2v",   "video/mpeg" },
64     { ".mp2",   "audio/mpeg" },
65     { ".mp3",   "audio/mpeg" },
66     { ".mpa",   "audio/mpeg" },
67     { ".mpg",   "video/mpeg" },
68     { ".mpeg",  "video/mpeg" },
69     { ".mpe",   "video/mpeg" },
70     { ".mov",   "video/quicktime" },
71     { ".moov",  "video/quicktime" },
72     { ".oga",   "audio/ogg" },
73     { ".ogg",   "application/ogg" },
74     { ".ogm",   "application/ogg" },
75     { ".ogv",   "video/ogg" },
76     { ".ogx",   "application/ogg" },
77     { ".opus",  "audio/ogg; codecs=opus" },
78     { ".spx",   "audio/ogg" },
79     { ".wav",   "audio/wav" },
80     { ".wma",   "audio/x-ms-wma" },
81     { ".wmv",   "video/x-ms-wmv" },
82     { ".webm",  "video/webm" },
83
84     /* end */
85     { "",       "" }
86 };
87
88 const char *vlc_mime_Ext2Mime( const char *psz_url )
89 {
90
91     char *psz_ext;
92
93     psz_ext = strrchr( psz_url, '.' );
94     if( psz_ext )
95     {
96         int i;
97
98         for( i = 0; ext_mime[i].psz_ext[0] ; i++ )
99         {
100             if( !strcasecmp( ext_mime[i].psz_ext, psz_ext ) )
101             {
102                 return ext_mime[i].psz_mime;
103             }
104         }
105     }
106     return "application/octet-stream";
107 }
108