New video-related options (#179)
This commit is contained in:
parent
52f2998576
commit
5124ca1b6d
9 changed files with 69 additions and 13 deletions
|
|
@ -2871,6 +2871,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"ktg_call_sure" = "Are you sure you want to call this user?";
|
||||
"ktg_call_button" = "Call";
|
||||
|
||||
"ktg_settings_ffmpeg_multithread" = "Multithread video decoding";
|
||||
"ktg_settings_ffmpeg_multithread_about" = "When enabled, CPU and RAM consumption is higher, video decodes faster. When disabled, CPU and RAM consumption is lower, video decodes slower. The more CPU cores you have, the more RAM consumption you have when this option is enabled. You can set exact number of threads in the JSON configuration file.";
|
||||
"ktg_settings_external_video_player" = "External video player";
|
||||
"ktg_settings_external_video_player_about" = "When this option is enabled, autoplay is force-disabled and system video player is used to play videos.";
|
||||
|
||||
"ktg_user_status_unaccessible" = "account inaccessible";
|
||||
|
||||
"ktg_settings_show_json_settings" = "Show settings file";
|
||||
|
|
|
|||
|
|
@ -79,6 +79,10 @@
|
|||
"ktg_settings_call_confirm": "Confirm before calling",
|
||||
"ktg_call_sure": "Are you sure you want to call this user?",
|
||||
"ktg_call_button": "Call",
|
||||
"ktg_settings_ffmpeg_multithread": "Multithread video decoding",
|
||||
"ktg_settings_ffmpeg_multithread_about": "When enabled, CPU and RAM consumption is higher, video decodes faster. When disabled, CPU and RAM consumption is lower, video decodes slower. The more CPU cores you have, the more RAM consumption you have when this option is enabled. You can set exact number of threads in the JSON configuration file.",
|
||||
"ktg_settings_external_video_player": "External video player",
|
||||
"ktg_settings_external_video_player_about": "When this option is enabled, autoplay is force-disabled and system video player is used to play videos.",
|
||||
"ktg_settings_adaptive_bubbles": "Adaptive bubbles",
|
||||
"ktg_settings_disable_sound_from_tray": "Disable sound",
|
||||
"ktg_settings_enable_sound_from_tray": "Enable sound",
|
||||
|
|
|
|||
|
|
@ -79,6 +79,10 @@
|
|||
"ktg_settings_call_confirm": "Подтверждение перед звонком",
|
||||
"ktg_call_sure": "Вы уверены, что хотите позвонить этому пользователю?",
|
||||
"ktg_call_button": "Позвонить",
|
||||
"ktg_settings_ffmpeg_multithread": "Декодировать видео в несколько потоков",
|
||||
"ktg_settings_ffmpeg_multithread_about": "Когда включено, расход ЦП и ОЗУ выше, видео декодируется быстрее. Когда выключено, расход ЦП и ОЗУ меньше, видео декодируется медленнее. Чем больше у вас ядер ЦП, тем больше расход ОЗУ, когда эта опция включена. Можно закрепить используемое число потоков в конфигурационном файле JSON.",
|
||||
"ktg_settings_external_video_player": "Внешний видеоплеер",
|
||||
"ktg_settings_external_video_player_about": "Когда эта опция включена, автовоспроизведение принудительно отключено и системный видеоплеер используется для проигрывания видео.",
|
||||
"ktg_settings_adaptive_bubbles": "Адаптивная ширина сообщений",
|
||||
"ktg_settings_disable_sound_from_tray": "Отключить звук",
|
||||
"ktg_settings_enable_sound_from_tray": "Включить звук",
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ffmpeg/ffmpeg_utility.h"
|
||||
|
||||
#include "base/algorithm.h"
|
||||
#include "kotato/settings.h"
|
||||
#include "logs.h"
|
||||
|
||||
#include <QImage>
|
||||
|
|
@ -175,7 +176,13 @@ CodecPointer MakeCodecPointer(not_null<AVStream*> stream) {
|
|||
return {};
|
||||
}
|
||||
context->pkt_timebase = stream->time_base;
|
||||
av_opt_set(context, "threads", "auto", 0);
|
||||
if(cFFmpegMultithread()) {
|
||||
if (cFFmpegThreadCount() > 0) {
|
||||
av_opt_set(context, "threads", std::to_string(cFFmpegThreadCount()).c_str(), 0);
|
||||
} else {
|
||||
av_opt_set(context, "threads", "auto", 0);
|
||||
}
|
||||
}
|
||||
av_opt_set_int(context, "refcounted_frames", 1, 0);
|
||||
|
||||
const auto codec = avcodec_find_decoder(context->codec_id);
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ https://github.com/kotatogram/kotatogram-desktop/blob/dev/LEGAL
|
|||
#include "facades.h"
|
||||
#include "ui/widgets/input_fields.h"
|
||||
#include "data/data_chat_filters.h"
|
||||
#include "platform/platform_file_utilities.h"
|
||||
|
||||
#include <QtCore/QJsonDocument>
|
||||
#include <QtCore/QJsonObject>
|
||||
|
|
@ -371,6 +372,8 @@ QByteArray GenerateSettingsJson(bool areDefault = false) {
|
|||
settings.insert(qsl("disable_up_edit"), cDisableUpEdit());
|
||||
settings.insert(qsl("auto_scroll_unfocused"), cAutoScrollUnfocused());
|
||||
settings.insert(qsl("confirm_before_calls"), cConfirmBeforeCall());
|
||||
settings.insert(qsl("ffmpeg_multithread"), cFFmpegMultithread());
|
||||
settings.insert(qsl("ffmpeg_thread_count"), int(cFFmpegThreadCount()));
|
||||
settings.insert(qsl("native_decorations"), cUseNativeDecorations());
|
||||
settings.insert(qsl("recent_stickers_limit"), RecentStickersLimit());
|
||||
settings.insert(qsl("userpic_corner_type"), cUserpicCornersType());
|
||||
|
|
@ -609,6 +612,14 @@ bool Manager::readCustomFile() {
|
|||
cSetConfirmBeforeCall(v);
|
||||
});
|
||||
|
||||
ReadBoolOption(settings, "ffmpeg_multithread", [&](auto v) {
|
||||
cSetFFmpegMultithread(v);
|
||||
});
|
||||
|
||||
ReadIntOption(settings, "ffmpeg_thread_count", [&](auto v) {
|
||||
cSetFFmpegThreadCount(v);
|
||||
});
|
||||
|
||||
ReadBoolOption(settings, "native_decorations", [&](auto v) {
|
||||
cSetUseNativeDecorations(v);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ https://github.com/kotatogram/kotatogram-desktop/blob/dev/LEGAL
|
|||
#include "kotato/settings.h"
|
||||
|
||||
#include "base/platform/base_platform_info.h"
|
||||
#include "platform/platform_file_utilities.h"
|
||||
|
||||
bool gKotatoFirstRun = true;
|
||||
|
||||
|
|
@ -127,6 +128,9 @@ bool AddCustomReplace(QString from, QString to) {
|
|||
|
||||
bool gConfirmBeforeCall = true;
|
||||
|
||||
bool gFFmpegMultithread = true;
|
||||
uint gFFmpegThreadCount = 0;
|
||||
|
||||
bool gUseNativeDecorations = false;
|
||||
bool UseNativeDecorations() {
|
||||
static const auto NativeDecorations = cUseNativeDecorations();
|
||||
|
|
|
|||
|
|
@ -7,7 +7,15 @@ https://github.com/kotatogram/kotatogram-desktop/blob/dev/LEGAL
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include "platform/platform_file_utilities.h"
|
||||
#include <rpl/producer.h>
|
||||
|
||||
namespace Platform {
|
||||
namespace FileDialog {
|
||||
|
||||
enum class ImplementationType;
|
||||
|
||||
} // namespace FileDialog
|
||||
} // namespace Platform
|
||||
|
||||
#define DeclareReadSetting(Type, Name) extern Type g##Name; \
|
||||
inline const Type &c##Name() { \
|
||||
|
|
@ -95,6 +103,9 @@ DeclareRefSetting(CustomReplacementsMap, CustomReplaces);
|
|||
bool AddCustomReplace(QString from, QString to);
|
||||
DeclareSetting(bool, ConfirmBeforeCall);
|
||||
|
||||
DeclareSetting(bool, FFmpegMultithread);
|
||||
DeclareSetting(uint, FFmpegThreadCount);
|
||||
|
||||
DeclareSetting(bool, UseNativeDecorations);
|
||||
[[nodiscard]] bool UseNativeDecorations();
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ https://github.com/kotatogram/kotatogram-desktop/blob/dev/LEGAL
|
|||
#include "boxes/about_box.h"
|
||||
#include "boxes/confirm_box.h"
|
||||
#include "platform/platform_specific.h"
|
||||
#include "platform/platform_file_utilities.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "core/update_checker.h"
|
||||
|
|
@ -657,8 +658,28 @@ void SetupKotatoOther(not_null<Ui::VerticalLayout*> container) {
|
|||
});
|
||||
|
||||
SettingsMenuCSwitch(ktg_settings_call_confirm, ConfirmBeforeCall);
|
||||
SettingsMenuCSwitch(ktg_settings_ffmpeg_multithread, FFmpegMultithread);
|
||||
|
||||
AddSkip(container);
|
||||
AddDividerText(container, tr::ktg_settings_ffmpeg_multithread_about());
|
||||
AddSkip(container);
|
||||
|
||||
AddButton(
|
||||
container,
|
||||
tr::ktg_settings_external_video_player(),
|
||||
st::settingsButton
|
||||
)->toggleOn(
|
||||
rpl::single(cUseExternalVideoPlayer())
|
||||
)->toggledValue(
|
||||
) | rpl::filter([](bool enabled) {
|
||||
return (enabled != cUseExternalVideoPlayer());
|
||||
}) | rpl::start_with_next([](bool enabled) {
|
||||
cSetUseExternalVideoPlayer(enabled);
|
||||
Core::App().saveSettingsDelayed();
|
||||
}, container->lifetime());
|
||||
|
||||
AddSkip(container);
|
||||
AddDividerText(container, tr::ktg_settings_external_video_player_about());
|
||||
}
|
||||
|
||||
Kotato::Kotato(
|
||||
|
|
|
|||
|
|
@ -81,17 +81,6 @@ auto GenerateCodes() {
|
|||
}
|
||||
});
|
||||
});
|
||||
codes.emplace(qsl("videoplayer"), [](SessionController *window) {
|
||||
if (!window) {
|
||||
return;
|
||||
}
|
||||
auto text = cUseExternalVideoPlayer() ? qsl("Use internal video player?") : qsl("Use external video player?");
|
||||
Ui::show(Box<ConfirmBox>(text, [=] {
|
||||
cSetUseExternalVideoPlayer(!cUseExternalVideoPlayer());
|
||||
window->session().saveSettingsDelayed();
|
||||
Ui::hideLayer();
|
||||
}));
|
||||
});
|
||||
codes.emplace(qsl("endpoints"), [](SessionController *window) {
|
||||
if (!Core::App().domain().started()) {
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue