1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date        : 2017-09-24
7  * Description : a media server to export collections through DLNA.
8  *               Implementation inspired on Platinum File Media Server.
9  *
10  * Copyright (C) 2017-2021 by Gilles Caulier <caulier dot gilles at gmail dot com>
11  *
12  * This program is free software; you can redistribute it
13  * and/or modify it under the terms of the GNU General
14  * Public License as published by the Free Software Foundation;
15  * either version 2, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * ============================================================ */
23 
24 #ifndef DIGIKAM_DLNA_SERVER_H
25 #define DIGIKAM_DLNA_SERVER_H
26 
27 // Qt includes
28 
29 #include <QImage>
30 #include <QString>
31 #include <QByteArray>
32 
33 // Qt includes
34 
35 #include <QApplication>
36 #include <QStandardPaths>
37 #include <QBuffer>
38 #include <QIODevice>
39 
40 // Local includes
41 
42 #include "digikam_debug.h"
43 #include "dmediaserver.h"
44 #include "dlnaserverdelegate.h"
45 
46 // Platinum includes
47 
48 #include "Neptune.h"
49 #include "PltMediaServer.h"
50 
51 using namespace Digikam;
52 
53 namespace DigikamGenericMediaServerPlugin
54 {
55 
56 /**
57  * File Media Server for digiKam.
58  * The DLNAMediaServer class is based on PLT_MediaServer implementation
59  * for a file system backed Media Server with album contents.
60  */
61 class DLNAMediaServer : public PLT_MediaServer,
62                         public DLNAMediaServerDelegate
63 {
64 
65 public:
66 
67     explicit DLNAMediaServer(const char*  friendly_name,
68                              bool         show_ip = false,
69                              const char*  uuid = nullptr,
70                              NPT_UInt16   port = 0,
71                              bool         port_rebind = false);
72 
73     void addAlbumsOnServer(const MediaServerMap& map);
74 
75     NPT_Result SetupIcons() override;
76 
77 protected:
78 
79     ~DLNAMediaServer()      override;
80 
81 private:
82 
83     QByteArray iconData(const QImage& img, int size, QString& uri, int& depth) const;
84 };
85 
86 } // namespace DigikamGenericMediaServerPlugin
87 
88 #endif // DIGIKAM_DLNA_SERVER_H
89