Mercurial > pt1.oyama
comparison libdlna-0.2.3/src/audio_lpcm.c @ 129:4f6d9621ee00
add multi session streaming & add depending librarys.
- libupnp-1.6.6
- libdlna-0.2.3
author | Naoya OYAMA <naoya.oyama@gmail.com> |
---|---|
date | Sun, 10 Oct 2010 15:33:18 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
128:3a7d8d2f0585 | 129:4f6d9621ee00 |
---|---|
1 /* | |
2 * libdlna: reference DLNA standards implementation. | |
3 * Copyright (C) 2007 Benjamin Zores <ben@geexbox.org> | |
4 * | |
5 * This file is part of libdlna. | |
6 * | |
7 * libdlna is free software; you can redistribute it and/or | |
8 * modify it under the terms of the GNU Lesser General Public | |
9 * License as published by the Free Software Foundation; either | |
10 * version 2.1 of the License, or (at your option) any later version. | |
11 * | |
12 * libdlna is distributed in the hope that it will be useful, | |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Lesser General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Lesser General Public | |
18 * License along with libdlna; if not, write to the Free Software | |
19 * Foundation, Inc, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
20 */ | |
21 | |
22 #include <stdlib.h> | |
23 #include <string.h> | |
24 | |
25 #include "dlna_internals.h" | |
26 #include "profiles.h" | |
27 | |
28 /* Profile for audio media class content */ | |
29 static dlna_profile_t lpcm = { | |
30 .id = "LPCM", | |
31 .mime = NULL, | |
32 .label = LABEL_AUDIO_2CH | |
33 }; | |
34 | |
35 static dlna_profile_t lpcm_low = { | |
36 .id = "LPCM_low", | |
37 .mime = NULL, | |
38 .label = LABEL_AUDIO_2CH | |
39 }; | |
40 | |
41 audio_profile_t | |
42 audio_profile_guess_lpcm (AVCodecContext *ac) | |
43 { | |
44 if (!ac) | |
45 return AUDIO_PROFILE_INVALID; | |
46 | |
47 /* check for 16-bit signed network-endian PCM codec */ | |
48 if (ac->codec_id != CODEC_ID_PCM_S16BE && | |
49 ac->codec_id != CODEC_ID_PCM_S16LE) | |
50 return AUDIO_PROFILE_INVALID; | |
51 | |
52 /* supported channels: mono or stereo */ | |
53 if (ac->channels > 2) | |
54 return AUDIO_PROFILE_INVALID; | |
55 | |
56 /* supported sampling rate: 8 kHz -> 48 kHz */ | |
57 if (ac->sample_rate < 8000 || ac->sample_rate > 48000) | |
58 return AUDIO_PROFILE_INVALID; | |
59 | |
60 return AUDIO_PROFILE_LPCM; | |
61 } | |
62 | |
63 static dlna_profile_t * | |
64 probe_lpcm (AVFormatContext *ctx dlna_unused, | |
65 dlna_container_type_t st dlna_unused, | |
66 av_codecs_t *codecs) | |
67 { | |
68 static dlna_profile_t p; | |
69 char mime[128]; | |
70 | |
71 if (!stream_ctx_is_audio (codecs)) | |
72 return NULL; | |
73 | |
74 if (audio_profile_guess_lpcm (codecs->ac) != AUDIO_PROFILE_LPCM) | |
75 return NULL; | |
76 | |
77 if (codecs->ac->sample_rate <= 32000) | |
78 memcpy (&p, &lpcm_low, sizeof (lpcm_low)); | |
79 else | |
80 memcpy (&p, &lpcm, sizeof (lpcm)); | |
81 sprintf (mime, "%s;rate=%d;channels=%d", | |
82 MIME_AUDIO_LPCM, codecs->ac->sample_rate, codecs->ac->channels); | |
83 p.mime = strdup (mime); | |
84 | |
85 return &p; | |
86 } | |
87 | |
88 dlna_registered_profile_t dlna_profile_audio_lpcm = { | |
89 .id = DLNA_PROFILE_AUDIO_LPCM, | |
90 .class = DLNA_CLASS_AUDIO, | |
91 .extensions = "pcm,lpcm,wav,aiff", | |
92 .probe = probe_lpcm, | |
93 .next = NULL | |
94 }; |