protocols: Support content-type-v1 proto (#9226)
This commit is contained in:
parent
70d94fec13
commit
31431a9271
20 changed files with 386 additions and 94 deletions
37
src/protocols/types/ContentType.cpp
Normal file
37
src/protocols/types/ContentType.cpp
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#include "ContentType.hpp"
|
||||
#include <drm_mode.h>
|
||||
#include <stdexcept>
|
||||
#include <format>
|
||||
|
||||
namespace NContentType {
|
||||
static std::unordered_map<std::string, eContentType> const table = {
|
||||
{"none", CONTENT_TYPE_NONE}, {"photo", CONTENT_TYPE_PHOTO}, {"video", CONTENT_TYPE_VIDEO}, {"game", CONTENT_TYPE_GAME}};
|
||||
|
||||
eContentType fromString(const std::string name) {
|
||||
auto it = table.find(name);
|
||||
if (it != table.end())
|
||||
return it->second;
|
||||
else
|
||||
throw std::invalid_argument(std::format("Unknown content type {}", name));
|
||||
}
|
||||
|
||||
eContentType fromWP(wpContentTypeV1Type contentType) {
|
||||
switch (contentType) {
|
||||
case WP_CONTENT_TYPE_V1_TYPE_NONE: return CONTENT_TYPE_NONE;
|
||||
case WP_CONTENT_TYPE_V1_TYPE_PHOTO: return CONTENT_TYPE_PHOTO;
|
||||
case WP_CONTENT_TYPE_V1_TYPE_VIDEO: return CONTENT_TYPE_VIDEO;
|
||||
case WP_CONTENT_TYPE_V1_TYPE_GAME: return CONTENT_TYPE_GAME;
|
||||
default: return CONTENT_TYPE_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t toDRM(eContentType contentType) {
|
||||
switch (contentType) {
|
||||
case CONTENT_TYPE_NONE: return DRM_MODE_CONTENT_TYPE_GRAPHICS;
|
||||
case CONTENT_TYPE_PHOTO: return DRM_MODE_CONTENT_TYPE_PHOTO;
|
||||
case CONTENT_TYPE_VIDEO: return DRM_MODE_CONTENT_TYPE_CINEMA;
|
||||
case CONTENT_TYPE_GAME: return DRM_MODE_CONTENT_TYPE_GAME;
|
||||
default: return DRM_MODE_CONTENT_TYPE_NO_DATA;
|
||||
}
|
||||
}
|
||||
}
|
||||
18
src/protocols/types/ContentType.hpp
Normal file
18
src/protocols/types/ContentType.hpp
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#pragma once
|
||||
|
||||
#include "content-type-v1.hpp"
|
||||
#include <cstdint>
|
||||
|
||||
namespace NContentType {
|
||||
|
||||
enum eContentType : uint8_t {
|
||||
CONTENT_TYPE_NONE = 0,
|
||||
CONTENT_TYPE_PHOTO = 1,
|
||||
CONTENT_TYPE_VIDEO = 2,
|
||||
CONTENT_TYPE_GAME = 3,
|
||||
};
|
||||
|
||||
eContentType fromString(const std::string name);
|
||||
eContentType fromWP(wpContentTypeV1Type contentType);
|
||||
uint16_t toDRM(eContentType contentType);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue