1 // FFMPEG Video Encoder Integration for OBS Studio
2 // Copyright (c) 2019 Michael Fabian Dirks <info@xaymar.com>
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining a copy
5 // of this software and associated documentation files (the "Software"), to deal
6 // in the Software without restriction, including without limitation the rights
7 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 // copies of the Software, and to permit persons to whom the Software is
9 // furnished to do so, subject to the following conditions:
10 //
11 // The above copyright notice and this permission notice shall be included in all
12 // copies or substantial portions of the Software.
13 //
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 // SOFTWARE.
21 
22 #pragma once
23 #include "handler.hpp"
24 
25 extern "C" {
26 #pragma warning(push)
27 #pragma warning(disable : 4244)
28 #include <libavcodec/avcodec.h>
29 #pragma warning(pop)
30 }
31 
32 namespace streamfx::encoder::ffmpeg::handler {
33 	class nvenc_hevc_handler : public handler {
34 		public:
~nvenc_hevc_handler()35 		virtual ~nvenc_hevc_handler(){};
36 
37 		public /*factory*/:
38 		virtual void adjust_info(ffmpeg_factory* factory, const AVCodec* codec, std::string& id, std::string& name,
39 								 std::string& codec_id);
40 
41 		virtual void get_defaults(obs_data_t* settings, const AVCodec* codec, AVCodecContext* context, bool hw_encode);
42 
43 		public /*support tests*/:
44 		virtual bool has_keyframe_support(ffmpeg_factory* instance);
45 
46 		virtual bool is_hardware_encoder(ffmpeg_factory* instance);
47 
48 		virtual bool has_threading_support(ffmpeg_factory* instance);
49 
50 		virtual bool has_pixel_format_support(ffmpeg_factory* instance);
51 
52 		public /*settings*/:
53 		virtual void get_properties(obs_properties_t* props, const AVCodec* codec, AVCodecContext* context,
54 									bool hw_encode);
55 
56 		virtual void migrate(obs_data_t* settings, uint64_t version, const AVCodec* codec, AVCodecContext* context);
57 
58 		virtual void update(obs_data_t* settings, const AVCodec* codec, AVCodecContext* context);
59 
60 		virtual void override_update(ffmpeg_instance* instance, obs_data_t* settings);
61 
62 		virtual void log_options(obs_data_t* settings, const AVCodec* codec, AVCodecContext* context);
63 
64 		private:
65 		void get_encoder_properties(obs_properties_t* props, const AVCodec* codec);
66 
67 		void get_runtime_properties(obs_properties_t* props, const AVCodec* codec, AVCodecContext* context);
68 	};
69 } // namespace streamfx::encoder::ffmpeg::handler
70