Commit Graph

248 Commits

Author SHA1 Message Date
Loïc Branstett f93de3ef23 stream/demux: move remaining callbacks to their respective ops struct
This commit moves the remaining callbacks of stream/demux: pf_read/
pf_block/pf_seek/pf_readdir and pf_demux into their operations table,
aiming at unifying all the callbacks under a unique place.
This is a follow-up to the introduction of typed controls callbacks
for stream and demux.

Like for the typed controls callbacks if no operation is provided
(ie, stream_t/demux_t.ops is NULL) by a module, the legacy pf_* will be
used instead as a fallback.

The commit doesn't migrate any of modules yet.
2023-03-24 10:51:36 +00:00
Loïc 2a4957c0f8 demux: introduce typed operations for demux
This commit introduce a typed virtual table for operations on demux,
aiming at replacing the legacy pf_control() callback which is using
va_list. As a counterpart to the typed virtual table, typed methods
are also introduce.

The operations can be implemented by the modules directly right now
and will be used when possible. This is done to provide type safety
at every level.

When no operation is provided (ie, demux_t.ops is NULL) by a module
implementation, the legacy pf_control will be used instead as a
fallback.

The commit doesn't migrate any of modules yet.
2023-03-16 14:20:37 +00:00
Steve Lhomme 007e5d910c codec/packtizer: rename p_fmt_in to fmt_in
We don't need to know it's a pointer and can save 2 characters.

No functional changes. This is simply renaming "dec->p_fmt_in",
"decoder->p_fmt_in", "dec.p_fmt_in" and "packetizer->p_fmt_in"
2022-11-16 17:42:04 +00:00
Steve Lhomme 08b24866dc codec/packetizer: make the writable input format private
The writable fmt_in is kept in the decoder/packetizer owner.

The decoder/packetizer only has access to a const version.
2022-11-16 17:42:04 +00:00
Steve Lhomme e652fc2b4f codec/packetizer: expose a read-only version of the input format
All code creating a decoder uses decoder_Init().
Packetizer creation needs to be taken care of as well.
2022-11-16 17:42:04 +00:00
Steve Lhomme 30a1608cb3 demux: add an owner to the packetizer object 2022-11-16 17:42:04 +00:00
Steve Lhomme b54048c100 demux: pass a vlc_object_t to create a custom packetizer 2022-05-18 10:14:50 +00:00
Lyndon Brown f6dad0e9f1 Revert "core: remove pointless re-initialisation of `stream_t` attributes"
This reverts commit b10f5a02e1.

as requested in follow-up discussion in !1104.
2022-01-13 15:42:21 +00:00
Lyndon Brown b10f5a02e1 core: remove pointless re-initialisation of `stream_t` attributes 2022-01-10 07:03:38 +00:00
Lyndon Brown d81e20055e demux: abort module loading upon search string creation failure
if in "any" mode and falling back to an extension based match, and if the
`asprintf()` call fails to create the extension based shortcut search
string, the consensus is that it should give up rather than proceed to try
an "any" based demux module load.

note that the `modbuf = NULL` statement was just resetting the undefined
state of the variable from the failed `asprintf()` call to ensure that the
later `free(modbuf)` was valid. it is not needed now that we go down the
error path.

note, the init of `s->psz_filepath` in `vlc_stream_CustomNew()` is not
strictly necessary to avoid `free()` on an initialised attribute, since
`calloc()` is actually involved in the object creation - much of the
initialisation done in `vlc_stream_CustomNew()` is actually redundant.
2022-01-10 07:03:38 +00:00
Lyndon Brown 0b17f567c7 demux: fix invalid free
upon `asprintf()` failure, the pointer variable used to capture
the result is left in an undefined state.

here, should such failure occur, the later `free(modbuf)` call
would be invalid. we must reset this variable to null upon
failure to fix this.

note that `modbuf` is not the same variable as `module`, which
seems to be causing some confusion in review. this patch has
absolutely no impact upon the operation of this function other
than fixing the bug just described only. it **does not** cause
the module search to operate upon a null search string. it does
not change the search string at all.

note that `module` initially holds a search string owned by the
caller of the function. the function may though need to replace
this with a new string that it must allocate on the heap. for
the purposes of ensuring that the function later only releases
the new string, a copy of the allocated string pointer is kept
in the `modbuf` variable. in fact the string pointer in `module`
is only replaced with the newly allocated one upon success of
`asprintf()`. thus, should the allocation fail, `module` will
remain as `"any"` (the allocation only occurs under an `"any"`
based search). the patch thus does not alter the search string,
and thus does not impact module loading in any way.
2022-01-10 07:03:38 +00:00
Rémi Denis-Courmont 5480568ae8 demux: allow passing URL to demux_New() 2021-10-07 17:57:14 +00:00
Rémi Denis-Courmont f617968196 input: absolute URLs do not necessarily have ://
This accepts a lone ':', which is not followed by two forward slashes
if the URL lacks a host part.
2021-09-19 18:02:31 +00:00
Rémi Denis-Courmont 1b69f64b87 demux: use vlc_uri2path() directly 2021-09-16 19:32:34 +00:00
Rémi Denis-Courmont bf1ba89a40 demux: require :// in MRL
Otherwise, creating the demux won't work anyway.
This is consistent with the current behaviour of access_New().
2021-09-16 19:32:34 +00:00
Lyndon Brown c17d3ae27f modules: widen use of module_Get[Long|Short]Name shortcuts 2021-08-06 07:18:27 +00:00
Romain Vimont f66590a84a stream: remove anonymous union
The two fields of the union have types demux_t and stream_t, which are
the same type (demux_t is a typedef of stream_t).

Signed-off-by: Thomas Guillem <thomas@gllm.fr>
2021-01-12 15:11:28 +01:00
Rémi Denis-Courmont 981bc28452 demux: remove DEMUX_IS_PLAYLIST control
This is always false/unimplemented.
2020-09-28 17:39:55 +03:00
Rémi Denis-Courmont 54df0541ee demux: allow demuxer to expose pf_readdir
This makes the demux_Demux() function handle a demuxer plugin that
exposes a pf_readdir function, and invoke it if the demuxer does not
provide a pf_demux function.
2020-09-28 17:39:55 +03:00
Rémi Denis-Courmont 96d67cec94 demux: de-inline demux_Demux() 2020-09-28 17:39:55 +03:00
Rémi Denis-Courmont 159be0ed8c demux: avoid one string comparison
Track the correct strict flag value. (Note that the strict flag has no
effects if the requested module name is "any".)
2020-09-26 22:22:28 +03:00
Rémi Denis-Courmont 565ed23acd demux: don't clobber psz_name by Content-Type
As is done for the file extension, match the Content-Type after teh
demux object is initialized. This preserves the correct psz_name
property.
2020-09-26 22:22:28 +03:00
Rémi Denis-Courmont 9d858fe2e9 demux: inline one trivial function 2020-09-25 19:04:07 +03:00
Rémi Denis-Courmont cc7762fd6e demux: do not hard-code file extensions in core
(except mp3 which remains a special preparsing case)
2020-09-25 19:04:07 +03:00
Rémi Denis-Courmont c16039c911 demux: always use strongly-typed file extensions
There are two sets of file extension to demux module mapping:
- The "strong" set contains file extensions deemed reliable, either
  because the demux probe is reasonably strict and safe, or because
  the extension is rarely mismatched.
- The "quick" set contains file extensions that are not considered
  reliable. This is essentially "mp3" which is supposedly (?) often
  misused for non-MPGA (or non-raw ES) files.

The quick set cannot be used in normal parsing, as it could pick the
the wrong demuxer (that is to say, MPEG ES). It was introduced in the
original preparsing changeset, presumably to limit the overhead.

There are however no obvious reasons not to use the strong set for
preparsing. This patch does exactly that, and then removes duplicated
mappings for Ogg and WMA.
2020-09-25 19:04:07 +03:00
Rémi Denis-Courmont cf79771c2e demux: merge two variables
(and don't use the same name as another variable in the same function)
2020-09-25 19:03:56 +03:00
Rémi Denis-Courmont 952761111a demux: remove file extension of dirac demuxer
The dirac demuxer was already removed in
eb8ab8df4b.
2020-09-25 16:53:28 +03:00
Rémi Denis-Courmont 05f5cdb1f5 demux: add DEMUX_GET_TYPE
Avoid systematic "unknown query 0x109 in demux_vaControlHelper" error.

Signed-off-by: Alexandre Janniaux <ajanni@videolabs.io>
2020-09-19 12:57:26 +02:00
Steve Lhomme c25d524fae demux: use samples_from_vlc_tick to convert ticks to blocks 2020-08-17 16:13:48 +02:00
Steve Lhomme b475ae88db demux: use vlc_tick_from_samples instead of hardcoded values 2020-08-17 16:13:48 +02:00
Thomas Guillem 7c961eacad demux: add DEMUX_GET_NORMAL_TIME 2019-09-23 13:30:30 +02:00
Roland Bewick 3555777282 demux: add DEMUX_SET_ES_LIST control
Signed-off-by: Thomas Guillem <thomas@gllm.fr>
2019-06-25 20:50:07 +02:00
Thomas Guillem 9dc34b4205 input: hide input_thread_t 2019-06-03 16:15:55 +02:00
Rémi Denis-Courmont 07b7122857 objects: introduce vlc_object_delete()
Objects have one strong reference held by their "owner", and zero or
more weak references generated by vlc_object_hold() et al. This
provides a separate function to remove the strong reference than
vlc_object_release() to remove weak ones.

With this sole change, this is really only an annotation though.
2019-03-06 22:53:24 +02:00
Rémi Denis-Courmont a6d1f82ced input: fix missing force flags (fixes #22002) 2019-03-05 18:16:34 +02:00
Rémi Denis-Courmont b209d29ebc demux: call vlc_objres_clear() on error 2019-03-04 22:02:35 +02:00
Rémi Denis-Courmont fc13953d90 modules: pass force flag as parameter to activation callback 2019-03-04 22:02:35 +02:00
Steve Lhomme 5363279805 remove the $Id$ in the source code 2019-01-17 12:21:18 +01:00
Rémi Denis-Courmont 07c1cc6c89 input: remove no-op casts 2018-12-03 19:55:30 +02:00
Steve Lhomme 929f09bfc0 core: use vlc_tick_t for DEMUX_SET_TIME officially 2018-09-20 10:07:08 +02:00
Steve Lhomme a58b739d06 core: use vlc_tick_t for DEMUX_GET_LENGTH officially 2018-09-20 10:07:07 +02:00
Steve Lhomme 07666913ef core: use vlc_tick_t for DEMUX_GET_TIME officially 2018-09-20 10:05:34 +02:00
Thomas Guillem 6b96ade7dd stream: replace input_thread_t by input_item_t
This will prevent all demuxers/access/streams to mess with the input_thread_t
state.
2018-07-20 17:23:03 +02:00
Steve Lhomme 129b682c36 demux: fix potential crash if the renderer has no demux filter 2018-06-29 17:35:47 +02:00
Rémi Denis-Courmont 6f4256146a demux: split DEMUX_SET_GROUP in ALL and LIST 2018-06-10 13:08:44 +03:00
Rémi Denis-Courmont 80f8e8ab0a demux: split DEMUX_SET_GROUP_DEFAULT from DEMUX_SET_GROUP
This adds a separate control for (re)setting selection to the default
program. This removes the semi-useless first variable argument to
DEMUX_SET_GROUP.
2018-06-10 13:08:44 +03:00
Rémi Denis-Courmont 169c6aee1c demux: merge access and location parameters as URL
(like is being done for access for a while)
2018-04-16 18:08:07 +03:00
Rémi Denis-Courmont ef99cf2d66 demux: remove constant demux_New() parameter 2018-04-16 18:08:07 +03:00
Rémi Denis-Courmont a126b0b758 demux: privatize module pointer 2018-04-06 20:45:10 +03:00
Rémi Denis-Courmont 82a48acb81 demux: set "demux filter" type name 2018-04-06 20:45:10 +03:00