#include "mime-type.h"
-pa_bool_t pa_sample_spec_is_mime(const pa_sample_spec *ss, const pa_channel_map *cm) {
+bool pa_sample_spec_is_mime(const pa_sample_spec *ss, const pa_channel_map *cm) {
pa_assert(pa_channel_map_compatible(cm, ss));
ss->rate != 32000 &&
ss->rate != 44100 &&
ss->rate != 48000)
- return FALSE;
+ return false;
if (ss->channels != 1 &&
ss->channels != 2)
- return FALSE;
+ return false;
if ((cm->channels == 1 && cm->map[0] != PA_CHANNEL_POSITION_MONO) ||
(cm->channels == 2 && (cm->map[0] != PA_CHANNEL_POSITION_LEFT || cm->map[1] != PA_CHANNEL_POSITION_RIGHT)))
- return FALSE;
+ return false;
- return TRUE;
+ return true;
case PA_SAMPLE_ULAW:
if (ss->rate != 8000)
- return FALSE;
+ return false;
if (ss->channels != 1)
- return FALSE;
+ return false;
if (cm->map[0] != PA_CHANNEL_POSITION_MONO)
- return FALSE;
+ return false;
- return TRUE;
+ return true;
default:
- return FALSE;
+ return false;
}
}
char *pa_sample_spec_to_mime_type(const pa_sample_spec *ss, const pa_channel_map *cm) {
pa_assert(pa_channel_map_compatible(cm, ss));
+ pa_assert(pa_sample_spec_valid(ss));
if (!pa_sample_spec_is_mime(ss, cm))
return NULL;
case PA_SAMPLE_S16BE:
case PA_SAMPLE_S24BE:
case PA_SAMPLE_U8:
- return pa_sprintf_malloc("audio/%s; rate=%u; channels=%u",
+ /* Stupid UPnP implementations (PS3...) choke on spaces in
+ * the mime type, that's why we write only ';' here,
+ * instead of '; '. */
+ return pa_sprintf_malloc("audio/%s;rate=%u;channels=%u",
ss->format == PA_SAMPLE_S16BE ? "L16" :
(ss->format == PA_SAMPLE_S24BE ? "L24" : "L8"),
ss->rate, ss->channels);
default:
pa_assert_not_reached();
}
-
- pa_assert(pa_sample_spec_valid(ss));
}
char *pa_sample_spec_to_mime_type_mimefy(const pa_sample_spec *_ss, const pa_channel_map *_cm) {