summaryrefslogtreecommitdiff
path: root/libgupnp-dlna/gupnp-dlna-profile-guesser-impl.c
blob: 785b45729100ef95179bf081a2d36dc8d63f7760 (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
/*
 * Copyright (C) 2010 Nokia Corporation.
 * Copyright (C) 2012 Intel Corporation.
 *
 * Authors: Arun Raghavan <arun.raghavan@collabora.co.uk>
 *          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.
 */

#include "gupnp-dlna-profile-guesser-impl.h"

G_DEFINE_ABSTRACT_TYPE (GUPnPDLNAProfileGuesserImpl,
                        gupnp_dlna_profile_guesser_impl,
                        G_TYPE_OBJECT)

struct _GUPnPDLNAProfileGuesserImplPrivate {
        gpointer placeholder;
};

static void
gupnp_dlna_profile_guesser_impl_class_init
                          (GUPnPDLNAProfileGuesserImplClass *guesser_impl_class)
{
        g_type_class_add_private (guesser_impl_class,
                                  sizeof (GUPnPDLNAProfileGuesserImplPrivate));
}

static void
gupnp_dlna_profile_guesser_impl_init (GUPnPDLNAProfileGuesserImpl *self)
{
        GUPnPDLNAProfileGuesserImplPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE
                                        (self,
                                         GUPNP_TYPE_DLNA_PROFILE_GUESSER_IMPL,
                                         GUPnPDLNAProfileGuesserImplPrivate);

        self->priv = priv;
}

GUPnPDLNAProfile *
gupnp_dlna_profile_guesser_impl_guess_profile
                                     (GUPnPDLNAProfileGuesserImpl *guesser_impl,
                                      GUPnPDLNAInformation        *info,
                                      GList                       *profiles)
{
        GUPnPDLNAVideoInformation *video_info =
                            gupnp_dlna_information_get_video_information (info);
        GUPnPDLNAAudioInformation *audio_info =
                            gupnp_dlna_information_get_audio_information (info);
        GUPnPDLNAImageInformation *image_info =
                            gupnp_dlna_information_get_image_information (info);
        GUPnPDLNAProfile *profile = NULL;
        GUPnPDLNAProfileGuesserImplClass *guesser_impl_class =
                       GUPNP_DLNA_PROFILE_GUESSER_IMPL_GET_CLASS (guesser_impl);

        g_return_val_if_fail
                 (GUPNP_IS_DLNA_PROFILE_GUESSER_IMPL_CLASS (guesser_impl_class),
                  NULL);

        if (image_info) {
                g_return_val_if_fail
                               (guesser_impl_class->guess_image_profile != NULL,
                                NULL);

                profile = guesser_impl_class->guess_image_profile (guesser_impl,
                                                                   info,
                                                                   profiles);
        } else if (video_info) {
                g_return_val_if_fail
                               (guesser_impl_class->guess_video_profile != NULL,
                                NULL);

                profile = guesser_impl_class->guess_video_profile (guesser_impl,
                                                                   info,
                                                                   profiles);
        } else if (audio_info) {
                g_return_val_if_fail
                               (guesser_impl_class->guess_audio_profile != NULL,
                                NULL);

                profile = guesser_impl_class->guess_audio_profile (guesser_impl,
                                                                   info,
                                                                   profiles);
        }

        return profile;
}