Commit Graph

6111 Commits

Author SHA1 Message Date
Martin Pulec
9938f6b082 av_log_ug_callback: handle overflow
If the buffer is full, flush the output even if there is no NL at the
end and issue a warning (should be handled - either some error or some
module produces unexpectedly long output).
2023-11-01 17:01:32 +01:00
Martin Pulec
fea0d10f67 improved UG FFmpeg logger
do not prefix messages not starting on new line by timestamps, eg.:

    $ uv -s embedded -t testcard -d file:n=/dev/null -V
    [1698853041.393] [lavc]   Stream #0:0[1698853041.393] : Video: rawvideo, 1 reference frame (UYVY / 0x59565955), uyvy422, 1920x1080 (0x0), q=2-31, 829440 kb/s[1698853041.393] , [1698853041.393] 25 tbn[1698853041.393]

Flush the output only on NL and before it store it in internal
thread-local buffer.

Locking was removed as static data are now thread-local.

this improves 808b3de3
2023-11-01 17:01:31 +01:00
Martin Pulec
40d2c66903 file disp.: initialize UG AV logging
not necessary, but better; also makes UG behavior deterministic, eg.:

    uv -s embedded -t testcard -d file:n=/dev/null [-c libavcodec] -V

produce different output for file depending if libavcodec is on or off
(AV messages prefixed by UG logger).
2023-11-01 17:01:31 +01:00
Martin Pulec
1589eae332 display file: changed allowed av diff to 100 ms
\+ set the option to be in seconds instead of video frame times

refers to GH-333
2023-11-01 12:01:09 +01:00
Martin Pulec
5d3c31c115 to_lavc_vid_conv: cp metadata out to tmp (refactor)
Set metadata to out_frame only and copy it to tmp_frame (not to repeat
every assignment and potentially forgotting something).

\+ check tmp_frame afor allocation failure
2023-10-31 11:03:36 +01:00
Martin Pulec
37ae3935e9 to_lavc_vid_conv: set AVFrame CS and range
Some encoders use `colorspace` and `color_range` from AVFrame,
eg. _hevc_videotoolbox_:

   uv -t testcard -c libavcodec:encoder=hevc_videotoolbox

(defaults to bgra, because other foramts don't keep 4:2:2 subsampling,
supported at the time: videotoolbox_vld nv12 yuv420p bgra p010le).

Fixed error was producing this message:
````
[lavc hevc_videotoolbox @ 0x12fc04190] Could not get pixel format for color format 'bgra' range 'unknown'.
[lavc hevc_videotoolbox @ 0x12fc04190] Error: Cannot convert format 28 color_range 0: -22
```
2023-10-31 10:57:07 +01:00
Martin Pulec
c5e5547229 avfoundation: fixed macOS 14 warning
AVCaptureDeviceTypeExternalUnknown is now AVCaptureDeviceTypeExternal
(the former is a deprecated alias).
2023-10-31 10:18:41 +01:00
Martin Pulec
e3f65ad836 ug_input: option to enforce decode pixfmt
refer to GH-349
2023-10-31 08:37:15 +01:00
Martin Pulec
6d548acf32 ug_input: refuse non-numeric opt
Currently only port number is accepted - refuse any option that doesn't
match this.

\+ created a separate function for parsing
2023-10-30 17:23:32 +01:00
Martin Pulec
f4aeae09a0 ug_input: improved includes+using
- sort includes alphabetically
- system includes first
- do not include config*.h (not needed)
- do use-include whole namespace (std and std::chrono)
2023-10-30 17:21:54 +01:00
Martin Pulec
0d82c70927 hd-rum-translator.cpp: refactor includes
- include system headers first
- do not include config*h (not needed)
- use C++ compatible header name for C headers (stdlib.h->cstdlib)
2023-10-30 16:10:02 +01:00
Martin Pulec
fef59e7b8d hide vidcap "none" in vidcap listing
(when `-t fullhelp` is not used)
2023-10-30 16:03:02 +01:00
Martin Pulec
bbedc297c4 pipewire_common.cpp: suppress a warning 2023-10-30 15:54:09 +01:00
Martin Pulec
eaf805d424 hd-rum-transcode: port val check updates
1. really check non-negativity - until now, the parsed string was
dirrectly assigned to ushort, effectively disabling the check ((short)-1
== 65535)
2. check also upper bound to be less than USHRT_MAX
3. **allow** 0 as a port - supposedly this is a relict when atoi() was
used to parse the port, so that it was supposed to be error in
conversion. There may be, however, legitimate reasons to use 0 as a port
to bind random port (although UG doesn't print it so the user would need
to obtain its value eg. with iproute2 if required). Just print a warn.
2023-10-30 15:40:05 +01:00
Martin Pulec
f09a56b84b hd-rum-translator: moved opt parsing from main()
As we are now throwing exeptions, the validity check can be moved to
the place where it is set.
2023-10-30 12:57:27 +01:00
Martin Pulec
6c64015fb3 hd-rum-transcode: better wrong usage handling
Process exceptions as with:

     hd-rum-transcode 5004 -P 6004 localhost

where buffer size is omitted - `-P` is parsed as buffer number producing
invalid argument exeption.

Converted the expected invalid_argument exceptions to ug_runtime_error
that is catched in main().
2023-10-30 12:47:51 +01:00
Martin Pulec
4b326fc709 hd-rum-transcode: moved size parsing to fn 2023-10-30 12:32:05 +01:00
Martin Pulec
97041f5a49 hd-rum-transcode: print error even if no argument
Until now, if called without argument, help was printed but without the
error message. Since arguments are mandatory and to query help, rather
'-h' should be used, rather print error in this case. This also correspons
with the exit with non-zero return code.
2023-10-30 12:29:30 +01:00
Martin Pulec
534aaa7273 hd-rum-translator: be specific which param is missing 2023-10-30 12:22:46 +01:00
Martin Pulec
8ccead27c7 hd-rum-translator: removed unneeded includes 2023-10-30 11:23:20 +01:00
Martin Pulec
ad59c943ba hd-rum-translator: use stoi instead of atoi
Catches situations when input parameter validation is unintentionally
omitted, eg.:

    hd-rum-transcode 5004 -P 6004 localhost

(missing buffer size not handled)
2023-10-30 11:22:35 +01:00
Martin Pulec
5294185671 hot-fixed crashing Spout on log setting
refer to GH-352
2023-10-30 10:31:33 +01:00
Martin Pulec
468b2ca2eb lavc audio: fixed typo
fixes #351
2023-10-30 10:31:16 +01:00
Martin Pulec
5ac3f93754 screen win: print examples in fullhelp 2023-10-27 15:04:58 +02:00
Martin Pulec
c9bdbc145f screen win: grab even if just screen:clear_prefs
Previously it cleared the preferences and exitted if no options followed
but starts grabbing otherwise, which is inconsistent. If user wants just
clearing preferences, Ctrl-c may be pressed immediately to exit.
2023-10-27 14:45:26 +02:00
Martin Pulec
8b412140d7 renamed get_win_error->get_win32_error
it formats win32 errors, but not HRESULT in general
2023-10-27 12:18:17 +02:00
Martin Pulec
9ac5e932c5 hresult_to_str: use HRESULT_FACILITY win32 check
Not all upper 16 bits denote the facility, only least significant last
13 of them. Eg. the most significant bit set to 1 indicates error.
2023-10-27 12:13:08 +02:00
Martin Pulec
a039efd643 screen win: print winreg configuration
As it is persistent, it should provide a hint if unexpected behavior
occurs because of the persistent setting.
2023-10-27 11:02:29 +02:00
Martin Pulec
333dd230e7 screen win: small updates
- don't print help on incorrect param - the help actually takes almost
exaxtly the size of default Windows Terminal size and the error message
is printed prior to the usage, so it is hard to find/not obvious at
first glance
- renamed functions modifying window register to contain it in name
2023-10-27 10:47:14 +02:00
Martin Pulec
23aaaa1336 screen win: pass any accepted reg key
Pass any key that screen-capture-recorder recognises as a register key.
2023-10-27 10:47:10 +02:00
Martin Pulec
be9f5a0a22 screen win: add size= and deprecate width/height 2023-10-27 08:50:06 +02:00
Martin Pulec
fff828b8b9 screen win: refactor a bit 2023-10-26 16:38:13 +02:00
Martin Pulec
f5570da5ff screen win: allow clean_params trailing opts 2023-10-26 16:27:36 +02:00
Martin Pulec
66e129766b screen win: report errors from set_key
\+ use SCREEN_CAP_REG_TREE macro instead of hard-codec string
2023-10-26 16:14:25 +02:00
Martin Pulec
dd70016f4e screen win: print reg path incl. prefix 2023-10-26 16:14:25 +02:00
Martin Pulec
34a8c7e767 screen win: print notice how to erase prefs 2023-10-26 16:14:25 +02:00
Martin Pulec
ff2deba1ff screen win: add clear_prefs
Since all preferences are written to (user) registry, it becomes
persistent. Instead of the hassle of storing/restoring previous value,
we let it for now saved but added this option to remove all prefs.
2023-10-26 16:12:54 +02:00
Martin Pulec
610a49c190 screen win: sleep 2 seconds after registration
It seems like there is slight delay before it can be used and since the
child process is started immmediately, wait for 2 secons to ensure.
2023-10-26 16:11:49 +02:00
Martin Pulec
9c8b8977c2 screen win: wait for process termination 2023-10-26 16:11:49 +02:00
Martin Pulec
624b34f7bd screen win uninitialize elevated: do not coinit
For uninit, screen-capture-recorder-x86.dll calls CoInitialize(0) and
fails because it fails.

Curiously this doesn't occur for register, which should be equivalent.
2023-10-26 16:11:49 +02:00
Martin Pulec
e0a590ad83 screen win: improve err handling
- print string errors in elevated [un]register
2023-10-26 15:32:17 +02:00
Martin Pulec
bf5e2f0896 win hresult_to_str: get_win_error for win32 errs 2023-10-26 15:32:13 +02:00
Martin Pulec
cd2ee21a5c screen win: pause after elevated [un]register
The output is open in new window and we like to see result (especially
if it fails).
2023-10-26 14:35:11 +02:00
Martin Pulec
0367872835 screen win: minor updates:
- help - help and unregister on new line
- if unknown option, print which it was
2023-10-26 14:34:51 +02:00
Martin Pulec
05b824a236 screen win: check ret value of ShellExecute 2023-10-26 12:08:32 +02:00
Martin Pulec
e3cf7779ee screen_win: print unregister errors 2023-10-26 12:08:27 +02:00
Martin Pulec
309f2dfa80 append_sig_desc: support for MSW 2023-10-26 09:18:57 +02:00
Martin Pulec
f3d7f996ce strappend doxy: clarification + use case 2023-10-26 08:44:45 +02:00
Martin Pulec
cfa25394a5 lavc audio: ensure NUL-termination on truncation
strappend() actually doesn't NUL-terminate output, so in the edge cases,
the output doesn't need to be terminated.
2023-10-26 08:44:45 +02:00
Martin Pulec
06956f0544 print caught signal desc in verbose 2023-10-26 08:44:43 +02:00