annotate m_struct.h @ 37185:917a3c4c2d39

lavf: fix AVSEEK_SIZE when STREAM_CTRL_GET_SIZE is not implemented. Would set the size to an uninitialized value before.
author reimar
date Wed, 17 Sep 2014 17:49:54 +0000
parents 36d586f37e26
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30429
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 26029
diff changeset
1 /*
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 26029
diff changeset
2 * This file is part of MPlayer.
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 26029
diff changeset
3 *
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 26029
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 26029
diff changeset
5 * it under the terms of the GNU General Public License as published by
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 26029
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 26029
diff changeset
7 * (at your option) any later version.
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 26029
diff changeset
8 *
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 26029
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 26029
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 26029
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 26029
diff changeset
12 * GNU General Public License for more details.
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 26029
diff changeset
13 *
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 26029
diff changeset
14 * You should have received a copy of the GNU General Public License along
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 26029
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 26029
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 26029
diff changeset
17 */
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 26029
diff changeset
18
26029
4129c8cfa742 Add MPLAYER_ prefix to multiple inclusion guards.
diego
parents: 24966
diff changeset
19 #ifndef MPLAYER_M_STRUCT_H
4129c8cfa742 Add MPLAYER_ prefix to multiple inclusion guards.
diego
parents: 24966
diff changeset
20 #define MPLAYER_M_STRUCT_H
8169
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
21
36768
fd1feb8ae5fd m_struct: use offsetof instead of a custom hack.
reimar
parents: 33882
diff changeset
22 #include <stddef.h>
37184
36d586f37e26 Add stdint.h include for intptr_t.
reimar
parents: 37183
diff changeset
23 #include <stdint.h>
36768
fd1feb8ae5fd m_struct: use offsetof instead of a custom hack.
reimar
parents: 33882
diff changeset
24
18258
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
25 /// \defgroup OptionsStruct Options struct
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
26 /// \ingroup Options
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
27 /// An API to manipulate structs using m_option.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
28 ///@{
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
29
33882
08a90b0e44e1 doxygen: drop filename from @file directive
diego
parents: 30695
diff changeset
30 /// \file
8169
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
31
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
32 struct m_option;
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
33
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
34 /// Struct definition
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
35 typedef struct m_struct_st {
18283
67d35fe89c8d Fix most of the mistakes pointed out by Diego.
albeu
parents: 18258
diff changeset
36 /// For error messages and debugging
19194
5949a654e2d4 marks some read-only char* inside structs as const, patch by Stefan Huehner, stefan At huehner-org
reynaldo
parents: 19104
diff changeset
37 const char* name;
18258
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
38 /// size of the whole struct
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
39 unsigned int size;
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
40 /// Pointer to a struct filled with the default settings
22027
0b262e00bc99 Mark m_struct_t defaults as const
reimar
parents: 19194
diff changeset
41 const void* defaults;
18258
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
42 /// Field list.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
43 /** The p field of the \ref m_option struct must contain the offset
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
44 * of the member in the struct (use M_ST_OFF macro for this).
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
45 */
24966
cc170348a763 correct const usage in the option handling code so that tables can be
rfelker
parents: 23689
diff changeset
46 const struct m_option* fields;
8169
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
47 } m_struct_t;
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
48
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
49
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
50 // From glib.h (modified ;-)
18258
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
51
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
52 /// Get the offset of a struct field.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
53 /** \param struct_type Struct type.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
54 * \param member Name of the field.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
55 * \return The offset of the field in bytes.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
56 */
8169
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
57 #define M_ST_OFF(struct_type, member) \
36768
fd1feb8ae5fd m_struct: use offsetof instead of a custom hack.
reimar
parents: 33882
diff changeset
58 ((void*)offsetof(struct_type, member))
18258
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
59
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
60 /// Get a pointer to a struct field.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
61 /** \param struct_p Pointer to the struct.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
62 * \param struct_offset Offset of the field in the struct.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
63 * \return Pointer to the struct field.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
64 */
8169
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
65 #define M_ST_MB_P(struct_p, struct_offset) \
37183
eaa58d991a06 Use intptr_t to cast a pointer.
reimar
parents: 36768
diff changeset
66 ((void *)((char *)(struct_p) + (intptr_t)(struct_offset)))
18258
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
67
23612
10a64a994a16 Some comment typo fixes
reimar
parents: 22027
diff changeset
68 /// Access a struct field at a given offset.
18258
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
69 /** \param member_type Type of the field.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
70 * \param struct_p Pointer to the struct.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
71 * \param struct_offset Offset of the field in the struct.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
72 * \return The struct field at the given offset.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
73 */
8169
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
74 #define M_ST_MB(member_type, struct_p, struct_offset) \
9586
albeu
parents: 8169
diff changeset
75 (*(member_type*) M_ST_MB_P ((struct_p), (struct_offset)))
8169
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
76
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
77
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
78
18258
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
79 /// Allocate the struct and set it to the defaults.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
80 /** \param st Struct definition.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
81 * \return The newly allocated object set to default.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
82 */
8169
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
83 void*
24966
cc170348a763 correct const usage in the option handling code so that tables can be
rfelker
parents: 23689
diff changeset
84 m_struct_alloc(const m_struct_t* st);
18258
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
85
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
86 /// Set a field of the struct.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
87 /** \param st Struct definition.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
88 * \param obj Pointer to the struct to set.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
89 * \param field Name of the field to set.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
90 * \param param New value of the field.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
91 * \return 0 on error, 1 on success.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
92 */
8169
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
93 int
30695
a26f6577d338 Make more option-parsing related function arguments const.
reimar
parents: 30429
diff changeset
94 m_struct_set(const m_struct_t* st, void* obj, const char* field, const char* param);
18258
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
95
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
96 /// Reset a field (or all if field == NULL) to defaults.
23612
10a64a994a16 Some comment typo fixes
reimar
parents: 22027
diff changeset
97 /** \param st Struct definition.
18258
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
98 * \param obj Pointer to the struct to set.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
99 * \param field Name of the field to reset, if NULL all fields are reseted.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
100 */
8169
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
101 void
24966
cc170348a763 correct const usage in the option handling code so that tables can be
rfelker
parents: 23689
diff changeset
102 m_struct_reset(const m_struct_t* st, void* obj, const char* field);
18258
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
103
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
104 /// Create a copy of an existing struct.
23612
10a64a994a16 Some comment typo fixes
reimar
parents: 22027
diff changeset
105 /** \param st Struct definition.
18258
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
106 * \param obj Pointer to the struct to copy.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
107 * \return Newly allocated copy of obj.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
108 */
8169
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
109 void*
24966
cc170348a763 correct const usage in the option handling code so that tables can be
rfelker
parents: 23689
diff changeset
110 m_struct_copy(const m_struct_t* st, void* obj);
18258
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
111
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
112 /// Free an allocated struct.
23612
10a64a994a16 Some comment typo fixes
reimar
parents: 22027
diff changeset
113 /** \param st Struct definition.
18258
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
114 * \param obj Pointer to the struct to copy.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
115 */
8169
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
116 void
24966
cc170348a763 correct const usage in the option handling code so that tables can be
rfelker
parents: 23689
diff changeset
117 m_struct_free(const m_struct_t* st, void* obj);
18258
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
118
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
119 /// Get a field description.
23612
10a64a994a16 Some comment typo fixes
reimar
parents: 22027
diff changeset
120 /** \param st Struct definition.
18258
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
121 * \param f Name of the field.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
122 * \return The \ref m_option struct describing the field or NULL if not found.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
123 */
24966
cc170348a763 correct const usage in the option handling code so that tables can be
rfelker
parents: 23689
diff changeset
124 const struct m_option*
cc170348a763 correct const usage in the option handling code so that tables can be
rfelker
parents: 23689
diff changeset
125 m_struct_get_field(const m_struct_t* st,const char* f);
8169
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
126
18258
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
127 ///@}
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
128
26029
4129c8cfa742 Add MPLAYER_ prefix to multiple inclusion guards.
diego
parents: 24966
diff changeset
129 #endif /* MPLAYER_M_STRUCT_H */