2003-08-02 18:43:59 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* demux.c
|
|
|
|
*****************************************************************************
|
LGPL
Re-license almost all of libVLC and libVLCcore to LGPLv2.1+
This move was authorized by the developers, either:
- by e-mail,
- by vote at the VideoLAN Dev Days 2011,
- on the license website,
- in a contract, oral or written.
No objection was raised, so far.
The developers agreeing are:
Justus Piater
Alexis Ballier
Alexander Bethke
Mohammed Adnène Trojette
Alex Converse
Alexey Sokolov
Alexis de Lattre
Andre Pang
Anthony Loiseau
Cyril Deguet
André Weber
Boris Dorès
Brieuc Jeunhomme
Benjamin Drung
Hugo Beauzée-Luyssen
Benoit Steiner
Benjamin Pracht
Bernie Purcell
Przemyslaw Fiala
Arnaud de Bossoreille de Ribou
Brad Smith
Nick Briggs
Christopher Rath
Christophe Courtaut
Christopher Mueller
Clement Chesnin
Andres Krapf
Damien Fouilleul
David Flynn
Sebastien Zwickert
Antoine Cellerier
Jérôme Decoodt
Jérome Decoodt
Dylan Yudaken
Eduard Babayan
Eugenio Jarosiewicz
Elliot Murphy
Eric Petit
Erwan Tulou
Etienne Membrives
Ludovic Fauvet
Fabio Ritrovato
Tobias Güntner
Jakub Wieczorek
Frédéric Crozat
Francois Cartegnie
Laurent Aimar
Florian G. Pflug
Felix Paul Kühne
Frank Enderle
Rafaël Carré
Simon Latapie
Gildas Bazin
Geoffroy Couprie
Julien / Gellule
Gildas Bazin
Arnaud Schauly
Toralf Niebuhr
Vicente Jimenez Aguilar
Derk-Jan Hartman
Henri Fallon
Ilkka Ollakka
Olivier Teulière
Rémi Duraffort
Jakob Leben
Jean-Baptiste Kempf
Jean-Paul Saman
Jean-Philippe Grimaldi
Jean-François Massol
Gaël Hendryckx
Jakob Leben
Jean-Marc Dressler
Jai Menon
Johan Bilien
Johann Ransay
Joris van Rooij
JP Dinger
Jean-Philippe André
Adrien Grand
Juha Jeronen
Juho Vähä-Herttua
Kaarlo Raiha
Kaarlo Raiha
Kamil Baldyga
Keary Griffin
Ken Self
KO Myung-Hun
Pierre Ynard
Filippo Carone
Loïc Minier
Luca Barbato
Lucas C. Villa Real
Lukas Durfina
Adrien Maglo
Marc Ariberti
Mark Lee
Mark Moriarty
Martin Storsjö
Christophe Massiot
Michel Kaempf
Marian Ďurkovič
Mirsal Ennaime
Carlo Calabrò
Damien Lucas
Naohiro Koriyama
Basos G
Pierre Baillet
Vincent Penquerc'h
Olivier Aubert
Pankaj Yadav
Paul Corke
Pierre d'Herbemont
Philippe Morin
Antoine Lejeune
Michael Ploujnikov
Jean-Marc Dressler
Michael Hanselmann
Rafaël Carré
Ramiro Polla
Rémi Denis-Courmont
Renaud Dartus
Richard Shepherd
Faustino Osuna
Arnaud Vallat
Rob Jonson
Robert Jedrzejczyk
Steve Lhomme
Rocky Bernstein
Romain Goyet
Rov Juvano
Sam Hocevar
Martin T. H. Sandsmark
Sebastian Birk
Sébastien Escudier
Vincent Seguin
Fabio Ritrovato
Sigmund Augdal Helberg
Casian Andrei
Srikanth Raju
Hannes Domani
Stéphane Borel
Stephan Krempel
Stephan Assmus
Tony Castley
Pavlov Konstantin
Eric Petit
Tanguy Krotoff
Dennis van Amerongen
Michel Lespinasse
Can Wu
Xavier Marchesini
Sébastien Toque
Christophe Mutricy
Yoann Peronneau
Yohann Martineau
Yuval Tze
Scott Caudle
Clément Stenac
It is possible, that some minor piece of code was badly tracked, for
some reasons (SVN, mainly) or that some small developers did not answer.
However, as an "œuvre collective", defined as in "CPI 113-2 alinéa 3",
and seeing "Cour. Cass. 17 Mai 1978", and seeing that the editor and
the very vast majority of developers have agreed (> 99.99% of the code,
> 99% of developers), we are fine here.
2011-11-27 21:44:15 +01:00
|
|
|
* Copyright (C) 1999-2004 VLC authors and VideoLAN
|
2003-08-02 18:43:59 +02:00
|
|
|
*
|
2003-12-22 15:32:57 +01:00
|
|
|
* Author: Laurent Aimar <fenrir@via.ecp.fr>
|
2003-08-02 18:43:59 +02:00
|
|
|
*
|
LGPL
Re-license almost all of libVLC and libVLCcore to LGPLv2.1+
This move was authorized by the developers, either:
- by e-mail,
- by vote at the VideoLAN Dev Days 2011,
- on the license website,
- in a contract, oral or written.
No objection was raised, so far.
The developers agreeing are:
Justus Piater
Alexis Ballier
Alexander Bethke
Mohammed Adnène Trojette
Alex Converse
Alexey Sokolov
Alexis de Lattre
Andre Pang
Anthony Loiseau
Cyril Deguet
André Weber
Boris Dorès
Brieuc Jeunhomme
Benjamin Drung
Hugo Beauzée-Luyssen
Benoit Steiner
Benjamin Pracht
Bernie Purcell
Przemyslaw Fiala
Arnaud de Bossoreille de Ribou
Brad Smith
Nick Briggs
Christopher Rath
Christophe Courtaut
Christopher Mueller
Clement Chesnin
Andres Krapf
Damien Fouilleul
David Flynn
Sebastien Zwickert
Antoine Cellerier
Jérôme Decoodt
Jérome Decoodt
Dylan Yudaken
Eduard Babayan
Eugenio Jarosiewicz
Elliot Murphy
Eric Petit
Erwan Tulou
Etienne Membrives
Ludovic Fauvet
Fabio Ritrovato
Tobias Güntner
Jakub Wieczorek
Frédéric Crozat
Francois Cartegnie
Laurent Aimar
Florian G. Pflug
Felix Paul Kühne
Frank Enderle
Rafaël Carré
Simon Latapie
Gildas Bazin
Geoffroy Couprie
Julien / Gellule
Gildas Bazin
Arnaud Schauly
Toralf Niebuhr
Vicente Jimenez Aguilar
Derk-Jan Hartman
Henri Fallon
Ilkka Ollakka
Olivier Teulière
Rémi Duraffort
Jakob Leben
Jean-Baptiste Kempf
Jean-Paul Saman
Jean-Philippe Grimaldi
Jean-François Massol
Gaël Hendryckx
Jakob Leben
Jean-Marc Dressler
Jai Menon
Johan Bilien
Johann Ransay
Joris van Rooij
JP Dinger
Jean-Philippe André
Adrien Grand
Juha Jeronen
Juho Vähä-Herttua
Kaarlo Raiha
Kaarlo Raiha
Kamil Baldyga
Keary Griffin
Ken Self
KO Myung-Hun
Pierre Ynard
Filippo Carone
Loïc Minier
Luca Barbato
Lucas C. Villa Real
Lukas Durfina
Adrien Maglo
Marc Ariberti
Mark Lee
Mark Moriarty
Martin Storsjö
Christophe Massiot
Michel Kaempf
Marian Ďurkovič
Mirsal Ennaime
Carlo Calabrò
Damien Lucas
Naohiro Koriyama
Basos G
Pierre Baillet
Vincent Penquerc'h
Olivier Aubert
Pankaj Yadav
Paul Corke
Pierre d'Herbemont
Philippe Morin
Antoine Lejeune
Michael Ploujnikov
Jean-Marc Dressler
Michael Hanselmann
Rafaël Carré
Ramiro Polla
Rémi Denis-Courmont
Renaud Dartus
Richard Shepherd
Faustino Osuna
Arnaud Vallat
Rob Jonson
Robert Jedrzejczyk
Steve Lhomme
Rocky Bernstein
Romain Goyet
Rov Juvano
Sam Hocevar
Martin T. H. Sandsmark
Sebastian Birk
Sébastien Escudier
Vincent Seguin
Fabio Ritrovato
Sigmund Augdal Helberg
Casian Andrei
Srikanth Raju
Hannes Domani
Stéphane Borel
Stephan Krempel
Stephan Assmus
Tony Castley
Pavlov Konstantin
Eric Petit
Tanguy Krotoff
Dennis van Amerongen
Michel Lespinasse
Can Wu
Xavier Marchesini
Sébastien Toque
Christophe Mutricy
Yoann Peronneau
Yohann Martineau
Yuval Tze
Scott Caudle
Clément Stenac
It is possible, that some minor piece of code was badly tracked, for
some reasons (SVN, mainly) or that some small developers did not answer.
However, as an "œuvre collective", defined as in "CPI 113-2 alinéa 3",
and seeing "Cour. Cass. 17 Mai 1978", and seeing that the editor and
the very vast majority of developers have agreed (> 99.99% of the code,
> 99% of developers), we are fine here.
2011-11-27 21:44:15 +01:00
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU Lesser General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2.1 of the License, or
|
2003-08-02 18:43:59 +02:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
LGPL
Re-license almost all of libVLC and libVLCcore to LGPLv2.1+
This move was authorized by the developers, either:
- by e-mail,
- by vote at the VideoLAN Dev Days 2011,
- on the license website,
- in a contract, oral or written.
No objection was raised, so far.
The developers agreeing are:
Justus Piater
Alexis Ballier
Alexander Bethke
Mohammed Adnène Trojette
Alex Converse
Alexey Sokolov
Alexis de Lattre
Andre Pang
Anthony Loiseau
Cyril Deguet
André Weber
Boris Dorès
Brieuc Jeunhomme
Benjamin Drung
Hugo Beauzée-Luyssen
Benoit Steiner
Benjamin Pracht
Bernie Purcell
Przemyslaw Fiala
Arnaud de Bossoreille de Ribou
Brad Smith
Nick Briggs
Christopher Rath
Christophe Courtaut
Christopher Mueller
Clement Chesnin
Andres Krapf
Damien Fouilleul
David Flynn
Sebastien Zwickert
Antoine Cellerier
Jérôme Decoodt
Jérome Decoodt
Dylan Yudaken
Eduard Babayan
Eugenio Jarosiewicz
Elliot Murphy
Eric Petit
Erwan Tulou
Etienne Membrives
Ludovic Fauvet
Fabio Ritrovato
Tobias Güntner
Jakub Wieczorek
Frédéric Crozat
Francois Cartegnie
Laurent Aimar
Florian G. Pflug
Felix Paul Kühne
Frank Enderle
Rafaël Carré
Simon Latapie
Gildas Bazin
Geoffroy Couprie
Julien / Gellule
Gildas Bazin
Arnaud Schauly
Toralf Niebuhr
Vicente Jimenez Aguilar
Derk-Jan Hartman
Henri Fallon
Ilkka Ollakka
Olivier Teulière
Rémi Duraffort
Jakob Leben
Jean-Baptiste Kempf
Jean-Paul Saman
Jean-Philippe Grimaldi
Jean-François Massol
Gaël Hendryckx
Jakob Leben
Jean-Marc Dressler
Jai Menon
Johan Bilien
Johann Ransay
Joris van Rooij
JP Dinger
Jean-Philippe André
Adrien Grand
Juha Jeronen
Juho Vähä-Herttua
Kaarlo Raiha
Kaarlo Raiha
Kamil Baldyga
Keary Griffin
Ken Self
KO Myung-Hun
Pierre Ynard
Filippo Carone
Loïc Minier
Luca Barbato
Lucas C. Villa Real
Lukas Durfina
Adrien Maglo
Marc Ariberti
Mark Lee
Mark Moriarty
Martin Storsjö
Christophe Massiot
Michel Kaempf
Marian Ďurkovič
Mirsal Ennaime
Carlo Calabrò
Damien Lucas
Naohiro Koriyama
Basos G
Pierre Baillet
Vincent Penquerc'h
Olivier Aubert
Pankaj Yadav
Paul Corke
Pierre d'Herbemont
Philippe Morin
Antoine Lejeune
Michael Ploujnikov
Jean-Marc Dressler
Michael Hanselmann
Rafaël Carré
Ramiro Polla
Rémi Denis-Courmont
Renaud Dartus
Richard Shepherd
Faustino Osuna
Arnaud Vallat
Rob Jonson
Robert Jedrzejczyk
Steve Lhomme
Rocky Bernstein
Romain Goyet
Rov Juvano
Sam Hocevar
Martin T. H. Sandsmark
Sebastian Birk
Sébastien Escudier
Vincent Seguin
Fabio Ritrovato
Sigmund Augdal Helberg
Casian Andrei
Srikanth Raju
Hannes Domani
Stéphane Borel
Stephan Krempel
Stephan Assmus
Tony Castley
Pavlov Konstantin
Eric Petit
Tanguy Krotoff
Dennis van Amerongen
Michel Lespinasse
Can Wu
Xavier Marchesini
Sébastien Toque
Christophe Mutricy
Yoann Peronneau
Yohann Martineau
Yuval Tze
Scott Caudle
Clément Stenac
It is possible, that some minor piece of code was badly tracked, for
some reasons (SVN, mainly) or that some small developers did not answer.
However, as an "œuvre collective", defined as in "CPI 113-2 alinéa 3",
and seeing "Cour. Cass. 17 Mai 1978", and seeing that the editor and
the very vast majority of developers have agreed (> 99.99% of the code,
> 99% of developers), we are fine here.
2011-11-27 21:44:15 +01:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License for more details.
|
2003-08-02 18:43:59 +02:00
|
|
|
*
|
LGPL
Re-license almost all of libVLC and libVLCcore to LGPLv2.1+
This move was authorized by the developers, either:
- by e-mail,
- by vote at the VideoLAN Dev Days 2011,
- on the license website,
- in a contract, oral or written.
No objection was raised, so far.
The developers agreeing are:
Justus Piater
Alexis Ballier
Alexander Bethke
Mohammed Adnène Trojette
Alex Converse
Alexey Sokolov
Alexis de Lattre
Andre Pang
Anthony Loiseau
Cyril Deguet
André Weber
Boris Dorès
Brieuc Jeunhomme
Benjamin Drung
Hugo Beauzée-Luyssen
Benoit Steiner
Benjamin Pracht
Bernie Purcell
Przemyslaw Fiala
Arnaud de Bossoreille de Ribou
Brad Smith
Nick Briggs
Christopher Rath
Christophe Courtaut
Christopher Mueller
Clement Chesnin
Andres Krapf
Damien Fouilleul
David Flynn
Sebastien Zwickert
Antoine Cellerier
Jérôme Decoodt
Jérome Decoodt
Dylan Yudaken
Eduard Babayan
Eugenio Jarosiewicz
Elliot Murphy
Eric Petit
Erwan Tulou
Etienne Membrives
Ludovic Fauvet
Fabio Ritrovato
Tobias Güntner
Jakub Wieczorek
Frédéric Crozat
Francois Cartegnie
Laurent Aimar
Florian G. Pflug
Felix Paul Kühne
Frank Enderle
Rafaël Carré
Simon Latapie
Gildas Bazin
Geoffroy Couprie
Julien / Gellule
Gildas Bazin
Arnaud Schauly
Toralf Niebuhr
Vicente Jimenez Aguilar
Derk-Jan Hartman
Henri Fallon
Ilkka Ollakka
Olivier Teulière
Rémi Duraffort
Jakob Leben
Jean-Baptiste Kempf
Jean-Paul Saman
Jean-Philippe Grimaldi
Jean-François Massol
Gaël Hendryckx
Jakob Leben
Jean-Marc Dressler
Jai Menon
Johan Bilien
Johann Ransay
Joris van Rooij
JP Dinger
Jean-Philippe André
Adrien Grand
Juha Jeronen
Juho Vähä-Herttua
Kaarlo Raiha
Kaarlo Raiha
Kamil Baldyga
Keary Griffin
Ken Self
KO Myung-Hun
Pierre Ynard
Filippo Carone
Loïc Minier
Luca Barbato
Lucas C. Villa Real
Lukas Durfina
Adrien Maglo
Marc Ariberti
Mark Lee
Mark Moriarty
Martin Storsjö
Christophe Massiot
Michel Kaempf
Marian Ďurkovič
Mirsal Ennaime
Carlo Calabrò
Damien Lucas
Naohiro Koriyama
Basos G
Pierre Baillet
Vincent Penquerc'h
Olivier Aubert
Pankaj Yadav
Paul Corke
Pierre d'Herbemont
Philippe Morin
Antoine Lejeune
Michael Ploujnikov
Jean-Marc Dressler
Michael Hanselmann
Rafaël Carré
Ramiro Polla
Rémi Denis-Courmont
Renaud Dartus
Richard Shepherd
Faustino Osuna
Arnaud Vallat
Rob Jonson
Robert Jedrzejczyk
Steve Lhomme
Rocky Bernstein
Romain Goyet
Rov Juvano
Sam Hocevar
Martin T. H. Sandsmark
Sebastian Birk
Sébastien Escudier
Vincent Seguin
Fabio Ritrovato
Sigmund Augdal Helberg
Casian Andrei
Srikanth Raju
Hannes Domani
Stéphane Borel
Stephan Krempel
Stephan Assmus
Tony Castley
Pavlov Konstantin
Eric Petit
Tanguy Krotoff
Dennis van Amerongen
Michel Lespinasse
Can Wu
Xavier Marchesini
Sébastien Toque
Christophe Mutricy
Yoann Peronneau
Yohann Martineau
Yuval Tze
Scott Caudle
Clément Stenac
It is possible, that some minor piece of code was badly tracked, for
some reasons (SVN, mainly) or that some small developers did not answer.
However, as an "œuvre collective", defined as in "CPI 113-2 alinéa 3",
and seeing "Cour. Cass. 17 Mai 1978", and seeing that the editor and
the very vast majority of developers have agreed (> 99.99% of the code,
> 99% of developers), we are fine here.
2011-11-27 21:44:15 +01:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
|
2003-08-02 18:43:59 +02:00
|
|
|
*****************************************************************************/
|
|
|
|
|
2008-01-23 22:50:58 +01:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2015-10-20 18:50:44 +02:00
|
|
|
#include <assert.h>
|
2017-02-07 20:56:30 +01:00
|
|
|
#include <limits.h>
|
2015-10-20 18:50:44 +02:00
|
|
|
|
2008-10-13 19:57:51 +02:00
|
|
|
#include "demux.h"
|
2008-10-13 20:20:54 +02:00
|
|
|
#include <libvlc.h>
|
|
|
|
#include <vlc_codec.h>
|
2008-12-05 10:47:31 +01:00
|
|
|
#include <vlc_meta.h>
|
2010-07-07 20:52:10 +02:00
|
|
|
#include <vlc_url.h>
|
2010-07-27 21:11:58 +02:00
|
|
|
#include <vlc_modules.h>
|
2015-07-26 17:18:34 +02:00
|
|
|
#include <vlc_strings.h>
|
2019-05-31 15:15:12 +02:00
|
|
|
#include "input_internal.h"
|
2003-11-30 18:29:56 +01:00
|
|
|
|
2016-07-30 05:47:08 +02:00
|
|
|
typedef const struct
|
2015-07-26 17:18:34 +02:00
|
|
|
{
|
2016-08-02 17:22:21 +02:00
|
|
|
char const key[20];
|
|
|
|
char const name[8];
|
2016-07-30 05:47:08 +02:00
|
|
|
|
|
|
|
} demux_mapping;
|
2015-07-26 17:18:34 +02:00
|
|
|
|
2016-07-30 05:48:06 +02:00
|
|
|
static int demux_mapping_cmp( const void *k, const void *v )
|
2015-07-26 17:18:34 +02:00
|
|
|
{
|
2016-07-30 05:48:06 +02:00
|
|
|
demux_mapping* entry = v;
|
|
|
|
return vlc_ascii_strcasecmp( k, entry->key );
|
2015-07-26 17:18:34 +02:00
|
|
|
}
|
|
|
|
|
2017-03-22 04:38:35 +01:00
|
|
|
static const char *demux_NameFromMimeType(const char *mime)
|
2015-07-26 17:18:34 +02:00
|
|
|
{
|
2016-07-30 05:47:08 +02:00
|
|
|
static demux_mapping types[] =
|
2015-07-26 17:18:34 +02:00
|
|
|
{ /* Must be sorted in ascending ASCII order */
|
|
|
|
{ "audio/aac", "m4a" },
|
|
|
|
{ "audio/aacp", "m4a" },
|
|
|
|
{ "audio/mpeg", "mp3" },
|
2015-08-08 17:17:01 +02:00
|
|
|
//{ "video/MP1S", "es,mpgv" }, !b_force
|
2016-03-03 21:30:12 +01:00
|
|
|
{ "video/dv", "rawdv" },
|
2015-08-08 17:17:01 +02:00
|
|
|
{ "video/MP2P", "ps" },
|
2015-07-26 17:18:34 +02:00
|
|
|
{ "video/MP2T", "ts" },
|
|
|
|
{ "video/nsa", "nsv" },
|
|
|
|
{ "video/nsv", "nsv" },
|
|
|
|
};
|
2020-09-24 16:47:49 +02:00
|
|
|
|
|
|
|
demux_mapping *type = bsearch(mime, types, ARRAY_SIZE(types),
|
|
|
|
sizeof (*types), demux_mapping_cmp);
|
2016-07-30 05:47:08 +02:00
|
|
|
return (type != NULL) ? type->name : "any";
|
2015-07-26 17:18:34 +02:00
|
|
|
}
|
|
|
|
|
2021-10-05 18:37:57 +02:00
|
|
|
demux_t *demux_New( vlc_object_t *p_obj, const char *module, const char *url,
|
2018-04-16 16:32:47 +02:00
|
|
|
stream_t *s, es_out_t *out )
|
2015-09-25 13:24:42 +02:00
|
|
|
{
|
2018-03-24 10:54:57 +01:00
|
|
|
assert(s != NULL );
|
2021-10-05 18:37:57 +02:00
|
|
|
return demux_NewAdvanced( p_obj, NULL, module, url, s, out, false );
|
2015-09-25 13:24:42 +02:00
|
|
|
}
|
|
|
|
|
2018-04-06 19:31:27 +02:00
|
|
|
struct vlc_demux_private
|
|
|
|
{
|
|
|
|
module_t *module;
|
|
|
|
};
|
|
|
|
|
2016-06-18 14:46:44 +02:00
|
|
|
static void demux_DestroyDemux(demux_t *demux)
|
|
|
|
{
|
2018-04-06 19:31:27 +02:00
|
|
|
struct vlc_demux_private *priv = vlc_stream_Private(demux);
|
|
|
|
|
|
|
|
module_unneed(demux, priv->module);
|
2018-03-29 18:04:20 +02:00
|
|
|
free(demux->psz_filepath);
|
|
|
|
free(demux->psz_name);
|
|
|
|
|
2016-06-18 14:46:44 +02:00
|
|
|
assert(demux->s != NULL);
|
2016-07-20 22:02:54 +02:00
|
|
|
vlc_stream_Delete(demux->s);
|
2016-06-18 14:46:44 +02:00
|
|
|
}
|
|
|
|
|
2019-03-04 18:50:11 +01:00
|
|
|
static int demux_Probe(void *func, bool forced, va_list ap)
|
2017-07-09 15:29:58 +02:00
|
|
|
{
|
|
|
|
int (*probe)(vlc_object_t *) = func;
|
|
|
|
demux_t *demux = va_arg(ap, demux_t *);
|
|
|
|
|
|
|
|
/* Restore input stream offset (in case previous probed demux failed to
|
|
|
|
* to do so). */
|
|
|
|
if (vlc_stream_Tell(demux->s) != 0 && vlc_stream_Seek(demux->s, 0))
|
|
|
|
{
|
|
|
|
msg_Err(demux, "seek failure before probing");
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
}
|
|
|
|
|
2019-03-05 17:15:23 +01:00
|
|
|
demux->obj.force = forced;
|
|
|
|
|
2019-03-04 20:03:45 +01:00
|
|
|
int ret = probe(VLC_OBJECT(demux));
|
|
|
|
if (ret)
|
|
|
|
vlc_objres_clear(VLC_OBJECT(demux));
|
|
|
|
return ret;
|
2017-07-09 15:29:58 +02:00
|
|
|
}
|
|
|
|
|
2018-07-20 17:20:55 +02:00
|
|
|
demux_t *demux_NewAdvanced( vlc_object_t *p_obj, input_thread_t *p_input,
|
2020-09-24 16:29:58 +02:00
|
|
|
const char *module, const char *url,
|
2016-06-04 17:05:21 +02:00
|
|
|
stream_t *s, es_out_t *out, bool b_preparsing )
|
2003-11-30 18:29:56 +01:00
|
|
|
{
|
2021-09-16 16:25:38 +02:00
|
|
|
const char *p = strchr(url, ':');
|
2021-09-15 16:04:57 +02:00
|
|
|
if (p == NULL) {
|
|
|
|
errno = EINVAL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2018-04-06 19:31:27 +02:00
|
|
|
struct vlc_demux_private *priv;
|
|
|
|
demux_t *p_demux = vlc_stream_CustomNew(p_obj, demux_DestroyDemux,
|
|
|
|
sizeof (*priv), "demux");
|
2003-11-30 18:29:56 +01:00
|
|
|
|
2018-03-29 21:40:57 +02:00
|
|
|
if (unlikely(p_demux == NULL))
|
|
|
|
return NULL;
|
2016-06-18 14:46:44 +02:00
|
|
|
|
2018-03-24 11:18:38 +01:00
|
|
|
assert(s != NULL);
|
2018-04-06 19:31:27 +02:00
|
|
|
priv = vlc_stream_Private(p_demux);
|
2018-03-24 11:18:38 +01:00
|
|
|
|
2018-07-20 17:20:55 +02:00
|
|
|
p_demux->p_input_item = p_input ? input_GetItem(p_input) : NULL;
|
2020-09-24 16:29:58 +02:00
|
|
|
p_demux->psz_name = strdup(module);
|
2017-12-02 22:05:58 +01:00
|
|
|
if (unlikely(p_demux->psz_name == NULL))
|
2017-12-02 21:57:10 +01:00
|
|
|
goto error;
|
2003-11-30 18:29:56 +01:00
|
|
|
|
2018-04-16 16:49:01 +02:00
|
|
|
p_demux->psz_url = strdup(url);
|
|
|
|
if (unlikely(p_demux->psz_url == NULL))
|
2014-03-10 21:00:40 +01:00
|
|
|
goto error;
|
2004-08-08 03:58:59 +02:00
|
|
|
|
2021-09-16 16:25:38 +02:00
|
|
|
p_demux->psz_location = p_demux->psz_url + 1 + (p - url);
|
|
|
|
if (strncmp(p_demux->psz_location, "//", 2) == 0)
|
|
|
|
p_demux->psz_location += 2;
|
2021-09-15 17:20:13 +02:00
|
|
|
p_demux->psz_filepath = vlc_uri2path(url); /* parse URL */
|
2017-12-02 21:57:10 +01:00
|
|
|
|
2016-06-04 17:05:21 +02:00
|
|
|
if( !b_preparsing )
|
2018-04-16 16:49:01 +02:00
|
|
|
msg_Dbg( p_obj, "creating demux \"%s\", URL: %s, path: %s",
|
2020-09-24 16:29:58 +02:00
|
|
|
module, url, p_demux->psz_filepath );
|
2003-11-30 18:29:56 +01:00
|
|
|
|
2016-06-07 09:27:54 +02:00
|
|
|
p_demux->s = s;
|
|
|
|
p_demux->out = out;
|
|
|
|
p_demux->b_preparsing = b_preparsing;
|
2003-11-30 18:29:56 +01:00
|
|
|
|
2022-01-10 14:35:17 +01:00
|
|
|
p_demux->pf_readdir = NULL;
|
|
|
|
p_demux->pf_demux = NULL;
|
|
|
|
p_demux->pf_control = NULL;
|
|
|
|
p_demux->p_sys = NULL;
|
2023-03-09 15:06:56 +01:00
|
|
|
p_demux->ops = NULL;
|
2022-01-10 14:35:17 +01:00
|
|
|
|
2020-09-24 16:36:12 +02:00
|
|
|
char *modbuf = NULL;
|
2020-09-25 18:17:10 +02:00
|
|
|
bool strict = true;
|
2020-09-24 16:36:12 +02:00
|
|
|
|
2020-09-25 18:13:35 +02:00
|
|
|
if (!strcasecmp(module, "any" ) || module[0] == '\0') {
|
|
|
|
/* Look up demux by content type for hard to detect formats */
|
|
|
|
char *type = stream_MimeType(s);
|
|
|
|
|
|
|
|
if (type != NULL) {
|
|
|
|
module = demux_NameFromMimeType(type);
|
|
|
|
free(type);
|
|
|
|
}
|
2020-09-25 18:17:10 +02:00
|
|
|
strict = false;
|
2020-09-25 18:13:35 +02:00
|
|
|
}
|
|
|
|
|
2020-09-24 16:29:58 +02:00
|
|
|
if (strcasecmp(module, "any") == 0 && p_demux->psz_filepath != NULL)
|
2018-03-24 11:18:38 +01:00
|
|
|
{
|
2020-09-24 16:36:12 +02:00
|
|
|
const char *ext = strrchr(p_demux->psz_filepath, '.');
|
|
|
|
|
|
|
|
if (ext != NULL) {
|
|
|
|
if (b_preparsing && !vlc_ascii_strcasecmp(ext, ".mp3"))
|
|
|
|
module = "mpga";
|
|
|
|
else
|
|
|
|
if (likely(asprintf(&modbuf, "ext-%s", ext + 1) >= 0))
|
|
|
|
module = modbuf;
|
2021-12-23 23:41:31 +01:00
|
|
|
else
|
2022-01-06 04:58:59 +01:00
|
|
|
goto error;
|
2020-09-24 16:36:12 +02:00
|
|
|
}
|
2020-09-25 18:17:10 +02:00
|
|
|
strict = false;
|
2018-03-24 11:18:38 +01:00
|
|
|
}
|
2004-03-19 17:27:52 +01:00
|
|
|
|
2020-09-24 16:29:58 +02:00
|
|
|
priv->module = vlc_module_load(p_demux, "demux", module, strict,
|
|
|
|
demux_Probe, p_demux);
|
2020-09-24 16:36:12 +02:00
|
|
|
free(modbuf);
|
|
|
|
|
2018-04-06 19:31:27 +02:00
|
|
|
if (priv->module == NULL)
|
2014-03-10 21:00:40 +01:00
|
|
|
goto error;
|
2003-11-30 18:29:56 +01:00
|
|
|
|
|
|
|
return p_demux;
|
2014-03-10 21:00:40 +01:00
|
|
|
error:
|
2022-01-06 04:58:59 +01:00
|
|
|
free( p_demux->psz_filepath );
|
2017-12-02 22:05:58 +01:00
|
|
|
free( p_demux->psz_name );
|
2018-03-29 21:40:57 +02:00
|
|
|
stream_CommonDelete( p_demux );
|
2014-03-10 21:00:40 +01:00
|
|
|
return NULL;
|
2003-11-30 18:29:56 +01:00
|
|
|
}
|
|
|
|
|
2023-03-17 11:48:19 +01:00
|
|
|
static int demux_ReadDir( stream_t *s, input_item_node_t *p_node )
|
|
|
|
{
|
|
|
|
assert(s->pf_readdir != NULL || (s->ops != NULL && s->ops->demux.readdir != NULL));
|
|
|
|
return (s->ops != NULL ? s->ops->demux.readdir : s->pf_readdir)( s, p_node );
|
|
|
|
}
|
|
|
|
|
2020-09-27 11:07:28 +02:00
|
|
|
int demux_Demux(demux_t *demux)
|
|
|
|
{
|
2023-03-17 11:48:19 +01:00
|
|
|
if (demux->pf_demux != NULL || (demux->ops != NULL && demux->ops->demux.demux != NULL))
|
|
|
|
return (demux->ops != NULL ? demux->ops->demux.demux : demux->pf_demux)(demux);
|
2020-09-27 11:13:58 +02:00
|
|
|
|
2023-03-17 11:48:19 +01:00
|
|
|
if ((demux->pf_readdir != NULL || (demux->ops != NULL && demux->ops->demux.readdir != NULL)) && demux->p_input_item != NULL) {
|
2020-09-27 11:13:58 +02:00
|
|
|
input_item_node_t *node = input_item_node_Create(demux->p_input_item);
|
|
|
|
|
|
|
|
if (unlikely(node == NULL))
|
|
|
|
return VLC_DEMUXER_EGENERIC;
|
|
|
|
|
2023-03-17 11:48:19 +01:00
|
|
|
if (demux_ReadDir(demux, node)) {
|
2020-09-27 11:13:58 +02:00
|
|
|
input_item_node_Delete(node);
|
|
|
|
return VLC_DEMUXER_EGENERIC;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (es_out_Control(demux->out, ES_OUT_POST_SUBNODE, node))
|
|
|
|
input_item_node_Delete(node);
|
|
|
|
return VLC_DEMUXER_EOF;
|
|
|
|
}
|
|
|
|
|
2020-09-27 11:07:28 +02:00
|
|
|
return VLC_DEMUXER_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2015-10-20 18:50:44 +02:00
|
|
|
#define static_control_match(foo) \
|
|
|
|
static_assert((unsigned) DEMUX_##foo == STREAM_##foo, "Mismatch")
|
|
|
|
|
2015-10-20 20:07:46 +02:00
|
|
|
int demux_vaControl( demux_t *demux, int query, va_list args )
|
|
|
|
{
|
2023-03-09 15:06:56 +01:00
|
|
|
if (demux->ops == NULL)
|
|
|
|
return demux->pf_control( demux, query, args );
|
|
|
|
|
|
|
|
switch (query) {
|
|
|
|
case DEMUX_CAN_SEEK:
|
|
|
|
{
|
|
|
|
bool *can_seek = va_arg(args, bool *);
|
|
|
|
if (demux->ops->can_seek != NULL) {
|
|
|
|
*can_seek = demux->ops->can_seek(demux);
|
|
|
|
} else {
|
|
|
|
*can_seek = false;
|
|
|
|
}
|
|
|
|
return VLC_SUCCESS;
|
|
|
|
}
|
|
|
|
case DEMUX_CAN_PAUSE:
|
|
|
|
{
|
|
|
|
bool *can_pause = va_arg(args, bool *);
|
|
|
|
if (demux->ops->can_pause != NULL) {
|
|
|
|
*can_pause = demux->ops->can_pause(demux);
|
|
|
|
} else {
|
|
|
|
*can_pause = false;
|
|
|
|
}
|
|
|
|
return VLC_SUCCESS;
|
|
|
|
}
|
|
|
|
case DEMUX_CAN_RECORD:
|
|
|
|
{
|
|
|
|
bool *can_record = va_arg(args, bool *);
|
|
|
|
if (demux->ops->demux.can_record != NULL) {
|
|
|
|
*can_record = demux->ops->demux.can_record(demux);
|
|
|
|
} else {
|
|
|
|
*can_record = false;
|
|
|
|
}
|
|
|
|
return VLC_SUCCESS;
|
|
|
|
}
|
|
|
|
case DEMUX_CAN_CONTROL_PACE:
|
|
|
|
{
|
|
|
|
bool *can_control_pace = va_arg(args, bool *);
|
|
|
|
if (demux->ops->can_control_pace != NULL) {
|
|
|
|
*can_control_pace = demux->ops->can_control_pace(demux);
|
|
|
|
} else {
|
|
|
|
*can_control_pace = false;
|
|
|
|
}
|
|
|
|
return VLC_SUCCESS;
|
|
|
|
}
|
|
|
|
case DEMUX_CAN_CONTROL_RATE:
|
|
|
|
{
|
|
|
|
bool *can_control_rate = va_arg(args, bool *);
|
|
|
|
if (demux->ops->demux.can_control_rate != NULL) {
|
|
|
|
*can_control_rate = demux->ops->demux.can_control_rate(demux);
|
|
|
|
} else {
|
|
|
|
*can_control_rate = false;
|
|
|
|
}
|
|
|
|
return VLC_SUCCESS;
|
|
|
|
}
|
|
|
|
case DEMUX_HAS_UNSUPPORTED_META:
|
|
|
|
{
|
|
|
|
bool *has_unsupported_meta = va_arg(args, bool *);
|
|
|
|
if (demux->ops->demux.has_unsupported_meta != NULL) {
|
|
|
|
*has_unsupported_meta = demux->ops->demux.has_unsupported_meta(demux);
|
|
|
|
} else {
|
|
|
|
*has_unsupported_meta = false;
|
|
|
|
}
|
|
|
|
return VLC_SUCCESS;
|
|
|
|
}
|
|
|
|
case DEMUX_GET_PTS_DELAY:
|
|
|
|
if (demux->ops->get_pts_delay != NULL) {
|
|
|
|
vlc_tick_t *pts_delay = va_arg(args, vlc_tick_t *);
|
|
|
|
return demux->ops->get_pts_delay(demux, pts_delay);
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
case DEMUX_GET_TITLE_INFO:
|
|
|
|
if (demux->ops->demux.get_title_info != NULL) {
|
|
|
|
input_title_t ***title_info = va_arg(args, input_title_t ***);
|
|
|
|
int *size = va_arg(args, int *);
|
|
|
|
int *pi_title_offset = va_arg(args, int *);
|
|
|
|
int *pi_seekpoint_offset = va_arg(args, int *);
|
|
|
|
return demux->ops->demux.get_title_info(demux, title_info, size, pi_title_offset, pi_seekpoint_offset);
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
case DEMUX_GET_TITLE:
|
|
|
|
if (demux->ops->demux.get_title != NULL) {
|
|
|
|
int *title = va_arg(args, int *);
|
|
|
|
return demux->ops->demux.get_title(demux, title);
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
case DEMUX_GET_SEEKPOINT:
|
|
|
|
if (demux->ops->demux.get_seekpoint != NULL) {
|
|
|
|
int *seekpoint = va_arg(args, int *);
|
|
|
|
return demux->ops->demux.get_seekpoint(demux, seekpoint);
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
case DEMUX_GET_META:
|
|
|
|
if (demux->ops->get_meta != NULL) {
|
|
|
|
vlc_meta_t *meta = va_arg(args, vlc_meta_t *);
|
|
|
|
return demux->ops->get_meta(demux, meta);
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
case DEMUX_GET_SIGNAL:
|
|
|
|
if (demux->ops->get_signal != NULL) {
|
|
|
|
double *quality = va_arg(args, double *);
|
|
|
|
double *strength = va_arg(args, double *);
|
|
|
|
return demux->ops->get_signal(demux, quality, strength);
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
case DEMUX_GET_TYPE:
|
|
|
|
if (demux->ops->get_type != NULL) {
|
|
|
|
int *type = va_arg(args, int *);
|
|
|
|
return demux->ops->get_type(demux, type);
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
case DEMUX_GET_POSITION:
|
|
|
|
if (demux->ops->demux.get_position != NULL) {
|
|
|
|
*va_arg(args, double *) = demux->ops->demux.get_position(demux);
|
|
|
|
return VLC_SUCCESS;
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
case DEMUX_GET_LENGTH:
|
|
|
|
if (demux->ops->demux.get_length != NULL) {
|
|
|
|
*va_arg(args, vlc_tick_t *) = demux->ops->demux.get_length(demux);
|
|
|
|
return VLC_SUCCESS;
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
case DEMUX_GET_TIME:
|
|
|
|
if (demux->ops->demux.get_time != NULL) {
|
|
|
|
*va_arg(args, vlc_tick_t *) = demux->ops->demux.get_time(demux);
|
|
|
|
return VLC_SUCCESS;
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
case DEMUX_GET_NORMAL_TIME:
|
|
|
|
if (demux->ops->demux.get_normal_time != NULL) {
|
|
|
|
vlc_tick_t *normal_time = va_arg(args, vlc_tick_t *);
|
|
|
|
return demux->ops->demux.get_normal_time(demux, normal_time);
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
case DEMUX_GET_FPS:
|
|
|
|
if (demux->ops->demux.get_fps != NULL) {
|
|
|
|
double *fps = va_arg(args, double *);
|
|
|
|
return demux->ops->demux.get_fps(demux, fps);
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
case DEMUX_GET_ATTACHMENTS:
|
|
|
|
if (demux->ops->demux.get_attachments != NULL) {
|
|
|
|
input_attachment_t ***attachments = va_arg(args, input_attachment_t ***);
|
|
|
|
return demux->ops->demux.get_attachments(demux, attachments);
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
case DEMUX_SET_SEEKPOINT:
|
|
|
|
if (demux->ops->set_seek_point != NULL) {
|
|
|
|
int seekpoint = va_arg(args, int);
|
|
|
|
return demux->ops->set_seek_point(demux, seekpoint);
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
case DEMUX_SET_TITLE:
|
|
|
|
if (demux->ops->set_title != NULL) {
|
|
|
|
int title = va_arg(args, int);
|
|
|
|
return demux->ops->set_title(demux, title);
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
case DEMUX_SET_PAUSE_STATE:
|
|
|
|
if (demux->ops->set_pause_state != NULL) {
|
|
|
|
bool pause_state = (bool)va_arg(args, int);
|
|
|
|
return demux->ops->set_pause_state(demux, pause_state);
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
case DEMUX_SET_RECORD_STATE:
|
|
|
|
if (demux->ops->demux.set_record_state != NULL) {
|
|
|
|
bool record_state = (bool)va_arg(args, int);
|
|
|
|
const char *dir_path = NULL;
|
|
|
|
if (record_state) {
|
|
|
|
dir_path = va_arg(args, const char *);
|
|
|
|
}
|
|
|
|
return demux->ops->demux.set_record_state(demux, record_state, dir_path);
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
case DEMUX_SET_POSITION:
|
|
|
|
{
|
|
|
|
if (demux->ops->demux.set_position != NULL) {
|
|
|
|
double position = va_arg(args, double);
|
|
|
|
bool precise = (bool)va_arg(args, int);
|
|
|
|
return demux->ops->demux.set_position(demux, position, precise);
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
}
|
|
|
|
case DEMUX_SET_TIME:
|
|
|
|
{
|
|
|
|
if (demux->ops->demux.set_time != NULL) {
|
|
|
|
vlc_tick_t time = va_arg(args, vlc_tick_t);
|
|
|
|
bool precise = (bool)va_arg(args, int);
|
|
|
|
return demux->ops->demux.set_time(demux, time, precise);
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
}
|
|
|
|
case DEMUX_SET_NEXT_DEMUX_TIME:
|
|
|
|
if (demux->ops->demux.set_next_demux_time != NULL) {
|
|
|
|
vlc_tick_t next_demux_time = va_arg(args, vlc_tick_t);
|
|
|
|
return demux->ops->demux.set_next_demux_time(demux, next_demux_time);
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
case DEMUX_SET_RATE:
|
|
|
|
if (demux->ops->demux.set_next_demux_time != NULL) {
|
|
|
|
float *rate = va_arg(args, float *);
|
|
|
|
return demux->ops->demux.set_rate(demux, rate);
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
case DEMUX_SET_GROUP_DEFAULT:
|
|
|
|
if (demux->ops->demux.set_group_default != NULL) {
|
|
|
|
return demux->ops->demux.set_group_default(demux);
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
case DEMUX_SET_GROUP_ALL:
|
|
|
|
if (demux->ops->demux.set_group_all != NULL) {
|
|
|
|
return demux->ops->demux.set_group_all(demux);
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
case DEMUX_SET_GROUP_LIST:
|
|
|
|
if (demux->ops->demux.set_group_list != NULL) {
|
|
|
|
size_t size = va_arg(args, size_t);
|
|
|
|
const int *idx = va_arg(args, const int *);
|
|
|
|
return demux->ops->demux.set_group_list(demux, size, idx);
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
case DEMUX_SET_ES:
|
|
|
|
if (demux->ops->demux.set_es != NULL) {
|
|
|
|
int es = va_arg(args, int);
|
|
|
|
return demux->ops->demux.set_es(demux, es);
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
case DEMUX_SET_ES_LIST:
|
|
|
|
if (demux->ops->demux.set_es_list != NULL) {
|
|
|
|
size_t size = va_arg(args, size_t);
|
|
|
|
const int *idx = va_arg(args, const int *);
|
|
|
|
return demux->ops->demux.set_es_list(demux, size, idx);
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
case DEMUX_NAV_ACTIVATE:
|
|
|
|
if (demux->ops->demux.nav_activate != NULL) {
|
|
|
|
return demux->ops->demux.nav_activate(demux);
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
case DEMUX_NAV_UP:
|
|
|
|
if (demux->ops->demux.nav_up != NULL) {
|
|
|
|
return demux->ops->demux.nav_up(demux);
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
case DEMUX_NAV_DOWN:
|
|
|
|
if (demux->ops->demux.nav_down != NULL) {
|
|
|
|
return demux->ops->demux.nav_down(demux);
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
case DEMUX_NAV_LEFT:
|
|
|
|
if (demux->ops->demux.nav_left != NULL) {
|
|
|
|
return demux->ops->demux.nav_left(demux);
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
case DEMUX_NAV_RIGHT:
|
|
|
|
if (demux->ops->demux.nav_right != NULL) {
|
|
|
|
return demux->ops->demux.nav_right(demux);
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
case DEMUX_NAV_POPUP:
|
|
|
|
if (demux->ops->demux.nav_popup != NULL) {
|
|
|
|
return demux->ops->demux.nav_popup(demux);
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
case DEMUX_NAV_MENU:
|
|
|
|
if (demux->ops->demux.nav_menu != NULL) {
|
|
|
|
return demux->ops->demux.nav_menu(demux);
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
case DEMUX_FILTER_ENABLE:
|
|
|
|
if (demux->ops->demux.filter_enable != NULL) {
|
|
|
|
return demux->ops->demux.filter_enable(demux);
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
case DEMUX_FILTER_DISABLE:
|
|
|
|
if (demux->ops->demux.filter_disable != NULL) {
|
|
|
|
return demux->ops->demux.filter_disable(demux);
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
case DEMUX_TEST_AND_CLEAR_FLAGS:
|
|
|
|
if (demux->ops->demux.test_and_clear_flags != NULL) {
|
|
|
|
unsigned *flags = va_arg(args, unsigned *);
|
|
|
|
return demux->ops->demux.test_and_clear_flags(demux, flags);
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
default:
|
|
|
|
vlc_assert_unreachable();
|
|
|
|
}
|
2015-10-20 20:07:46 +02:00
|
|
|
}
|
|
|
|
|
2004-03-03 13:01:38 +01:00
|
|
|
/*****************************************************************************
|
2008-04-14 00:20:09 +02:00
|
|
|
* demux_vaControlHelper:
|
2004-03-03 13:01:38 +01:00
|
|
|
*****************************************************************************/
|
2008-04-14 00:20:09 +02:00
|
|
|
int demux_vaControlHelper( stream_t *s,
|
2004-03-03 13:01:38 +01:00
|
|
|
int64_t i_start, int64_t i_end,
|
2008-11-07 12:29:39 +01:00
|
|
|
int64_t i_bitrate, int i_align,
|
2004-03-03 13:01:38 +01:00
|
|
|
int i_query, va_list args )
|
|
|
|
{
|
|
|
|
int64_t i_tell;
|
|
|
|
double f, *pf;
|
2018-05-05 16:49:15 +02:00
|
|
|
vlc_tick_t i64;
|
2004-03-03 13:01:38 +01:00
|
|
|
|
|
|
|
if( i_end < 0 ) i_end = stream_Size( s );
|
|
|
|
if( i_start < 0 ) i_start = 0;
|
|
|
|
if( i_align <= 0 ) i_align = 1;
|
2016-07-20 22:02:54 +02:00
|
|
|
i_tell = vlc_stream_Tell( s );
|
2004-03-03 13:01:38 +01:00
|
|
|
|
2015-10-20 18:50:44 +02:00
|
|
|
static_control_match(CAN_PAUSE);
|
|
|
|
static_control_match(CAN_CONTROL_PACE);
|
|
|
|
static_control_match(GET_PTS_DELAY);
|
|
|
|
static_control_match(GET_META);
|
|
|
|
static_control_match(GET_SIGNAL);
|
|
|
|
static_control_match(SET_PAUSE_STATE);
|
|
|
|
|
2004-03-03 13:01:38 +01:00
|
|
|
switch( i_query )
|
|
|
|
{
|
2015-10-20 18:50:44 +02:00
|
|
|
case DEMUX_CAN_SEEK:
|
|
|
|
{
|
|
|
|
bool *b = va_arg( args, bool * );
|
|
|
|
|
|
|
|
if( (i_bitrate <= 0 && i_start >= i_end)
|
2016-07-20 22:02:54 +02:00
|
|
|
|| vlc_stream_Control( s, STREAM_CAN_SEEK, b ) )
|
2015-10-20 18:50:44 +02:00
|
|
|
*b = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case DEMUX_CAN_PAUSE:
|
|
|
|
case DEMUX_CAN_CONTROL_PACE:
|
|
|
|
case DEMUX_GET_PTS_DELAY:
|
|
|
|
case DEMUX_GET_META:
|
|
|
|
case DEMUX_GET_SIGNAL:
|
2020-09-19 08:00:02 +02:00
|
|
|
case DEMUX_GET_TYPE:
|
2015-10-20 18:50:44 +02:00
|
|
|
case DEMUX_SET_PAUSE_STATE:
|
2016-07-20 22:02:54 +02:00
|
|
|
return vlc_stream_vaControl( s, i_query, args );
|
2015-10-20 18:50:44 +02:00
|
|
|
|
2004-03-03 13:01:38 +01:00
|
|
|
case DEMUX_GET_LENGTH:
|
|
|
|
if( i_bitrate > 0 && i_end > i_start )
|
|
|
|
{
|
2020-08-13 06:52:08 +02:00
|
|
|
*va_arg( args, vlc_tick_t * ) = vlc_tick_from_samples((i_end - i_start) * 8, i_bitrate);
|
2004-03-03 13:01:38 +01:00
|
|
|
return VLC_SUCCESS;
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
|
|
|
|
case DEMUX_GET_TIME:
|
2009-05-22 21:30:16 +02:00
|
|
|
if( i_bitrate > 0 && i_tell >= i_start )
|
2004-03-03 13:01:38 +01:00
|
|
|
{
|
2020-08-13 06:52:08 +02:00
|
|
|
*va_arg( args, vlc_tick_t * ) = vlc_tick_from_samples((i_tell - i_start) * 8, i_bitrate);
|
2004-03-03 13:01:38 +01:00
|
|
|
return VLC_SUCCESS;
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
|
|
|
|
case DEMUX_GET_POSITION:
|
2018-12-03 18:52:53 +01:00
|
|
|
pf = va_arg( args, double * );
|
2004-03-03 13:01:38 +01:00
|
|
|
if( i_start < i_end )
|
|
|
|
{
|
|
|
|
*pf = (double)( i_tell - i_start ) /
|
|
|
|
(double)( i_end - i_start );
|
|
|
|
return VLC_SUCCESS;
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
2019-09-10 18:26:49 +02:00
|
|
|
case DEMUX_GET_NORMAL_TIME:
|
|
|
|
return VLC_EGENERIC;
|
2004-03-03 13:01:38 +01:00
|
|
|
|
|
|
|
case DEMUX_SET_POSITION:
|
2018-12-03 18:52:53 +01:00
|
|
|
f = va_arg( args, double );
|
2004-03-03 13:01:38 +01:00
|
|
|
if( i_start < i_end && f >= 0.0 && f <= 1.0 )
|
|
|
|
{
|
|
|
|
int64_t i_block = (f * ( i_end - i_start )) / i_align;
|
|
|
|
|
2016-07-20 22:02:54 +02:00
|
|
|
if( vlc_stream_Seek( s, i_start + i_block * i_align ) )
|
2004-03-03 13:01:38 +01:00
|
|
|
{
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
}
|
|
|
|
return VLC_SUCCESS;
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
|
|
|
|
case DEMUX_SET_TIME:
|
2018-05-05 16:49:15 +02:00
|
|
|
i64 = va_arg( args, vlc_tick_t );
|
2004-03-03 13:01:38 +01:00
|
|
|
if( i_bitrate > 0 && i64 >= 0 )
|
|
|
|
{
|
2020-08-13 06:55:41 +02:00
|
|
|
int64_t i_block = samples_from_vlc_tick( i64, i_bitrate ) / (8 * i_align);
|
2016-07-20 22:02:54 +02:00
|
|
|
if( vlc_stream_Seek( s, i_start + i_block * i_align ) )
|
2004-03-03 13:01:38 +01:00
|
|
|
{
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
}
|
|
|
|
return VLC_SUCCESS;
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
|
|
|
|
case DEMUX_GET_FPS:
|
2007-10-08 20:30:11 +02:00
|
|
|
case DEMUX_HAS_UNSUPPORTED_META:
|
2004-06-25 00:19:29 +02:00
|
|
|
case DEMUX_SET_NEXT_DEMUX_TIME:
|
|
|
|
case DEMUX_GET_TITLE_INFO:
|
2018-06-09 11:31:44 +02:00
|
|
|
case DEMUX_SET_GROUP_DEFAULT:
|
2018-06-09 10:51:59 +02:00
|
|
|
case DEMUX_SET_GROUP_ALL:
|
|
|
|
case DEMUX_SET_GROUP_LIST:
|
2013-12-03 19:05:20 +01:00
|
|
|
case DEMUX_SET_ES:
|
2019-05-21 20:08:26 +02:00
|
|
|
case DEMUX_SET_ES_LIST:
|
2007-05-31 21:22:27 +02:00
|
|
|
case DEMUX_GET_ATTACHMENTS:
|
2008-08-26 12:54:18 +02:00
|
|
|
case DEMUX_CAN_RECORD:
|
2016-06-21 12:12:08 +02:00
|
|
|
case DEMUX_TEST_AND_CLEAR_FLAGS:
|
2016-07-25 23:44:27 +02:00
|
|
|
case DEMUX_GET_TITLE:
|
|
|
|
case DEMUX_GET_SEEKPOINT:
|
2017-06-10 12:01:36 +02:00
|
|
|
case DEMUX_NAV_ACTIVATE:
|
|
|
|
case DEMUX_NAV_UP:
|
|
|
|
case DEMUX_NAV_DOWN:
|
|
|
|
case DEMUX_NAV_LEFT:
|
|
|
|
case DEMUX_NAV_RIGHT:
|
|
|
|
case DEMUX_NAV_POPUP:
|
|
|
|
case DEMUX_NAV_MENU:
|
2017-06-21 13:08:49 +02:00
|
|
|
case DEMUX_FILTER_ENABLE:
|
|
|
|
case DEMUX_FILTER_DISABLE:
|
2004-03-03 13:01:38 +01:00
|
|
|
return VLC_EGENERIC;
|
|
|
|
|
2015-10-20 18:50:44 +02:00
|
|
|
case DEMUX_SET_TITLE:
|
|
|
|
case DEMUX_SET_SEEKPOINT:
|
|
|
|
case DEMUX_SET_RECORD_STATE:
|
|
|
|
assert(0);
|
2004-03-03 13:01:38 +01:00
|
|
|
default:
|
2016-07-25 23:44:19 +02:00
|
|
|
msg_Err( s, "unknown query 0x%x in %s", i_query, __func__ );
|
2004-03-03 13:01:38 +01:00
|
|
|
return VLC_EGENERIC;
|
|
|
|
}
|
2015-10-20 18:50:44 +02:00
|
|
|
return VLC_SUCCESS;
|
2004-03-03 13:01:38 +01:00
|
|
|
}
|
|
|
|
|
2022-11-10 13:37:18 +01:00
|
|
|
struct packetizer_owner
|
|
|
|
{
|
|
|
|
decoder_t packetizer;
|
2022-11-15 07:57:27 +01:00
|
|
|
es_format_t fmt_in;
|
2022-11-10 13:37:18 +01:00
|
|
|
};
|
|
|
|
|
2005-04-09 13:27:23 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Utility functions
|
|
|
|
****************************************************************************/
|
2022-05-17 11:22:47 +02:00
|
|
|
decoder_t *demux_PacketizerNew( vlc_object_t *p_demux, es_format_t *p_fmt, const char *psz_msg )
|
2008-09-13 00:10:33 +02:00
|
|
|
{
|
2022-11-10 13:37:18 +01:00
|
|
|
struct packetizer_owner *owner = vlc_custom_create( p_demux, sizeof( *owner ),
|
2011-07-11 17:32:04 +02:00
|
|
|
"demux packetizer" );
|
2022-11-10 13:37:18 +01:00
|
|
|
if( !owner )
|
2008-09-13 00:10:33 +02:00
|
|
|
{
|
|
|
|
es_format_Clean( p_fmt );
|
|
|
|
return NULL;
|
|
|
|
}
|
2022-11-10 13:37:18 +01:00
|
|
|
decoder_t *p_packetizer = &owner->packetizer;
|
2009-04-29 20:40:06 +02:00
|
|
|
p_fmt->b_packetized = false;
|
2008-09-13 00:10:33 +02:00
|
|
|
|
2017-02-07 10:21:22 +01:00
|
|
|
p_packetizer->pf_decode = NULL;
|
2008-09-13 00:10:33 +02:00
|
|
|
p_packetizer->pf_packetize = NULL;
|
|
|
|
|
2022-11-15 07:57:27 +01:00
|
|
|
owner->fmt_in = *p_fmt;
|
2022-11-15 08:43:39 +01:00
|
|
|
p_packetizer->fmt_in = &owner->fmt_in;
|
2017-07-05 17:00:18 +02:00
|
|
|
es_format_Init( &p_packetizer->fmt_out, p_fmt->i_cat, 0 );
|
2008-09-13 00:10:33 +02:00
|
|
|
|
2008-12-13 17:05:14 +01:00
|
|
|
p_packetizer->p_module = module_need( p_packetizer, "packetizer", NULL, false );
|
2008-09-13 00:10:33 +02:00
|
|
|
if( !p_packetizer->p_module )
|
|
|
|
{
|
|
|
|
es_format_Clean( p_fmt );
|
2019-03-06 19:15:18 +01:00
|
|
|
vlc_object_delete(p_packetizer);
|
2008-09-13 00:10:33 +02:00
|
|
|
msg_Err( p_demux, "cannot find packetizer for %s", psz_msg );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return p_packetizer;
|
|
|
|
}
|
2009-05-23 17:32:28 +02:00
|
|
|
|
2008-09-13 00:10:33 +02:00
|
|
|
void demux_PacketizerDestroy( decoder_t *p_packetizer )
|
|
|
|
{
|
2022-11-15 07:57:27 +01:00
|
|
|
struct packetizer_owner *owner = container_of(p_packetizer, struct packetizer_owner, packetizer);
|
2008-09-13 00:10:33 +02:00
|
|
|
if( p_packetizer->p_module )
|
2008-09-21 13:58:57 +02:00
|
|
|
module_unneed( p_packetizer, p_packetizer->p_module );
|
2022-11-15 07:57:27 +01:00
|
|
|
es_format_Clean( &owner->fmt_in );
|
2016-01-13 17:37:39 +01:00
|
|
|
es_format_Clean( &p_packetizer->fmt_out );
|
2008-12-05 10:47:31 +01:00
|
|
|
if( p_packetizer->p_description )
|
|
|
|
vlc_meta_Delete( p_packetizer->p_description );
|
2019-03-06 19:15:18 +01:00
|
|
|
vlc_object_delete(p_packetizer);
|
2008-09-13 00:10:33 +02:00
|
|
|
}
|
|
|
|
|
2016-06-09 19:58:55 +02:00
|
|
|
unsigned demux_TestAndClearFlags( demux_t *p_demux, unsigned flags )
|
2016-06-07 11:15:16 +02:00
|
|
|
{
|
2017-07-08 15:22:46 +02:00
|
|
|
unsigned update = flags;
|
|
|
|
|
2018-01-28 15:17:39 +01:00
|
|
|
if (demux_Control( p_demux, DEMUX_TEST_AND_CLEAR_FLAGS, &update))
|
|
|
|
return 0;
|
2017-07-08 15:22:46 +02:00
|
|
|
return update;
|
2016-06-07 11:15:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int demux_GetTitle( demux_t *p_demux )
|
|
|
|
{
|
2017-12-03 11:18:21 +01:00
|
|
|
int title;
|
|
|
|
|
|
|
|
if (demux_Control(p_demux, DEMUX_GET_TITLE, &title))
|
|
|
|
title = 0;
|
|
|
|
return title;
|
2016-06-07 11:15:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int demux_GetSeekpoint( demux_t *p_demux )
|
|
|
|
{
|
2017-12-03 11:18:21 +01:00
|
|
|
int seekpoint;
|
|
|
|
|
|
|
|
if (demux_Control(p_demux, DEMUX_GET_SEEKPOINT, &seekpoint))
|
|
|
|
seekpoint = 0;
|
|
|
|
return seekpoint;
|
2016-06-07 11:15:16 +02:00
|
|
|
}
|
2016-06-12 08:22:00 +02:00
|
|
|
|
|
|
|
static demux_t *demux_FilterNew( demux_t *p_next, const char *p_name )
|
|
|
|
{
|
2018-04-06 19:31:27 +02:00
|
|
|
struct vlc_demux_private *priv;
|
2018-04-06 19:28:51 +02:00
|
|
|
demux_t *p_demux = vlc_stream_CustomNew(VLC_OBJECT(p_next),
|
2018-04-06 19:31:27 +02:00
|
|
|
demux_DestroyDemux, sizeof (*priv),
|
2018-04-06 19:28:51 +02:00
|
|
|
"demux filter");
|
2018-03-29 21:40:57 +02:00
|
|
|
if (unlikely(p_demux == NULL))
|
2016-06-12 08:22:00 +02:00
|
|
|
return NULL;
|
|
|
|
|
2022-01-06 23:37:40 +01:00
|
|
|
priv = vlc_stream_Private(p_demux);
|
2022-01-10 14:35:17 +01:00
|
|
|
p_demux->s = p_next;
|
|
|
|
p_demux->p_input_item = NULL;
|
|
|
|
p_demux->p_sys = NULL;
|
|
|
|
p_demux->psz_name = NULL;
|
|
|
|
p_demux->psz_url = NULL;
|
|
|
|
p_demux->psz_location = NULL;
|
|
|
|
p_demux->psz_filepath = NULL;
|
|
|
|
p_demux->out = NULL;
|
|
|
|
|
2018-04-06 19:31:27 +02:00
|
|
|
priv->module = module_need(p_demux, "demux_filter", p_name,
|
|
|
|
p_name != NULL);
|
|
|
|
if (priv->module == NULL)
|
2016-06-12 08:22:00 +02:00
|
|
|
goto error;
|
|
|
|
|
|
|
|
return p_demux;
|
|
|
|
error:
|
2018-03-29 21:40:57 +02:00
|
|
|
stream_CommonDelete( p_demux );
|
2016-06-12 08:22:00 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
demux_t *demux_FilterChainNew( demux_t *p_demux, const char *psz_chain )
|
|
|
|
{
|
|
|
|
if( !psz_chain || !*psz_chain )
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
char *psz_parser = strdup(psz_chain);
|
|
|
|
if(!psz_parser)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* parse chain */
|
|
|
|
while(psz_parser)
|
|
|
|
{
|
|
|
|
config_chain_t *p_cfg;
|
|
|
|
char *psz_name;
|
|
|
|
char *psz_rest_chain = config_ChainCreate( &psz_name, &p_cfg, psz_parser );
|
|
|
|
free( psz_parser );
|
|
|
|
psz_parser = psz_rest_chain;
|
|
|
|
|
2017-07-30 20:26:00 +02:00
|
|
|
demux_t *filter = demux_FilterNew(p_demux, psz_name);
|
|
|
|
if (filter != NULL)
|
|
|
|
p_demux = filter;
|
2017-07-08 15:57:51 +02:00
|
|
|
|
2017-07-30 20:26:00 +02:00
|
|
|
free(psz_name);
|
|
|
|
config_ChainDestroy(p_cfg);
|
2016-06-12 08:22:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return p_demux;
|
|
|
|
}
|
2017-06-21 13:08:49 +02:00
|
|
|
|
2018-04-06 19:31:27 +02:00
|
|
|
static bool demux_filter_enable_disable(demux_t *p_demux,
|
|
|
|
const char *psz_demux, bool b_enable)
|
2017-06-21 13:08:49 +02:00
|
|
|
{
|
2018-04-06 19:31:27 +02:00
|
|
|
struct vlc_demux_private *priv = vlc_stream_Private(p_demux);
|
2017-09-19 18:05:44 +02:00
|
|
|
|
2018-06-29 09:38:50 +02:00
|
|
|
if ( psz_demux &&
|
2019-05-04 16:47:08 +02:00
|
|
|
(strcmp(module_GetShortName(priv->module), psz_demux) == 0
|
|
|
|
|| strcmp(module_GetLongName(priv->module), psz_demux) == 0) )
|
2018-04-06 19:31:27 +02:00
|
|
|
{
|
2017-09-19 18:05:44 +02:00
|
|
|
demux_Control( p_demux,
|
|
|
|
b_enable ? DEMUX_FILTER_ENABLE : DEMUX_FILTER_DISABLE );
|
|
|
|
return true;
|
2017-06-21 13:08:49 +02:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool demux_FilterEnable( demux_t *p_demux_chain, const char* psz_demux )
|
|
|
|
{
|
|
|
|
return demux_filter_enable_disable( p_demux_chain, psz_demux, true );
|
|
|
|
}
|
|
|
|
|
|
|
|
bool demux_FilterDisable( demux_t *p_demux_chain, const char* psz_demux )
|
|
|
|
{
|
|
|
|
return demux_filter_enable_disable( p_demux_chain, psz_demux, false );
|
|
|
|
}
|