Commit Graph

2190 Commits

Author SHA1 Message Date
nanahi 1d82932cce various: use fopen wrapper for cloexec handling 2026-06-04 04:58:16 +02:00
Kacper Michajłow ad119d9dc9 stream_curl: expose redirect location to lavf
Some demuxers like DASH and HLS, query the location through the
"location" av option, this is how http.c in lavf exposes it. Respect
this interface and expose effective url.

Fixes: https://github.com/mpv-player/mpv/pull/18044
2026-06-02 08:36:21 +02:00
Kacper Michajłow 13a3e3ad0e stream_curl: log user friendly message when TLS verification fails 2026-05-28 20:14:35 +02:00
Kacper Michajłow ee3d72ce02 options: enable tls-verify by default
We shouldn't default to no verification in current year. User can
opt-out if needed.

Keep it disable for builds without libcurl when libavformat is older
than 63.0.100. This is done to match ffmpeg's timeline for enabling
tls_verify by default in lavf, also to ensure we the default verify
locations will be loaded on such version.
2026-05-28 20:14:35 +02:00
Kacper Michajłow ca89a744c9 stream_curl: tell libcurl to use the native CA store
This is independent of other CA certificate locations set at run time or
build time. Those locations are searched in addition to the native CA
store.
2026-05-28 20:14:35 +02:00
Kacper Michajłow 427e4bf25d stream_curl: support offset/end_offset passed in AVDictionary
lavf's http demuxer exposes initial/final byte offsets as AVOptions.
Some demuxers, like lavf/hls.c assume it is always available, even for
custom IO. We need to use those values for correct demuxing.

Fixes: https://github.com/mpv-player/mpv/pull/17879#issuecomment-4468476976
2026-05-26 19:32:02 +02:00
Kacper Michajłow 059bc7025b stream_curl: disable by default on libavformat < 62.15.101 2026-05-16 18:20:42 +02:00
Kacper Michajłow 724b76fe0a stream_curl: add --curl-enabled option 2026-05-16 18:20:42 +02:00
Kacper Michajłow 9a9c890e23 stream_curl: use for ftp/ftps
It's significantly more stable than Lavf. Fixes seeking out of cached
ranges. Additionally correctly marks demuxer_is_network for ftp too.
2026-05-16 18:20:42 +02:00
Kacper Michajłow 4dc772c429 stream: don't drop data on stream_read_more
At the initial file open, the buffer may be populated with more data,
than later requested by decoder, but don't drop this data. This fixes
initial open to perform multiple reads of the area, especially for
images that are likelly fully read for probbing already.
2026-05-16 18:20:42 +02:00
Kacper Michajłow 332764d909 stream_curl: build protocol list based on libcurl state
Allow only subset of supported protocols by libcurl.
2026-05-16 18:20:42 +02:00
Kacper Michajłow b14d8f5ee1 demux_lavf: route nested HTTP opens through the curl backend
Hook AVFormatContext.io_open so HLS/DASH segment fetches and other
nested FFmpeg I/O go through stream_http when libcurl is available.
This lets segments inherit the connection reuse, HTTP/2 multiplexing,
mid-stream resume and conditional compression of the top-level stream.

Falls back to FFmpeg's default I/O for non-HTTP URLs and when the curl
backend is not built in.
2026-05-16 18:20:42 +02:00
Kacper Michajłow f658223abb stream_curl: allow reading cookies not only from a local file 2026-05-16 18:20:42 +02:00
Kacper Michajłow c6833a9307 stream_curl: add libcurl-based stream backend
Introduces stream_http, an internal libcurl-driven backend for http://
and https:// URLs. Runs all transfers on a dedicated curl multi thread
with a producer-side ring buffer, and exposes HTTP/2 multiplexing,
QUIC/HTTP/3 (when libcurl supports it), HSTS and TCP keep-alive.

Should generally be more stable and faster than FFmpeg HTTP/1.1 impl,
additionally connections are kept-alive between files open, so if you
open playlist of network files and navigate through them, it will re-use
the same connection.

Build is gated on the new 'libcurl' meson option (auto). When disabled
or unavailable, mpv silently falls back to FFmpeg's HTTP implementation.
2026-05-16 18:20:42 +02:00
Kacper Michajłow cdd3f1197f stream: split shared network options into their own sub-options
Will be useful for future commits
2026-05-16 18:20:42 +02:00
Kacper Michajłow 893313e5af stream/cookies: allow reading cookies not only from a local file 2026-05-16 18:20:42 +02:00
Kacper Michajłow 48bd97b5bb stream_dvdnav: don't leak times in STREAM_CTRL_GET_CHAPTER_TIME 2026-05-01 05:01:37 +02:00
Kacper Michajłow 4182a1df43 stream_dvdnav: use named definition for return val 2026-05-01 05:01:37 +02:00
Kacper Michajłow 118dda68c1 stream_dvdnav: fix STREAM_CTRL_SET_ANGLE return value
It was flipped and returned ok on error.
2026-05-01 05:01:37 +02:00
nanahi da2739f44f various: don't check if endptr is null for strto[udll]
These functions always set endptr to non-null so there is no need to
check.
2026-04-17 04:09:23 +02:00
NRK e2180e581e demux_playlist: only autocreate on regular file
trying to autocreate playlist when the file is a fifo breaks
playback. the bug report is a special case of `/dev/fd/*` but
even for named fifos, opening and closing them can cause the
other end to stop writing.

Closes: https://github.com/mpv-player/mpv/issues/17682
2026-04-06 18:50:28 +02:00
Rudi Heitbaum 8ace278cbe various: fix Wdiscarded-qualifiers warnings
Signed-off-by: Rudi Heitbaum <rudi@heitbaum.com>
2026-03-15 14:49:00 +01:00
nanahi 8ac52fd1ab various: use mp_sleep_ns 2025-10-27 20:00:59 +01:00
arch1t3cht eba7a11a2e player/command: do seamless angle change when bluray-angle is changed 2025-09-15 03:52:35 +02:00
arch1t3cht 31bd176357 stream_bluray: add bluray-angle option
1-index angles to be consistent with DVD angles in mpv and with the
1-indexing in other applications like libbluray's example programs.

The three existing calls to bd_get_title_info all only access the
duration, the playlist, and the number of angles, which do not depend on
the passed angle, so they can keep being called with angle 0 for
simplicity.

Documentation taken from before
35e8b6c1e6.

Fixes #5012.
2025-09-15 03:52:35 +02:00
arch1t3cht 7b791733ce stream_bluray: show number of angles in title list 2025-09-15 03:52:35 +02:00
Attila Fidan 211c9cb7c9 stream_libarchive: seek source stream to 0 before probing
If p->mpa = NULL due to an error during a seek or fill_buffer, then when
archive_entry_seek(), if newpos != s->pos, reopen_archive() ->
mp_archive_new() -> mp_archive_probe(), which asserts stream_tell(src)
== 0. This won't be the case if the previous mpa left the source stream
seeked in the middle of the file.

For example, in samples in archives where avformat_find_stream_info
takes a long time, if playback is aborted while the demuxer is doing
that, reading from the source stream will stop working due to cancels
being triggered. When archive_entry_seek() and newpos != s->pos,
reopen_archive() -> mp_archive_new_raw() -> archive_read_open1() fails
and returns with mpa == NULL due to reads not working. Then when another
seek happens, reopen_archive() -> mp_archive_new() -> mp_archive_probe()
-> assertion failed.

One solution is to have reopen_archive return STREAM_ERROR if the stream
is cancelled, since nothing useful can happen in this case. But there
are other situations where p->mpa could become NULL (fatal errors), and
it is supposed to be possible to seek back to a working area of the
archive.

Fixes: https://github.com/mpv-player/mpv/issues/15174
2025-08-12 18:38:50 +02:00
Dudemanguy 26373c5497 Reapply "options: parse tls-related options as path"
This reverts commit 5c4c067ee6.
2025-08-08 01:07:00 +00:00
Dudemanguy 29307c26ba Reapply "various: expand paths for all file/directory related options"
This reverts commit 43fda5442f.
2025-08-08 01:07:00 +00:00
Kacper Michajłow c4bc4f6d5b stream_bluray: use bd_get_main_title() to get main title
It uses a more sophisticated heuristic for title selection. It not only
selects the longest title but also considers quality and chapters. Refer
to the libbluray source for details.

No documentation change, "longest" option will still look for the
longest, just may work better now.

Fixes selection of title on some discs.
2025-08-06 18:04:46 +02:00
Kacper Michajłow bdca44773a stream: remove stream_info_bdnav
It was disabled in 3b3170aedb.
2025-08-06 18:04:46 +02:00
Kacper Michajłow b6d8336658 stream_dvdnav: fix --edition when dvd:// is not used directly
When directory is redirected to dvd demuxer, --edition was ignored.
2025-08-06 18:04:46 +02:00
Kacper Michajłow 218561fe69 stream_bluray: fix --edition when bd:// is not used directly
When directory is redirected to bd demuxer, --edition was ignored.
2025-08-06 18:04:46 +02:00
Dudemanguy 5c4c067ee6 Revert "options: parse tls-related options as path"
Since the core option parsing does this, we no longer need special
handling here.

This reverts commit 43e83dc74b.
2025-07-22 17:52:41 +00:00
Dudemanguy 43fda5442f Revert "various: expand paths for all file/directory related options"
Since the option system now handles all the path expansion
automatically, these recent changes can be reverted for simplicity.

This reverts commit be15be3a83.
2025-07-22 17:52:41 +00:00
Oliver Freyermuth 7bfc038528 stream_dvb: allow to enforce DVB-S/T for old zap format channels.conf
If a card supports both DVB-T/T2 or DVB-S/S2, channels.conf.{sat,ter}
was always interpreted as DVB-T2 / DVB-S2 before this change.
After this change, using channels.conf.{sat1,ter1} will enforce
interpretation as DVB-S/T.
The superior VDR channel config format is still the recommended solution
for such cards as it allows to specify the delivery system variant per
channel, but enforcing T2/S2 for cards supporting it whenever the zap
format is used does not seem reasonable.
2025-07-22 08:29:21 +02:00
sfan5 cf00b07536 various: use MP_ARRAY_SIZE macro 2025-05-31 09:59:54 +02:00
Patrick Wang 43e83dc74b options: parse tls-related options as path 2025-05-21 14:43:24 +00:00
xyfish 139591a078 libarchive: try to use utf8 pathname 2025-05-08 00:46:23 +02:00
Kacper Michajłow f152674246 stream_edl: allow opening edl only from local resources
edl is complex and prone to errors. Also there is no good reason for
external network playlist to require edl use.
2025-03-07 14:19:15 +01:00
Kacper Michajłow babea3da1f Revert "stream/stream: mark mf:// and edl:// as unsafe protocols"
At least part of it, because there was rebase error in original commit
with unrelated changes.

This reverts commit 9bc3aee6fb.
2025-03-07 14:19:15 +01:00
Kacper Michajłow 45c6077756 stream_mpv: restrict only to network links 2025-03-07 14:19:15 +01:00
Kacper Michajłow 93ea3df0a9 player: add mpv:// protocol
This is useful to run mpv from URL handler. Can be used to start mpv
from you web browser or anything that would trigger url handler for
given protocol. Only safe protocols are allowed.

Current solutions to run mpv in such context are to spawn IPC proxy and
run mpv when requested, but this is in most cases not necessary.

Currently the protocol is added in mpv.desktop. Windows related
registration will follow in future changes.
2025-03-07 00:15:23 +01:00
Kacper Michajłow 9bc3aee6fb stream/stream: mark mf:// and edl:// as unsafe protocols 2025-03-07 00:15:23 +01:00
Kacper Michajłow d035a63913 stream_dvdnav: cast to int64_t before multiplication
Just to silence static analysis warning. It is assigned to int64_t
anyway.
2025-03-06 21:58:38 +01:00
Kacper Michajłow dd107a1a39 stream_cdda: cast to int64_t before multiplication
Just to silence static analysis warning. It is assigned to int64_t
anyway.
2025-03-06 21:58:38 +01:00
Kacper Michajłow 401939b6e3 stream_cdda: add sanity checks on track numbers
Makes sure that we return error when end or start track fails to be
found.
2025-03-06 21:58:38 +01:00
Kacper Michajłow 1c49cfdb97 various: use mp_assert macro 2025-03-04 20:07:29 +01:00
Kacper Michajłow d759e26fd0 libmpv: use correct header directory name
libmpv headers are installed to `mpv/`, so why are we pretending it is
`libmpv`?

Fixes documentation, libmpv meson dependency, tests.
2025-02-23 01:40:12 +01:00
Yozora80 131973806d Revert "stream_{bluray,cdda,dvdnav}: deprecate setting device after schema"
This reverts part of PR #15899 (commit dd6e3a0ece).

"Why is this even useful?": It's very useful for multi-disc playlists. Compare:
`mpv bd:///DISC{1..4}`
`mpv -\{ bd:// --bluray-device=DISC1 -\} -\{ bd:// --bluray-device=DISC2 -\} -\{ bd:// --bluray-device=DISC3 -\} -\{ bd:// --bluray-device=DISC4 -\}`
2025-02-21 15:26:23 +00:00