Commit Graph
100 Commits
Author SHA1 Message Date
Richard StanwayandRodney b51773b97b rtmp-services: Specify RTMP_SERVICES_FORMAT_VERSION in package.json 2023-01-06 21:16:21 +01:00
Richard StanwayandJim 20d4bab77a win-capture: Always reset timeout when searching for target display
If the display wasn't found, the timer was not reset, causing the code
to execute on every single tick, stalling the graphics thread and using
excessive CPU.
2023-01-04 23:20:41 -08:00
Richard StanwayandRyan Foster 510f0116a6 cmake: Specify utf-8 for MSVC builds
If there is no BOM, MSVC defaults to the user's code page which can
result in errors if UTF-8 characters are present in the source files.
2022-11-20 17:38:23 -05:00
Richard StanwayandMatt Gajownik 02c6ce8b58 obs-vst: Improve some string handling
- Use constant references where appropriate
- Avoid unnecessary use of strcmp / strlen
- Clear std::string with clear()

Issues detected by PVS Studio.
2022-11-20 17:25:33 +11:00
Richard StanwayandMatt Gajownik fe9c3748ce obs-vst: Use libobs memory allocation functions 2022-11-20 17:25:33 +11:00
Richard Stanway 63c3299a9f obs-outputs: Increase librtmp send timeout to 15 seconds
Based on what we're seeing after the release of OBS 28, six seconds is
too low and causes disconnects instead of dropped frames.
2022-11-11 20:53:10 +01:00
Richard StanwayandJim 7e0ade0df0 UI: Remove support for toggling Aero
We no longer support Windows 7 and Aero (DWM composition) is
permanently enabled for all newer versions, so this code is obsolete.
2022-11-08 20:44:47 -08:00
Richard StanwayandJim da3a81a637 libobs: Remove Aero logging 2022-11-08 20:44:47 -08:00
Richard StanwayandJim c9c20008da UI: Fix always on top not being saved on exit
By the time we reach this part of the code it's too late to be checking
the window flags as the window has already been closed.
2022-11-05 11:06:39 -07:00
Richard StanwayandJim 2ad517e91e obs-filters: Remove unused assignments 2022-10-15 16:17:46 -07:00
Richard StanwayandJim 1d044db4f6 UI: Check return value of ConvertResText before accessing results 2022-10-15 16:17:46 -07:00
Richard StanwayandJim a282b1c64d libobs: Add ifdef for Windows-only variable assignment 2022-10-15 16:17:46 -07:00
Richard StanwayandJim cba81638b5 UI: Fix potential memory leak when parsing OBSThemeMeta 2022-10-15 16:17:46 -07:00
Richard StanwayandJim f021da2afa UI: Copy result of getenv before use
Another call to getenv, as well as a call to the POSIX functions
setenv(), unsetenv(), and putenv() may invalidate the pointer
returned by a previous call or modify the string obtained from a
previous call.

https://en.cppreference.com/w/c/program/getenv
2022-10-15 16:17:46 -07:00
Richard StanwayandJim daee83373c UI: Remove unused assignments 2022-10-15 16:17:46 -07:00
Richard Stanway e93ad13529 UI: Don't offer current resolution in auto config if < 240p
Fixes #3612.
2022-10-13 23:13:27 +02:00
Richard StanwayandJim 21c711d46b UI: Ignore left-click on non-multiview projectors
Fixes a crash that could occur after having both multiview and
non-multiview projectors active.
2022-09-17 16:19:24 -07:00
Richard Stanway 47e441b2e5 UI/updater: CMake: Add /utf-8 to MSVC command line
Fixes compiler interpreting UTF-8 as individual bytes when building the
wide string and showing the wrong characters.

Fixes #7304.
2022-09-05 22:51:15 +02:00
Richard Stanway 1cae3d4a3c UI/updater: Fix manifest XML namespace for dpiAware setting 2022-09-05 22:49:11 +02:00
Richard StanwayandRodney 3332beece5 obs-ffmpeg: Fix seek offset being calculated incorrectly
If FFmpeg wrote data and then seeked back to immediately overwrite it,
the second seek would be skipped as our virtual offset was incorrectly
thinking it hadn't changed. This caused MP4 corruption when seeking
back in the file to write the moov atom.

Fixes https://github.com/obsproject/obs-studio/issues/7269
Fixes https://github.com/obsproject/obs-studio/issues/7144
2022-09-03 01:34:14 +02:00
Richard Stanway 31414d2d7a UI/updater: Fix wrong parameter order for MessageBox 2022-09-01 00:44:57 +02:00
Richard Stanway 854d75919f UI/updater: Use a unique temp path for patch files
Fixes a case where patches for the same destination file but different
source files would clobber each other and cause integrity check
failures.
2022-09-01 00:37:53 +02:00
Richard Stanway edca16d77d UI: Add HTTP header if the update check is manually initiated
With the addition of server-side release rate control, having the server
know if the update check was manually initiated can allow it to deliver
the update to the user even if they would normally not be eligible.
Windows only.
2022-08-30 16:12:56 +02:00
Richard StanwayandJim 894bc4078b obs-ffmpeg: Log codec when creating NVENC encoders
With HEVC and H264 settings being near-identical, it was impossible to
figure out which codec was being used by context alone. This applies to
both ffmpeg output and jim-nvenc.

Fixes #6976.
2022-08-29 21:43:04 -07:00
Richard StanwayandJim e58485e0b2 UI: Fix padding on context bar buttons in System and Dark themes 2022-08-29 21:42:25 -07:00
Richard StanwayandJim ac55328e7f UI: Simplify multiview projector removal 2022-08-24 05:33:47 -07:00
Richard StanwayandJim 5e6cbebcb9 UI: Remove allProjectors list
Seems like this wasn't used anywhere and projectors were not being
removed on destruction, resulting in a memory leak.
2022-08-24 05:33:47 -07:00
Richard StanwayandJim c64997ed80 UI: Fix crash when toggling volume control mode
The toggleControlLayoutAction (change between horizontal and vertical
display mode) deletes and re-recreates the volume controls, meaning we
were writing to freed memory. This is a kind of hacky fix but it's the
only action we need to be concerned with for now.
2022-08-24 05:14:56 -07:00
Richard Stanway ef48f5b28d UI/installer: Update references to dependencies for 28.0.0 2022-08-21 17:26:27 +02:00
Richard StanwayandJim 8227dccf77 libobs: Initialize main_view video mix before video thread
Fixes a race condition where the video thread would exit because it sees
no active mixes, causing OBS to freeze on startup.

Fixes #7095
2022-08-20 01:27:47 -07:00
Richard StanwayandJim abedc7d08b UI: Fix use-after-free in properties view 2022-08-17 05:30:57 -07:00
Richard Stanway dcc79c374d obs-ffmpeg: Fix format specifier in obs-amf-test 2022-08-12 23:05:58 +02:00
Richard Stanway 3c6c44e1fe win-capture: Fix incorrect path in CMakeLists 2022-08-09 02:31:50 +02:00
Richard Stanwayandjpark37 86963f65d2 libobs, win-capture: Don't export ms_get_obfuscated_func
Since this was included in things like the inject helper and game
capture DLLs, it added an additional export to those programs. Instead,
simply share the source files directly in the projects that need it.

Co-authored-by: jpark37 <jpark37@users.noreply.github.com>
2022-08-07 19:41:23 +02:00
Richard StanwayandJim 8ab6fffec4 obs-amf-test: Add 2.5 second timeout for AMF test process
If the test process freezes for whatever reason, OBS would block
indefinitely on reading the pipe. This commit adds a 2.5 second timeout
on the AMF test process after which it will self-terminate.
2022-08-01 13:34:27 -07:00
Richard StanwayandJim 68415fa08f obs-ffmpeg: Throw on invalid amf_format 2022-08-01 13:34:27 -07:00
Richard StanwayandJim ac025b51ac obs-ffmpeg: Use get_buf function to ensure buffers_mutex is locked 2022-08-01 13:34:27 -07:00
Richard StanwayandJim 2e8b8c5ae1 obs-ffmpeg: Fix typo in min_qp_p / max_qp_p options
Detected by PVS Studio.
2022-08-01 13:34:27 -07:00
Richard StanwayandJim 00408b6b3b obs-ffmpeg: Don't load AMF DLL before amf-test
In the event that simply loading the AMF DLL causes initialization code
to run that might crash, don't load the DLL before the AMF test process
has succeeded. Instead, we load the DLL as data to see if it exists,
then run the AMF test, then load the DLL for real.
2022-08-01 13:34:27 -07:00
Richard Stanway ad11ae2f5c libobs: Remove redundant get_data calls in obs_data functions 2022-07-27 21:58:16 +02:00
Richard Stanway 88226db6b3 obs-ffmpeg: Fix AMF AVC / HEVC check logic 2022-07-22 00:45:34 +02:00
Richard Stanway 009fc43bee deps/opts-parser: Skip parsing of empty strings 2022-07-20 03:29:59 +02:00
Richard Stanway 22ef40ba17 text-freetype2: Don't read / write empty size arrays 2022-07-18 23:23:12 +02:00
Richard Stanway 174e91f211 rtmp-services: Avoid calling bmemdup on NULL resolution list 2022-07-18 23:12:49 +02:00
Richard StanwayandJim c5965c8605 libobs: Log errors for bmalloc(0)
malloc(0) is implementation defined and almost always a mistake. I
believe we should be more like malloc and treat bmalloc(0) as an error
instead of tying to handle it. For now we can log an error in case 3rd
party plugins are broken, in the future I would suggest this becomes a
crash-worthy error.
2022-07-16 15:20:55 -07:00
Richard StanwayandJim dbdbfe79d2 libobs: Deprecate base_set_allocator and make it no-op
Hopefully nothing is actually using this in the first place. As a
library libobs has alignment requirements so we should probably not
allow an application to replace our aligned mallocs with something else.
This also allows more aggressive optimizations inside libobs as the call
can be completely inlined into a libc malloc.
2022-07-16 15:20:55 -07:00
Richard StanwayandJim 17c39ccb07 obs-ffmpeg, obs-outputs: Check return of obs_encoder_get_extra_data
A race condition can occur in obs-outputs where the send_thread is in
the process of (re)connecting but the encoder was shut down in the
meantime. This causes the expected header data to be garbage, resulting
in a crash.
2022-06-25 16:03:12 -07:00
Richard Stanway dada82fec1 obs-outputs: Don't shutdown RTMP session when silently reconnecting
The silent reconnect (GOAWAY) is supposed to be used for switching the
connection to a different server. As such, cleanly shutting down the
RTMP connection can destroy state that needs to be preserved in order
for the GOAWAY-enabled server to properly resume the same stream on
reconnect.

This commit closes the TLS/TCP connection before calling RTMP_Close,
causing librtmp to skip the FCUnpublish and deleteStream messages.
2022-06-20 22:10:06 +02:00
Richard Stanway 34bbb94acd UI: Use int return type in OBSIgnoreWheelProxyStyle 2022-05-30 22:55:36 +02:00
Richard StanwayandJim 898256d416 obs-ffmpeg: Add a circlebuf to buffer output in ffmpeg-mux
This adds a circular buffer to ffmpeg-mux when writing to a file.
Output from ffmpeg is buffered so that slow disk I/O does not block
ffmpeg writes, as this causes the pipe to become full and OBS stops
sending frames with a misleading "Encoding overloaded!" warning. The
buffer may grow to 256 MB depending on the rate of data coming in and
out, if the buffer is full OBS will start waiting in ffmpeg writes.

A separate I/O thread is responsible for processing the contents of
the buffer and writing them to the output file. It tries to process 1 MB
at a time to minimize small I/O.

Complicating things considerably, some formats in ffmpeg require seeking
on the output, so we can't just treat everything as a stream of bytes.
To handle this, we record offsets of each write and try to buffer as
many contiguous writes as possible. This unfortunately makes the code
quite complicated, but hopefully well commented.
2022-05-30 10:06:09 -07:00
Richard StanwayandJim 108d32c0c6 UI: Remove m3u8 format from simple output mode
This option regularly confuses users, who accidentally select it and
then ask why they have hundreds of 2-4 second video clips in their
output folder. HLS output format to file is a pretty niche use case,
so let's keep it in advanced mode only.
2022-05-21 15:46:40 -07:00
Richard StanwayandJim c7e83518e1 win-wasapi: Log source name when showing device errors
Sometimes users have a forgotten source pointing to an invalid device,
which is very difficult to locate without us showing the source name.
2022-05-17 02:47:08 -07:00
Richard Stanway 377af35016 UI: Move scene import dialog to the stack
Changed for consistency as almost every other dialog in the application
is stack-allocated.
2022-05-16 21:51:01 +02:00
Richard Stanway 8bd4ef61a0 obs-ffmpeg: Change types to avoid unnecessary casts 2022-05-07 16:01:48 +02:00
Richard Stanway 4c96feafab obs-ffmpeg: Fix compiler warning 2022-04-19 03:23:53 +02:00
Richard Stanway 42ce624b13 libobs: Remove unnecessary blend_type assignment
The code pattern for all other assignments skips the default value.
Detected by PVS Studio.
2022-04-19 03:16:48 +02:00
Richard Stanway 0bc955bdf2 libobs: Fix wrong enum in obs_sceneitem_get_blending_method
Detected by PVS Studio.
2022-04-19 03:16:48 +02:00
Richard Stanway a8ecf3c8f2 UI: Fix display affinity logic when re-applying
The old behavior toggled display affinity every time the window was
updated instead of applying it consistently.
2022-03-31 17:23:53 +02:00
Richard StanwayandJim 85addc3dac UI, file-updater, rtmp-services: Enable curl ALPN support
In the years since this code was added, ALPN is now widely supported,
and NPN is being removed entirely in the latest version of nginx. It's
time to start using ALPN!
2022-03-24 17:10:01 -07:00
Richard Stanway 9170e0a9b1 obs-qsv11: Fix double free on CreateSurface failure
_dx9_simple_free already frees this pointer. I don't think this code
path is currently reachable, but it should probably still be fixed.
Detected by Coverity Scan.
2022-03-18 18:11:24 +01:00
Richard Stanway da4d98d0e4 UI: Remove some globals in AAC bitrate population 2022-03-09 22:54:22 +01:00
Richard StanwayandJim 702df3cd8d win-wasapi: Fall back to old code if RTWQ fails
Fixes a crash if RTWQ is unavailable, e.g. if the mmcss service is not
running.
2022-02-24 19:28:19 -08:00
Richard StanwayandJim a39d174100 obs-outputs: Set a fixed size socket buffer on Windows 7
Auto tuning apparently doesn't work very well on this version and
af6844f5c2 caused throughput
regressions.
2022-02-20 16:16:17 -08:00
Richard Stanway aa73de952b UI: Fix uninitialized memory access in OBSPropertiesView
Bug introduced in b0528e0cf7. Closes
https://github.com/obsproject/obs-studio/issues/5934.
2022-02-08 21:57:08 +01:00
Richard StanwayandJim 4cc419e3c9 libobs: Free module if obs_module_load callback returns false
Currently if a module fails its load callback, it remains loaded and OBS
continues to call additional exports such as obs_module_post_load. This
goes against the documented behavior, which states that a module that
fails its load callback is unloaded.

This commit releases locale resources and frees the module's
information, preventing further callbacks from libobs. The module itself
(the DLL) is not yet unloaded from memory as os_dlclose is commented out
for causing unspecified issues - this should be revisited in the future.
2022-01-28 19:14:00 -08:00
Richard Stanway 5ed45d06da UI: Check current affinity before calling SetWindowDisplayAffinity
For some reason, SetWindowDisplayAffinity can make windows visible even
when it sets the same value for affinity that GetWindowDisplayAffinity
reports. Possibly an API bug as this is probably not a widely used API
yet?

Fixes a weird window with no size appearing when browsing for files on
Windows.
2022-01-27 02:47:11 +01:00
Richard StanwayandJim 40a598008d UI: Fix QLabel leak in OBSPropertiesView::AddProperty
OBS_PROPERTY_GROUP creates neither a widget nor a label, causing
AddProperty to create a default one. Without a widget, it does not
get attached to the layout, resulting in a memory leak.

This commit also simplifies a bit of the code to avoid repeatedly
testing the same condition.
2022-01-25 06:01:23 -08:00
Richard StanwayandJim 076cd5d5d4 UI: Add option to hide OBS windows on Windows
This uses the SetWindowDisplayAffinity API to hide windows from capture
applications (including OBS). This is not perfect - internal windows
such as context menus, combo box dropdowns, etc will still be displayed.
Even with these limitations, it should help people with single monitors
capture content with less interference from the OBS window.

This implementation is for Windows only but the code is generic enough
that adding other platforms should be straightforward.
2022-01-22 15:14:16 -08:00
Richard Stanway 3ce12bc5e9 UI: Optimize undo/redo functions with constant references 2022-01-19 21:39:43 +01:00
Richard StanwayandJim 82b5a39ea4 libobs: Mark raw_active and gpu_encoder_active as volatile
These were operated on by atomic functions but were not marked as
volatile or loaded with os_atomic_load_long, potentially introducing
subtle race conditions. Detected by ThreadSanitizer.
2022-01-18 03:49:20 -08:00
Richard StanwayandJim 85ac469458 UI: Use regexp to filter filename formatting
Avoids unbounded stack growth when pasting content that has many invalid
characters. Fixes https://github.com/obsproject/obs-studio/issues/5815.
2022-01-18 03:34:58 -08:00
Richard Stanway d458780f02 win-capture: Use stack buffer for small window titles
Avoids expensive malloc calls that might also contribute to excessive
heap fragmentation.
2022-01-18 01:58:45 +01:00
Richard Stanway ecf8c1239d win-capture: Make open_process_proc static
Seems like the original intention and avoids repeatedly calling
GetProcAddress. Detected by PVS Studio.
2022-01-18 00:00:10 +01:00
Richard Stanway 1af1a432e2 text-freetype2: Fix incorrect fread argument order
This fixes UTF-16 BOM files being loaded incorrectly and having their
newlines parsed incorrectly in read from end mode. Detected by PVS
Studio.
2022-01-17 23:40:48 +01:00
Richard Stanway a3c97dfad2 libobs-opengl: Miscellaneous static analysis fixes
Detected by PVS Studio.
2022-01-15 23:02:38 +00:00
Richard Stanway 3240b05cec libobs-d3d11: Fix formatting 2022-01-15 00:38:02 +01:00
Richard Stanway dccf569982 libobs: Specify format string for bcrash
Detected by PVS Studio.
2022-01-15 00:31:31 +01:00
Richard Stanway 42fc705333 obs-filters: Fix incorrect format string
Detected by PVS Studio.
2022-01-15 00:17:02 +01:00
Richard Stanway 74b5bed116 libobs-d3d11: Fix incorrect format string
Detected by PVS Studio.
2022-01-15 00:16:39 +01:00
Richard Stanway 7f2dfd53a9 libobs-opengl: Use correct size for PIXELFORMATDESCRIPTOR
Issue detected by PVS Studio.
2021-12-30 22:53:22 +01:00
Richard StanwayandJim af6844f5c2 obs-outputs: Only log SO_SNDBUF on RTMP socket
From Windows 7 onwards, dynamic send buffering is enabled. By setting
SO_SNDBUF explicitly, we actually disabled the dynamic send buffering
feature which results in reduced throughput. Thankfully this did not
affect the majority of users since the default send buffer is usually
already 64k.

This commit replaces the setting of SO_SNDBUF with log output showing
the current value of SO_SNDBUF at stream start and end. This will aid in
debugging throughput issues caused by a buffer that isn't big enough,
perhaps as a result of the user disabling dynamic send buffering
system-wide.
2021-12-27 14:29:43 -08:00
Richard Stanway 5be6681687 libobs: Check memory allocation in Windows crash handler
If we're crashing due to a low memory condition, it's dangerous to
try to allocate more memory without checking for success.
2021-12-26 17:48:54 +01:00
Richard Stanway 7d64e9d598 libobs: Use size_t for obs_encoder_get_frame_size 2021-12-26 17:32:00 +01:00
Richard Stanway ea1ae59149 UI: More user-friendly error when using a bad output path 2021-12-13 22:32:09 +01:00
Richard Stanway e7aa332d38 libobs: Disable function attributes for SWIG 2021-12-09 03:36:40 +01:00
Richard Stanway 10446c1a0b UI/updater: Explicitly set PSAPI_VERSION=2
If the user didn't set their minimum SDK level this would default to
PSAPI_VERSION=1 which requires psapi.lib (removed in 4614c057).
2021-12-09 02:51:08 +01:00
Richard Stanway b37acbcbc1 libobs: Add OBS_NORETURN and use it for crash handler
Fixes some analyzers flagging code after a crashing path makes it
impossible to reach.
2021-12-09 02:42:37 +01:00
Richard Stanway 0438d60499 UI: Remove duplicate translate_button macro call 2021-12-08 02:24:50 +01:00
fad299f99f aja: Static analysis bug fixes
* aja: Use inline const for header initializations

Avoids duplicating across compilation units. Detected by PVS Studio.

* aja: Avoid unnecessary type conversions

Detected by PVS Studio.

* aja: Remove duplicate assignments

Detected by PVS Studio.

* aja: Fix return value of aja_output_create

Detected by PVS Studio.

* aja: Remove unused variable

Detected by PVS Studio.

* aja: Fix compiler warning

* aja: Remove unreachable if branch in aja routing

* aja; Cleanup return in card manager

Co-authored-by: Colin Edwards <colin@recursivepenguin.com>
2021-12-05 22:17:39 -06:00
Richard StanwayandJim 4395005a24 UI: Remove thread from YouTube auto config
This was causing crashes on auto config dialog creation, as Qt GUI
objects can only be safely accessed from the main thread. Fixes #5364.
2021-10-01 13:57:48 -07:00
Richard StanwayandJim 422a206371 UI: Force minimum reconnect delay of 1 second
Setting this to zero breaks reconnecting (and OBS) entirely as various
parts of the reconnect system do not handle zero values properly, and
there are also possible race conditions with the reconnect thread. Set a
minimum of 1 second to avoid this.
2021-09-16 03:32:46 -07:00
Richard StanwayandJim 4687e99563 UI: Use secure RNG for generating YouTube state parameter
mt19937 is a deterministic RNG and was not seeded, so the state
parameter was identical for all runs. Switch to using Qt's
QRandomGenerator::system() which is implemented as a CSPRNG on
all platforms we care about.
2021-09-15 06:16:29 -07:00
Richard StanwayandJim 0a13ce851d UI: Properly verify state parameter for YouTube auth
Very low risk of anything bad here since we use a random port and the
chance of a CSRF attack is tiny, but this is a best practie to do when
using OAuth.
2021-09-15 06:16:29 -07:00
Richard Stanway 9411c548d3 obs-outputs: Disable Windows socket loop when using RTMPS
Since this is activated after starting the output, it assumes there is
no need to read anything from the connection as RTMP is send-only from
that point on. However with TLS, reading protocol messages is required
for proper operation, causing it to immediately fail on RTMPS
connections. This is a complex fix due to the way it interacts with
librtmp and mbedTLS so let's just disable it for now to avoid breaking
things for users.
2021-09-03 18:15:17 +02:00
Richard StanwayandJim 4772a99e3e libobs: Defer reconfiguring encoders to the encode threads
Fixes a long-standing issue with Dynamic Bitrate where the RTMP output
thread could try to reconfigure an encoder while the encoder is in the
middle of encoding. x264 seems to handle multithreaded calls well, but
NVENC would deadlock in this situation with no error visible to the
user.
2021-08-23 18:26:37 -07:00
Richard StanwayandJim 1444ead812 Revert "obs-ffmpeg, obs-qsv11: Disable dynamic bitrate support"
This reverts commit 1b29bfc884.
2021-08-23 18:26:37 -07:00
Richard StanwayandJim f131c0c36b UI: Use inline const for shared vector
Issue detected by PVS Studio.
2021-08-22 17:12:00 -07:00
Richard StanwayandGitHub 64f3b29e02 Merge pull request #4678 from cg2121/logviewer-fixes
UI: Log viewer fixes
2021-08-21 21:59:05 +02:00
Richard StanwayandJim 1b29bfc884 obs-ffmpeg, obs-qsv11: Disable dynamic bitrate support
Unfortunately these encoders tend to crash or freeze after after
multiple bitrate changes. Users with dynamic bitrate enabled
experience a random encoder freeze which manifests as OBS dropping to
0kb/sec and disconnecting and it's not at all obvious that dynamic
bitrate is the cause. Disable it for now until we can figure out if
there is any workaround or bug on our end.
2021-08-20 14:51:16 -07:00
Richard Stanway 30257c9fe3 libobs-winrt: Improve error logging code
Use code() instead of to_abi() on hresult_error structs as the latter
has additional side effects. Cast all values to int32_t to ensure the
hresult int32_t() operator is called so we pass the actual value and not
the full struct (detected by PVS Studio).
2021-08-19 02:16:45 +02:00