Git init
[framework/multimedia/pulseaudio.git] / src / pulsecore / tagstruct.h
1 #ifndef footagstructhfoo
2 #define footagstructhfoo
3
4 /***
5   This file is part of PulseAudio.
6
7   Copyright 2004-2006 Lennart Poettering
8
9   PulseAudio is free software; you can redistribute it and/or modify
10   it under the terms of the GNU Lesser General Public License as
11   published by the Free Software Foundation; either version 2.1 of the
12   License, or (at your option) any later version.
13
14   PulseAudio is distributed in the hope that it will be useful, but
15   WITHOUT ANY WARRANTY; without even the implied warranty of
16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17   Lesser General Public License for more details.
18
19   You should have received a copy of the GNU Lesser General Public
20   License along with PulseAudio; if not, write to the Free Software
21   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22   USA.
23 ***/
24
25 #include <inttypes.h>
26 #include <sys/types.h>
27 #include <sys/time.h>
28 #include <time.h>
29
30 #include <pulse/sample.h>
31 #include <pulse/channelmap.h>
32 #include <pulse/volume.h>
33 #include <pulse/proplist.h>
34 #include <pulse/gccmacro.h>
35
36 #include <pulsecore/macro.h>
37
38 typedef struct pa_tagstruct pa_tagstruct;
39
40 /* Due to a stupid design flaw, proplists may only be at the END of a
41  * packet or not before a STRING! Don't forget that! We can't really
42  * fix this without breaking compat. */
43
44 enum {
45     PA_TAG_INVALID = 0,
46     PA_TAG_STRING = 't',
47     PA_TAG_STRING_NULL = 'N',
48     PA_TAG_U32 = 'L',
49     PA_TAG_U8 = 'B',
50     PA_TAG_U64 = 'R',
51     PA_TAG_S64 = 'r',
52     PA_TAG_SAMPLE_SPEC = 'a',
53     PA_TAG_ARBITRARY = 'x',
54     PA_TAG_BOOLEAN_TRUE = '1',
55     PA_TAG_BOOLEAN_FALSE = '0',
56     PA_TAG_BOOLEAN = PA_TAG_BOOLEAN_TRUE,
57     PA_TAG_TIMEVAL = 'T',
58     PA_TAG_USEC = 'U'  /* 64bit unsigned */,
59     PA_TAG_CHANNEL_MAP = 'm',
60     PA_TAG_CVOLUME = 'v',
61     PA_TAG_PROPLIST = 'P',
62     PA_TAG_VOLUME = 'V'
63 };
64
65 pa_tagstruct *pa_tagstruct_new(const uint8_t* data, size_t length);
66 void pa_tagstruct_free(pa_tagstruct*t);
67 uint8_t* pa_tagstruct_free_data(pa_tagstruct*t, size_t *l);
68
69 int pa_tagstruct_eof(pa_tagstruct*t);
70 const uint8_t* pa_tagstruct_data(pa_tagstruct*t, size_t *l);
71
72 void pa_tagstruct_put(pa_tagstruct *t, ...);
73
74 void pa_tagstruct_puts(pa_tagstruct*t, const char *s);
75 void pa_tagstruct_putu8(pa_tagstruct*t, uint8_t c);
76 void pa_tagstruct_putu32(pa_tagstruct*t, uint32_t i);
77 void pa_tagstruct_putu64(pa_tagstruct*t, uint64_t i);
78 void pa_tagstruct_puts64(pa_tagstruct*t, int64_t i);
79 void pa_tagstruct_put_sample_spec(pa_tagstruct *t, const pa_sample_spec *ss);
80 void pa_tagstruct_put_arbitrary(pa_tagstruct*t, const void *p, size_t length);
81 void pa_tagstruct_put_boolean(pa_tagstruct*t, pa_bool_t b);
82 void pa_tagstruct_put_timeval(pa_tagstruct*t, const struct timeval *tv);
83 void pa_tagstruct_put_usec(pa_tagstruct*t, pa_usec_t u);
84 void pa_tagstruct_put_channel_map(pa_tagstruct *t, const pa_channel_map *map);
85 void pa_tagstruct_put_cvolume(pa_tagstruct *t, const pa_cvolume *cvolume);
86 void pa_tagstruct_put_proplist(pa_tagstruct *t, pa_proplist *p);
87 void pa_tagstruct_put_volume(pa_tagstruct *t, pa_volume_t volume);
88
89 int pa_tagstruct_get(pa_tagstruct *t, ...);
90
91 int pa_tagstruct_gets(pa_tagstruct*t, const char **s);
92 int pa_tagstruct_getu8(pa_tagstruct*t, uint8_t *c);
93 int pa_tagstruct_getu32(pa_tagstruct*t, uint32_t *i);
94 int pa_tagstruct_getu64(pa_tagstruct*t, uint64_t *i);
95 int pa_tagstruct_gets64(pa_tagstruct*t, int64_t *i);
96 int pa_tagstruct_get_sample_spec(pa_tagstruct *t, pa_sample_spec *ss);
97 int pa_tagstruct_get_arbitrary(pa_tagstruct *t, const void **p, size_t length);
98 int pa_tagstruct_get_boolean(pa_tagstruct *t, pa_bool_t *b);
99 int pa_tagstruct_get_timeval(pa_tagstruct*t, struct timeval *tv);
100 int pa_tagstruct_get_usec(pa_tagstruct*t, pa_usec_t *u);
101 int pa_tagstruct_get_channel_map(pa_tagstruct *t, pa_channel_map *map);
102 int pa_tagstruct_get_cvolume(pa_tagstruct *t, pa_cvolume *v);
103 int pa_tagstruct_get_proplist(pa_tagstruct *t, pa_proplist *p);
104 int pa_tagstruct_get_volume(pa_tagstruct *t, pa_volume_t *v);
105
106 #endif