<!DOCTYPE html><html><head><title></title><style type="text/css">p.MsoNormal,p.MsoNoSpacing{margin:0}</style></head><body><div><br></div><div><br></div><div>On Mon, Dec 10, 2018, at 09:35, Shaleen Jain wrote:<br></div><blockquote type="cite" id="fastmail-quoted"><div>On Fri, 2018-12-07 at 10:01 +0100, Thomas Guillem wrote:<br></div><blockquote style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-color:rgb(114, 159, 207);border-left-style:solid;border-left-width:2px;padding-left:1ex;" type="cite"><pre><br></pre><pre>On Fri, Dec 7, 2018, at 05:43, Shaleen Jain wrote:<br></pre><blockquote style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-color:rgb(114, 159, 207);border-left-style:solid;border-left-width:2px;padding-left:1ex;" type="cite"><pre>---<br></pre><pre> modules/stream_out/Makefile.am | 2 +<br></pre><pre> modules/stream_out/chromecast/cast.cpp | 242 ++-----------------------<br></pre><pre> modules/stream_out/renderer_common.cpp | 213 ++++++++++++++++++++++<br></pre><pre> modules/stream_out/renderer_common.hpp | 109 +++++++++++<br></pre><pre> 4 files changed, 335 insertions(+), 231 deletions(-)<br></pre><pre> create mode 100644 modules/stream_out/renderer_common.cpp<br></pre><pre> create mode 100644 modules/stream_out/renderer_common.hpp<br></pre><pre><br></pre><pre>diff --git a/modules/stream_out/Makefile.am b/modules/stream_out/<br></pre><pre>Makefile.am<br></pre><pre>index 6bfc38fff2..dfb262c467 100644<br></pre><pre>--- a/modules/stream_out/Makefile.am<br></pre><pre>+++ b/modules/stream_out/Makefile.am<br></pre><pre>@@ -107,6 +107,8 @@ libdemux_chromecast_plugin_la_CPPFLAGS = $<br></pre><pre>(AM_CPPFLAGS) -Istream_out/chromecast<br></pre><pre> <br></pre><pre> libstream_out_chromecast_plugin_la_SOURCES = stream_out/chromecast/<br></pre><pre>cast.cpp stream_out/chromecast/chromecast.h \<br></pre><pre> stream_out/chromecast/<br></pre><pre>cast_channel.proto \<br></pre><pre>+ stream_out/<br></pre><pre>renderer_common.hpp \<br></pre><pre>+ stream_out/<br></pre><pre>renderer_common.cpp \<br></pre><pre> stream_out/chromecast/<br></pre><pre>chromecast_common.h stream_out/chromecast/chromecast_ctrl.cpp \<br></pre><pre> misc/webservices/json.h <br></pre><pre>misc/webservices/json.c stream_out/chromecast/<br></pre><pre>chromecast_communication.cpp<br></pre><pre> nodist_libstream_out_chromecast_plugin_la_SOURCES = stream_out/<br></pre><pre>chromecast/cast_channel.pb.cc<br></pre><pre>diff --git a/modules/stream_out/chromecast/cast.cpp b/modules/<br></pre><pre>stream_out/chromecast/cast.cpp<br></pre><pre>index 7026eb1a95..b442fc1e1e 100644<br></pre><pre>--- a/modules/stream_out/chromecast/cast.cpp<br></pre><pre>+++ b/modules/stream_out/chromecast/cast.cpp<br></pre><pre>@@ -30,6 +30,7 @@<br></pre><pre> # include "config.h"<br></pre><pre> #endif<br></pre><pre> <br></pre><pre>+#include "../renderer_common.hpp"<br></pre><pre> #include "chromecast.h"<br></pre><pre> #include <vlc_dialog.h><br></pre><pre> <br></pre><pre>@@ -157,8 +158,6 @@ struct sout_stream_sys_t<br></pre><pre> unsigned int spu_streams_count;<br></pre><pre> <br></pre><pre> private:<br></pre><pre>- std::string GetVencOption( sout_stream_t *, vlc_fourcc_t *,<br></pre><pre>- const video_format_t *, int );<br></pre><pre> std::string GetAcodecOption( sout_stream_t *, vlc_fourcc_t *, const <br></pre><pre>audio_format_t *, int );<br></pre><pre> std::string GetVcodecOption( sout_stream_t *, vlc_fourcc_t *, const <br></pre><pre>video_format_t *, int );<br></pre><pre> bool UpdateOutput( sout_stream_t * );<br></pre><pre>@@ -199,39 +198,6 @@ static const char *const ppsz_sout_options[] = {<br></pre><pre> #define HTTP_PORT_TEXT N_("HTTP port")<br></pre><pre> #define HTTP_PORT_LONGTEXT N_("This sets the HTTP port of the local <br></pre><pre>server " \<br></pre><pre> "used to stream the media to the <br></pre><pre>Chromecast.")<br></pre><pre>-#define PERF_TEXT N_( "Performance warning" )<br></pre><pre>-#define PERF_LONGTEXT N_( "Display a performance warning when <br></pre><pre>transcoding" )<br></pre><pre>-#define AUDIO_PASSTHROUGH_TEXT N_( "Enable Audio passthrough" )<br></pre><pre>-#define AUDIO_PASSTHROUGH_LONGTEXT N_( "Disable if your receiver does <br></pre><pre>not support Dolby®." )<br></pre><pre>-<br></pre><pre>-enum {<br></pre><pre>- CONVERSION_QUALITY_HIGH = 0,<br></pre><pre>- CONVERSION_QUALITY_MEDIUM = 1,<br></pre><pre>- CONVERSION_QUALITY_LOW = 2,<br></pre><pre>- CONVERSION_QUALITY_LOWCPU = 3,<br></pre><pre>-};<br></pre><pre>-<br></pre><pre>-#if defined (__ANDROID__) || defined (__arm__) || (defined <br></pre><pre>(TARGET_OS_IPHONE) && TARGET_OS_IPHONE)<br></pre><pre>-# define CONVERSION_QUALITY_DEFAULT CONVERSION_QUALITY_LOW<br></pre><pre>-#else<br></pre><pre>-# define CONVERSION_QUALITY_DEFAULT CONVERSION_QUALITY_MEDIUM<br></pre><pre>-#endif<br></pre><pre>-<br></pre><pre>-static const int conversion_quality_list[] = {<br></pre><pre>- CONVERSION_QUALITY_HIGH,<br></pre><pre>- CONVERSION_QUALITY_MEDIUM,<br></pre><pre>- CONVERSION_QUALITY_LOW,<br></pre><pre>- CONVERSION_QUALITY_LOWCPU,<br></pre><pre>-};<br></pre><pre>-static const char *const conversion_quality_list_text[] = {<br></pre><pre>- N_( "High (high quality and high bandwidth)" ),<br></pre><pre>- N_( "Medium (medium quality and medium bandwidth)" ),<br></pre><pre>- N_( "Low (low quality and low bandwidth)" ),<br></pre><pre>- N_( "Low CPU (low quality but high bandwidth)" ),<br></pre><pre>-};<br></pre><pre>-<br></pre><pre>-#define CONVERSION_QUALITY_TEXT N_( "Conversion quality" )<br></pre><pre>-#define CONVERSION_QUALITY_LONGTEXT N_( "Change this option to increase <br></pre><pre>conversion speed or quality." )<br></pre><pre> <br></pre><pre> #define IP_ADDR_TEXT N_("IP Address")<br></pre><pre> #define IP_ADDR_LONGTEXT N_("IP Address of the Chromecast.")<br></pre><pre>@@ -263,12 +229,7 @@ vlc_module_begin ()<br></pre><pre> add_integer(SOUT_CFG_PREFIX "http-port", HTTP_PORT, HTTP_PORT_TEXT, <br></pre><pre>HTTP_PORT_LONGTEXT, false)<br></pre><pre> add_obsolete_string(SOUT_CFG_PREFIX "mux")<br></pre><pre> add_obsolete_string(SOUT_CFG_PREFIX "mime")<br></pre><pre>- add_integer(SOUT_CFG_PREFIX "show-perf-warning", 1, PERF_TEXT, <br></pre><pre>PERF_LONGTEXT, true )<br></pre><pre>- change_private()<br></pre><pre>- add_bool(SOUT_CFG_PREFIX "audio-passthrough", false, <br></pre><pre>AUDIO_PASSTHROUGH_TEXT, AUDIO_PASSTHROUGH_LONGTEXT, false )<br></pre><pre>- add_integer(SOUT_CFG_PREFIX "conversion-quality", <br></pre><pre>CONVERSION_QUALITY_DEFAULT,<br></pre><pre>- CONVERSION_QUALITY_TEXT, CONVERSION_QUALITY_LONGTEXT, <br></pre><pre>false );<br></pre><pre>- change_integer_list(conversion_quality_list, <br></pre><pre>conversion_quality_list_text)<br></pre><pre>+ add_renderer_opts(SOUT_CFG_PREFIX)<br></pre><pre> <br></pre><pre> add_submodule()<br></pre><pre> /* sout proxy that start the cc input when all streams are loaded */<br></pre><pre>@@ -927,198 +888,16 @@ bool sout_stream_sys_t::transcodingCanFallback() const<br></pre><pre> return transcoding_state != (TRANSCODING_VIDEO|TRANSCODING_AUDIO);<br></pre><pre> }<br></pre><pre> <br></pre><pre>-static std::string GetVencVPXOption( sout_stream_t * /* p_stream */,<br></pre><pre>- const video_format_t * /* p_vid <br></pre><pre>*/,<br></pre><pre>- int /* i_quality */ )<br></pre><pre>-{<br></pre><pre>- return "venc=vpx{quality-mode=1}";<br></pre><pre>-}<br></pre><pre>-<br></pre><pre>-static std::string GetVencQSVH264Option( sout_stream_t * /* p_stream <br></pre><pre>*/,<br></pre><pre>- const video_format_t * /* <br></pre><pre>p_vid */,<br></pre><pre>- int i_quality )<br></pre><pre>-{<br></pre><pre>- std::stringstream ssout;<br></pre><pre>- static const char video_target_usage_quality[] = "quality";<br></pre><pre>- static const char video_target_usage_balanced[] = "balanced";<br></pre><pre>- static const char video_target_usage_speed[] = "speed";<br></pre><pre>- static const char video_bitrate_high[] = "vb=8000000";<br></pre><pre>- static const char video_bitrate_low[] = "vb=3000000";<br></pre><pre>- const char *psz_video_target_usage;<br></pre><pre>- const char *psz_video_bitrate;<br></pre><pre>-<br></pre><pre>- switch ( i_quality )<br></pre><pre>- {<br></pre><pre>- case CONVERSION_QUALITY_HIGH:<br></pre><pre>- psz_video_target_usage = video_target_usage_quality;<br></pre><pre>- psz_video_bitrate = video_bitrate_high;<br></pre><pre>- break;<br></pre><pre>- case CONVERSION_QUALITY_MEDIUM:<br></pre><pre>- psz_video_target_usage = video_target_usage_balanced;<br></pre><pre>- psz_video_bitrate = video_bitrate_high;<br></pre><pre>- break;<br></pre><pre>- case CONVERSION_QUALITY_LOW:<br></pre><pre>- psz_video_target_usage = video_target_usage_balanced;<br></pre><pre>- psz_video_bitrate = video_bitrate_low;<br></pre><pre>- break;<br></pre><pre>- default:<br></pre><pre>- case CONVERSION_QUALITY_LOWCPU:<br></pre><pre>- psz_video_target_usage = video_target_usage_speed;<br></pre><pre>- psz_video_bitrate = video_bitrate_low;<br></pre><pre>- break;<br></pre><pre>- }<br></pre><pre>-<br></pre><pre>- ssout << "venc=qsv{target-usage=" << psz_video_target_usage <<<br></pre><pre>- "}," << psz_video_bitrate;<br></pre><pre>- return ssout.str();<br></pre><pre>-}<br></pre><pre>-<br></pre><pre>-static std::string GetVencX264Option( sout_stream_t * /* p_stream */,<br></pre><pre>- const video_format_t *p_vid,<br></pre><pre>- int i_quality )<br></pre><pre>-{<br></pre><pre>- std::stringstream ssout;<br></pre><pre>- static const char video_x264_preset_veryfast[] = "veryfast";<br></pre><pre>- static const char video_x264_preset_ultrafast[] = "ultrafast";<br></pre><pre>- const char *psz_video_x264_preset;<br></pre><pre>- unsigned i_video_x264_crf_hd, i_video_x264_crf_720p;<br></pre><pre>-<br></pre><pre>- switch ( i_quality )<br></pre><pre>- {<br></pre><pre>- case CONVERSION_QUALITY_HIGH:<br></pre><pre>- i_video_x264_crf_hd = i_video_x264_crf_720p = 21;<br></pre><pre>- psz_video_x264_preset = video_x264_preset_veryfast;<br></pre><pre>- break;<br></pre><pre>- case CONVERSION_QUALITY_MEDIUM:<br></pre><pre>- i_video_x264_crf_hd = 23;<br></pre><pre>- i_video_x264_crf_720p = 21;<br></pre><pre>- psz_video_x264_preset = video_x264_preset_veryfast;<br></pre><pre>- break;<br></pre><pre>- case CONVERSION_QUALITY_LOW:<br></pre><pre>- i_video_x264_crf_hd = i_video_x264_crf_720p = 23;<br></pre><pre>- psz_video_x264_preset = video_x264_preset_veryfast;<br></pre><pre>- break;<br></pre><pre>- default:<br></pre><pre>- case CONVERSION_QUALITY_LOWCPU:<br></pre><pre>- i_video_x264_crf_hd = i_video_x264_crf_720p = 23;<br></pre><pre>- psz_video_x264_preset = video_x264_preset_ultrafast;<br></pre><pre>- break;<br></pre><pre>- }<br></pre><pre>-<br></pre><pre>- const bool b_hdres = p_vid->i_height == 0 || p_vid->i_height >= <br></pre><pre>800;<br></pre><pre>- unsigned i_video_x264_crf = b_hdres ? i_video_x264_crf_hd : <br></pre><pre>i_video_x264_crf_720p;<br></pre><pre>-<br></pre><pre>- ssout << "venc=x264{preset=" << psz_video_x264_preset<br></pre><pre>- << ",crf=" << i_video_x264_crf << "}";<br></pre><pre>- return ssout.str();<br></pre><pre>-}<br></pre><pre>-<br></pre><pre>-#ifdef __APPLE__<br></pre><pre>-static std::string GetVencAvcodecVTOption( sout_stream_t * /* p_stream <br></pre><pre>*/,<br></pre><pre>- const video_format_t * <br></pre><pre>p_vid,<br></pre><pre>- int i_quality )<br></pre><pre>-{<br></pre><pre>- std::stringstream ssout;<br></pre><pre>- ssout << <br></pre><pre>"venc=avcodec{codec=h264_videotoolbox,options{realtime=1}}";<br></pre><pre>- switch( i_quality )<br></pre><pre>- {<br></pre><pre>- /* Here, performances issues won't come from videotoolbox but <br></pre><pre>from<br></pre><pre>- * some old chromecast devices */<br></pre><pre>-<br></pre><pre>- case CONVERSION_QUALITY_HIGH:<br></pre><pre>- break;<br></pre><pre>- case CONVERSION_QUALITY_MEDIUM:<br></pre><pre>- ssout << ",vb=8000000";<br></pre><pre>- break;<br></pre><pre>- case CONVERSION_QUALITY_LOW:<br></pre><pre>- case CONVERSION_QUALITY_LOWCPU:<br></pre><pre>- ssout << ",vb=3000000";<br></pre><pre>- break;<br></pre><pre>- }<br></pre><pre>-<br></pre><pre>- return ssout.str();<br></pre><pre>-}<br></pre><pre>-#endif<br></pre><pre>-<br></pre><pre>-static struct<br></pre><pre>-{<br></pre><pre>- vlc_fourcc_t fcc;<br></pre><pre>- std::string (*get_opt)( sout_stream_t *, const video_format_t *, <br></pre><pre>int);<br></pre><pre>-} venc_opt_list[] = {<br></pre><pre>+venc_options venc_opt_list[] = {<br></pre><pre> #ifdef __APPLE__<br></pre><pre>- { .fcc = VLC_CODEC_H264, .get_opt = GetVencAvcodecVTOption },<br></pre><pre>+ { .fcc = VLC_CODEC_H264, .get_opt = <br></pre><pre>vlc_sout_renderer_GetVencAvcodecVTOption },<br></pre><pre> #endif<br></pre><pre>- { .fcc = VLC_CODEC_H264, .get_opt = GetVencQSVH264Option },<br></pre><pre>- { .fcc = VLC_CODEC_H264, .get_opt = GetVencX264Option },<br></pre><pre>- { .fcc = VLC_CODEC_VP8, .get_opt = GetVencVPXOption },<br></pre><pre>+ { .fcc = VLC_CODEC_H264, .get_opt = <br></pre><pre>vlc_sout_renderer_GetVencQSVH264Option },<br></pre><pre>+ { .fcc = VLC_CODEC_H264, .get_opt = <br></pre><pre>vlc_sout_renderer_GetVencX264Option },<br></pre><pre>+ { .fcc = VLC_CODEC_VP8, .get_opt = <br></pre><pre>vlc_sout_renderer_GetVencVPXOption },<br></pre><pre> { .fcc = VLC_CODEC_H264, .get_opt = NULL },<br></pre><pre> };<br></pre><pre> <br></pre></blockquote><pre><br></pre><pre>I see a lot of duplicate code between cast.cpp GetVcodecOption() and dlna.cpp GetVcodecOption()<br></pre><pre><br></pre><pre>This list should be internal to renderer_common.cpp<br></pre><pre>Renderer modules shouldn't handle what H264 encoder module need to be used. This should be done by your renderer_common.cpp helper.<br></pre><pre><br></pre><pre>The only thing that will change between renderer modules are the codecs. The way to encode for a particular codec should be hidden then."<br></pre><pre><br></pre></blockquote><pre><br></pre><pre>The problem with this is that chromecast doesn't provide a codec to use upfront.<br></pre><pre>It wait's on GetVencOption() to try every encoder before returning the codec to use.<br></pre></blockquote><div><br></div><div>I don't get it.<br></div><div><br></div><div>Why not having the following for chromecast:<br></div><div><br></div><pre class="u-article">const char *string = vlc_sout_renderer_GetVencOption(VLC_CODEC_H264);
if (!string)
string = vlc_sout_renderer_GetVencOption(VLC_CODEC_VP8);<br></pre><div><br></div><div>That way, renderer module don't have to specify which encoder module to use.<br></div><div><br></div><div>PS: you can forget the last line "{ .fcc = VLC_CODEC_H264, .get_opt = NULL }," that was always useless.<br></div><div><br></div><div><br></div><blockquote type="cite" id="fastmail-quoted"><pre><br></pre><pre><br></pre><blockquote style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-color:rgb(114, 159, 207);border-left-style:solid;border-left-width:2px;padding-left:1ex;" type="cite"><pre>You should also factorize the maxwidth/with/fps code.<br></pre><pre><br></pre><pre><br></pre><blockquote style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-color:rgb(114, 159, 207);border-left-style:solid;border-left-width:2px;padding-left:1ex;" type="cite"><pre>-std::string<br></pre><pre>-sout_stream_sys_t::GetVencOption( sout_stream_t *p_stream, vlc_fourcc_t <br></pre><pre>*p_codec_video,<br></pre><pre>- const video_format_t *p_vid, int <br></pre><pre>i_quality )<br></pre><pre>-{<br></pre><pre>- for( size_t i = (venc_opt_idx == -1 ? 0 : venc_opt_idx);<br></pre><pre>- i < ARRAY_SIZE(venc_opt_list); ++i )<br></pre><pre>- {<br></pre><pre>- std::stringstream ssout, ssvenc;<br></pre><pre>- char fourcc[5];<br></pre><pre>- ssvenc << "vcodec=";<br></pre><pre>- vlc_fourcc_to_char( venc_opt_list[i].fcc, fourcc );<br></pre><pre>- fourcc[4] = '\0';<br></pre><pre>- ssvenc << fourcc << ',';<br></pre><pre>-<br></pre><pre>- if( venc_opt_list[i].get_opt != NULL )<br></pre><pre>- ssvenc << venc_opt_list[i].get_opt( p_stream, p_vid, <br></pre><pre>i_quality ) << ',';<br></pre><pre>-<br></pre><pre>- if( venc_opt_list[i].get_opt == NULL<br></pre><pre>- || ( venc_opt_idx != -1 && (unsigned) venc_opt_idx == i) )<br></pre><pre>- {<br></pre><pre>- venc_opt_idx = i;<br></pre><pre>- *p_codec_video = venc_opt_list[i].fcc;<br></pre><pre>- return ssvenc.str();<br></pre><pre>- }<br></pre><pre>-<br></pre><pre>- /* Test if a module can encode with the specified options / <br></pre><pre>fmt_video. */<br></pre><pre>- ssout << "transcode{" << ssvenc.str() << "}:dummy";<br></pre><pre>-<br></pre><pre>- sout_stream_t *p_sout_test =<br></pre><pre>- sout_StreamChainNew( p_stream->p_sout, ssout.str().c_str(), <br></pre><pre>NULL, NULL );<br></pre><pre>-<br></pre><pre>- if( p_sout_test != NULL )<br></pre><pre>- {<br></pre><pre>- p_sout_test->obj.flags |= OBJECT_FLAGS_QUIET|<br></pre><pre>OBJECT_FLAGS_NOINTERACT;<br></pre><pre>-<br></pre><pre>- es_format_t fmt;<br></pre><pre>- es_format_InitFromVideo( &fmt, p_vid );<br></pre><pre>- fmt.i_codec = fmt.video.i_chroma = VLC_CODEC_I420;<br></pre><pre>-<br></pre><pre>- /* Test the maximum size/fps we will encode */<br></pre><pre>- fmt.video.i_visible_width = fmt.video.i_width = 1920;<br></pre><pre>- fmt.video.i_visible_height = fmt.video.i_height = 1080;<br></pre><pre>- fmt.video.i_frame_rate = 30;<br></pre><pre>- fmt.video.i_frame_rate_base = 1;<br></pre><pre>-<br></pre><pre>- void *id = sout_StreamIdAdd( p_sout_test, &fmt );<br></pre><pre>-<br></pre><pre>- es_format_Clean( &fmt );<br></pre><pre>- const bool success = id != NULL;<br></pre><pre>-<br></pre><pre>- if( id )<br></pre><pre>- sout_StreamIdDel( p_sout_test, id );<br></pre><pre>- sout_StreamChainDelete( p_sout_test, NULL );<br></pre><pre>-<br></pre><pre>- if( success )<br></pre><pre>- {<br></pre><pre>- venc_opt_idx = i;<br></pre><pre>- *p_codec_video = venc_opt_list[i].fcc;<br></pre><pre>- return ssvenc.str();<br></pre><pre>- }<br></pre><pre>- }<br></pre><pre>- }<br></pre><pre>- vlc_assert_unreachable();<br></pre><pre>-}<br></pre><pre>-<br></pre><pre> std::string<br></pre><pre> sout_stream_sys_t::GetVcodecOption( sout_stream_t *p_stream, <br></pre><pre>vlc_fourcc_t *p_codec_video,<br></pre><pre> const video_format_t *p_vid, int <br></pre><pre>i_quality )<br></pre><pre>@@ -1127,7 +906,8 @@ sout_stream_sys_t::GetVcodecOption( sout_stream_t <br></pre><pre>*p_stream, vlc_fourcc_t *p_cod<br></pre><pre> static const char video_maxres_hd[] = <br></pre><pre>"maxwidth=1920,maxheight=1080";<br></pre><pre> static const char video_maxres_720p[] = <br></pre><pre>"maxwidth=1280,maxheight=720";<br></pre><pre> <br></pre><pre>- ssout << GetVencOption( p_stream, p_codec_video, p_vid, <br></pre><pre>i_quality );<br></pre><pre>+ ssout << vlc_sout_renderer_GetVencOption( p_stream, venc_opt_idx, <br></pre><pre>venc_opt_list,<br></pre><pre>+ ARRAY_SIZE(venc_opt_list), p_codec_video, p_vid, <br></pre><pre>i_quality );<br></pre><pre> <br></pre><pre> switch ( i_quality )<br></pre><pre> {<br></pre><pre>@@ -1291,7 +1071,7 @@ bool <br></pre><pre>sout_stream_sys_t::UpdateOutput( sout_stream_t *p_stream )<br></pre><pre> if ( !canRemux )<br></pre><pre> {<br></pre><pre> if ( !perf_warning_shown && i_codec_video == 0 && <br></pre><pre>p_original_video<br></pre><pre>- && var_InheritInteger( p_stream, SOUT_CFG_PREFIX "show-perf-<br></pre><pre>warning" ) )<br></pre><pre>+ && var_InheritInteger( p_stream, RENDERER_CFG_PREFIX "show-<br></pre><pre>perf-warning" ) )<br></pre><pre> {<br></pre><pre> int res = vlc_dialog_wait_question( p_stream,<br></pre><pre> VLC_DIALOG_QUESTION_WARNING,<br></pre><pre>@@ -1304,7 +1084,7 @@ bool <br></pre><pre>sout_stream_sys_t::UpdateOutput( sout_stream_t *p_stream )<br></pre><pre> return false;<br></pre><pre> perf_warning_shown = true;<br></pre><pre> if ( res == 2 )<br></pre><pre>- config_PutInt(SOUT_CFG_PREFIX "show-perf-warning", 0 );<br></pre><pre>+ config_PutInt(RENDERER_CFG_PREFIX "show-perf-warning", <br></pre><pre>0 );<br></pre><pre> }<br></pre><pre> <br></pre><pre> const int i_quality = var_InheritInteger( p_stream, <br></pre><pre>SOUT_CFG_PREFIX "conversion-quality" );<br></pre><pre>diff --git a/modules/stream_out/renderer_common.cpp b/modules/<br></pre><pre>stream_out/renderer_common.cpp<br></pre><pre>new file mode 100644<br></pre><pre>index 0000000000..6571685a22<br></pre><pre>--- /dev/null<br></pre><pre>+++ b/modules/stream_out/renderer_common.cpp<br></pre><pre>@@ -0,0 +1,213 @@<br></pre><pre>+/<br></pre><pre>*****************************************************************************<br></pre><pre>+ * renderer_common.cpp : renderer helper functions<br></pre><pre>+ <br></pre><pre>*****************************************************************************<br></pre><pre>+ * Copyright © 2014-2018 VideoLAN<br></pre><pre>+ *<br></pre><pre>+ * Authors: Adrien Maglo <<br></pre><pre>magsoft@videolan.org<br></pre><pre>><br></pre><pre>+ * Jean-Baptiste Kempf <<br></pre><pre>jb@videolan.org<br></pre><pre>><br></pre><pre>+ * Steve Lhomme <<br></pre><pre>robux4@videolabs.io<br></pre><pre>><br></pre><pre>+ * Shaleen Jain <<br></pre><pre>shaleen@jain.sh<br></pre><pre>><br></pre><pre>+ *<br></pre><pre>+ * This program is free software; you can redistribute it and/or modify <br></pre><pre>it<br></pre><pre>+ * under the terms of the GNU Lesser General Public License as <br></pre><pre>published by<br></pre><pre>+ * the Free Software Foundation; either version 2.1 of the License, or<br></pre><pre>+ * (at your option) any later version.<br></pre><pre>+ *<br></pre><pre>+ * This program is distributed in the hope that it will be useful,<br></pre><pre>+ * but WITHOUT ANY WARRANTY; without even the implied warranty of<br></pre><pre>+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br></pre><pre>+ * GNU Lesser General Public License for more details.<br></pre><pre>+ *<br></pre><pre>+ * You should have received a copy of the GNU Lesser General Public <br></pre><pre>License<br></pre><pre>+ * along with this program; if not, write to the Free Software <br></pre><pre>Foundation,<br></pre><pre>+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.<br></pre><pre>+ <br></pre><pre>*****************************************************************************/<br></pre><pre>+<br></pre><pre>+#ifdef HAVE_CONFIG_H<br></pre><pre>+# include "config.h"<br></pre><pre>+#endif<br></pre><pre>+<br></pre><pre>+#include <assert.h><br></pre><pre>+#include <sstream><br></pre><pre>+<br></pre><pre>+#include "renderer_common.hpp"<br></pre><pre>+<br></pre><pre>+std::string<br></pre><pre>+vlc_sout_renderer_GetVencOption( sout_stream_t *p_stream, int <br></pre><pre>venc_opt_idx,<br></pre><pre>+ venc_options venc_opt_list[], size_t opt_list_length,<br></pre><pre>+ vlc_fourcc_t *p_codec_video, const video_format_t *p_vid,<br></pre><pre>+ int i_quality )<br></pre><pre>+{<br></pre><pre>+ for( size_t i = (venc_opt_idx == -1 ? 0 : venc_opt_idx);<br></pre><pre>+ i < opt_list_length; ++i )<br></pre><pre>+ {<br></pre><pre>+ std::stringstream ssout, ssvenc;<br></pre><pre>+ char fourcc[5];<br></pre><pre>+ ssvenc << "vcodec=";<br></pre><pre>+ vlc_fourcc_to_char( venc_opt_list[i].fcc, fourcc );<br></pre><pre>+ fourcc[4] = '\0';<br></pre><pre>+ ssvenc << fourcc << ',';<br></pre><pre>+<br></pre><pre>+ if( venc_opt_list[i].get_opt != NULL )<br></pre><pre>+ ssvenc << venc_opt_list[i].get_opt( p_stream, p_vid, <br></pre><pre>i_quality ) << ',';<br></pre><pre>+<br></pre><pre>+ if( venc_opt_list[i].get_opt == NULL<br></pre><pre>+ || ( venc_opt_idx != -1 && (unsigned) venc_opt_idx == i) )<br></pre><pre>+ {<br></pre><pre>+ venc_opt_idx = i;<br></pre><pre>+ *p_codec_video = venc_opt_list[i].fcc;<br></pre><pre>+ return ssvenc.str();<br></pre><pre>+ }<br></pre><pre>+<br></pre><pre>+ /* Test if a module can encode with the specified options / <br></pre><pre>fmt_video. */<br></pre><pre>+ ssout << "transcode{" << ssvenc.str() << "}:dummy";<br></pre><pre>+<br></pre><pre>+ sout_stream_t *p_sout_test =<br></pre><pre>+ sout_StreamChainNew( p_stream->p_sout, ssout.str().c_str(), <br></pre><pre>NULL, NULL );<br></pre><pre>+<br></pre><pre>+ if( p_sout_test != NULL )<br></pre><pre>+ {<br></pre><pre>+ p_sout_test->obj.flags |= OBJECT_FLAGS_QUIET|<br></pre><pre>OBJECT_FLAGS_NOINTERACT;<br></pre><pre>+<br></pre><pre>+ es_format_t fmt;<br></pre><pre>+ es_format_InitFromVideo( &fmt, p_vid );<br></pre><pre>+ fmt.i_codec = fmt.video.i_chroma = VLC_CODEC_I420;<br></pre><pre>+<br></pre><pre>+ /* Test the maximum size/fps we will encode */<br></pre><pre>+ fmt.video.i_visible_width = fmt.video.i_width = 1920;<br></pre><pre>+ fmt.video.i_visible_height = fmt.video.i_height = 1080;<br></pre><pre>+ fmt.video.i_frame_rate = 30;<br></pre><pre>+ fmt.video.i_frame_rate_base = 1;<br></pre><pre>+<br></pre><pre>+ void *id = sout_StreamIdAdd( p_sout_test, &fmt );<br></pre><pre>+<br></pre><pre>+ es_format_Clean( &fmt );<br></pre><pre>+ const bool success = id != NULL;<br></pre><pre>+<br></pre><pre>+ if( id )<br></pre><pre>+ sout_StreamIdDel( p_sout_test, id );<br></pre><pre>+ sout_StreamChainDelete( p_sout_test, NULL );<br></pre><pre>+<br></pre><pre>+ if( success )<br></pre><pre>+ {<br></pre><pre>+ venc_opt_idx = i;<br></pre><pre>+ *p_codec_video = venc_opt_list[i].fcc;<br></pre><pre>+ return ssvenc.str();<br></pre><pre>+ }<br></pre><pre>+ }<br></pre><pre>+ }<br></pre><pre>+ vlc_assert_unreachable();<br></pre><pre>+}<br></pre><pre>+<br></pre><pre>+std::string vlc_sout_renderer_GetVencVPXOption( sout_stream_t * /* <br></pre><pre>p_stream */,<br></pre><pre>+ const video_format_t * /* p_vid <br></pre><pre>*/,<br></pre><pre>+ int /* i_quality */ )<br></pre><pre>+{<br></pre><pre>+ return "venc=vpx{quality-mode=1}";<br></pre><pre>+}<br></pre><pre>+<br></pre><pre>+std::string vlc_sout_renderer_GetVencQSVH264Option( sout_stream_t * /* <br></pre><pre>p_stream */,<br></pre><pre>+ const video_format_t * /* <br></pre><pre>p_vid */,<br></pre><pre>+ int i_quality )<br></pre><pre>+{<br></pre><pre>+ std::stringstream ssout;<br></pre><pre>+ static const char video_target_usage_quality[] = "quality";<br></pre><pre>+ static const char video_target_usage_balanced[] = "balanced";<br></pre><pre>+ static const char video_target_usage_speed[] = "speed";<br></pre><pre>+ static const char video_bitrate_high[] = "vb=8000000";<br></pre><pre>+ static const char video_bitrate_low[] = "vb=3000000";<br></pre><pre>+ const char *psz_video_target_usage;<br></pre><pre>+ const char *psz_video_bitrate;<br></pre><pre>+<br></pre><pre>+ switch ( i_quality )<br></pre><pre>+ {<br></pre><pre>+ case CONVERSION_QUALITY_HIGH:<br></pre><pre>+ psz_video_target_usage = video_target_usage_quality;<br></pre><pre>+ psz_video_bitrate = video_bitrate_high;<br></pre><pre>+ break;<br></pre><pre>+ case CONVERSION_QUALITY_MEDIUM:<br></pre><pre>+ psz_video_target_usage = video_target_usage_balanced;<br></pre><pre>+ psz_video_bitrate = video_bitrate_high;<br></pre><pre>+ break;<br></pre><pre>+ case CONVERSION_QUALITY_LOW:<br></pre><pre>+ psz_video_target_usage = video_target_usage_balanced;<br></pre><pre>+ psz_video_bitrate = video_bitrate_low;<br></pre><pre>+ break;<br></pre><pre>+ default:<br></pre><pre>+ case CONVERSION_QUALITY_LOWCPU:<br></pre><pre>+ psz_video_target_usage = video_target_usage_speed;<br></pre><pre>+ psz_video_bitrate = video_bitrate_low;<br></pre><pre>+ break;<br></pre><pre>+ }<br></pre><pre>+<br></pre><pre>+ ssout << "venc=qsv{target-usage=" << psz_video_target_usage <<<br></pre><pre>+ "}," << psz_video_bitrate;<br></pre><pre>+ return ssout.str();<br></pre><pre>+}<br></pre><pre>+<br></pre><pre>+std::string vlc_sout_renderer_GetVencX264Option( sout_stream_t * /* <br></pre><pre>p_stream */,<br></pre><pre>+ const video_format_t *p_vid,<br></pre><pre>+ int i_quality )<br></pre><pre>+{<br></pre><pre>+ std::stringstream ssout;<br></pre><pre>+ static const char video_x264_preset_veryfast[] = "veryfast";<br></pre><pre>+ static const char video_x264_preset_ultrafast[] = "ultrafast";<br></pre><pre>+ const char *psz_video_x264_preset;<br></pre><pre>+ unsigned i_video_x264_crf_hd, i_video_x264_crf_720p;<br></pre><pre>+<br></pre><pre>+ switch ( i_quality )<br></pre><pre>+ {<br></pre><pre>+ case CONVERSION_QUALITY_HIGH:<br></pre><pre>+ i_video_x264_crf_hd = i_video_x264_crf_720p = 21;<br></pre><pre>+ psz_video_x264_preset = video_x264_preset_veryfast;<br></pre><pre>+ break;<br></pre><pre>+ case CONVERSION_QUALITY_MEDIUM:<br></pre><pre>+ i_video_x264_crf_hd = 23;<br></pre><pre>+ i_video_x264_crf_720p = 21;<br></pre><pre>+ psz_video_x264_preset = video_x264_preset_veryfast;<br></pre><pre>+ break;<br></pre><pre>+ case CONVERSION_QUALITY_LOW:<br></pre><pre>+ i_video_x264_crf_hd = i_video_x264_crf_720p = 23;<br></pre><pre>+ psz_video_x264_preset = video_x264_preset_veryfast;<br></pre><pre>+ break;<br></pre><pre>+ default:<br></pre><pre>+ case CONVERSION_QUALITY_LOWCPU:<br></pre><pre>+ i_video_x264_crf_hd = i_video_x264_crf_720p = 23;<br></pre><pre>+ psz_video_x264_preset = video_x264_preset_ultrafast;<br></pre><pre>+ break;<br></pre><pre>+ }<br></pre><pre>+<br></pre><pre>+ const bool b_hdres = p_vid->i_height == 0 || p_vid->i_height >= <br></pre><pre>800;<br></pre><pre>+ unsigned i_video_x264_crf = b_hdres ? i_video_x264_crf_hd : <br></pre><pre>i_video_x264_crf_720p;<br></pre><pre>+<br></pre><pre>+ ssout << "venc=x264{preset=" << psz_video_x264_preset<br></pre><pre>+ << ",crf=" << i_video_x264_crf << "}";<br></pre><pre>+ return ssout.str();<br></pre><pre>+}<br></pre><pre>+<br></pre><pre>+#ifdef __APPLE__<br></pre><pre>+std::string vlc_sout_renderer_GetVencAvcodecVTOption( sout_stream_t * /<br></pre><pre>* p_stream */,<br></pre><pre>+ const video_format_t * <br></pre><pre>p_vid,<br></pre><pre>+ int i_quality )<br></pre><pre>+{<br></pre><pre>+ std::stringstream ssout;<br></pre><pre>+ ssout << <br></pre><pre>"venc=avcodec{codec=h264_videotoolbox,options{realtime=1}}";<br></pre><pre>+ switch( i_quality )<br></pre><pre>+ {<br></pre><pre>+ /* Here, performances issues won't come from videotoolbox but <br></pre><pre>from<br></pre><pre>+ * some old chromecast devices */<br></pre><pre>+<br></pre><pre>+ case CONVERSION_QUALITY_HIGH:<br></pre><pre>+ break;<br></pre><pre>+ case CONVERSION_QUALITY_MEDIUM:<br></pre><pre>+ ssout << ",vb=8000000";<br></pre><pre>+ break;<br></pre><pre>+ case CONVERSION_QUALITY_LOW:<br></pre><pre>+ case CONVERSION_QUALITY_LOWCPU:<br></pre><pre>+ ssout << ",vb=3000000";<br></pre><pre>+ break;<br></pre><pre>+ }<br></pre><pre>+<br></pre><pre>+ return ssout.str();<br></pre><pre>+}<br></pre><pre>+#endif<br></pre><pre>diff --git a/modules/stream_out/renderer_common.hpp b/modules/<br></pre><pre>stream_out/renderer_common.hpp<br></pre><pre>new file mode 100644<br></pre><pre>index 0000000000..8233d5874b<br></pre><pre>--- /dev/null<br></pre><pre>+++ b/modules/stream_out/renderer_common.hpp<br></pre><pre>@@ -0,0 +1,109 @@<br></pre><pre>+/<br></pre><pre>*****************************************************************************<br></pre><pre>+ * renderer_common.hpp : renderer helper functions<br></pre><pre>+ <br></pre><pre>*****************************************************************************<br></pre><pre>+ * Copyright © 2014-2018 VideoLAN<br></pre><pre>+ *<br></pre><pre>+ * Authors: Adrien Maglo <<br></pre><pre>magsoft@videolan.org<br></pre><pre>><br></pre><pre>+ * Jean-Baptiste Kempf <<br></pre><pre>jb@videolan.org<br></pre><pre>><br></pre><pre>+ * Steve Lhomme <<br></pre><pre>robux4@videolabs.io<br></pre><pre>><br></pre><pre>+ * Shaleen Jain <<br></pre><pre>shaleen@jain.sh<br></pre><pre>><br></pre><pre>+ *<br></pre><pre>+ * This program is free software; you can redistribute it and/or modify <br></pre><pre>it<br></pre><pre>+ * under the terms of the GNU Lesser General Public License as <br></pre><pre>published by<br></pre><pre>+ * the Free Software Foundation; either version 2.1 of the License, or<br></pre><pre>+ * (at your option) any later version.<br></pre><pre>+ *<br></pre><pre>+ * This program is distributed in the hope that it will be useful,<br></pre><pre>+ * but WITHOUT ANY WARRANTY; without even the implied warranty of<br></pre><pre>+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br></pre><pre>+ * GNU Lesser General Public License for more details.<br></pre><pre>+ *<br></pre><pre>+ * You should have received a copy of the GNU Lesser General Public <br></pre><pre>License<br></pre><pre>+ * along with this program; if not, write to the Free Software <br></pre><pre>Foundation,<br></pre><pre>+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.<br></pre><pre>+ <br></pre><pre>*****************************************************************************/<br></pre><pre>+<br></pre><pre>+#ifndef RENDERER_COMMON_H<br></pre><pre>+#define RENDERER_COMMON_H<br></pre><pre>+<br></pre><pre>+#include <string><br></pre><pre>+<br></pre><pre>+#include <vlc_common.h><br></pre><pre>+#include <vlc_sout.h><br></pre><pre>+<br></pre><pre>+#define PERF_TEXT N_( "Performance warning" )<br></pre><pre>+#define PERF_LONGTEXT N_( "Display a performance warning when <br></pre><pre>transcoding" )<br></pre><pre>+#define AUDIO_PASSTHROUGH_TEXT N_( "Enable Audio passthrough" )<br></pre><pre>+#define AUDIO_PASSTHROUGH_LONGTEXT N_( "Disable if your receiver does <br></pre><pre>not support Dolby®." )<br></pre><pre>+#define CONVERSION_QUALITY_TEXT N_( "Conversion quality" )<br></pre><pre>+#define CONVERSION_QUALITY_LONGTEXT N_( "Change this option to increase <br></pre><pre>conversion speed or quality." )<br></pre><pre>+<br></pre><pre>+#if defined (__ANDROID__) || defined (__arm__) || (defined <br></pre><pre>(TARGET_OS_IPHONE) && TARGET_OS_IPHONE)<br></pre><pre>+# define CONVERSION_QUALITY_DEFAULT CONVERSION_QUALITY_LOW<br></pre><pre>+#else<br></pre><pre>+# define CONVERSION_QUALITY_DEFAULT CONVERSION_QUALITY_MEDIUM<br></pre><pre>+#endif<br></pre><pre>+<br></pre><pre>+#define RENDERER_CFG_PREFIX "sout-renderer-"<br></pre><pre>+<br></pre><pre>+#define add_renderer_opts(prefix) \<br></pre><pre>+ add_integer(RENDERER_CFG_PREFIX "show-perf-warning", 1, \<br></pre><pre>+ PERF_TEXT, PERF_LONGTEXT, true ) \<br></pre><pre>+ change_private() \<br></pre><pre>+ add_bool(prefix "audio-passthrough", false, \<br></pre><pre>+ AUDIO_PASSTHROUGH_TEXT, AUDIO_PASSTHROUGH_LONGTEXT, false ) <br></pre><pre>\<br></pre><pre>+ add_integer(prefix "conversion-quality", <br></pre><pre>CONVERSION_QUALITY_DEFAULT, \<br></pre><pre>+ CONVERSION_QUALITY_TEXT, CONVERSION_QUALITY_LONGTEXT, <br></pre><pre>false ); \<br></pre><pre>+ change_integer_list(conversion_quality_list, <br></pre><pre>conversion_quality_list_text)<br></pre><pre>+<br></pre><pre>+static const char *const conversion_quality_list_text[] = {<br></pre><pre>+ N_( "High (high quality and high bandwidth)" ),<br></pre><pre>+ N_( "Medium (medium quality and medium bandwidth)" ),<br></pre><pre>+ N_( "Low (low quality and low bandwidth)" ),<br></pre><pre>+ N_( "Low CPU (low quality but high bandwidth)" ),<br></pre><pre>+};<br></pre><pre>+<br></pre><pre>+enum {<br></pre><pre>+ CONVERSION_QUALITY_HIGH = 0,<br></pre><pre>+ CONVERSION_QUALITY_MEDIUM = 1,<br></pre><pre>+ CONVERSION_QUALITY_LOW = 2,<br></pre><pre>+ CONVERSION_QUALITY_LOWCPU = 3,<br></pre><pre>+};<br></pre><pre>+<br></pre><pre>+static const int conversion_quality_list[] = {<br></pre><pre>+ CONVERSION_QUALITY_HIGH,<br></pre><pre>+ CONVERSION_QUALITY_MEDIUM,<br></pre><pre>+ CONVERSION_QUALITY_LOW,<br></pre><pre>+ CONVERSION_QUALITY_LOWCPU,<br></pre><pre>+};<br></pre><pre>+<br></pre><pre>+struct venc_options<br></pre><pre>+{<br></pre><pre>+ vlc_fourcc_t fcc;<br></pre><pre>+ std::string (*get_opt)( sout_stream_t *, const video_format_t *, <br></pre><pre>int);<br></pre><pre>+};<br></pre><pre>+<br></pre><pre>+std::string<br></pre><pre>+vlc_sout_renderer_GetVencOption( sout_stream_t *p_stream, int <br></pre><pre>venc_opt_idx,<br></pre><pre>+ venc_options venc_opt_list[], size_t opt_list_length,<br></pre><pre>+ vlc_fourcc_t *p_codec_video, const video_format_t *p_vid,<br></pre><pre>+ int i_quality );<br></pre><pre>+<br></pre><pre>+std::string vlc_sout_renderer_GetVencVPXOption( sout_stream_t * /* <br></pre><pre>p_stream */,<br></pre><pre>+ const video_format_t * /* p_vid <br></pre><pre>*/,<br></pre><pre>+ int /* i_quality */ );<br></pre><pre>+<br></pre><pre>+std::string vlc_sout_renderer_GetVencQSVH264Option( sout_stream_t * /* <br></pre><pre>p_stream */,<br></pre><pre>+ const video_format_t * /* <br></pre><pre>p_vid */,<br></pre><pre>+ int i_quality );<br></pre><pre>+<br></pre><pre>+std::string vlc_sout_renderer_GetVencX264Option( sout_stream_t * /* <br></pre><pre>p_stream */,<br></pre><pre>+ const video_format_t *p_vid,<br></pre><pre>+ int i_quality );<br></pre><pre>+#ifdef __APPLE__<br></pre><pre>+std::string vlc_sout_renderer_GetVencAvcodecVTOption( sout_stream_t * /<br></pre><pre>* p_stream */,<br></pre><pre>+ const video_format_t * <br></pre><pre>p_vid,<br></pre><pre>+ int i_quality );<br></pre><pre>+#endif<br></pre><pre>+<br></pre><pre>+#endif /* RENDERER_COMMON_H */<br></pre><pre>-- <br></pre><pre>2.19.2<br></pre><pre>_______________________________________________<br></pre><pre>vlc-devel mailing list<br></pre><pre>To unsubscribe or modify your subscription options:<br></pre><pre>https://mailman.videolan.org/listinfo/vlc-devel<br></pre><pre><br></pre></blockquote><pre>_______________________________________________<br></pre><pre>vlc-devel mailing list<br></pre><pre>To unsubscribe or modify your subscription options:<br></pre><pre>https://mailman.videolan.org/listinfo/vlc-devel<br></pre></blockquote><div><span><pre>-- <br></pre><div style="width:71ch;">Regards,<br></div><div style="width:71ch;">Shaleen Jain<br></div></span></div><div>_______________________________________________<br></div><div>vlc-devel mailing list<br></div><div>To unsubscribe or modify your subscription options:<br></div><div>https://mailman.videolan.org/listinfo/vlc-devel<br></div></blockquote><div><br></div></body></html>