Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions docs/source/about/advanced_usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,41 @@ resolutions
3840x1600,
]

max_bitrate
^^^^^^^^^^^

**Description**
The maximum bitrate (in Kbps) that Sunshine will encode the stream at. If set to 0, it will always use the bitrate requested by Moonlight.

**Default**
``0``

**Example**
.. code-block:: text

max_bitrate = 5000

dwmflush
^^^^^^^^

**Description**
Invoke DwmFlush() to sync screen capture to the Windows presentation interval.

.. Caution:: Applies to Windows only. Alleviates visual stuttering during mouse movement.
If enabled, this feature will automatically deactivate if the client framerate exceeds
the host monitor's current refresh rate.

.. Note:: If you disable this option, you may see video stuttering during mouse movement in certain scenarios.
It is recommended to leave enabled when possible.

**Default**
``enabled``

**Example**
.. code-block:: text

dwmflush = enabled

Audio
-----

Expand Down
2 changes: 2 additions & 0 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ namespace config {
}, // supported resolutions

{ 10, 30, 60, 90, 120 }, // supported fps
0, // max bitrate
};

input_t input {
Expand Down Expand Up @@ -1049,6 +1050,7 @@ namespace config {
list_string_f(vars, "resolutions"s, nvhttp.resolutions);
list_int_f(vars, "fps"s, nvhttp.fps);
list_prep_cmd_f(vars, "global_prep_cmd", config::sunshine.prep_cmds);
int_f(vars, "max_bitrate", nvhttp.max_bitrate);

string_f(vars, "audio_sink", audio.sink);
string_f(vars, "virtual_sink", audio.virtual_sink);
Expand Down
1 change: 1 addition & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ namespace config {
std::string external_ip;
std::vector<std::string> resolutions;
std::vector<int> fps;
int max_bitrate;
};

struct input_t {
Expand Down
7 changes: 4 additions & 3 deletions src/platform/windows/publish.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ using namespace std::literals;
#define SV(quote) __SV(quote)

extern "C" {
#ifndef __MINGW32__
constexpr auto DNS_REQUEST_PENDING = 9506L;

#ifndef __MINGW32__
constexpr auto DNS_QUERY_REQUEST_VERSION1 = 0x1;
constexpr auto DNS_QUERY_RESULTS_VERSION1 = 0x1;
#endif
Expand Down Expand Up @@ -129,14 +130,14 @@ namespace platf::publish {

if (enable) {
status = _DnsServiceRegister(&req, nullptr);
if (status != DNS_REQUEST_PENDING) {
if (status != MY_DNS_REQUEST_PENDING) {
print_status("DnsServiceRegister()"sv, status);
return -1;
}
}
else {
status = _DnsServiceDeRegister(&req, nullptr);
if (status != DNS_REQUEST_PENDING) {
if (status != MY_DNS_REQUEST_PENDING) {
print_status("DnsServiceDeRegister()"sv, status);
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion src/video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1543,7 +1543,7 @@ namespace video {
}

if (video_format[encoder_t::CBR]) {
auto bitrate = config.bitrate * 1000;
auto bitrate = ((config::nvhttp.max_bitrate != 0) ? std::min(config.bitrate, config::nvhttp.max_bitrate) : config.bitrate) * 1000;
ctx->rc_max_rate = bitrate;
ctx->bit_rate = bitrate;

Expand Down
18 changes: 16 additions & 2 deletions src_assets/common/assets/web/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,19 @@ <h1 class="my-4">Configuration</h1>
resolutions and fps are supported.<br>
This setting does <b>not</b> change how the screen stream is sent to Moonlight
</div>
<div class="mb-3">
<label for="max_bitrate" class="form-label">Max Bitrate</label>
<input
type="number"
class="form-control"
id="max_bitrate"
placeholder="5000"
v-model="config.max_bitrate"
/>
<div class="form-text">
Maximum bitrate for streaming in Kbps. If not specified, the default bitrate is used
</div>
</div>
</div>
<!-- Mapping Key AltRight to Key Windows -->
<div class="mb-3">
Expand Down Expand Up @@ -1054,11 +1067,13 @@ <h1 class="my-4">Configuration</h1>
"dwmflush": "enabled",
"encoder": "",
"fps": "[10,30,60,90,120]",
"gamepad": "auto",
"gamepad": "x360",
"global_prep_cmd": "[]",
"hevc_mode": 0,
"av1_mode": 0,
"key_rightalt_to_key_win": "disabled",
"keyboard": "enabled",
"max_bitrate": 0,
"min_log_level": 2,
"mouse": "enabled",
"nv_coder": "auto",
Expand All @@ -1076,7 +1091,6 @@ <h1 class="my-4">Configuration</h1>
"vt_coder": "auto",
"vt_realtime": "enabled",
"vt_software": "auto",
"global_prep_cmd": "[]",
}

new Vue({
Expand Down