From e5bf18f2a6965fc48b45aa97bd35f41ca94751d3 Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Sun, 7 Jul 2019 13:45:01 +0200 Subject: [PATCH] ui/prores_aw_handler: Implement UI Handler for prores_aw --- CMakeLists.txt | 2 + data/locale/en-US.ini | 8 ++++ source/ui/prores_aw_handler.cpp | 77 +++++++++++++++++++++++++++++++++ source/ui/prores_aw_handler.hpp | 42 ++++++++++++++++++ 4 files changed, 129 insertions(+) create mode 100644 source/ui/prores_aw_handler.cpp create mode 100644 source/ui/prores_aw_handler.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 45482be..d9619ad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -280,6 +280,8 @@ set(PROJECT_PRIVATE "${PROJECT_SOURCE_DIR}/source/ffmpeg/tools.cpp" "${PROJECT_SOURCE_DIR}/source/ui/handler.hpp" "${PROJECT_SOURCE_DIR}/source/ui/handler.cpp" + "${PROJECT_SOURCE_DIR}/source/ui/prores_aw_handler.hpp" + "${PROJECT_SOURCE_DIR}/source/ui/prores_aw_handler.cpp" ) diff --git a/data/locale/en-US.ini b/data/locale/en-US.ini index c270c56..5a5c755 100644 --- a/data/locale/en-US.ini +++ b/data/locale/en-US.ini @@ -29,3 +29,11 @@ FFmpeg.StandardCompliance.Strict="Strict" FFmpeg.StandardCompliance.Normal="Normal" FFmpeg.StandardCompliance.Unofficial="Unofficial" FFmpeg.StandardCompliance.Experimental="Experimental" + +# Apple ProRes +AppleProRes.Profile="Profile" +AppleProRes.Profile.APCO="Proxy" +AppleProRes.Profile.APCS="LT" +AppleProRes.Profile.APCN="Standard Definition" +AppleProRes.Profile.APCH="High Quality" +AppleProRes.Profile.AP4H="4444" diff --git a/source/ui/prores_aw_handler.cpp b/source/ui/prores_aw_handler.cpp new file mode 100644 index 0000000..cb2cb6a --- /dev/null +++ b/source/ui/prores_aw_handler.cpp @@ -0,0 +1,77 @@ +// FFMPEG Video Encoder Integration for OBS Studio +// Copyright (C) 2018 - 2019 Michael Fabian Dirks +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program 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 this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +#include "prores_aw_handler.hpp" +#include "plugin.hpp" +#include "utility.hpp" + +extern "C" { +#include +} + +#define P_PROFILE "AppleProRes.Profile" +#define P_PROFILE_APCO "AppleProRes.Profile.APCO" +#define P_PROFILE_APCS "AppleProRes.Profile.APCS" +#define P_PROFILE_APCN "AppleProRes.Profile.APCN" +#define P_PROFILE_APCH "AppleProRes.Profile.APCH" +#define P_PROFILE_AP4H "AppleProRes.Profile.AP4H" + +INITIALIZER(prores_aw_handler_init) +{ + obsffmpeg::initializers.push_back([]() { + obsffmpeg::register_codec_handler("prores_aw", std::make_shared()); + }); +}; + +void obsffmpeg::ui::prores_aw_handler::get_defaults(obs_data_t* settings, AVCodec*, AVCodecContext*) +{ + obs_data_set_default_int(settings, P_PROFILE, 0); +} + +void obsffmpeg::ui::prores_aw_handler::get_properties(obs_properties_t* props, AVCodec* codec, AVCodecContext*) +{ + { + auto p = obs_properties_add_list(props, P_PROFILE, TRANSLATE(P_PROFILE), OBS_COMBO_TYPE_LIST, + OBS_COMBO_FORMAT_INT); + obs_property_set_long_description(p, TRANSLATE(DESC(P_PROFILE))); + for (auto ptr = codec->profiles; ptr->profile != FF_PROFILE_UNKNOWN; ptr++) { + if (strcmp("apco", ptr->name) == 0) { + obs_property_list_add_int(p, TRANSLATE(P_PROFILE_APCO), + static_cast(ptr->profile)); + } else if (strcmp("apcs", ptr->name) == 0) { + obs_property_list_add_int(p, TRANSLATE(P_PROFILE_APCS), + static_cast(ptr->profile)); + } else if (strcmp("apcn", ptr->name) == 0) { + obs_property_list_add_int(p, TRANSLATE(P_PROFILE_APCN), + static_cast(ptr->profile)); + } else if (strcmp("apch", ptr->name) == 0) { + obs_property_list_add_int(p, TRANSLATE(P_PROFILE_APCH), + static_cast(ptr->profile)); + } else if (strcmp("ap4h", ptr->name) == 0) { + obs_property_list_add_int(p, TRANSLATE(P_PROFILE_AP4H), + static_cast(ptr->profile)); + } else { + obs_property_list_add_int(p, ptr->name, ptr->profile); + } + } + } +} + +void obsffmpeg::ui::prores_aw_handler::update(obs_data_t* settings, AVCodec* codec, AVCodecContext* context) +{ + context->profile = obs_data_get_int(settings, P_PROFILE); +} diff --git a/source/ui/prores_aw_handler.hpp b/source/ui/prores_aw_handler.hpp new file mode 100644 index 0000000..b06c4ab --- /dev/null +++ b/source/ui/prores_aw_handler.hpp @@ -0,0 +1,42 @@ +// FFMPEG Video Encoder Integration for OBS Studio +// Copyright (C) 2018 - 2019 Michael Fabian Dirks +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program 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 this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +#pragma once +#include "handler.hpp" + +extern "C" { +#include +#pragma warning(push) +#pragma warning(disable : 4244) +#include +#pragma warning(pop) +} + +namespace obsffmpeg { + namespace ui { + class prores_aw_handler : public handler { + public: + virtual void get_defaults(obs_data_t* settings, AVCodec* codec, + AVCodecContext* context) override; + + virtual void get_properties(obs_properties_t* props, AVCodec* codec, + AVCodecContext* context) override; + + virtual void update(obs_data_t* settings, AVCodec* codec, AVCodecContext* context) override; + }; + } // namespace ui +} // namespace obsffmpeg