summaryrefslogtreecommitdiff
path: root/libgupnp-dlna/gupnp-dlna-container-information.c
blob: 742449ed9c4aef24448e687167bb049253b2a654 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
/*
 * Copyright (C) 2012, 2013 Intel Corporation.
 *
 * Authors: Krzesimir Nowak <krnowak@openismus.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

/**
 * SECTION:gupnp-dlna-container-information
 * @short_description: Base class representing container metadata
 * needed for DLNA profiles matching.
 * @see_also: #GUPnPDLNABoolValue, #GUPnPDLNAFractionValue,
 * #GUPnPDLNAIntValue, #GUPnPDLNAStringValue
 *
 * #GUPnPDLNAContainerInformation holds all container metadatas
 * important for matching profiles. Note that it does not mean all
 * data should be provided for every media file as in some cases it
 * does not make sense (e.g. MPEG version does not make sense for WMA
 * media files).
 *
 * For metadata attributes that do not exist in current media file an
 * unset value should be returned. For metadata attributes that do
 * exist a set value with proper underlying value should be
 * returned. In case metadata extractor has completely no clue how to
 * extract some metadata attribute at all, an unsupported value should
 * be returned. Note that unsupported values should be a temporary
 * mean before fixing the multimedia framework to be able to extract
 * such attribute.
 *
 * Note that gupnp_dlna_container_information_get_mime() should always
 * return a set value. Otherwise it is highly probably that the file
 * will not match against any DLNA profile.
 */

#include "gupnp-dlna-container-information.h"

struct _GUPnPDLNAContainerInformationPrivate {
        gpointer placeholder;
};
typedef struct _GUPnPDLNAContainerInformationPrivate
        GUPnPDLNAContainerInformationPrivate;

G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GUPnPDLNAContainerInformation,
                                     gupnp_dlna_container_information,
                                     G_TYPE_OBJECT)

static void
gupnp_dlna_container_information_class_init
                                (GUPnPDLNAContainerInformationClass *info_class)
{
        info_class->get_mpeg_version = NULL;
        info_class->get_packet_size = NULL;
        info_class->get_profile = NULL;
        info_class->is_system_stream = NULL;
        info_class->get_variant = NULL;
        info_class->get_mime = NULL;
}

static void
gupnp_dlna_container_information_init (GUPnPDLNAContainerInformation *info)
{
}

/**
 * gupnp_dlna_container_information_get_mpeg_version: (skip)
 * @info: A #GUPnPDLNAContainerInformation object.
 *
 * Returns: An MPEG version.
 */
GUPnPDLNAIntValue
gupnp_dlna_container_information_get_mpeg_version
                                        (GUPnPDLNAContainerInformation *info)
{
        GUPnPDLNAContainerInformationClass *info_class;

        g_return_val_if_fail (GUPNP_DLNA_IS_CONTAINER_INFORMATION (info),
                              GUPNP_DLNA_INT_VALUE_UNSET);

        info_class = GUPNP_DLNA_CONTAINER_INFORMATION_GET_CLASS (info);

        g_return_val_if_fail
                        (GUPNP_DLNA_IS_CONTAINER_INFORMATION_CLASS (info_class),
                         GUPNP_DLNA_INT_VALUE_UNSET);
        g_return_val_if_fail (info_class->get_mpeg_version != NULL,
                              GUPNP_DLNA_INT_VALUE_UNSET);

        return info_class->get_mpeg_version (info);
}

/**
 * gupnp_dlna_container_information_get_packet_size: (skip)
 * @info: A #GUPnPDLNAContainerInformation object.
 *
 * Returns: A packet size.
 */
GUPnPDLNAIntValue
gupnp_dlna_container_information_get_packet_size
                                        (GUPnPDLNAContainerInformation *info)
{
        GUPnPDLNAContainerInformationClass *info_class;

        g_return_val_if_fail (GUPNP_DLNA_IS_CONTAINER_INFORMATION (info),
                              GUPNP_DLNA_INT_VALUE_UNSET);

        info_class = GUPNP_DLNA_CONTAINER_INFORMATION_GET_CLASS (info);

        g_return_val_if_fail
                        (GUPNP_DLNA_IS_CONTAINER_INFORMATION_CLASS (info_class),
                         GUPNP_DLNA_INT_VALUE_UNSET);
        g_return_val_if_fail (info_class->get_packet_size != NULL,
                              GUPNP_DLNA_INT_VALUE_UNSET);

        return info_class->get_packet_size (info);
}

/**
 * gupnp_dlna_container_information_get_profile: (skip)
 * @info: A #GUPnPDLNAContainerInformation object.
 *
 * Returns: A profile.
 */
GUPnPDLNAStringValue
gupnp_dlna_container_information_get_profile
                                        (GUPnPDLNAContainerInformation *info)
{
        GUPnPDLNAContainerInformationClass *info_class;

        g_return_val_if_fail (GUPNP_DLNA_IS_CONTAINER_INFORMATION (info),
                              GUPNP_DLNA_STRING_VALUE_UNSET);

        info_class = GUPNP_DLNA_CONTAINER_INFORMATION_GET_CLASS (info);

        g_return_val_if_fail
                        (GUPNP_DLNA_IS_CONTAINER_INFORMATION_CLASS (info_class),
                         GUPNP_DLNA_STRING_VALUE_UNSET);
        g_return_val_if_fail (info_class->get_profile != NULL,
                              GUPNP_DLNA_STRING_VALUE_UNSET);

        return info_class->get_profile (info);
}

/**
 * gupnp_dlna_container_information_is_system_stream: (skip)
 * @info: A #GUPnPDLNAContainerInformation object.
 *
 * Returns: Whether it is system stream.
 */
GUPnPDLNABoolValue
gupnp_dlna_container_information_is_system_stream
                                        (GUPnPDLNAContainerInformation *info)
{
        GUPnPDLNAContainerInformationClass *info_class;

        g_return_val_if_fail (GUPNP_DLNA_IS_CONTAINER_INFORMATION (info),
                              GUPNP_DLNA_BOOL_VALUE_UNSET);

        info_class = GUPNP_DLNA_CONTAINER_INFORMATION_GET_CLASS (info);

        g_return_val_if_fail
                        (GUPNP_DLNA_IS_CONTAINER_INFORMATION_CLASS (info_class),
                         GUPNP_DLNA_BOOL_VALUE_UNSET);
        g_return_val_if_fail (info_class->is_system_stream != NULL,
                              GUPNP_DLNA_BOOL_VALUE_UNSET);

        return info_class->is_system_stream (info);
}

/**
 * gupnp_dlna_container_information_get_variant: (skip)
 * @info: A #GUPnPDLNAContainerInformation object.
 *
 * Returns: A variant.
 */
GUPnPDLNAStringValue
gupnp_dlna_container_information_get_variant
                                        (GUPnPDLNAContainerInformation *info)
{
        GUPnPDLNAContainerInformationClass *info_class;

        g_return_val_if_fail (GUPNP_DLNA_IS_CONTAINER_INFORMATION (info),
                              GUPNP_DLNA_STRING_VALUE_UNSET);

        info_class = GUPNP_DLNA_CONTAINER_INFORMATION_GET_CLASS (info);

        g_return_val_if_fail
                        (GUPNP_DLNA_IS_CONTAINER_INFORMATION_CLASS (info_class),
                         GUPNP_DLNA_STRING_VALUE_UNSET);
        g_return_val_if_fail (info_class->get_variant != NULL,
                              GUPNP_DLNA_STRING_VALUE_UNSET);

        return info_class->get_variant (info);
}

/**
 * gupnp_dlna_container_information_get_mime: (skip)
 * @info: A #GUPnPDLNAContainerInformation object.
 *
 * Returns: A MIME type.
 */
GUPnPDLNAStringValue
gupnp_dlna_container_information_get_mime (GUPnPDLNAContainerInformation *info)
{
        GUPnPDLNAContainerInformationClass *info_class;

        g_return_val_if_fail (GUPNP_DLNA_IS_CONTAINER_INFORMATION (info),
                              GUPNP_DLNA_STRING_VALUE_UNSET);

        info_class = GUPNP_DLNA_CONTAINER_INFORMATION_GET_CLASS (info);

        g_return_val_if_fail
                        (GUPNP_DLNA_IS_CONTAINER_INFORMATION_CLASS (info_class),
                         GUPNP_DLNA_STRING_VALUE_UNSET);
        g_return_val_if_fail (info_class->get_mime != NULL,
                              GUPNP_DLNA_STRING_VALUE_UNSET);

        return info_class->get_mime (info);
}