diff --git a/plugins/obs-outputs/rtmp-stream.c b/plugins/obs-outputs/rtmp-stream.c index 03136c44ef67e6fdee991cb03b641b4bb9756e24..b3d3a4b3fdc5466d184103c87512354aa5cc3837 100644 --- a/plugins/obs-outputs/rtmp-stream.c +++ b/plugins/obs-outputs/rtmp-stream.c @@ -267,6 +267,49 @@ static void droptest_cap_data_rate(struct rtmp_stream *stream, size_t size) uint64_t ts = os_gettime_ns(); struct droptest_info info; +#if defined(_WIN32) && defined(TEST_FRAMEDROPS_WITH_BITRATE_SHORTCUTS) + uint64_t check_elapsed = ts - stream->droptest_last_key_check; + + if (check_elapsed > (200ULL * MSEC_TO_NSEC)) { + size_t bitrate = 0; + + stream->droptest_last_key_check = ts; + + if (GetAsyncKeyState(VK_NUMPAD0) & 0x8000) { + stream->droptest_max = 0; + } else if (GetAsyncKeyState(VK_NUMPAD1) & 0x8000) { + bitrate = 1000; + } else if (GetAsyncKeyState(VK_NUMPAD2) & 0x8000) { + bitrate = 2000; + } else if (GetAsyncKeyState(VK_NUMPAD3) & 0x8000) { + bitrate = 3000; + } else if (GetAsyncKeyState(VK_NUMPAD4) & 0x8000) { + bitrate = 4000; + } else if (GetAsyncKeyState(VK_NUMPAD5) & 0x8000) { + bitrate = 5000; + } else if (GetAsyncKeyState(VK_NUMPAD6) & 0x8000) { + bitrate = 6000; + } else if (GetAsyncKeyState(VK_NUMPAD7) & 0x8000) { + bitrate = 7000; + } else if (GetAsyncKeyState(VK_NUMPAD8) & 0x8000) { + bitrate = 8000; + } else if (GetAsyncKeyState(VK_NUMPAD9) & 0x8000) { + bitrate = 9000; + } + + if (bitrate) { + stream->droptest_max = (bitrate * 1000 / 8); + } + } + if (!stream->droptest_max) { + return; + } +#else + if (!stream->droptest_max) { + stream->droptest_max = DROPTEST_MAX_BYTES; + } +#endif + info.ts = ts; info.size = size; @@ -277,7 +320,7 @@ static void droptest_cap_data_rate(struct rtmp_stream *stream, size_t size) circlebuf_peek_front(&stream->droptest_info, &info, sizeof(info)); - if (stream->droptest_size > DROPTEST_MAX_BYTES) { + if (stream->droptest_size > stream->droptest_max) { uint64_t elapsed = ts - info.ts; if (elapsed < 1000000000ULL) { @@ -285,7 +328,7 @@ static void droptest_cap_data_rate(struct rtmp_stream *stream, size_t size) os_sleepto_ns(ts + elapsed); } - while (stream->droptest_size > DROPTEST_MAX_BYTES) { + while (stream->droptest_size > stream->droptest_max) { circlebuf_pop_front(&stream->droptest_info, &info, sizeof(info)); stream->droptest_size -= info.size; diff --git a/plugins/obs-outputs/rtmp-stream.h b/plugins/obs-outputs/rtmp-stream.h index b872ce077b5cb754abdbdb685e56c9986358499b..4c1bd7870497f70dcaa4417dc8e60e8b2502c2f1 100644 --- a/plugins/obs-outputs/rtmp-stream.h +++ b/plugins/obs-outputs/rtmp-stream.h @@ -32,6 +32,7 @@ #define OPT_LOWLATENCY_ENABLED "low_latency_mode_enabled" //#define TEST_FRAMEDROPS +//#define TEST_FRAMEDROPS_WITH_BITRATE_SHORTCUTS #ifdef TEST_FRAMEDROPS @@ -87,6 +88,8 @@ struct rtmp_stream { #ifdef TEST_FRAMEDROPS struct circlebuf droptest_info; + uint64_t droptest_last_key_check; + size_t droptest_max; size_t droptest_size; #endif