summaryrefslogtreecommitdiff
path: root/libgupnp-dlna/gupnp-dlna-image-information.c
blob: 999db40d9b10026342c1e4b03806f403d572ede8 (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
/*
 * 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-image-information
 * @short_description: Base class representing image metadata needed
 * for DLNA profiles matching.
 * @see_also: #GUPnPDLNABoolValue, #GUPnPDLNAFractionValue,
 * #GUPnPDLNAIntValue, #GUPnPDLNAStringValue
 *
 * #GUPnPDLNAImageInformation holds all image metadatas important for
 * matching profiles. Note that it does not mean all data should be
 * provided for every image file as in some cases it does not make
 * sense.
 *
 * For metadata attributes that do not exist in current image 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_image_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-image-information.h"

struct _GUPnPDLNAImageInformationPrivate {
        gpointer placeholder;
};
typedef struct _GUPnPDLNAImageInformationPrivate
        GUPnPDLNAImageInformationPrivate;

G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GUPnPDLNAImageInformation,
                                     gupnp_dlna_image_information,
                                     G_TYPE_OBJECT)

static void
gupnp_dlna_image_information_class_init
                                    (GUPnPDLNAImageInformationClass *info_class)
{
        info_class->get_depth = NULL;
        info_class->get_height = NULL;
        info_class->get_width = NULL;
        info_class->get_mime = NULL;
}

static void
gupnp_dlna_image_information_init (GUPnPDLNAImageInformation *info)
{
}

/**
 * gupnp_dlna_image_information_get_depth: (skip)
 * @info: A #GUPnPDLNAImageInformation object.
 *
 * Returns: A depth of an image.
 */
GUPnPDLNAIntValue
gupnp_dlna_image_information_get_depth (GUPnPDLNAImageInformation *info)
{
        GUPnPDLNAImageInformationClass *info_class;

        g_return_val_if_fail (GUPNP_DLNA_IS_IMAGE_INFORMATION (info),
                              GUPNP_DLNA_INT_VALUE_UNSET);

        info_class = GUPNP_DLNA_IMAGE_INFORMATION_GET_CLASS (info);

        g_return_val_if_fail
                            (GUPNP_DLNA_IS_IMAGE_INFORMATION_CLASS (info_class),
                             GUPNP_DLNA_INT_VALUE_UNSET);
        g_return_val_if_fail (info_class->get_depth != NULL,
                              GUPNP_DLNA_INT_VALUE_UNSET);

        return info_class->get_depth (info);
}

/**
 * gupnp_dlna_image_information_get_height: (skip)
 * @info: A #GUPnPDLNAImageInformation object.
 *
 * Returns: A height of an image.
 */
GUPnPDLNAIntValue
gupnp_dlna_image_information_get_height (GUPnPDLNAImageInformation *info)
{
        GUPnPDLNAImageInformationClass *info_class;

        g_return_val_if_fail (GUPNP_DLNA_IS_IMAGE_INFORMATION (info),
                              GUPNP_DLNA_INT_VALUE_UNSET);

        info_class = GUPNP_DLNA_IMAGE_INFORMATION_GET_CLASS (info);

        g_return_val_if_fail
                            (GUPNP_DLNA_IS_IMAGE_INFORMATION_CLASS (info_class),
                             GUPNP_DLNA_INT_VALUE_UNSET);
        g_return_val_if_fail (info_class->get_height != NULL,
                              GUPNP_DLNA_INT_VALUE_UNSET);

        return info_class->get_height (info);
}

/**
 * gupnp_dlna_image_information_get_width: (skip)
 * @info: A #GUPnPDLNAImageInformation object.
 *
 * Returns: A width of an image.
 */
GUPnPDLNAIntValue
gupnp_dlna_image_information_get_width (GUPnPDLNAImageInformation *info)
{
        GUPnPDLNAImageInformationClass *info_class;

        g_return_val_if_fail (GUPNP_DLNA_IS_IMAGE_INFORMATION (info),
                              GUPNP_DLNA_INT_VALUE_UNSET);

        info_class = GUPNP_DLNA_IMAGE_INFORMATION_GET_CLASS (info);

        g_return_val_if_fail
                            (GUPNP_DLNA_IS_IMAGE_INFORMATION_CLASS (info_class),
                             GUPNP_DLNA_INT_VALUE_UNSET);
        g_return_val_if_fail (info_class->get_width != NULL,
                              GUPNP_DLNA_INT_VALUE_UNSET);

        return info_class->get_width (info);
}

/**
 * gupnp_dlna_image_information_get_mime: (skip)
 * @info: A #GUPnPDLNAImageInformation object.
 *
 * Returns: A MIME type of an image.
 */
GUPnPDLNAStringValue
gupnp_dlna_image_information_get_mime (GUPnPDLNAImageInformation *info)
{
        GUPnPDLNAImageInformationClass *info_class;

        g_return_val_if_fail (GUPNP_DLNA_IS_IMAGE_INFORMATION (info),
                              GUPNP_DLNA_STRING_VALUE_UNSET);

        info_class = GUPNP_DLNA_IMAGE_INFORMATION_GET_CLASS (info);

        g_return_val_if_fail
                            (GUPNP_DLNA_IS_IMAGE_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);
}