-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
UI: Add pre-stream encoder setup wizard #3515
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
7900dad
UI: Add Settings Endpoints for Pre-Live Wizard
JohannMG 7721c4f
UI: Create model to start to pre-stream wizard
JohannMG 9dbd927
UI: Prompt & explain the streaming encoder wizard
JohannMG 4764a94
UI: Setup FacebookEncoderSettingsProvider
JohannMG 3132ac4
UI: PreStream Wizard parse & display options
JohannMG dc2c1a7
UI: PreStream Wizard add completion page
JohannMG 1ee85d5
UI: Add error page to PreStream Wizard
JohannMG 3039731
UI: Add loading page to PreStream Wizard
JohannMG e78202c
UI: Pre-stream wizard buttons are dynamic
JohannMG 7df6801
UI: Apply settings gathered by Pre-stream wizard
JohannMG 8a16363
UI: Pre-stream wizard show & hide button correctly
JohannMG 6e53c89
UI: Remove QtNetwork Dependency from Settings UI
JohannMG bdc3a3e
UI: Solves issue with QMap Keys & Feedback
JohannMG File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,184 @@ | ||
| #include "common-settings.hpp" | ||
|
|
||
| #include "audio-encoders.hpp" | ||
|
|
||
| bool CommonSettings::IsAdvancedMode(config_t *config) | ||
| { | ||
| const char *outputMode = config_get_string(config, "Output", "Mode"); | ||
| return (strcmp(outputMode, "Advanced") == 0); | ||
| } | ||
|
|
||
| OBSData CommonSettings::GetDataFromJsonFile(const char *jsonFile) | ||
| { | ||
| char fullPath[512]; | ||
| obs_data_t *data = nullptr; | ||
|
|
||
| int ret = GetProfilePath(fullPath, sizeof(fullPath), jsonFile); | ||
| if (ret > 0) { | ||
| BPtr<char> jsonData = os_quick_read_utf8_file(fullPath); | ||
| if (jsonData) { | ||
| data = obs_data_create_from_json(jsonData); | ||
| } | ||
| } | ||
|
|
||
| if (!data) | ||
| data = obs_data_create(); | ||
|
|
||
| OBSData dataRet(data); | ||
| obs_data_release(data); | ||
JohannMG marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return dataRet; | ||
| } | ||
|
|
||
| void CommonSettings::GetConfigFPS(config_t *config, uint32_t &num, | ||
| uint32_t &den) | ||
| { | ||
| uint32_t type = config_get_uint(config, videoSection, "FPSType"); | ||
|
|
||
| if (type == 1) //"Integer" | ||
| GetFPSInteger(config, num, den); | ||
| else if (type == 2) //"Fraction" | ||
| GetFPSFraction(config, num, den); | ||
| else if (false) //"Nanoseconds", currently not implemented | ||
| GetFPSNanoseconds(config, num, den); | ||
| else | ||
| GetFPSCommon(config, num, den); | ||
| } | ||
|
|
||
| double CommonSettings::GetConfigFPSDouble(config_t *config) | ||
| { | ||
| uint32_t num = 0; | ||
| uint32_t den = 0; | ||
| CommonSettings::GetConfigFPS(config, num, den); | ||
| return (double)num / (double)den; | ||
| } | ||
|
|
||
| void CommonSettings::GetFPSCommon(config_t *config, uint32_t &num, | ||
| uint32_t &den) | ||
| { | ||
| const char *val = config_get_string(config, videoSection, "FPSCommon"); | ||
|
|
||
| if (strcmp(val, "10") == 0) { | ||
JohannMG marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| num = 10; | ||
| den = 1; | ||
| } else if (strcmp(val, "20") == 0) { | ||
| num = 20; | ||
| den = 1; | ||
| } else if (strcmp(val, "24 NTSC") == 0) { | ||
| num = 24000; | ||
| den = 1001; | ||
| } else if (strcmp(val, "25 PAL") == 0) { | ||
| num = 25; | ||
| den = 1; | ||
| } else if (strcmp(val, "29.97") == 0) { | ||
| num = 30000; | ||
| den = 1001; | ||
| } else if (strcmp(val, "48") == 0) { | ||
| num = 48; | ||
| den = 1; | ||
| } else if (strcmp(val, "50 PAL") == 0) { | ||
| num = 50; | ||
| den = 1; | ||
| } else if (strcmp(val, "59.94") == 0) { | ||
| num = 60000; | ||
| den = 1001; | ||
| } else if (strcmp(val, "60") == 0) { | ||
| num = 60; | ||
| den = 1; | ||
| } else { | ||
| num = 30; | ||
| den = 1; | ||
| } | ||
| } | ||
|
|
||
| void CommonSettings::GetFPSInteger(config_t *config, uint32_t &num, | ||
| uint32_t &den) | ||
| { | ||
| num = (uint32_t)config_get_uint(config, videoSection, "FPSInt"); | ||
| den = 1; | ||
| } | ||
|
|
||
| void CommonSettings::GetFPSFraction(config_t *config, uint32_t &num, | ||
| uint32_t &den) | ||
| { | ||
| num = (uint32_t)config_get_uint(config, videoSection, "FPSNum"); | ||
| den = (uint32_t)config_get_uint(config, videoSection, "FPSDen"); | ||
| } | ||
|
|
||
| void CommonSettings::GetFPSNanoseconds(config_t *config, uint32_t &num, | ||
| uint32_t &den) | ||
| { | ||
| num = 1000000000; | ||
| den = (uint32_t)config_get_uint(config, videoSection, "FPSNS"); | ||
| } | ||
|
|
||
| int CommonSettings::GetAudioChannelCount(config_t *config) | ||
| { | ||
| const char *channelSetup = | ||
| config_get_string(config, "Audio", "ChannelSetup"); | ||
|
|
||
| if (strcmp(channelSetup, "Mono") == 0) | ||
| return 1; | ||
| if (strcmp(channelSetup, "Stereo") == 0) | ||
| return 2; | ||
| if (strcmp(channelSetup, "2.1") == 0) | ||
| return 3; | ||
| if (strcmp(channelSetup, "4.0") == 0) | ||
| return 4; | ||
| if (strcmp(channelSetup, "4.1") == 0) | ||
| return 5; | ||
| if (strcmp(channelSetup, "5.1") == 0) | ||
| return 6; | ||
| if (strcmp(channelSetup, "7.1") == 0) | ||
| return 8; | ||
|
|
||
| return 2; | ||
| } | ||
|
|
||
| int CommonSettings::GetStreamingAudioBitrate(config_t *config) | ||
| { | ||
| if (IsAdvancedMode(config)) { | ||
| return GetAdvancedAudioBitrate(config); | ||
| } | ||
| return GetSimpleAudioBitrate(config); | ||
| } | ||
|
|
||
| int CommonSettings::GetSimpleAudioBitrate(config_t *config) | ||
| { | ||
| int bitrate = config_get_uint(config, "SimpleOutput", "ABitrate"); | ||
| return FindClosestAvailableAACBitrate(bitrate); | ||
| } | ||
|
|
||
| int CommonSettings::GetAdvancedAudioBitrate(config_t *config) | ||
| { | ||
| int track = config_get_int(config, "AdvOut", "TrackIndex"); | ||
| return GetAdvancedAudioBitrateForTrack(config, track - 1); | ||
| } | ||
|
|
||
| int CommonSettings::GetAdvancedAudioBitrateForTrack(config_t *config, | ||
| int trackIndex) | ||
| { | ||
| static const char *names[] = { | ||
| "Track1Bitrate", "Track2Bitrate", "Track3Bitrate", | ||
| "Track4Bitrate", "Track5Bitrate", "Track6Bitrate", | ||
| }; | ||
|
|
||
| // Sanity check for out of bounds, clamp to bounds | ||
| if (trackIndex > 5) { | ||
| trackIndex = 5; | ||
| } else if (trackIndex < 0) { | ||
| trackIndex = 0; | ||
| } | ||
|
|
||
| int bitrate = (int)config_get_uint(config, "AdvOut", names[trackIndex]); | ||
| return FindClosestAvailableAACBitrate(bitrate); | ||
| } | ||
|
|
||
| int CommonSettings::GetVideoBitrateInUse(config_t *config) | ||
| { | ||
| if (!IsAdvancedMode(config)) { | ||
| return config_get_int(config, "SimpleOutput", "VBitrate"); | ||
| } | ||
|
|
||
| OBSData streamEncSettings = GetDataFromJsonFile("streamEncoder.json"); | ||
| return obs_data_get_int(streamEncSettings, "bitrate"); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| /* | ||
| Helper to get common video and audio setting that are accessed from more than | ||
| one file. | ||
| */ | ||
| #pragma once | ||
|
|
||
| #include <obs.hpp> | ||
| #include "obs-app.hpp" | ||
|
|
||
| class CommonSettings { | ||
|
|
||
| public: | ||
| static bool IsAdvancedMode(config_t *config); | ||
| /* Shared Utility Functions --------------------------*/ | ||
| static OBSData GetDataFromJsonFile(const char *jsonFile); | ||
|
|
||
| /* Framerate ----------------------------------------*/ | ||
| static void GetConfigFPS(config_t *config, uint32_t &num, | ||
| uint32_t &den); | ||
| static double GetConfigFPSDouble(config_t *config); | ||
|
|
||
| /* Audio Data ---------------------------------------*/ | ||
| // Returns int of audio, sub (the .1 in 2.1) is a channel i.e., 2.1 -> 3ch | ||
| static int GetAudioChannelCount(config_t *config); | ||
| // Gets streaming track's bitrate, simple or advanced mode | ||
| static int GetStreamingAudioBitrate(config_t *config); | ||
| static int GetSimpleAudioBitrate(config_t *config); | ||
| static int GetAdvancedAudioBitrate(config_t *config); | ||
| // Advanced setting's streaming bitrate for track number (starts at 1) | ||
| static int GetAdvancedAudioBitrateForTrack(config_t *config, | ||
| int trackIndex); | ||
|
|
||
| /* Stream Encoder ——————————————————————————————————*/ | ||
| static int GetVideoBitrateInUse(config_t *config); | ||
| static void SetAllVideoBitrates(config_t *config, int newBitrate); | ||
|
|
||
| private: | ||
| // Reused Strings | ||
| static constexpr const char *videoSection = "Video"; | ||
JohannMG marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| static void GetFPSCommon(config_t *config, uint32_t &num, | ||
| uint32_t &den); | ||
| static void GetFPSInteger(config_t *config, uint32_t &num, | ||
| uint32_t &den); | ||
| static void GetFPSFraction(config_t *config, uint32_t &num, | ||
| uint32_t &den); | ||
| static void GetFPSNanoseconds(config_t *config, uint32_t &num, | ||
| uint32_t &den); | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.