2007-06-17 18:24:49 +02:00
|
|
|
/*****************************************************************************
|
2022-01-07 18:23:46 +01:00
|
|
|
* media.c: Libvlc API media descriptor management
|
2007-06-17 18:24:49 +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
|
|
|
* Copyright (C) 2007 VLC authors and VideoLAN
|
2007-06-17 18:24:49 +02:00
|
|
|
*
|
|
|
|
* Authors: Pierre d'Herbemont <pdherbemont@videolan.org>
|
|
|
|
*
|
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
|
2007-06-17 18:24:49 +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.
|
2007-06-17 18:24:49 +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.
|
2007-06-17 18:24:49 +02:00
|
|
|
*****************************************************************************/
|
|
|
|
|
2009-05-25 15:09:40 +02:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2009-10-05 20:52:49 +02:00
|
|
|
#include <assert.h>
|
2014-02-26 17:24:10 +01:00
|
|
|
#include <errno.h>
|
2021-10-05 18:05:47 +02:00
|
|
|
#include <limits.h>
|
2009-10-05 20:52:49 +02:00
|
|
|
|
2007-06-17 18:24:49 +02:00
|
|
|
#include <vlc/libvlc.h>
|
2018-10-05 13:23:00 +02:00
|
|
|
#include <vlc/libvlc_picture.h>
|
2009-05-25 10:47:38 +02:00
|
|
|
#include <vlc/libvlc_media.h>
|
|
|
|
#include <vlc/libvlc_media_list.h> // For the subitems, here for convenience
|
|
|
|
#include <vlc/libvlc_events.h>
|
|
|
|
|
|
|
|
#include <vlc_common.h>
|
2007-06-17 18:24:49 +02:00
|
|
|
#include <vlc_meta.h>
|
2010-02-18 18:56:15 +01:00
|
|
|
#include <vlc_url.h>
|
2018-10-05 13:23:00 +02:00
|
|
|
#include <vlc_thumbnailer.h>
|
2020-11-21 13:03:49 +01:00
|
|
|
#include <vlc_atomic.h>
|
2007-06-17 18:24:49 +02:00
|
|
|
|
2011-08-30 22:40:14 +02:00
|
|
|
#include "../src/libvlc.h"
|
2009-05-25 10:47:38 +02:00
|
|
|
|
|
|
|
#include "libvlc_internal.h"
|
|
|
|
#include "media_internal.h"
|
2015-01-19 11:22:49 +01:00
|
|
|
#include "media_list_internal.h"
|
2018-10-05 13:23:00 +02:00
|
|
|
#include "picture_internal.h"
|
2007-08-22 18:49:43 +02:00
|
|
|
|
2007-08-15 20:27:49 +02:00
|
|
|
static const vlc_meta_type_t libvlc_to_vlc_meta[] =
|
|
|
|
{
|
|
|
|
[libvlc_meta_Title] = vlc_meta_Title,
|
|
|
|
[libvlc_meta_Artist] = vlc_meta_Artist,
|
|
|
|
[libvlc_meta_Genre] = vlc_meta_Genre,
|
|
|
|
[libvlc_meta_Copyright] = vlc_meta_Copyright,
|
|
|
|
[libvlc_meta_Album] = vlc_meta_Album,
|
|
|
|
[libvlc_meta_TrackNumber] = vlc_meta_TrackNumber,
|
|
|
|
[libvlc_meta_Description] = vlc_meta_Description,
|
|
|
|
[libvlc_meta_Rating] = vlc_meta_Rating,
|
|
|
|
[libvlc_meta_Date] = vlc_meta_Date,
|
|
|
|
[libvlc_meta_Setting] = vlc_meta_Setting,
|
|
|
|
[libvlc_meta_URL] = vlc_meta_URL,
|
|
|
|
[libvlc_meta_Language] = vlc_meta_Language,
|
|
|
|
[libvlc_meta_NowPlaying] = vlc_meta_NowPlaying,
|
|
|
|
[libvlc_meta_Publisher] = vlc_meta_Publisher,
|
|
|
|
[libvlc_meta_EncodedBy] = vlc_meta_EncodedBy,
|
|
|
|
[libvlc_meta_ArtworkURL] = vlc_meta_ArtworkURL,
|
2014-02-08 15:10:13 +01:00
|
|
|
[libvlc_meta_TrackID] = vlc_meta_TrackID,
|
|
|
|
[libvlc_meta_TrackTotal] = vlc_meta_TrackTotal,
|
|
|
|
[libvlc_meta_Director] = vlc_meta_Director,
|
|
|
|
[libvlc_meta_Season] = vlc_meta_Season,
|
|
|
|
[libvlc_meta_Episode] = vlc_meta_Episode,
|
|
|
|
[libvlc_meta_ShowName] = vlc_meta_ShowName,
|
2014-11-22 23:01:17 +01:00
|
|
|
[libvlc_meta_Actors] = vlc_meta_Actors,
|
2014-12-05 20:11:05 +01:00
|
|
|
[libvlc_meta_AlbumArtist] = vlc_meta_AlbumArtist,
|
2015-10-16 19:15:20 +02:00
|
|
|
[libvlc_meta_DiscNumber] = vlc_meta_DiscNumber,
|
|
|
|
[libvlc_meta_DiscTotal] = vlc_meta_DiscTotal
|
2007-08-15 20:27:49 +02:00
|
|
|
};
|
|
|
|
|
2009-07-06 04:50:03 +02:00
|
|
|
static const libvlc_meta_t vlc_to_libvlc_meta[] =
|
2007-08-15 20:27:49 +02:00
|
|
|
{
|
|
|
|
[vlc_meta_Title] = libvlc_meta_Title,
|
|
|
|
[vlc_meta_Artist] = libvlc_meta_Artist,
|
|
|
|
[vlc_meta_Genre] = libvlc_meta_Genre,
|
|
|
|
[vlc_meta_Copyright] = libvlc_meta_Copyright,
|
|
|
|
[vlc_meta_Album] = libvlc_meta_Album,
|
|
|
|
[vlc_meta_TrackNumber] = libvlc_meta_TrackNumber,
|
|
|
|
[vlc_meta_Description] = libvlc_meta_Description,
|
|
|
|
[vlc_meta_Rating] = libvlc_meta_Rating,
|
|
|
|
[vlc_meta_Date] = libvlc_meta_Date,
|
|
|
|
[vlc_meta_Setting] = libvlc_meta_Setting,
|
|
|
|
[vlc_meta_URL] = libvlc_meta_URL,
|
|
|
|
[vlc_meta_Language] = libvlc_meta_Language,
|
|
|
|
[vlc_meta_NowPlaying] = libvlc_meta_NowPlaying,
|
2014-12-17 14:26:50 +01:00
|
|
|
[vlc_meta_ESNowPlaying] = libvlc_meta_NowPlaying,
|
2007-08-15 20:27:49 +02:00
|
|
|
[vlc_meta_Publisher] = libvlc_meta_Publisher,
|
|
|
|
[vlc_meta_EncodedBy] = libvlc_meta_EncodedBy,
|
|
|
|
[vlc_meta_ArtworkURL] = libvlc_meta_ArtworkURL,
|
2014-02-08 15:10:13 +01:00
|
|
|
[vlc_meta_TrackID] = libvlc_meta_TrackID,
|
|
|
|
[vlc_meta_TrackTotal] = libvlc_meta_TrackTotal,
|
|
|
|
[vlc_meta_Director] = libvlc_meta_Director,
|
|
|
|
[vlc_meta_Season] = libvlc_meta_Season,
|
|
|
|
[vlc_meta_Episode] = libvlc_meta_Episode,
|
|
|
|
[vlc_meta_ShowName] = libvlc_meta_ShowName,
|
2014-11-22 23:01:17 +01:00
|
|
|
[vlc_meta_Actors] = libvlc_meta_Actors,
|
2014-12-05 20:11:05 +01:00
|
|
|
[vlc_meta_AlbumArtist] = libvlc_meta_AlbumArtist,
|
2015-10-16 19:15:20 +02:00
|
|
|
[vlc_meta_DiscNumber] = libvlc_meta_DiscNumber,
|
|
|
|
[vlc_meta_DiscTotal] = libvlc_meta_DiscTotal
|
2007-08-15 20:27:49 +02:00
|
|
|
};
|
|
|
|
|
2016-11-24 18:03:03 +01:00
|
|
|
static_assert(
|
|
|
|
ORIENT_TOP_LEFT == (int) libvlc_video_orient_top_left &&
|
|
|
|
ORIENT_TOP_RIGHT == (int) libvlc_video_orient_top_right &&
|
|
|
|
ORIENT_BOTTOM_LEFT == (int) libvlc_video_orient_bottom_left &&
|
|
|
|
ORIENT_BOTTOM_RIGHT == (int) libvlc_video_orient_bottom_right &&
|
|
|
|
ORIENT_LEFT_TOP == (int) libvlc_video_orient_left_top &&
|
|
|
|
ORIENT_LEFT_BOTTOM == (int) libvlc_video_orient_left_bottom &&
|
|
|
|
ORIENT_RIGHT_TOP == (int) libvlc_video_orient_right_top &&
|
|
|
|
ORIENT_RIGHT_BOTTOM == (int) libvlc_video_orient_right_bottom,
|
|
|
|
"Mismatch between libvlc_video_orient_t and video_orientation_t" );
|
|
|
|
|
2016-11-24 18:03:32 +01:00
|
|
|
static_assert(
|
|
|
|
PROJECTION_MODE_RECTANGULAR == (int) libvlc_video_projection_rectangular &&
|
|
|
|
PROJECTION_MODE_EQUIRECTANGULAR == (int) libvlc_video_projection_equirectangular &&
|
|
|
|
PROJECTION_MODE_CUBEMAP_LAYOUT_STANDARD == (int) libvlc_video_projection_cubemap_layout_standard,
|
|
|
|
"Mismatch between libvlc_video_projection_t and video_projection_mode_t" );
|
|
|
|
|
2018-04-12 14:43:14 +02:00
|
|
|
static_assert(
|
|
|
|
MULTIVIEW_2D == (int) libvlc_video_multiview_2d &&
|
|
|
|
MULTIVIEW_STEREO_SBS == (int) libvlc_video_multiview_stereo_sbs &&
|
|
|
|
MULTIVIEW_STEREO_TB == (int) libvlc_video_multiview_stereo_tb &&
|
|
|
|
MULTIVIEW_STEREO_ROW == (int) libvlc_video_multiview_stereo_row &&
|
|
|
|
MULTIVIEW_STEREO_COL == (int) libvlc_video_multiview_stereo_col &&
|
|
|
|
MULTIVIEW_STEREO_FRAME == (int) libvlc_video_multiview_stereo_frame &&
|
|
|
|
MULTIVIEW_STEREO_CHECKERBOARD == (int) libvlc_video_multiview_stereo_checkerboard,
|
|
|
|
"Mismatch between libvlc_video_multiview_t and video_multiview_mode_t");
|
|
|
|
|
2015-02-04 09:55:53 +01:00
|
|
|
static libvlc_media_list_t *media_get_subitems( libvlc_media_t * p_md,
|
|
|
|
bool b_create )
|
2015-01-19 11:22:48 +01:00
|
|
|
{
|
|
|
|
libvlc_media_list_t *p_subitems = NULL;
|
|
|
|
|
|
|
|
vlc_mutex_lock( &p_md->subitems_lock );
|
2015-02-04 09:55:53 +01:00
|
|
|
if( p_md->p_subitems == NULL && b_create )
|
2015-01-19 11:22:48 +01:00
|
|
|
{
|
2020-07-15 18:08:06 +02:00
|
|
|
p_md->p_subitems = libvlc_media_list_new();
|
2015-01-19 11:22:48 +01:00
|
|
|
if( p_md->p_subitems != NULL )
|
2015-01-19 11:22:49 +01:00
|
|
|
{
|
|
|
|
p_md->p_subitems->b_read_only = true;
|
2015-01-20 10:46:29 +01:00
|
|
|
p_md->p_subitems->p_internal_md = p_md;
|
2015-01-19 11:22:49 +01:00
|
|
|
}
|
2015-01-19 11:22:48 +01:00
|
|
|
}
|
|
|
|
p_subitems = p_md->p_subitems;
|
|
|
|
vlc_mutex_unlock( &p_md->subitems_lock );
|
|
|
|
return p_subitems;
|
|
|
|
}
|
|
|
|
|
2017-05-17 21:06:32 +02:00
|
|
|
static libvlc_media_t *input_item_add_subitem( libvlc_media_t *p_md,
|
|
|
|
input_item_t *item )
|
2007-08-16 20:05:07 +02:00
|
|
|
{
|
2008-03-30 03:59:32 +02:00
|
|
|
libvlc_media_t * p_md_child;
|
2015-01-19 11:22:48 +01:00
|
|
|
libvlc_media_list_t *p_subitems;
|
2007-08-16 20:05:07 +02:00
|
|
|
libvlc_event_t event;
|
|
|
|
|
2022-06-14 18:42:01 +02:00
|
|
|
p_md_child = libvlc_media_new_from_input_item( item );
|
2007-08-16 20:05:07 +02:00
|
|
|
|
2007-08-21 21:43:04 +02:00
|
|
|
/* Add this to our media list */
|
2015-02-04 09:55:53 +01:00
|
|
|
p_subitems = media_get_subitems( p_md, true );
|
2015-01-19 11:22:48 +01:00
|
|
|
if( p_subitems != NULL )
|
2015-01-19 11:22:50 +01:00
|
|
|
{
|
|
|
|
libvlc_media_list_lock( p_subitems );
|
2015-01-19 11:22:49 +01:00
|
|
|
libvlc_media_list_internal_add_media( p_subitems, p_md_child );
|
2015-01-19 11:22:50 +01:00
|
|
|
libvlc_media_list_unlock( p_subitems );
|
|
|
|
}
|
2007-08-21 21:43:04 +02:00
|
|
|
|
2007-08-16 20:05:07 +02:00
|
|
|
/* Construct the event */
|
2008-03-31 06:35:08 +02:00
|
|
|
event.type = libvlc_MediaSubItemAdded;
|
2008-03-30 03:59:32 +02:00
|
|
|
event.u.media_subitem_added.new_child = p_md_child;
|
2007-08-16 20:05:07 +02:00
|
|
|
|
|
|
|
/* Send the event */
|
2017-05-15 19:16:45 +02:00
|
|
|
libvlc_event_send( &p_md->event_manager, &event );
|
2017-05-17 21:06:32 +02:00
|
|
|
return p_md_child;
|
|
|
|
}
|
|
|
|
|
2020-07-14 22:18:05 +02:00
|
|
|
struct vlc_item_list
|
|
|
|
{
|
|
|
|
struct vlc_list node;
|
|
|
|
input_item_node_t *item;
|
|
|
|
libvlc_media_t *media;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct vlc_item_list *
|
|
|
|
wrap_item_in_list( libvlc_media_t *media, input_item_node_t *item )
|
|
|
|
{
|
|
|
|
struct vlc_item_list *node = malloc( sizeof *node );
|
|
|
|
if( node == NULL )
|
|
|
|
return NULL;
|
|
|
|
node->item = item;
|
|
|
|
node->media = media;
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2017-05-17 21:06:32 +02:00
|
|
|
static void input_item_add_subnode( libvlc_media_t *md,
|
2020-07-14 22:18:05 +02:00
|
|
|
input_item_node_t *root )
|
2017-05-17 21:06:32 +02:00
|
|
|
{
|
2020-07-14 22:18:05 +02:00
|
|
|
struct vlc_list list;
|
|
|
|
vlc_list_init( &list );
|
|
|
|
|
|
|
|
/* Retain the media because we don't want the search algorithm to release
|
|
|
|
* it when its subitems get parsed. */
|
|
|
|
libvlc_media_retain(md);
|
|
|
|
|
|
|
|
struct vlc_item_list *node_root = wrap_item_in_list( md, root );
|
|
|
|
if( node_root == NULL )
|
|
|
|
{
|
|
|
|
libvlc_media_release(md);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This is a depth-first search algorithm, so stash the root of the tree
|
|
|
|
* first, then stash its children and loop back on the last item in the
|
|
|
|
* list until the full subtree is parsed, and eventually the full tree is
|
|
|
|
* parsed. */
|
|
|
|
vlc_list_append( &node_root->node, &list );
|
|
|
|
|
|
|
|
while( !vlc_list_is_empty( &list ) )
|
2017-05-17 21:06:32 +02:00
|
|
|
{
|
2020-07-14 22:18:05 +02:00
|
|
|
/* Pop last item in the list. */
|
|
|
|
struct vlc_item_list *node =
|
|
|
|
vlc_list_last_entry_or_null( &list, struct vlc_item_list, node );
|
|
|
|
vlc_list_remove(&node->node);
|
2017-05-17 21:06:32 +02:00
|
|
|
|
2020-07-14 22:18:05 +02:00
|
|
|
for( int i = 0; i < node->item->i_children; i++ )
|
2017-05-17 21:06:32 +02:00
|
|
|
{
|
2020-07-14 22:18:05 +02:00
|
|
|
input_item_node_t *child = node->item->pp_children[i];
|
|
|
|
|
|
|
|
/* The media will be released when its children will be added to
|
|
|
|
* the list. */
|
|
|
|
libvlc_media_t *md_child = input_item_add_subitem( node->media, child->p_item );
|
|
|
|
if( md_child == NULL )
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
struct vlc_item_list *submedia =
|
|
|
|
wrap_item_in_list( md_child, child );
|
|
|
|
if (submedia == NULL)
|
|
|
|
{
|
|
|
|
libvlc_media_release( md_child );
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Stash a request to parse this subtree. */
|
|
|
|
vlc_list_append( &submedia->node, &list );
|
2017-05-17 21:06:32 +02:00
|
|
|
}
|
2020-07-14 22:18:05 +02:00
|
|
|
|
|
|
|
libvlc_media_release( node->media );
|
|
|
|
free( node );
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
|
|
|
|
error:
|
|
|
|
libvlc_printerr( "Not enough memory" );
|
|
|
|
|
|
|
|
struct vlc_item_list *node;
|
|
|
|
vlc_list_foreach( node, &list, node )
|
|
|
|
{
|
|
|
|
if( node->media != NULL )
|
|
|
|
libvlc_media_release( node->media );
|
|
|
|
free( node );
|
2017-05-17 21:06:32 +02:00
|
|
|
}
|
2007-08-16 20:05:07 +02:00
|
|
|
}
|
|
|
|
|
2020-03-04 12:03:12 +01:00
|
|
|
/**
|
|
|
|
* \internal
|
2013-09-01 16:00:18 +02:00
|
|
|
* input_item_subitemtree_added (Private) (vlc event Callback)
|
2020-03-04 12:03:12 +01:00
|
|
|
*/
|
2018-08-16 09:51:10 +02:00
|
|
|
static void input_item_subtree_added(input_item_t *item,
|
|
|
|
input_item_node_t *node,
|
|
|
|
void *user_data)
|
2013-09-01 16:00:18 +02:00
|
|
|
{
|
2018-08-16 09:51:10 +02:00
|
|
|
VLC_UNUSED(item);
|
2013-09-01 16:00:18 +02:00
|
|
|
libvlc_media_t * p_md = user_data;
|
2018-08-16 09:51:10 +02:00
|
|
|
libvlc_media_add_subtree(p_md, node);
|
|
|
|
}
|
2017-05-17 21:06:32 +02:00
|
|
|
|
2018-08-16 09:51:10 +02:00
|
|
|
void libvlc_media_add_subtree(libvlc_media_t *p_md, input_item_node_t *node)
|
|
|
|
{
|
2017-05-17 21:06:32 +02:00
|
|
|
input_item_add_subnode( p_md, node );
|
2013-09-01 16:00:18 +02:00
|
|
|
|
|
|
|
/* Construct the event */
|
2018-08-16 09:51:10 +02:00
|
|
|
libvlc_event_t event;
|
2013-09-01 16:00:18 +02:00
|
|
|
event.type = libvlc_MediaSubItemTreeAdded;
|
|
|
|
event.u.media_subitemtree_added.item = p_md;
|
|
|
|
|
|
|
|
/* Send the event */
|
2017-05-15 19:16:45 +02:00
|
|
|
libvlc_event_send( &p_md->event_manager, &event );
|
2013-09-01 16:00:18 +02:00
|
|
|
}
|
|
|
|
|
2020-03-04 12:03:12 +01:00
|
|
|
/**
|
|
|
|
* \internal
|
2007-08-15 20:27:49 +02:00
|
|
|
* input_item_meta_changed (Private) (vlc event Callback)
|
2020-03-04 12:03:12 +01:00
|
|
|
*/
|
2007-08-15 20:27:49 +02:00
|
|
|
static void input_item_meta_changed( const vlc_event_t *p_event,
|
|
|
|
void * user_data )
|
|
|
|
{
|
2008-03-30 03:59:32 +02:00
|
|
|
libvlc_media_t * p_md = user_data;
|
2007-08-15 20:27:49 +02:00
|
|
|
libvlc_event_t event;
|
|
|
|
|
|
|
|
/* Construct the event */
|
2008-03-31 06:35:08 +02:00
|
|
|
event.type = libvlc_MediaMetaChanged;
|
2008-03-30 03:59:32 +02:00
|
|
|
event.u.media_meta_changed.meta_type =
|
2007-08-15 20:27:49 +02:00
|
|
|
vlc_to_libvlc_meta[p_event->u.input_item_meta_changed.meta_type];
|
|
|
|
|
|
|
|
/* Send the event */
|
2017-05-15 19:16:45 +02:00
|
|
|
libvlc_event_send( &p_md->event_manager, &event );
|
2007-08-15 20:27:49 +02:00
|
|
|
}
|
|
|
|
|
2020-03-04 12:03:12 +01:00
|
|
|
/**
|
|
|
|
* \internal
|
2007-10-20 19:56:00 +02:00
|
|
|
* input_item_duration_changed (Private) (vlc event Callback)
|
2020-03-04 12:03:12 +01:00
|
|
|
*/
|
2007-10-20 19:56:00 +02:00
|
|
|
static void input_item_duration_changed( const vlc_event_t *p_event,
|
|
|
|
void * user_data )
|
|
|
|
{
|
2008-03-30 03:59:32 +02:00
|
|
|
libvlc_media_t * p_md = user_data;
|
2007-10-20 19:56:00 +02:00
|
|
|
libvlc_event_t event;
|
|
|
|
|
|
|
|
/* Construct the event */
|
2008-03-31 06:35:08 +02:00
|
|
|
event.type = libvlc_MediaDurationChanged;
|
2010-01-16 16:11:08 +01:00
|
|
|
event.u.media_duration_changed.new_duration =
|
2022-08-12 06:17:42 +02:00
|
|
|
libvlc_time_from_vlc_tick(p_event->u.input_item_duration_changed.new_duration);
|
2007-10-20 19:56:00 +02:00
|
|
|
|
|
|
|
/* Send the event */
|
2017-05-15 19:16:45 +02:00
|
|
|
libvlc_event_send( &p_md->event_manager, &event );
|
2007-10-20 19:56:00 +02:00
|
|
|
}
|
|
|
|
|
2020-11-18 14:54:41 +01:00
|
|
|
static void input_item_attachments_found( const vlc_event_t *p_event,
|
|
|
|
void * user_data )
|
|
|
|
{
|
|
|
|
libvlc_media_t * p_md = user_data;
|
|
|
|
libvlc_event_t event;
|
|
|
|
|
|
|
|
libvlc_picture_list_t* list = libvlc_picture_list_from_attachments(
|
|
|
|
p_event->u.input_item_attachments_found.attachments,
|
|
|
|
p_event->u.input_item_attachments_found.count );
|
|
|
|
if( !list )
|
|
|
|
return;
|
|
|
|
if( !libvlc_picture_list_count(list) )
|
|
|
|
{
|
|
|
|
libvlc_picture_list_destroy( list );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Construct the event */
|
|
|
|
event.type = libvlc_MediaAttachedThumbnailsFound;
|
|
|
|
event.u.media_attached_thumbnails_found.thumbnails = list;
|
|
|
|
|
|
|
|
/* Send the event */
|
|
|
|
libvlc_event_send( &p_md->event_manager, &event );
|
|
|
|
|
|
|
|
libvlc_picture_list_destroy( list );
|
|
|
|
}
|
|
|
|
|
2016-05-24 11:19:42 +02:00
|
|
|
static void send_parsed_changed( libvlc_media_t *p_md,
|
|
|
|
libvlc_media_parsed_status_t new_status )
|
2007-10-20 19:56:00 +02:00
|
|
|
{
|
|
|
|
libvlc_event_t event;
|
|
|
|
|
2022-06-15 18:36:10 +02:00
|
|
|
if (atomic_exchange(&p_md->parsed_status, new_status) == new_status)
|
2016-04-14 15:20:24 +02:00
|
|
|
return;
|
2016-05-24 11:19:42 +02:00
|
|
|
|
2007-10-20 19:56:00 +02:00
|
|
|
/* Construct the event */
|
2010-02-22 18:34:32 +01:00
|
|
|
event.type = libvlc_MediaParsedChanged;
|
2016-05-24 11:19:42 +02:00
|
|
|
event.u.media_parsed_changed.new_status = new_status;
|
2007-10-20 19:56:00 +02:00
|
|
|
|
|
|
|
/* Send the event */
|
2017-05-15 19:16:45 +02:00
|
|
|
libvlc_event_send( &p_md->event_manager, &event );
|
2020-11-09 15:10:39 +01:00
|
|
|
|
|
|
|
libvlc_media_list_t *p_subitems = media_get_subitems( p_md, false );
|
|
|
|
if( p_subitems != NULL )
|
|
|
|
{
|
|
|
|
/* notify the media list */
|
|
|
|
libvlc_media_list_lock( p_subitems );
|
|
|
|
libvlc_media_list_internal_end_reached( p_subitems );
|
|
|
|
libvlc_media_list_unlock( p_subitems );
|
|
|
|
}
|
2016-04-14 15:20:24 +02:00
|
|
|
}
|
|
|
|
|
2020-03-04 12:03:12 +01:00
|
|
|
/**
|
|
|
|
* \internal
|
2015-02-04 09:55:53 +01:00
|
|
|
* input_item_preparse_ended (Private) (vlc event Callback)
|
2020-03-04 12:03:12 +01:00
|
|
|
*/
|
2018-08-16 09:51:10 +02:00
|
|
|
static void input_item_preparse_ended(input_item_t *item,
|
|
|
|
enum input_item_preparse_status status,
|
|
|
|
void *user_data)
|
2015-02-04 09:55:53 +01:00
|
|
|
{
|
2018-08-16 09:51:10 +02:00
|
|
|
VLC_UNUSED(item);
|
2015-02-04 09:55:53 +01:00
|
|
|
libvlc_media_t * p_md = user_data;
|
2016-05-24 11:19:42 +02:00
|
|
|
libvlc_media_parsed_status_t new_status;
|
2016-04-14 17:04:04 +02:00
|
|
|
|
2018-08-16 09:51:10 +02:00
|
|
|
switch( status )
|
2016-04-14 17:04:04 +02:00
|
|
|
{
|
|
|
|
case ITEM_PREPARSE_SKIPPED:
|
2016-05-24 11:19:42 +02:00
|
|
|
new_status = libvlc_media_parsed_status_skipped;
|
2016-04-14 17:04:04 +02:00
|
|
|
break;
|
|
|
|
case ITEM_PREPARSE_FAILED:
|
2016-05-24 11:19:42 +02:00
|
|
|
new_status = libvlc_media_parsed_status_failed;
|
2016-04-14 17:04:04 +02:00
|
|
|
break;
|
2016-06-05 11:36:19 +02:00
|
|
|
case ITEM_PREPARSE_TIMEOUT:
|
|
|
|
new_status = libvlc_media_parsed_status_timeout;
|
|
|
|
break;
|
2016-04-14 17:04:04 +02:00
|
|
|
case ITEM_PREPARSE_DONE:
|
2016-05-24 11:19:42 +02:00
|
|
|
new_status = libvlc_media_parsed_status_done;
|
2016-04-14 17:04:04 +02:00
|
|
|
break;
|
2016-05-24 11:19:42 +02:00
|
|
|
default:
|
|
|
|
return;
|
2016-04-14 17:04:04 +02:00
|
|
|
}
|
2016-05-24 11:19:42 +02:00
|
|
|
send_parsed_changed( p_md, new_status );
|
lib: media: wait preparse end before release
This is a quick fix for #25296 actually reverting the commit
a708c988091d6bc770212f5deeaba45e2395f4b2, replacing the Hold/Release
lifecycle used there by an ad-hoc Hold/Release which actually defer the
actual release by blocking instead of releasing in the preparser thread.
Indeed, libvlc_media is holding the instance used to create it, though
it only needs it for preparsing. If the last reference of the media is
hold by the preparser, libvlc_media will be released by the preparser
thread and the libvlc_instance potentially released from there too.
Since killing the libvlc_instance will join the preparser thread, it
cannot be done from the preparser thread, or would lead to the failure
detailed in #25296. Written differently, only the final client should
make use of Hold/Release, directly through the adequate function or
indirectly through the creation of new objects.
In addition, a708c988091d6bc770212f5deeaba45e2395f4b2 cannot just be
reverted as it was fixing cases where the libvlc_media_t object were
released before preparsing is finished, and the libvlc application
cannot just wait for the preparsing event to arrive since it must still
typically unlock the event manager and manage subitems.
Ideally, the libvlc_media would just not have a strong reference to the
libvlc instance, which would allow detaching the libvlc state from the
libvlccore state, but it cannot be done just yet, since the preparsing
API must be splitted from libvlc_media first.
Fix #25296
2021-02-12 12:28:27 +01:00
|
|
|
|
2021-10-05 18:05:47 +02:00
|
|
|
if (atomic_fetch_sub_explicit(&p_md->worker_count, 1,
|
|
|
|
memory_order_release) == 1)
|
|
|
|
vlc_atomic_notify_one(&p_md->worker_count);
|
2015-02-04 09:55:53 +01:00
|
|
|
}
|
|
|
|
|
2020-03-04 12:03:12 +01:00
|
|
|
/**
|
|
|
|
* \internal
|
2007-08-15 20:27:49 +02:00
|
|
|
* Install event handler (Private)
|
2020-03-04 12:03:12 +01:00
|
|
|
*/
|
2008-03-30 03:59:32 +02:00
|
|
|
static void install_input_item_observer( libvlc_media_t *p_md )
|
2007-08-15 20:27:49 +02:00
|
|
|
{
|
|
|
|
vlc_event_attach( &p_md->p_input_item->event_manager,
|
|
|
|
vlc_InputItemMetaChanged,
|
|
|
|
input_item_meta_changed,
|
|
|
|
p_md );
|
2007-10-20 19:56:00 +02:00
|
|
|
vlc_event_attach( &p_md->p_input_item->event_manager,
|
|
|
|
vlc_InputItemDurationChanged,
|
|
|
|
input_item_duration_changed,
|
|
|
|
p_md );
|
2020-11-18 14:54:41 +01:00
|
|
|
vlc_event_attach( &p_md->p_input_item->event_manager,
|
|
|
|
vlc_InputItemAttachmentsFound,
|
|
|
|
input_item_attachments_found,
|
|
|
|
p_md );
|
2007-08-15 20:27:49 +02:00
|
|
|
}
|
|
|
|
|
2020-03-04 12:03:12 +01:00
|
|
|
/**
|
|
|
|
* \internal
|
2007-08-15 20:27:49 +02:00
|
|
|
* Uninstall event handler (Private)
|
2020-03-04 12:03:12 +01:00
|
|
|
*/
|
2008-03-30 03:59:32 +02:00
|
|
|
static void uninstall_input_item_observer( libvlc_media_t *p_md )
|
2007-08-15 20:27:49 +02:00
|
|
|
{
|
|
|
|
vlc_event_detach( &p_md->p_input_item->event_manager,
|
|
|
|
vlc_InputItemMetaChanged,
|
|
|
|
input_item_meta_changed,
|
|
|
|
p_md );
|
2007-10-20 19:56:00 +02:00
|
|
|
vlc_event_detach( &p_md->p_input_item->event_manager,
|
|
|
|
vlc_InputItemDurationChanged,
|
|
|
|
input_item_duration_changed,
|
|
|
|
p_md );
|
2020-11-18 14:54:41 +01:00
|
|
|
vlc_event_detach( &p_md->p_input_item->event_manager,
|
|
|
|
vlc_InputItemAttachmentsFound,
|
|
|
|
input_item_attachments_found,
|
|
|
|
p_md );
|
2007-08-15 20:27:49 +02:00
|
|
|
}
|
2007-06-17 18:24:49 +02:00
|
|
|
|
2020-03-04 12:03:12 +01:00
|
|
|
/**
|
|
|
|
* \internal
|
|
|
|
* Create a new media descriptor object from an input_item (Private)
|
2020-07-09 17:35:08 +02:00
|
|
|
*
|
2007-08-15 20:27:49 +02:00
|
|
|
* That's the generic constructor
|
2020-03-04 12:03:12 +01:00
|
|
|
*/
|
2022-06-14 18:42:01 +02:00
|
|
|
libvlc_media_t * libvlc_media_new_from_input_item(input_item_t *p_input_item )
|
2007-06-17 18:24:49 +02:00
|
|
|
{
|
2008-03-30 03:59:32 +02:00
|
|
|
libvlc_media_t * p_md;
|
2007-06-17 18:24:49 +02:00
|
|
|
|
|
|
|
if (!p_input_item)
|
2007-06-24 13:19:48 +02:00
|
|
|
{
|
2009-09-07 21:13:49 +02:00
|
|
|
libvlc_printerr( "No input item given" );
|
2007-06-24 13:19:48 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
2007-06-17 18:24:49 +02:00
|
|
|
|
2010-01-19 14:32:31 +01:00
|
|
|
p_md = calloc( 1, sizeof(libvlc_media_t) );
|
2008-05-18 13:09:26 +02:00
|
|
|
if( !p_md )
|
|
|
|
{
|
2009-09-07 21:13:49 +02:00
|
|
|
libvlc_printerr( "Not enough memory" );
|
2008-05-18 13:09:26 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2007-07-09 22:52:11 +02:00
|
|
|
p_md->p_input_item = p_input_item;
|
2020-11-21 13:03:49 +01:00
|
|
|
vlc_atomic_rc_init(&p_md->rc);
|
2007-12-24 19:45:10 +01:00
|
|
|
|
2015-01-19 11:22:48 +01:00
|
|
|
vlc_mutex_init(&p_md->subitems_lock);
|
2021-10-05 18:05:47 +02:00
|
|
|
atomic_init(&p_md->worker_count, 0);
|
lib: media: wait preparse end before release
This is a quick fix for #25296 actually reverting the commit
a708c988091d6bc770212f5deeaba45e2395f4b2, replacing the Hold/Release
lifecycle used there by an ad-hoc Hold/Release which actually defer the
actual release by blocking instead of releasing in the preparser thread.
Indeed, libvlc_media is holding the instance used to create it, though
it only needs it for preparsing. If the last reference of the media is
hold by the preparser, libvlc_media will be released by the preparser
thread and the libvlc_instance potentially released from there too.
Since killing the libvlc_instance will join the preparser thread, it
cannot be done from the preparser thread, or would lead to the failure
detailed in #25296. Written differently, only the final client should
make use of Hold/Release, directly through the adequate function or
indirectly through the creation of new objects.
In addition, a708c988091d6bc770212f5deeaba45e2395f4b2 cannot just be
reverted as it was fixing cases where the libvlc_media_t object were
released before preparsing is finished, and the libvlc application
cannot just wait for the preparsing event to arrive since it must still
typically unlock the event manager and manage subitems.
Ideally, the libvlc_media would just not have a strong reference to the
libvlc instance, which would allow detaching the libvlc state from the
libvlccore state, but it cannot be done just yet, since the preparsing
API must be splitted from libvlc_media first.
Fix #25296
2021-02-12 12:28:27 +01:00
|
|
|
|
2007-08-21 21:43:04 +02:00
|
|
|
/* A media descriptor can be a playlist. When you open a playlist
|
|
|
|
* It can give a bunch of item to read. */
|
|
|
|
p_md->p_subitems = NULL;
|
2020-09-18 14:29:32 +02:00
|
|
|
p_md->p_input_item->libvlc_owner = p_md;
|
2022-06-15 18:36:10 +02:00
|
|
|
atomic_init(&p_md->parsed_status, libvlc_media_parsed_status_none);
|
2007-08-21 21:43:04 +02:00
|
|
|
|
2017-05-15 19:16:45 +02:00
|
|
|
libvlc_event_manager_init( &p_md->event_manager, p_md );
|
2010-02-22 18:34:32 +01:00
|
|
|
|
2017-04-09 16:23:17 +02:00
|
|
|
input_item_Hold( p_md->p_input_item );
|
2007-06-17 18:24:49 +02:00
|
|
|
|
2007-08-15 20:27:49 +02:00
|
|
|
install_input_item_observer( p_md );
|
2007-07-09 22:52:11 +02:00
|
|
|
return p_md;
|
2007-06-17 18:24:49 +02:00
|
|
|
}
|
|
|
|
|
2020-03-04 12:03:12 +01:00
|
|
|
// Create a media with a certain given media resource location
|
2022-06-14 18:52:02 +02:00
|
|
|
libvlc_media_t *libvlc_media_new_location(const char * psz_mrl)
|
2007-06-17 22:54:32 +02:00
|
|
|
{
|
2007-08-15 20:27:49 +02:00
|
|
|
input_item_t * p_input_item;
|
2008-03-30 03:59:32 +02:00
|
|
|
libvlc_media_t * p_md;
|
2007-06-17 22:54:32 +02:00
|
|
|
|
2011-07-10 17:23:41 +02:00
|
|
|
p_input_item = input_item_New( psz_mrl, NULL );
|
2007-08-15 20:27:49 +02:00
|
|
|
|
2007-06-17 22:54:32 +02:00
|
|
|
if (!p_input_item)
|
2007-06-24 13:19:48 +02:00
|
|
|
{
|
2009-09-07 21:13:49 +02:00
|
|
|
libvlc_printerr( "Not enough memory" );
|
2007-06-24 13:19:48 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
2007-06-17 22:54:32 +02:00
|
|
|
|
2022-06-14 18:42:01 +02:00
|
|
|
p_md = libvlc_media_new_from_input_item( p_input_item );
|
2007-06-17 22:54:32 +02:00
|
|
|
|
2008-03-30 03:59:32 +02:00
|
|
|
/* The p_input_item is retained in libvlc_media_new_from_input_item */
|
2017-04-09 16:26:19 +02:00
|
|
|
input_item_Release( p_input_item );
|
2008-05-18 13:09:26 +02:00
|
|
|
|
2007-07-09 22:52:11 +02:00
|
|
|
return p_md;
|
2007-06-17 22:54:32 +02:00
|
|
|
}
|
|
|
|
|
2020-03-04 12:03:12 +01:00
|
|
|
// Create a media for a certain file path
|
2022-06-14 18:53:35 +02:00
|
|
|
libvlc_media_t *libvlc_media_new_path(const char *path)
|
2010-02-18 18:56:15 +01:00
|
|
|
{
|
2013-06-10 21:15:45 +02:00
|
|
|
char *mrl = vlc_path2uri( path, NULL );
|
2010-02-18 18:56:15 +01:00
|
|
|
if( unlikely(mrl == NULL) )
|
|
|
|
{
|
2014-02-26 17:24:10 +01:00
|
|
|
libvlc_printerr( "%s", vlc_strerror_c(errno) );
|
2010-02-18 18:56:15 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2022-06-14 18:52:02 +02:00
|
|
|
libvlc_media_t *m = libvlc_media_new_location(mrl);
|
2010-02-18 18:56:15 +01:00
|
|
|
free( mrl );
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
2020-03-04 12:03:12 +01:00
|
|
|
// Create a media for an already open file descriptor
|
2022-06-14 18:54:10 +02:00
|
|
|
libvlc_media_t *libvlc_media_new_fd(int fd)
|
2010-11-06 17:40:26 +01:00
|
|
|
{
|
|
|
|
char mrl[16];
|
|
|
|
snprintf( mrl, sizeof(mrl), "fd://%d", fd );
|
|
|
|
|
2022-06-14 18:52:02 +02:00
|
|
|
return libvlc_media_new_location(mrl);
|
2010-11-06 17:40:26 +01:00
|
|
|
}
|
|
|
|
|
2020-03-04 12:03:12 +01:00
|
|
|
// Create a media with custom callbacks to read the data from
|
2022-06-14 18:55:11 +02:00
|
|
|
libvlc_media_t *libvlc_media_new_callbacks(libvlc_media_open_cb open_cb,
|
2015-03-30 21:39:47 +02:00
|
|
|
libvlc_media_read_cb read_cb,
|
|
|
|
libvlc_media_seek_cb seek_cb,
|
|
|
|
libvlc_media_close_cb close_cb,
|
|
|
|
void *opaque)
|
|
|
|
{
|
2022-06-14 18:52:02 +02:00
|
|
|
libvlc_media_t *m = libvlc_media_new_location("imem://");
|
2015-03-30 21:39:47 +02:00
|
|
|
if (unlikely(m == NULL))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
assert(read_cb != NULL);
|
|
|
|
input_item_AddOpaque(m->p_input_item, "imem-data", opaque);
|
|
|
|
input_item_AddOpaque(m->p_input_item, "imem-open", open_cb);
|
|
|
|
input_item_AddOpaque(m->p_input_item, "imem-read", read_cb);
|
|
|
|
input_item_AddOpaque(m->p_input_item, "imem-seek", seek_cb);
|
|
|
|
input_item_AddOpaque(m->p_input_item, "imem-close", close_cb);
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
2020-03-04 12:03:12 +01:00
|
|
|
// Create a media as an empty node with a given name
|
2022-06-14 18:55:37 +02:00
|
|
|
libvlc_media_t * libvlc_media_new_as_node(const char *psz_name)
|
2007-12-20 00:10:31 +01:00
|
|
|
{
|
|
|
|
input_item_t * p_input_item;
|
2008-03-30 03:59:32 +02:00
|
|
|
libvlc_media_t * p_md;
|
2015-01-19 11:22:48 +01:00
|
|
|
libvlc_media_list_t * p_subitems;
|
2007-12-20 00:10:31 +01:00
|
|
|
|
2018-07-26 07:22:58 +02:00
|
|
|
p_input_item = input_item_New( INPUT_ITEM_URI_NOP, psz_name );
|
2007-12-20 00:10:31 +01:00
|
|
|
|
|
|
|
if (!p_input_item)
|
|
|
|
{
|
2009-09-07 21:13:49 +02:00
|
|
|
libvlc_printerr( "Not enough memory" );
|
2007-12-20 00:10:31 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2022-06-14 18:42:01 +02:00
|
|
|
p_md = libvlc_media_new_from_input_item( p_input_item );
|
2016-06-10 13:47:28 +02:00
|
|
|
input_item_Release( p_input_item );
|
2007-12-20 00:10:31 +01:00
|
|
|
|
2015-02-04 09:55:53 +01:00
|
|
|
p_subitems = media_get_subitems( p_md, true );
|
2015-01-19 11:22:48 +01:00
|
|
|
if( p_subitems == NULL) {
|
|
|
|
libvlc_media_release( p_md );
|
|
|
|
return NULL;
|
|
|
|
}
|
2007-12-20 00:10:31 +01:00
|
|
|
|
|
|
|
return p_md;
|
|
|
|
}
|
|
|
|
|
2020-03-04 12:03:12 +01:00
|
|
|
// Add an option to the media descriptor
|
2010-02-04 17:07:15 +01:00
|
|
|
void libvlc_media_add_option( libvlc_media_t * p_md,
|
|
|
|
const char * psz_option )
|
2007-12-14 15:33:06 +01:00
|
|
|
{
|
2010-02-04 17:07:15 +01:00
|
|
|
libvlc_media_add_option_flag( p_md, psz_option,
|
2009-01-17 17:37:23 +01:00
|
|
|
VLC_INPUT_OPTION_UNIQUE|VLC_INPUT_OPTION_TRUSTED );
|
2007-12-14 15:33:06 +01:00
|
|
|
}
|
|
|
|
|
2020-03-04 12:03:12 +01:00
|
|
|
// Same as libvlc_media_add_option but with configurable flags
|
2010-02-04 17:07:15 +01:00
|
|
|
void libvlc_media_add_option_flag( libvlc_media_t * p_md,
|
2009-01-28 20:20:21 +01:00
|
|
|
const char * ppsz_option,
|
2010-02-04 17:07:15 +01:00
|
|
|
unsigned i_flags )
|
2009-01-28 20:20:21 +01:00
|
|
|
{
|
2010-02-04 17:07:15 +01:00
|
|
|
input_item_AddOption( p_md->p_input_item, ppsz_option, i_flags );
|
2009-01-28 20:20:21 +01:00
|
|
|
}
|
|
|
|
|
2020-03-04 12:03:12 +01:00
|
|
|
// Delete a media descriptor object
|
2008-03-30 03:59:32 +02:00
|
|
|
void libvlc_media_release( libvlc_media_t *p_md )
|
2007-06-17 18:24:49 +02:00
|
|
|
{
|
2021-10-05 18:05:47 +02:00
|
|
|
unsigned int ref;
|
|
|
|
|
2007-06-17 22:54:32 +02:00
|
|
|
if (!p_md)
|
2007-06-17 18:24:49 +02:00
|
|
|
return;
|
|
|
|
|
2020-11-21 13:03:49 +01:00
|
|
|
if( !vlc_atomic_rc_dec(&p_md->rc) )
|
2007-08-08 23:12:02 +02:00
|
|
|
return;
|
2007-08-15 20:27:49 +02:00
|
|
|
|
2015-11-05 12:35:21 +01:00
|
|
|
uninstall_input_item_observer( p_md );
|
|
|
|
|
lib: media: wait preparse end before release
This is a quick fix for #25296 actually reverting the commit
a708c988091d6bc770212f5deeaba45e2395f4b2, replacing the Hold/Release
lifecycle used there by an ad-hoc Hold/Release which actually defer the
actual release by blocking instead of releasing in the preparser thread.
Indeed, libvlc_media is holding the instance used to create it, though
it only needs it for preparsing. If the last reference of the media is
hold by the preparser, libvlc_media will be released by the preparser
thread and the libvlc_instance potentially released from there too.
Since killing the libvlc_instance will join the preparser thread, it
cannot be done from the preparser thread, or would lead to the failure
detailed in #25296. Written differently, only the final client should
make use of Hold/Release, directly through the adequate function or
indirectly through the creation of new objects.
In addition, a708c988091d6bc770212f5deeaba45e2395f4b2 cannot just be
reverted as it was fixing cases where the libvlc_media_t object were
released before preparsing is finished, and the libvlc application
cannot just wait for the preparsing event to arrive since it must still
typically unlock the event manager and manage subitems.
Ideally, the libvlc_media would just not have a strong reference to the
libvlc instance, which would allow detaching the libvlc state from the
libvlccore state, but it cannot be done just yet, since the preparsing
API must be splitted from libvlc_media first.
Fix #25296
2021-02-12 12:28:27 +01:00
|
|
|
/* Wait for all async tasks to stop. */
|
2021-10-05 18:05:47 +02:00
|
|
|
while ((ref = atomic_load_explicit(&p_md->worker_count,
|
|
|
|
memory_order_acquire)) > 0)
|
|
|
|
vlc_atomic_wait(&p_md->worker_count, ref);
|
lib: media: wait preparse end before release
This is a quick fix for #25296 actually reverting the commit
a708c988091d6bc770212f5deeaba45e2395f4b2, replacing the Hold/Release
lifecycle used there by an ad-hoc Hold/Release which actually defer the
actual release by blocking instead of releasing in the preparser thread.
Indeed, libvlc_media is holding the instance used to create it, though
it only needs it for preparsing. If the last reference of the media is
hold by the preparser, libvlc_media will be released by the preparser
thread and the libvlc_instance potentially released from there too.
Since killing the libvlc_instance will join the preparser thread, it
cannot be done from the preparser thread, or would lead to the failure
detailed in #25296. Written differently, only the final client should
make use of Hold/Release, directly through the adequate function or
indirectly through the creation of new objects.
In addition, a708c988091d6bc770212f5deeaba45e2395f4b2 cannot just be
reverted as it was fixing cases where the libvlc_media_t object were
released before preparsing is finished, and the libvlc application
cannot just wait for the preparsing event to arrive since it must still
typically unlock the event manager and manage subitems.
Ideally, the libvlc_media would just not have a strong reference to the
libvlc instance, which would allow detaching the libvlc state from the
libvlccore state, but it cannot be done just yet, since the preparsing
API must be splitted from libvlc_media first.
Fix #25296
2021-02-12 12:28:27 +01:00
|
|
|
|
2007-08-24 23:54:27 +02:00
|
|
|
if( p_md->p_subitems )
|
|
|
|
libvlc_media_list_release( p_md->p_subitems );
|
2007-08-21 21:43:04 +02:00
|
|
|
|
2017-04-09 16:26:19 +02:00
|
|
|
input_item_Release( p_md->p_input_item );
|
2007-08-15 20:27:49 +02:00
|
|
|
|
2017-05-15 19:16:45 +02:00
|
|
|
libvlc_event_manager_destroy( &p_md->event_manager );
|
2007-06-17 22:54:32 +02:00
|
|
|
free( p_md );
|
|
|
|
}
|
|
|
|
|
2020-03-04 12:03:12 +01:00
|
|
|
// Retain a media descriptor object
|
2008-03-30 03:59:32 +02:00
|
|
|
void libvlc_media_retain( libvlc_media_t *p_md )
|
2007-08-08 23:12:02 +02:00
|
|
|
{
|
2009-10-05 20:58:34 +02:00
|
|
|
assert (p_md);
|
2020-11-21 13:03:49 +01:00
|
|
|
vlc_atomic_rc_inc( &p_md->rc );
|
2007-08-08 23:12:02 +02:00
|
|
|
}
|
|
|
|
|
2020-03-04 12:03:12 +01:00
|
|
|
// Duplicate a media descriptor object
|
2008-03-30 03:59:32 +02:00
|
|
|
libvlc_media_t *
|
|
|
|
libvlc_media_duplicate( libvlc_media_t *p_md_orig )
|
2007-06-17 22:54:32 +02:00
|
|
|
{
|
2020-10-02 16:14:57 +02:00
|
|
|
|
|
|
|
input_item_t *dup = input_item_Copy( p_md_orig->p_input_item );
|
|
|
|
if( dup == NULL )
|
|
|
|
return NULL;
|
2022-06-14 18:42:01 +02:00
|
|
|
return libvlc_media_new_from_input_item( dup );
|
2007-06-17 18:24:49 +02:00
|
|
|
}
|
|
|
|
|
2020-03-04 12:03:12 +01:00
|
|
|
// Get mrl from a media descriptor object
|
2007-08-09 18:08:14 +02:00
|
|
|
char *
|
2009-10-05 20:41:21 +02:00
|
|
|
libvlc_media_get_mrl( libvlc_media_t * p_md )
|
2007-08-09 18:08:14 +02:00
|
|
|
{
|
2009-10-05 20:41:21 +02:00
|
|
|
assert( p_md );
|
2007-08-22 22:19:23 +02:00
|
|
|
return input_item_GetURI( p_md->p_input_item );
|
2007-08-09 18:08:14 +02:00
|
|
|
}
|
|
|
|
|
2020-03-04 12:03:12 +01:00
|
|
|
// Getter for meta information
|
2009-10-05 20:41:21 +02:00
|
|
|
char *libvlc_media_get_meta( libvlc_media_t *p_md, libvlc_meta_t e_meta )
|
2007-06-17 18:24:49 +02:00
|
|
|
{
|
2014-12-17 14:26:50 +01:00
|
|
|
char *psz_meta = NULL;
|
2007-08-15 19:53:27 +02:00
|
|
|
|
2014-12-17 14:26:50 +01:00
|
|
|
if( e_meta == libvlc_meta_NowPlaying )
|
|
|
|
{
|
|
|
|
psz_meta = input_item_GetNowPlayingFb( p_md->p_input_item );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
psz_meta = input_item_GetMeta( p_md->p_input_item,
|
|
|
|
libvlc_to_vlc_meta[e_meta] );
|
|
|
|
/* Should be integrated in core */
|
|
|
|
if( psz_meta == NULL && e_meta == libvlc_meta_Title
|
|
|
|
&& p_md->p_input_item->psz_name != NULL )
|
|
|
|
psz_meta = strdup( p_md->p_input_item->psz_name );
|
|
|
|
}
|
2007-08-18 05:22:03 +02:00
|
|
|
return psz_meta;
|
2007-06-17 18:24:49 +02:00
|
|
|
}
|
2007-07-09 22:52:11 +02:00
|
|
|
|
2020-03-04 12:03:12 +01:00
|
|
|
// Set the meta of the media
|
2009-12-08 10:04:53 +01:00
|
|
|
void libvlc_media_set_meta( libvlc_media_t *p_md, libvlc_meta_t e_meta, const char *psz_value )
|
|
|
|
{
|
|
|
|
assert( p_md );
|
|
|
|
input_item_SetMeta( p_md->p_input_item, libvlc_to_vlc_meta[e_meta], psz_value );
|
|
|
|
}
|
|
|
|
|
2020-03-04 12:03:12 +01:00
|
|
|
// Save the meta previously set
|
2022-06-14 17:46:03 +02:00
|
|
|
int libvlc_media_save_meta( libvlc_instance_t *inst, libvlc_media_t *p_md )
|
2009-12-08 10:04:53 +01:00
|
|
|
{
|
|
|
|
assert( p_md );
|
2022-06-14 17:46:03 +02:00
|
|
|
vlc_object_t *p_obj = VLC_OBJECT(inst->p_libvlc_int);
|
2009-12-08 10:04:53 +01:00
|
|
|
return input_item_WriteMeta( p_obj, p_md->p_input_item ) == VLC_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2020-03-04 12:03:12 +01:00
|
|
|
// Get subitems of media descriptor object.
|
2007-08-24 23:54:27 +02:00
|
|
|
libvlc_media_list_t *
|
2009-10-05 20:41:21 +02:00
|
|
|
libvlc_media_subitems( libvlc_media_t * p_md )
|
2007-08-24 23:54:27 +02:00
|
|
|
{
|
2015-02-04 09:55:53 +01:00
|
|
|
libvlc_media_list_t *p_subitems = media_get_subitems( p_md, true );
|
2015-01-19 11:22:48 +01:00
|
|
|
if( p_subitems )
|
|
|
|
libvlc_media_list_retain( p_subitems );
|
|
|
|
return p_subitems;
|
2007-08-24 23:54:27 +02:00
|
|
|
}
|
2007-08-25 18:28:13 +02:00
|
|
|
|
2020-03-04 12:03:12 +01:00
|
|
|
// Getter for statistics information
|
2019-05-19 09:44:21 +02:00
|
|
|
bool libvlc_media_get_stats(libvlc_media_t *p_md,
|
|
|
|
libvlc_media_stats_t *p_stats)
|
2009-11-20 12:17:13 +01:00
|
|
|
{
|
2017-12-11 20:09:25 +01:00
|
|
|
input_item_t *item = p_md->p_input_item;
|
|
|
|
|
2009-11-20 12:17:13 +01:00
|
|
|
if( !p_md->p_input_item )
|
|
|
|
return false;
|
|
|
|
|
2017-12-11 20:09:25 +01:00
|
|
|
vlc_mutex_lock( &item->lock );
|
|
|
|
|
2009-11-20 12:17:13 +01:00
|
|
|
input_stats_t *p_itm_stats = p_md->p_input_item->p_stats;
|
2017-12-11 20:09:25 +01:00
|
|
|
if( p_itm_stats == NULL )
|
|
|
|
{
|
|
|
|
vlc_mutex_unlock( &item->lock );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-11-20 12:17:13 +01:00
|
|
|
p_stats->i_read_bytes = p_itm_stats->i_read_bytes;
|
|
|
|
p_stats->f_input_bitrate = p_itm_stats->f_input_bitrate;
|
|
|
|
|
|
|
|
p_stats->i_demux_read_bytes = p_itm_stats->i_demux_read_bytes;
|
|
|
|
p_stats->f_demux_bitrate = p_itm_stats->f_demux_bitrate;
|
|
|
|
p_stats->i_demux_corrupted = p_itm_stats->i_demux_corrupted;
|
|
|
|
p_stats->i_demux_discontinuity = p_itm_stats->i_demux_discontinuity;
|
|
|
|
|
|
|
|
p_stats->i_decoded_video = p_itm_stats->i_decoded_video;
|
|
|
|
p_stats->i_decoded_audio = p_itm_stats->i_decoded_audio;
|
|
|
|
|
|
|
|
p_stats->i_displayed_pictures = p_itm_stats->i_displayed_pictures;
|
2020-08-10 07:40:35 +02:00
|
|
|
p_stats->i_late_pictures = p_itm_stats->i_late_pictures;
|
2009-11-20 12:17:13 +01:00
|
|
|
p_stats->i_lost_pictures = p_itm_stats->i_lost_pictures;
|
|
|
|
|
|
|
|
p_stats->i_played_abuffers = p_itm_stats->i_played_abuffers;
|
|
|
|
p_stats->i_lost_abuffers = p_itm_stats->i_lost_abuffers;
|
|
|
|
|
2017-12-11 20:09:25 +01:00
|
|
|
vlc_mutex_unlock( &item->lock );
|
2009-11-20 12:17:13 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-03-04 12:03:12 +01:00
|
|
|
// Get event manager from a media descriptor object
|
2007-08-25 18:28:13 +02:00
|
|
|
libvlc_event_manager_t *
|
2009-10-05 20:41:21 +02:00
|
|
|
libvlc_media_event_manager( libvlc_media_t * p_md )
|
2007-08-25 18:28:13 +02:00
|
|
|
{
|
2009-10-05 20:41:21 +02:00
|
|
|
assert( p_md );
|
2008-01-28 17:23:17 +01:00
|
|
|
|
2017-05-15 19:16:45 +02:00
|
|
|
return &p_md->event_manager;
|
2007-08-25 18:28:13 +02:00
|
|
|
}
|
2007-10-20 19:56:00 +02:00
|
|
|
|
2020-03-04 12:03:12 +01:00
|
|
|
// Get duration of media object (in ms)
|
2022-08-11 14:43:02 +02:00
|
|
|
libvlc_time_t
|
2010-02-02 22:44:43 +01:00
|
|
|
libvlc_media_get_duration( libvlc_media_t * p_md )
|
2007-10-20 19:56:00 +02:00
|
|
|
{
|
2009-10-05 20:41:21 +02:00
|
|
|
assert( p_md );
|
2008-01-28 17:23:17 +01:00
|
|
|
|
2009-10-05 20:41:21 +02:00
|
|
|
if( !p_md->p_input_item )
|
2007-10-20 19:56:00 +02:00
|
|
|
{
|
2009-09-07 21:13:49 +02:00
|
|
|
libvlc_printerr( "No input item" );
|
2007-10-20 19:56:00 +02:00
|
|
|
return -1;
|
|
|
|
}
|
2008-08-03 19:40:30 +02:00
|
|
|
|
2010-01-16 15:41:43 +01:00
|
|
|
if (!input_item_IsPreparsed( p_md->p_input_item ))
|
|
|
|
return -1;
|
|
|
|
|
2022-08-12 06:17:42 +02:00
|
|
|
return libvlc_time_from_vlc_tick(input_item_GetDuration( p_md->p_input_item ));
|
2007-10-20 19:56:00 +02:00
|
|
|
}
|
|
|
|
|
2021-07-22 13:58:20 +02:00
|
|
|
int
|
2022-01-14 13:34:58 +01:00
|
|
|
libvlc_media_get_filestat( libvlc_media_t *p_md, unsigned type, uint64_t *out )
|
2021-07-22 13:58:20 +02:00
|
|
|
{
|
|
|
|
assert( p_md );
|
|
|
|
assert( out );
|
|
|
|
|
|
|
|
if( !p_md->p_input_item )
|
|
|
|
{
|
|
|
|
libvlc_printerr( "No input item" );
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *name;
|
|
|
|
switch (type)
|
|
|
|
{
|
2022-01-14 13:34:58 +01:00
|
|
|
case libvlc_media_filestat_mtime: name = "mtime"; break;
|
|
|
|
case libvlc_media_filestat_size: name = "size"; break;
|
2021-07-22 13:58:20 +02:00
|
|
|
default:
|
|
|
|
libvlc_printerr( "unknown libvlc_media_stat" );
|
|
|
|
return -1;
|
|
|
|
};
|
|
|
|
|
|
|
|
char *str = input_item_GetInfo( p_md->p_input_item, ".stat", name );
|
|
|
|
if( str == NULL )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
char *end;
|
|
|
|
unsigned long long val = strtoull( str, &end, 10 );
|
|
|
|
|
|
|
|
if( *end != '\0' )
|
2021-12-13 10:01:56 +01:00
|
|
|
{
|
|
|
|
free( str );
|
2021-07-22 13:58:20 +02:00
|
|
|
return -1;
|
2021-12-13 10:01:56 +01:00
|
|
|
}
|
|
|
|
free( str );
|
2021-07-22 13:58:20 +02:00
|
|
|
|
|
|
|
*out = val;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2018-08-16 09:51:10 +02:00
|
|
|
static const input_preparser_callbacks_t input_preparser_callbacks = {
|
|
|
|
.on_preparse_ended = input_item_preparse_ended,
|
|
|
|
.on_subtree_added = input_item_subtree_added,
|
|
|
|
};
|
|
|
|
|
2022-06-14 18:23:09 +02:00
|
|
|
int libvlc_media_parse_request(libvlc_instance_t *inst, libvlc_media_t *media,
|
|
|
|
libvlc_media_parse_flag_t parse_flag,
|
|
|
|
int timeout)
|
2011-07-10 18:31:09 +02:00
|
|
|
{
|
2022-06-15 18:36:10 +02:00
|
|
|
libvlc_media_parsed_status_t expected = libvlc_media_parsed_status_none;
|
2015-01-20 10:46:32 +01:00
|
|
|
|
2022-06-15 18:36:10 +02:00
|
|
|
while (!atomic_compare_exchange_weak(&media->parsed_status, &expected,
|
|
|
|
libvlc_media_parsed_status_pending))
|
|
|
|
if (expected == libvlc_media_parsed_status_pending
|
|
|
|
|| expected == libvlc_media_parsed_status_done)
|
|
|
|
return -1;
|
2022-06-15 18:03:39 +02:00
|
|
|
|
|
|
|
libvlc_int_t *libvlc = inst->p_libvlc_int;
|
|
|
|
input_item_t *item = media->p_input_item;
|
|
|
|
input_item_meta_request_option_t parse_scope = META_REQUEST_OPTION_SCOPE_LOCAL;
|
|
|
|
int ret;
|
|
|
|
unsigned int ref = atomic_load_explicit(&media->worker_count,
|
|
|
|
memory_order_relaxed);
|
|
|
|
do
|
2015-01-20 10:46:32 +01:00
|
|
|
{
|
2022-06-15 18:03:39 +02:00
|
|
|
if (unlikely(ref == UINT_MAX))
|
2022-06-14 17:48:49 +02:00
|
|
|
return -1;
|
2015-01-20 10:46:32 +01:00
|
|
|
}
|
2022-06-15 18:03:39 +02:00
|
|
|
while (!atomic_compare_exchange_weak_explicit(&media->worker_count,
|
|
|
|
&ref, ref + 1,
|
|
|
|
memory_order_relaxed,
|
|
|
|
memory_order_relaxed));
|
|
|
|
|
|
|
|
if (parse_flag & libvlc_media_parse_network)
|
|
|
|
parse_scope |= META_REQUEST_OPTION_SCOPE_NETWORK;
|
|
|
|
if (parse_flag & libvlc_media_fetch_local)
|
|
|
|
parse_scope |= META_REQUEST_OPTION_FETCH_LOCAL;
|
|
|
|
if (parse_flag & libvlc_media_fetch_network)
|
|
|
|
parse_scope |= META_REQUEST_OPTION_FETCH_NETWORK;
|
|
|
|
if (parse_flag & libvlc_media_do_interact)
|
|
|
|
parse_scope |= META_REQUEST_OPTION_DO_INTERACT;
|
2022-12-05 14:31:32 +01:00
|
|
|
if (parse_flag & libvlc_media_no_skip)
|
|
|
|
parse_scope |= META_REQUEST_OPTION_NO_SKIP;
|
2022-06-15 18:03:39 +02:00
|
|
|
|
|
|
|
ret = libvlc_MetadataRequest(libvlc, item, parse_scope,
|
|
|
|
&input_preparser_callbacks, media,
|
|
|
|
timeout, media);
|
|
|
|
if (ret != VLC_SUCCESS)
|
|
|
|
{
|
|
|
|
atomic_fetch_sub_explicit(&media->worker_count, 1,
|
|
|
|
memory_order_relaxed);
|
2022-06-14 17:48:49 +02:00
|
|
|
return -1;
|
2022-06-15 18:03:39 +02:00
|
|
|
}
|
2022-06-14 17:48:49 +02:00
|
|
|
return 0;
|
2010-02-22 17:23:14 +01:00
|
|
|
}
|
|
|
|
|
2020-03-04 12:03:12 +01:00
|
|
|
// Stop parsing of the media
|
2016-10-12 14:05:02 +02:00
|
|
|
void
|
2022-06-14 18:11:13 +02:00
|
|
|
libvlc_media_parse_stop(libvlc_instance_t *inst, libvlc_media_t *media)
|
2016-10-12 14:05:02 +02:00
|
|
|
{
|
2022-06-14 18:11:13 +02:00
|
|
|
libvlc_MetadataCancel(inst->p_libvlc_int, media);
|
2016-10-12 14:05:02 +02:00
|
|
|
}
|
|
|
|
|
2020-03-04 12:03:12 +01:00
|
|
|
// Get Parsed status for media descriptor object
|
2016-04-14 17:04:39 +02:00
|
|
|
libvlc_media_parsed_status_t
|
|
|
|
libvlc_media_get_parsed_status(libvlc_media_t *media)
|
|
|
|
{
|
2022-06-15 18:36:10 +02:00
|
|
|
return atomic_load(&media->parsed_status);
|
2016-04-14 17:04:39 +02:00
|
|
|
}
|
|
|
|
|
2020-03-04 12:03:12 +01:00
|
|
|
// Sets media descriptor's user_data
|
2010-02-22 12:01:32 +01:00
|
|
|
void
|
2009-10-05 20:41:21 +02:00
|
|
|
libvlc_media_set_user_data( libvlc_media_t * p_md, void * p_new_user_data )
|
2007-10-20 19:56:00 +02:00
|
|
|
{
|
2009-10-05 20:41:21 +02:00
|
|
|
assert( p_md );
|
|
|
|
p_md->p_user_data = p_new_user_data;
|
2007-10-20 19:56:00 +02:00
|
|
|
}
|
|
|
|
|
2020-03-04 12:03:12 +01:00
|
|
|
// Get media descriptor's user_data
|
2007-10-20 19:56:00 +02:00
|
|
|
void *
|
2009-10-05 20:41:21 +02:00
|
|
|
libvlc_media_get_user_data( libvlc_media_t * p_md )
|
2007-10-20 19:56:00 +02:00
|
|
|
{
|
2009-10-05 20:41:21 +02:00
|
|
|
assert( p_md );
|
|
|
|
return p_md->p_user_data;
|
2007-10-22 18:57:33 +02:00
|
|
|
}
|
2010-01-22 14:52:20 +01:00
|
|
|
|
2020-06-02 19:06:18 +02:00
|
|
|
libvlc_media_tracklist_t *
|
|
|
|
libvlc_media_get_tracklist( libvlc_media_t *p_md, libvlc_track_type_t type )
|
|
|
|
{
|
|
|
|
assert( p_md );
|
|
|
|
|
|
|
|
input_item_t *p_input_item = p_md->p_input_item;
|
|
|
|
|
|
|
|
vlc_mutex_lock( &p_input_item->lock );
|
|
|
|
libvlc_media_tracklist_t *list =
|
|
|
|
libvlc_media_tracklist_from_es_array( p_input_item->es,
|
|
|
|
p_input_item->i_es, type );
|
|
|
|
vlc_mutex_unlock( &p_input_item->lock );
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2020-03-04 12:03:12 +01:00
|
|
|
// Get codec description from media elementary stream
|
2015-01-12 10:39:14 +01:00
|
|
|
const char *
|
|
|
|
libvlc_media_get_codec_description( libvlc_track_type_t i_type,
|
|
|
|
uint32_t i_codec )
|
|
|
|
{
|
2020-01-29 13:24:57 +01:00
|
|
|
return vlc_fourcc_GetDescription( libvlc_track_type_to_escat( i_type),
|
|
|
|
i_codec );
|
2015-01-12 10:39:14 +01:00
|
|
|
}
|
2013-02-12 21:45:25 +01:00
|
|
|
|
2020-03-04 12:03:12 +01:00
|
|
|
// Get the media type of the media descriptor object
|
2015-03-24 17:22:20 +01:00
|
|
|
libvlc_media_type_t libvlc_media_get_type( libvlc_media_t *p_md )
|
|
|
|
{
|
|
|
|
assert( p_md );
|
|
|
|
|
2018-07-26 08:33:14 +02:00
|
|
|
enum input_item_type_e i_type;
|
2015-03-24 17:22:20 +01:00
|
|
|
input_item_t *p_input_item = p_md->p_input_item;
|
|
|
|
|
|
|
|
vlc_mutex_lock( &p_input_item->lock );
|
|
|
|
i_type = p_md->p_input_item->i_type;
|
|
|
|
vlc_mutex_unlock( &p_input_item->lock );
|
|
|
|
|
|
|
|
switch( i_type )
|
|
|
|
{
|
|
|
|
case ITEM_TYPE_FILE:
|
|
|
|
return libvlc_media_type_file;
|
|
|
|
case ITEM_TYPE_NODE:
|
|
|
|
case ITEM_TYPE_DIRECTORY:
|
|
|
|
return libvlc_media_type_directory;
|
|
|
|
case ITEM_TYPE_DISC:
|
|
|
|
return libvlc_media_type_disc;
|
|
|
|
case ITEM_TYPE_STREAM:
|
|
|
|
return libvlc_media_type_stream;
|
|
|
|
case ITEM_TYPE_PLAYLIST:
|
|
|
|
return libvlc_media_type_playlist;
|
|
|
|
default:
|
|
|
|
return libvlc_media_type_unknown;
|
|
|
|
}
|
|
|
|
}
|
2016-05-17 17:33:32 +02:00
|
|
|
|
2018-10-05 13:23:00 +02:00
|
|
|
struct libvlc_media_thumbnail_request_t
|
|
|
|
{
|
2022-06-14 18:33:19 +02:00
|
|
|
libvlc_instance_t *instance;
|
2018-10-05 13:23:00 +02:00
|
|
|
libvlc_media_t *md;
|
|
|
|
unsigned int width;
|
|
|
|
unsigned int height;
|
2019-06-20 09:44:47 +02:00
|
|
|
bool crop;
|
2018-10-05 13:23:00 +02:00
|
|
|
libvlc_picture_type_t type;
|
|
|
|
vlc_thumbnailer_request_t* req;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void media_on_thumbnail_ready( void* data, picture_t* thumbnail )
|
|
|
|
{
|
|
|
|
libvlc_media_thumbnail_request_t *req = data;
|
|
|
|
libvlc_media_t *p_media = req->md;
|
|
|
|
libvlc_event_t event;
|
|
|
|
event.type = libvlc_MediaThumbnailGenerated;
|
|
|
|
libvlc_picture_t* pic = NULL;
|
|
|
|
if ( thumbnail != NULL )
|
2022-06-14 18:33:19 +02:00
|
|
|
pic = libvlc_picture_new( VLC_OBJECT(req->instance->p_libvlc_int),
|
2019-06-20 09:44:47 +02:00
|
|
|
thumbnail, req->type, req->width, req->height,
|
|
|
|
req->crop );
|
2018-10-05 13:23:00 +02:00
|
|
|
event.u.media_thumbnail_generated.p_thumbnail = pic;
|
|
|
|
libvlc_event_send( &p_media->event_manager, &event );
|
|
|
|
if ( pic != NULL )
|
|
|
|
libvlc_picture_release( pic );
|
|
|
|
}
|
|
|
|
|
2020-03-04 12:03:12 +01:00
|
|
|
// Start an asynchronous thumbnail generation
|
2018-10-05 13:23:00 +02:00
|
|
|
libvlc_media_thumbnail_request_t*
|
2022-06-14 18:37:19 +02:00
|
|
|
libvlc_media_thumbnail_request_by_time( libvlc_instance_t *inst,
|
|
|
|
libvlc_media_t *md, libvlc_time_t time,
|
2018-11-12 17:51:15 +01:00
|
|
|
libvlc_thumbnailer_seek_speed_t speed,
|
2018-10-05 13:23:00 +02:00
|
|
|
unsigned int width, unsigned int height,
|
2019-06-20 09:44:47 +02:00
|
|
|
bool crop, libvlc_picture_type_t picture_type,
|
2018-10-05 13:23:00 +02:00
|
|
|
libvlc_time_t timeout )
|
|
|
|
{
|
|
|
|
assert( md );
|
2022-06-14 18:33:19 +02:00
|
|
|
|
|
|
|
libvlc_priv_t *p_priv = libvlc_priv(inst->p_libvlc_int);
|
2018-10-05 13:23:00 +02:00
|
|
|
if( unlikely( p_priv->p_thumbnailer == NULL ) )
|
|
|
|
return NULL;
|
2022-06-14 18:33:19 +02:00
|
|
|
|
2018-10-05 13:23:00 +02:00
|
|
|
libvlc_media_thumbnail_request_t *req = malloc( sizeof( *req ) );
|
|
|
|
if ( unlikely( req == NULL ) )
|
|
|
|
return NULL;
|
|
|
|
|
2022-06-14 18:33:19 +02:00
|
|
|
req->instance = inst;
|
2018-10-05 13:23:00 +02:00
|
|
|
req->md = md;
|
|
|
|
req->width = width;
|
|
|
|
req->height = height;
|
|
|
|
req->type = picture_type;
|
2019-06-20 09:44:47 +02:00
|
|
|
req->crop = crop;
|
2018-10-05 13:23:00 +02:00
|
|
|
libvlc_media_retain( md );
|
|
|
|
req->req = vlc_thumbnailer_RequestByTime( p_priv->p_thumbnailer,
|
2022-08-12 06:17:42 +02:00
|
|
|
vlc_tick_from_libvlc_time( time ),
|
2018-10-05 13:23:00 +02:00
|
|
|
speed == libvlc_media_thumbnail_seek_fast ?
|
|
|
|
VLC_THUMBNAILER_SEEK_FAST : VLC_THUMBNAILER_SEEK_PRECISE,
|
|
|
|
md->p_input_item,
|
2022-08-12 06:17:42 +02:00
|
|
|
timeout > 0 ? vlc_tick_from_libvlc_time( timeout ) : VLC_TICK_INVALID,
|
2018-10-05 13:23:00 +02:00
|
|
|
media_on_thumbnail_ready, req );
|
|
|
|
if ( req->req == NULL )
|
|
|
|
{
|
|
|
|
free( req );
|
|
|
|
libvlc_media_release( md );
|
|
|
|
return NULL;
|
|
|
|
}
|
2022-06-14 18:33:19 +02:00
|
|
|
libvlc_retain(inst);
|
2018-10-05 13:23:00 +02:00
|
|
|
return req;
|
|
|
|
}
|
|
|
|
|
2020-03-04 12:03:12 +01:00
|
|
|
// Start an asynchronous thumbnail generation
|
2018-10-05 13:23:00 +02:00
|
|
|
libvlc_media_thumbnail_request_t*
|
2022-06-14 18:37:19 +02:00
|
|
|
libvlc_media_thumbnail_request_by_pos( libvlc_instance_t *inst,
|
2022-08-03 13:55:40 +02:00
|
|
|
libvlc_media_t *md, double pos,
|
2018-11-12 17:51:15 +01:00
|
|
|
libvlc_thumbnailer_seek_speed_t speed,
|
2018-10-05 13:23:00 +02:00
|
|
|
unsigned int width, unsigned int height,
|
2019-06-20 09:44:47 +02:00
|
|
|
bool crop, libvlc_picture_type_t picture_type,
|
2018-10-05 13:23:00 +02:00
|
|
|
libvlc_time_t timeout )
|
|
|
|
{
|
|
|
|
assert( md );
|
2022-06-14 18:33:19 +02:00
|
|
|
|
|
|
|
libvlc_priv_t *priv = libvlc_priv(inst->p_libvlc_int);
|
2018-10-05 13:23:00 +02:00
|
|
|
if( unlikely( priv->p_thumbnailer == NULL ) )
|
|
|
|
return NULL;
|
2022-06-14 18:33:19 +02:00
|
|
|
|
2018-10-05 13:23:00 +02:00
|
|
|
libvlc_media_thumbnail_request_t *req = malloc( sizeof( *req ) );
|
|
|
|
if ( unlikely( req == NULL ) )
|
|
|
|
return NULL;
|
|
|
|
|
2022-06-14 18:33:19 +02:00
|
|
|
req->instance = inst;
|
2018-10-05 13:23:00 +02:00
|
|
|
req->md = md;
|
|
|
|
req->width = width;
|
|
|
|
req->height = height;
|
2019-06-20 09:44:47 +02:00
|
|
|
req->crop = crop;
|
2018-10-05 13:23:00 +02:00
|
|
|
req->type = picture_type;
|
|
|
|
libvlc_media_retain( md );
|
|
|
|
req->req = vlc_thumbnailer_RequestByPos( priv->p_thumbnailer, pos,
|
|
|
|
speed == libvlc_media_thumbnail_seek_fast ?
|
|
|
|
VLC_THUMBNAILER_SEEK_FAST : VLC_THUMBNAILER_SEEK_PRECISE,
|
|
|
|
md->p_input_item,
|
2022-08-12 06:17:42 +02:00
|
|
|
timeout > 0 ? vlc_tick_from_libvlc_time( timeout ) : VLC_TICK_INVALID,
|
2018-10-05 13:23:00 +02:00
|
|
|
media_on_thumbnail_ready, req );
|
|
|
|
if ( req->req == NULL )
|
|
|
|
{
|
|
|
|
free( req );
|
|
|
|
libvlc_media_release( md );
|
|
|
|
return NULL;
|
|
|
|
}
|
2022-06-14 18:33:19 +02:00
|
|
|
libvlc_retain(inst);
|
2018-10-05 13:23:00 +02:00
|
|
|
return req;
|
|
|
|
}
|
|
|
|
|
2020-03-04 12:03:12 +01:00
|
|
|
// Cancel a thumbnail request
|
2019-10-24 11:25:58 +02:00
|
|
|
void libvlc_media_thumbnail_request_cancel( libvlc_media_thumbnail_request_t *req )
|
2018-10-05 13:23:00 +02:00
|
|
|
{
|
2022-06-14 18:33:19 +02:00
|
|
|
libvlc_priv_t *p_priv = libvlc_priv(req->instance->p_libvlc_int);
|
2018-10-05 13:23:00 +02:00
|
|
|
assert( p_priv->p_thumbnailer != NULL );
|
|
|
|
vlc_thumbnailer_Cancel( p_priv->p_thumbnailer, req->req );
|
2019-10-24 11:20:21 +02:00
|
|
|
}
|
|
|
|
|
2020-03-04 12:03:12 +01:00
|
|
|
// Destroy a thumbnail request
|
2019-10-24 11:25:58 +02:00
|
|
|
void libvlc_media_thumbnail_request_destroy( libvlc_media_thumbnail_request_t *req )
|
2019-10-24 11:20:21 +02:00
|
|
|
{
|
2018-10-05 13:23:00 +02:00
|
|
|
libvlc_media_release( req->md );
|
2022-06-14 18:33:19 +02:00
|
|
|
libvlc_release(req->instance);
|
2018-10-05 13:23:00 +02:00
|
|
|
free( req );
|
|
|
|
}
|
|
|
|
|
2020-03-04 12:03:12 +01:00
|
|
|
// Add a slave to the media descriptor
|
2016-05-17 17:33:32 +02:00
|
|
|
int libvlc_media_slaves_add( libvlc_media_t *p_md,
|
|
|
|
libvlc_media_slave_type_t i_type,
|
|
|
|
unsigned int i_priority,
|
|
|
|
const char *psz_uri )
|
|
|
|
{
|
|
|
|
assert( p_md && psz_uri );
|
|
|
|
input_item_t *p_input_item = p_md->p_input_item;
|
|
|
|
|
|
|
|
enum slave_type i_input_slave_type;
|
|
|
|
switch( i_type )
|
|
|
|
{
|
|
|
|
case libvlc_media_slave_type_subtitle:
|
|
|
|
i_input_slave_type = SLAVE_TYPE_SPU;
|
|
|
|
break;
|
2021-04-22 15:26:25 +02:00
|
|
|
case libvlc_media_slave_type_generic:
|
2021-04-22 14:25:22 +02:00
|
|
|
i_input_slave_type = SLAVE_TYPE_GENERIC;
|
2016-05-25 15:10:39 +02:00
|
|
|
break;
|
2016-05-17 17:33:32 +02:00
|
|
|
default:
|
|
|
|
vlc_assert_unreachable();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum slave_priority i_input_slave_priority;
|
|
|
|
switch( i_priority )
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
i_input_slave_priority = SLAVE_PRIORITY_MATCH_NONE;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
i_input_slave_priority = SLAVE_PRIORITY_MATCH_RIGHT;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
i_input_slave_priority = SLAVE_PRIORITY_MATCH_LEFT;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
i_input_slave_priority = SLAVE_PRIORITY_MATCH_ALL;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
case 4:
|
|
|
|
i_input_slave_priority = SLAVE_PRIORITY_USER;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
input_item_slave_t *p_slave = input_item_slave_New( psz_uri,
|
|
|
|
i_input_slave_type,
|
|
|
|
i_input_slave_priority );
|
|
|
|
if( p_slave == NULL )
|
|
|
|
return -1;
|
|
|
|
return input_item_AddSlave( p_input_item, p_slave ) == VLC_SUCCESS ? 0 : -1;
|
|
|
|
}
|
|
|
|
|
2020-03-04 12:03:12 +01:00
|
|
|
// Clear all slaves of the media descriptor
|
2016-05-17 17:33:32 +02:00
|
|
|
void libvlc_media_slaves_clear( libvlc_media_t *p_md )
|
|
|
|
{
|
|
|
|
assert( p_md );
|
|
|
|
input_item_t *p_input_item = p_md->p_input_item;
|
|
|
|
|
|
|
|
vlc_mutex_lock( &p_input_item->lock );
|
|
|
|
for( int i = 0; i < p_input_item->i_slaves; i++ )
|
|
|
|
input_item_slave_Delete( p_input_item->pp_slaves[i] );
|
|
|
|
TAB_CLEAN( p_input_item->i_slaves, p_input_item->pp_slaves );
|
|
|
|
vlc_mutex_unlock( &p_input_item->lock );
|
|
|
|
}
|
|
|
|
|
2020-03-04 12:03:12 +01:00
|
|
|
// Get a media descriptor's slave list
|
2016-05-17 17:33:32 +02:00
|
|
|
unsigned int libvlc_media_slaves_get( libvlc_media_t *p_md,
|
|
|
|
libvlc_media_slave_t ***ppp_slaves )
|
|
|
|
{
|
|
|
|
assert( p_md && ppp_slaves );
|
|
|
|
input_item_t *p_input_item = p_md->p_input_item;
|
2017-01-18 11:11:12 +01:00
|
|
|
*ppp_slaves = NULL;
|
2016-05-17 17:33:32 +02:00
|
|
|
|
|
|
|
vlc_mutex_lock( &p_input_item->lock );
|
|
|
|
|
|
|
|
int i_count = p_input_item->i_slaves;
|
|
|
|
if( i_count <= 0 )
|
|
|
|
return vlc_mutex_unlock( &p_input_item->lock ), 0;
|
|
|
|
|
|
|
|
libvlc_media_slave_t **pp_slaves = calloc( i_count, sizeof(*pp_slaves) );
|
|
|
|
if( pp_slaves == NULL )
|
|
|
|
return vlc_mutex_unlock( &p_input_item->lock ), 0;
|
|
|
|
|
|
|
|
for( int i = 0; i < i_count; ++i )
|
|
|
|
{
|
|
|
|
input_item_slave_t *p_item_slave = p_input_item->pp_slaves[i];
|
2016-05-19 18:41:06 +02:00
|
|
|
assert( p_item_slave->i_priority >= SLAVE_PRIORITY_MATCH_NONE );
|
2016-05-17 17:33:32 +02:00
|
|
|
|
2016-05-20 10:33:23 +02:00
|
|
|
/* also allocate psz_uri buffer at the end of the struct */
|
2016-05-17 17:33:32 +02:00
|
|
|
libvlc_media_slave_t *p_slave = malloc( sizeof(*p_slave) +
|
|
|
|
strlen( p_item_slave->psz_uri )
|
|
|
|
+ 1 );
|
|
|
|
if( p_slave == NULL )
|
|
|
|
{
|
|
|
|
libvlc_media_slaves_release(pp_slaves, i);
|
|
|
|
return vlc_mutex_unlock( &p_input_item->lock ), 0;
|
|
|
|
}
|
2016-05-20 10:33:23 +02:00
|
|
|
p_slave->psz_uri = (char *) ((uint8_t *)p_slave) + sizeof(*p_slave);
|
2016-05-17 17:33:32 +02:00
|
|
|
strcpy( p_slave->psz_uri, p_item_slave->psz_uri );
|
|
|
|
|
|
|
|
switch( p_item_slave->i_type )
|
|
|
|
{
|
|
|
|
case SLAVE_TYPE_SPU:
|
|
|
|
p_slave->i_type = libvlc_media_slave_type_subtitle;
|
|
|
|
break;
|
2021-04-22 14:25:22 +02:00
|
|
|
case SLAVE_TYPE_GENERIC:
|
2021-04-22 15:26:25 +02:00
|
|
|
p_slave->i_type = libvlc_media_slave_type_generic;
|
2016-05-17 17:33:32 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
vlc_assert_unreachable();
|
|
|
|
}
|
|
|
|
|
|
|
|
switch( p_item_slave->i_priority )
|
|
|
|
{
|
|
|
|
case SLAVE_PRIORITY_MATCH_NONE:
|
|
|
|
p_slave->i_priority = 0;
|
|
|
|
break;
|
|
|
|
case SLAVE_PRIORITY_MATCH_RIGHT:
|
|
|
|
p_slave->i_priority = 1;
|
|
|
|
break;
|
|
|
|
case SLAVE_PRIORITY_MATCH_LEFT:
|
|
|
|
p_slave->i_priority = 2;
|
|
|
|
break;
|
|
|
|
case SLAVE_PRIORITY_MATCH_ALL:
|
|
|
|
p_slave->i_priority = 3;
|
|
|
|
break;
|
|
|
|
case SLAVE_PRIORITY_USER:
|
|
|
|
p_slave->i_priority = 4;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
vlc_assert_unreachable();
|
|
|
|
}
|
|
|
|
pp_slaves[i] = p_slave;
|
|
|
|
}
|
|
|
|
vlc_mutex_unlock( &p_input_item->lock );
|
|
|
|
|
|
|
|
*ppp_slaves = pp_slaves;
|
|
|
|
return i_count;
|
|
|
|
}
|
|
|
|
|
2020-03-04 12:03:12 +01:00
|
|
|
// Release a media descriptor's slave list
|
2016-05-17 17:33:32 +02:00
|
|
|
void libvlc_media_slaves_release( libvlc_media_slave_t **pp_slaves,
|
|
|
|
unsigned int i_count )
|
|
|
|
{
|
2016-05-31 15:13:42 +02:00
|
|
|
if( i_count > 0 )
|
|
|
|
{
|
|
|
|
assert( pp_slaves );
|
|
|
|
for( unsigned int i = 0; i < i_count; ++i )
|
|
|
|
free( pp_slaves[i] );
|
|
|
|
}
|
2017-01-18 11:11:12 +01:00
|
|
|
free( pp_slaves );
|
2016-05-17 17:33:32 +02:00
|
|
|
}
|