-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
82c91e7
commit 563e2e1
Showing
38 changed files
with
539 additions
and
489 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/*GRB* | ||
Gerbera - https://gerbera.io/ | ||
cds_types.cc - this file is part of Gerbera. | ||
Copyright (C) 2005 Gena Batyan <bgeradz@mediatomb.cc>, | ||
Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc> | ||
Copyright (C) 2006-2010 Gena Batyan <bgeradz@mediatomb.cc>, | ||
Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>, | ||
Leonhard Wimmer <leo@mediatomb.cc> | ||
Copyright (C) 2016-2024 Gerbera Contributors | ||
Gerbera is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License version 2 | ||
as published by the Free Software Foundation. | ||
Gerbera 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 General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with Gerbera. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
/// \file cds_types.cc | ||
|
||
#include "cds_enums.h" // API | ||
|
||
#include <algorithm> | ||
#include <array> | ||
#include <fmt/format.h> | ||
|
||
#include "exceptions.h" | ||
#include "util/logger.h" | ||
|
||
static constexpr std::array chKeys = { | ||
std::pair(ContentHandler::DEFAULT, "Default"), | ||
#ifdef HAVE_LIBEXIF | ||
std::pair(ContentHandler::LIBEXIF, "LibExif"), | ||
#endif | ||
#ifdef HAVE_TAGLIB | ||
std::pair(ContentHandler::ID3, "TagLib"), | ||
#endif | ||
std::pair(ContentHandler::TRANSCODE, "Transcode"), | ||
std::pair(ContentHandler::EXTURL, "Exturl"), | ||
std::pair(ContentHandler::MP4, "MP4"), | ||
#ifdef HAVE_FFMPEGTHUMBNAILER | ||
std::pair(ContentHandler::FFTH, "FFmpegThumbnailer"), | ||
#endif | ||
std::pair(ContentHandler::FLAC, "Flac"), | ||
std::pair(ContentHandler::FANART, "Fanart"), | ||
std::pair(ContentHandler::CONTAINERART, "ContainerArt"), | ||
#ifdef HAVE_MATROSKA | ||
std::pair(ContentHandler::MATROSKA, "Matroska"), | ||
#endif | ||
#ifdef HAVE_WAVPACK | ||
std::pair(ContentHandler::WAVPACK, "WavPack"), | ||
#endif | ||
std::pair(ContentHandler::SUBTITLE, "Subtitle"), | ||
std::pair(ContentHandler::METAFILE, "MetaFile"), | ||
std::pair(ContentHandler::RESOURCE, "Resource"), | ||
}; | ||
|
||
bool EnumMapper::checkContentHandler(const std::string& contHandler) | ||
{ | ||
auto chEntry = std::find_if(chKeys.begin(), chKeys.end(), [contHandler](auto&& entry) { return contHandler == entry.second; }); | ||
return chEntry != chKeys.end(); | ||
} | ||
|
||
ContentHandler EnumMapper::remapContentHandler(const std::string& contHandler) | ||
{ | ||
auto chEntry = std::find_if(chKeys.begin(), chKeys.end(), [contHandler](auto&& entry) { return contHandler == entry.second; }); | ||
if (chEntry != chKeys.end()) { | ||
return chEntry->first; | ||
} | ||
throw_std_runtime_error("Invalid content handler value {}", contHandler); | ||
} | ||
|
||
ContentHandler EnumMapper::remapContentHandler(int ch) | ||
{ | ||
return static_cast<ContentHandler>(ch); | ||
} | ||
|
||
std::string EnumMapper::mapContentHandler2String(ContentHandler ch) | ||
{ | ||
auto chEntry = std::find_if(chKeys.begin(), chKeys.end(), [ch](auto&& entry) { return ch == entry.first; }); | ||
if (chEntry != chKeys.end()) { | ||
return chEntry->second; | ||
} | ||
throw_std_runtime_error("Invalid content handler value {}", ch); | ||
} | ||
|
||
std::string EnumMapper::getPurposeDisplay(ResourcePurpose purpose) | ||
{ | ||
return purposeToDisplay.at(purpose); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
/*GRB* | ||
Gerbera - https://gerbera.io/ | ||
cds_types.h - this file is part of Gerbera. | ||
Copyright (C) 2005 Gena Batyan <bgeradz@mediatomb.cc>, | ||
Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc> | ||
Copyright (C) 2006-2010 Gena Batyan <bgeradz@mediatomb.cc>, | ||
Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>, | ||
Leonhard Wimmer <leo@mediatomb.cc> | ||
Copyright (C) 2016-2024 Gerbera Contributors | ||
Gerbera is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License version 2 | ||
as published by the Free Software Foundation. | ||
Gerbera 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 General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with Gerbera. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
/// \file cds_types.h | ||
|
||
#ifndef __CDS_TYPES_H__ | ||
#define __CDS_TYPES_H__ | ||
|
||
#include <map> | ||
#include <string> | ||
|
||
// ATTENTION: These values need to be changed in web/js/items.js too. | ||
#define OBJECT_TYPE_CONTAINER 0x00000001u | ||
#define OBJECT_TYPE_ITEM 0x00000002u | ||
#define OBJECT_TYPE_ITEM_EXTERNAL_URL 0x00000008u | ||
|
||
#define STRING_OBJECT_TYPE_CONTAINER "container" | ||
#define STRING_OBJECT_TYPE_ITEM "item" | ||
#define STRING_OBJECT_TYPE_EXTERNAL_URL "external_url" | ||
|
||
static constexpr bool IS_CDS_CONTAINER(unsigned int type) | ||
{ | ||
return type & OBJECT_TYPE_CONTAINER; | ||
} | ||
static constexpr bool IS_CDS_ITEM_EXTERNAL_URL(unsigned int type) | ||
{ | ||
return type & OBJECT_TYPE_ITEM_EXTERNAL_URL; | ||
} | ||
|
||
#define OBJECT_FLAG_RESTRICTED 0x00000001u | ||
#define OBJECT_FLAG_SEARCHABLE 0x00000002u | ||
#define OBJECT_FLAG_USE_RESOURCE_REF 0x00000004u | ||
#define OBJECT_FLAG_PERSISTENT_CONTAINER 0x00000008u | ||
#define OBJECT_FLAG_PLAYLIST_REF 0x00000010u | ||
#define OBJECT_FLAG_PROXY_URL 0x00000020u | ||
#define OBJECT_FLAG_ONLINE_SERVICE 0x00000040u | ||
#define OBJECT_FLAG_OGG_THEORA 0x00000080u | ||
|
||
#define OBJECT_AUTOSCAN_NONE 0u | ||
#define OBJECT_AUTOSCAN_UI 1u | ||
#define OBJECT_AUTOSCAN_CFG 2u | ||
|
||
enum class ResourcePurpose : int { | ||
Content = 0, | ||
Thumbnail, | ||
Subtitle, | ||
Transcode | ||
}; | ||
|
||
enum class ResourceAttribute : int { | ||
SIZE = 0, | ||
DURATION, | ||
BITRATE, | ||
SAMPLEFREQUENCY, | ||
NRAUDIOCHANNELS, | ||
RESOLUTION, | ||
COLORDEPTH, | ||
PROTOCOLINFO, | ||
RESOURCE_FILE, | ||
TYPE, | ||
FANART_OBJ_ID, | ||
FANART_RES_ID, | ||
BITS_PER_SAMPLE, | ||
LANGUAGE, | ||
AUDIOCODEC, | ||
VIDEOCODEC, | ||
FORMAT, | ||
MAX | ||
}; | ||
|
||
// content handler Id's | ||
enum class ContentHandler : int { | ||
DEFAULT = 0, | ||
LIBEXIF = 1, | ||
ID3 = 2, | ||
TRANSCODE = 3, | ||
EXTURL = 4, | ||
MP4 = 5, | ||
FFTH = 6, | ||
FLAC = 7, | ||
FANART = 8, | ||
MATROSKA = 9, | ||
SUBTITLE = 10, | ||
CONTAINERART = 11, | ||
WAVPACK = 12, | ||
METAFILE = 13, | ||
RESOURCE = 20, | ||
}; | ||
|
||
class EnumMapper { | ||
private: | ||
inline static const std::map<ResourcePurpose, std::string> purposeToDisplay { | ||
{ ResourcePurpose::Content, "Content" }, | ||
{ ResourcePurpose::Thumbnail, "Thumbnail" }, | ||
{ ResourcePurpose::Subtitle, "Subtitle" }, | ||
{ ResourcePurpose::Transcode, "Transcode" }, | ||
}; | ||
|
||
public: | ||
static std::string mapContentHandler2String(ContentHandler ch); | ||
static bool checkContentHandler(const std::string& contHandler); | ||
static ContentHandler remapContentHandler(const std::string& contHandler); | ||
static ContentHandler remapContentHandler(int ch); | ||
|
||
static ResourcePurpose remapPurpose(int ip) { return static_cast<ResourcePurpose>(ip); } | ||
static std::string getPurposeDisplay(ResourcePurpose purpose); | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.