summaryrefslogtreecommitdiff
path: root/src/rygel/rygel-thumbnail.vala
blob: e4f3a9cd9b01cd33de11deabf8229f46e1876b1a (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
/*
 * Copyright (C) 2008 Zeeshan Ali <zeenix@gmail.com>.
 *
 * Author: Zeeshan Ali <zeenix@gmail.com>
 *
 * This file is part of Rygel.
 *
 * Rygel 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.
 *
 * Rygel 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 program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

using GUPnP;

/**
 * Represents a picture or video thumbnail.
 */
public class Rygel.Thumbnail : Rygel.IconInfo {
    public string dlna_profile;

    public Thumbnail (string mime_type = "image/jpeg",
                      string dlna_profile = "JPEG_TN",
                      string file_extension = "jpg") {
        base (mime_type, file_extension);

        this.dlna_profile = dlna_profile;
    }

    internal virtual DIDLLiteResource? add_resource (DIDLLiteItem didl_item,
                                                     string       protocol) {
        var res = didl_item.add_resource ();

        res.uri = this.uri;
        res.size64 = this.size;

        res.width = this.width;
        res.height = this.height;
        res.color_depth = this.depth;

        /* Protocol info */
        res.protocol_info = this.get_protocol_info (protocol);

        return res;
    }

    private ProtocolInfo get_protocol_info (string protocol) {
        var protocol_info = new ProtocolInfo ();

        protocol_info.mime_type = this.mime_type;
        protocol_info.dlna_profile = this.dlna_profile;
        protocol_info.protocol = protocol;
        protocol_info.dlna_flags |= DLNAFlags.INTERACTIVE_TRANSFER_MODE |
                                    DLNAFlags.BACKGROUND_TRANSFER_MODE |
                                    DLNAFlags.CONNECTION_STALL |
                                    DLNAFlags.DLNA_V15;
        protocol_info.dlna_operation = DLNAOperation.RANGE;
        protocol_info.dlna_conversion = DLNAConversion.TRANSCODED;

        return protocol_info;
    }
}