2006-01-08 17:32:33 +01:00
|
|
|
/*****************************************************************************
|
2008-03-30 03:59:32 +02:00
|
|
|
* media_player.c: Libvlc API Media Instance management functions
|
2006-01-08 17:32:33 +01:00
|
|
|
*****************************************************************************
|
2015-01-26 20:37:02 +01:00
|
|
|
* Copyright (C) 2005-2015 VLC authors and VideoLAN
|
2006-01-08 17:32:33 +01:00
|
|
|
*
|
2006-02-01 19:06:48 +01:00
|
|
|
* Authors: Clément Stenac <zorglub@videolan.org>
|
2006-01-08 17:32:33 +01: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
|
2006-01-08 17:32:33 +01: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.
|
2006-01-08 17:32:33 +01: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.
|
2006-01-08 17:32:33 +01:00
|
|
|
*****************************************************************************/
|
|
|
|
|
2009-05-25 15:09:40 +02:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2009-05-25 10:47:38 +02:00
|
|
|
#include <assert.h>
|
2008-01-23 22:50:58 +01:00
|
|
|
|
2006-01-08 17:32:33 +01:00
|
|
|
#include <vlc/libvlc.h>
|
2016-09-19 19:01:50 +02:00
|
|
|
#include <vlc/libvlc_renderer_discoverer.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_events.h>
|
|
|
|
|
2006-11-26 15:20:34 +01:00
|
|
|
#include <vlc_demux.h>
|
2008-06-13 15:47:11 +02:00
|
|
|
#include <vlc_vout.h>
|
2013-07-13 20:21:37 +02:00
|
|
|
#include <vlc_aout.h>
|
2017-08-03 15:10:35 +02:00
|
|
|
#include <vlc_actions.h>
|
2022-05-18 20:29:54 +02:00
|
|
|
#include <vlc_modules.h>
|
2009-05-25 10:47:38 +02:00
|
|
|
|
|
|
|
#include "libvlc_internal.h"
|
|
|
|
#include "media_player_internal.h"
|
2016-09-19 19:01:50 +02:00
|
|
|
#include "renderer_discoverer_internal.h"
|
2006-01-08 17:32:33 +01:00
|
|
|
|
2017-03-31 11:52:48 +02:00
|
|
|
#define ES_INIT (-2) /* -1 is reserved for ES deselect */
|
|
|
|
|
2008-01-13 23:41:45 +01:00
|
|
|
static int
|
2019-05-13 14:01:55 +02:00
|
|
|
snapshot_was_taken( vlc_object_t *p_this, char const *psz_cmd,
|
|
|
|
vlc_value_t oldval, vlc_value_t newval, void *p_data );
|
2008-01-13 23:41:45 +01:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
static void media_attach_preparsed_event(libvlc_media_t *);
|
|
|
|
static void media_detach_preparsed_event(libvlc_media_t *);
|
2014-08-04 12:07:25 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
static void libvlc_media_player_destroy( libvlc_media_player_t *p_mi );
|
2015-07-27 13:00:08 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
// player callbacks
|
2015-07-27 13:05:37 +02:00
|
|
|
|
2014-08-04 12:07:25 +02:00
|
|
|
static void
|
2019-05-13 14:01:55 +02:00
|
|
|
on_current_media_changed(vlc_player_t *player, input_item_t *new_media,
|
|
|
|
void *data)
|
|
|
|
{
|
|
|
|
(void) player;
|
2014-08-04 12:07:25 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
libvlc_media_player_t *mp = data;
|
2014-08-04 12:07:25 +02:00
|
|
|
|
2020-09-18 14:29:32 +02:00
|
|
|
libvlc_media_t *libmedia;
|
|
|
|
if (new_media != NULL)
|
2019-05-13 14:01:55 +02:00
|
|
|
{
|
2020-09-18 14:29:32 +02:00
|
|
|
libmedia = new_media->libvlc_owner;
|
|
|
|
assert(libmedia != NULL);
|
2019-05-13 14:01:55 +02:00
|
|
|
}
|
|
|
|
else
|
2020-09-18 14:29:32 +02:00
|
|
|
libmedia = NULL;
|
2019-05-13 14:01:55 +02:00
|
|
|
|
|
|
|
libvlc_event_t event;
|
|
|
|
event.type = libvlc_MediaPlayerMediaChanged;
|
2020-09-18 14:29:32 +02:00
|
|
|
event.u.media_player_media_changed.new_media = libmedia;
|
2019-05-13 14:01:55 +02:00
|
|
|
libvlc_event_send(&mp->event_manager, &event);
|
2009-09-16 09:28:23 +02:00
|
|
|
}
|
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
static void
|
|
|
|
on_state_changed(vlc_player_t *player, enum vlc_player_state new_state,
|
|
|
|
void *data)
|
2009-09-16 09:28:23 +02:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
(void) player;
|
|
|
|
|
|
|
|
libvlc_media_player_t *mp = data;
|
|
|
|
|
|
|
|
libvlc_event_t event;
|
|
|
|
switch (new_state) {
|
|
|
|
case VLC_PLAYER_STATE_STOPPED:
|
|
|
|
event.type = libvlc_MediaPlayerStopped;
|
|
|
|
break;
|
|
|
|
case VLC_PLAYER_STATE_STOPPING:
|
2022-03-10 11:59:27 +01:00
|
|
|
event.type = libvlc_MediaPlayerStopping;
|
2019-05-13 14:01:55 +02:00
|
|
|
break;
|
|
|
|
case VLC_PLAYER_STATE_STARTED:
|
|
|
|
event.type = libvlc_MediaPlayerOpening;
|
|
|
|
break;
|
|
|
|
case VLC_PLAYER_STATE_PLAYING:
|
|
|
|
event.type = libvlc_MediaPlayerPlaying;
|
|
|
|
break;
|
|
|
|
case VLC_PLAYER_STATE_PAUSED:
|
|
|
|
event.type = libvlc_MediaPlayerPaused;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
vlc_assert_unreachable();
|
|
|
|
}
|
|
|
|
|
|
|
|
libvlc_event_send(&mp->event_manager, &event);
|
2009-09-16 09:28:23 +02:00
|
|
|
}
|
|
|
|
|
2018-09-27 18:40:39 +02:00
|
|
|
static void
|
|
|
|
on_recording_changed(vlc_player_t *player, bool recording, void *data)
|
|
|
|
{
|
|
|
|
(void) player;
|
|
|
|
libvlc_media_player_t *mp = data;
|
|
|
|
|
|
|
|
/* "record-file" is only valid when recording ends */
|
|
|
|
char *file_path = !recording ? var_GetString(mp, "record-file") : NULL;
|
|
|
|
|
|
|
|
libvlc_event_t event;
|
|
|
|
event.type = libvlc_MediaPlayerRecordChanged;
|
|
|
|
event.u.media_player_record_changed.recorded_file_path = file_path;
|
|
|
|
event.u.media_player_record_changed.recording = recording;
|
|
|
|
|
|
|
|
libvlc_event_send(&mp->event_manager, &event);
|
|
|
|
|
|
|
|
free(file_path);
|
|
|
|
}
|
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
static void
|
|
|
|
on_error_changed(vlc_player_t *player, enum vlc_player_error error, void *data)
|
2010-02-17 23:04:39 +01:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
(void) player;
|
|
|
|
|
|
|
|
libvlc_media_player_t *mp = data;
|
|
|
|
|
|
|
|
libvlc_event_t event;
|
|
|
|
switch (error) {
|
|
|
|
case VLC_PLAYER_ERROR_NONE:
|
|
|
|
event.type = libvlc_MediaPlayerNothingSpecial;
|
|
|
|
break;
|
|
|
|
case VLC_PLAYER_ERROR_GENERIC:
|
|
|
|
event.type = libvlc_MediaPlayerEncounteredError;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
vlc_assert_unreachable();
|
|
|
|
}
|
|
|
|
|
|
|
|
libvlc_event_send(&mp->event_manager, &event);
|
2010-02-17 23:04:39 +01:00
|
|
|
}
|
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
static void
|
|
|
|
on_buffering_changed(vlc_player_t *player, float new_buffering, void *data)
|
2010-02-17 23:04:39 +01:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
(void) player;
|
|
|
|
|
|
|
|
libvlc_media_player_t *mp = data;
|
|
|
|
|
|
|
|
libvlc_event_t event;
|
|
|
|
event.type = libvlc_MediaPlayerBuffering;
|
|
|
|
event.u.media_player_buffering.new_cache = 100 * new_buffering;
|
|
|
|
|
|
|
|
libvlc_event_send(&mp->event_manager, &event);
|
2010-02-17 23:04:39 +01:00
|
|
|
}
|
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
static void
|
|
|
|
on_capabilities_changed(vlc_player_t *player, int old_caps, int new_caps, void *data)
|
2016-05-24 11:19:42 +02:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
(void) player;
|
|
|
|
|
|
|
|
libvlc_media_player_t *mp = data;
|
|
|
|
|
|
|
|
libvlc_event_t event;
|
|
|
|
|
2019-05-31 15:18:56 +02:00
|
|
|
bool old_seekable = old_caps & VLC_PLAYER_CAP_SEEK;
|
|
|
|
bool new_seekable = new_caps & VLC_PLAYER_CAP_SEEK;
|
2019-05-13 14:01:55 +02:00
|
|
|
if (new_seekable != old_seekable)
|
2016-05-24 11:19:42 +02:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
event.type = libvlc_MediaPlayerSeekableChanged;
|
|
|
|
event.u.media_player_seekable_changed.new_seekable = new_seekable;
|
|
|
|
libvlc_event_send(&mp->event_manager, &event);
|
2016-05-24 11:19:42 +02:00
|
|
|
}
|
|
|
|
|
2019-05-31 15:18:56 +02:00
|
|
|
bool old_pauseable = old_caps & VLC_PLAYER_CAP_PAUSE;
|
|
|
|
bool new_pauseable = new_caps & VLC_PLAYER_CAP_PAUSE;
|
2019-05-13 14:01:55 +02:00
|
|
|
if (new_pauseable != old_pauseable)
|
|
|
|
{
|
|
|
|
event.type = libvlc_MediaPlayerPausableChanged;
|
|
|
|
event.u.media_player_pausable_changed.new_pausable = new_pauseable;
|
|
|
|
libvlc_event_send(&mp->event_manager, &event);
|
|
|
|
}
|
2016-05-24 11:19:42 +02:00
|
|
|
}
|
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
static void
|
2022-08-03 13:53:48 +02:00
|
|
|
on_position_changed(vlc_player_t *player, vlc_tick_t new_time, double new_pos,
|
2019-05-13 14:01:55 +02:00
|
|
|
void *data)
|
2016-05-24 11:19:42 +02:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
(void) player;
|
|
|
|
|
|
|
|
libvlc_media_player_t *mp = data;
|
|
|
|
|
|
|
|
libvlc_event_t event;
|
|
|
|
|
|
|
|
event.type = libvlc_MediaPlayerPositionChanged;
|
|
|
|
event.u.media_player_position_changed.new_position = new_pos;
|
|
|
|
libvlc_event_send(&mp->event_manager, &event);
|
|
|
|
|
|
|
|
event.type = libvlc_MediaPlayerTimeChanged;
|
|
|
|
event.u.media_player_time_changed.new_time = MS_FROM_VLC_TICK(new_time);
|
|
|
|
libvlc_event_send(&mp->event_manager, &event);
|
2016-05-24 11:19:42 +02:00
|
|
|
}
|
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
static void
|
|
|
|
on_length_changed(vlc_player_t *player, vlc_tick_t new_length, void *data)
|
2007-06-24 15:19:21 +02:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
(void) player;
|
2007-06-24 15:19:21 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
libvlc_media_player_t *mp = data;
|
2007-06-24 15:19:21 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
libvlc_event_t event;
|
2016-05-24 11:19:42 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
event.type = libvlc_MediaPlayerLengthChanged;
|
|
|
|
event.u.media_player_length_changed.new_length =
|
|
|
|
MS_FROM_VLC_TICK(new_length);
|
2009-05-13 17:27:19 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
libvlc_event_send(&mp->event_manager, &event);
|
2007-06-24 15:19:21 +02:00
|
|
|
}
|
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
static int
|
|
|
|
track_type_from_cat(enum es_format_category_e cat)
|
2006-01-08 17:32:33 +01:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
switch (cat)
|
|
|
|
{
|
|
|
|
case VIDEO_ES:
|
|
|
|
return libvlc_track_video;
|
|
|
|
case AUDIO_ES:
|
|
|
|
return libvlc_track_audio;
|
|
|
|
case SPU_ES:
|
|
|
|
return libvlc_track_text;
|
|
|
|
default:
|
|
|
|
return libvlc_track_unknown;
|
|
|
|
}
|
|
|
|
}
|
2006-01-08 17:32:33 +01:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
static void
|
|
|
|
on_track_list_changed(vlc_player_t *player, enum vlc_player_list_action action,
|
|
|
|
const struct vlc_player_track *track, void *data)
|
|
|
|
{
|
|
|
|
(void) player;
|
|
|
|
|
|
|
|
libvlc_media_player_t *mp = data;
|
2008-05-18 13:09:26 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
libvlc_event_t event;
|
2020-06-04 23:13:49 +02:00
|
|
|
switch (action)
|
|
|
|
{
|
|
|
|
case VLC_PLAYER_LIST_ADDED:
|
|
|
|
event.type = libvlc_MediaPlayerESAdded; break;
|
|
|
|
case VLC_PLAYER_LIST_REMOVED:
|
|
|
|
event.type = libvlc_MediaPlayerESDeleted; break;
|
|
|
|
case VLC_PLAYER_LIST_UPDATED:
|
|
|
|
event.type = libvlc_MediaPlayerESUpdated; break;
|
|
|
|
}
|
2008-03-19 02:32:28 +01:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
event.u.media_player_es_changed.i_type =
|
|
|
|
track_type_from_cat(track->fmt.i_cat);
|
2020-06-12 11:25:49 +02:00
|
|
|
event.u.media_player_es_changed.i_id = vlc_es_id_GetInputId(track->es_id);
|
2020-06-04 23:13:49 +02:00
|
|
|
event.u.media_player_es_changed.psz_id = vlc_es_id_GetStrId(track->es_id);
|
2019-05-13 14:01:55 +02:00
|
|
|
|
|
|
|
libvlc_event_send(&mp->event_manager, &event);
|
2006-06-05 20:23:56 +02:00
|
|
|
}
|
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
static void
|
|
|
|
on_track_selection_changed(vlc_player_t *player, vlc_es_id_t *unselected_id,
|
|
|
|
vlc_es_id_t *selected_id, void *data)
|
2010-01-18 09:06:16 +01:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
(void) player;
|
|
|
|
(void) unselected_id;
|
2010-02-05 14:13:29 +01:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
libvlc_media_player_t *mp = data;
|
2010-02-05 14:13:29 +01:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
libvlc_event_t event;
|
|
|
|
event.type = libvlc_MediaPlayerESSelected;
|
2009-12-07 20:35:10 +01:00
|
|
|
|
2020-06-04 23:13:49 +02:00
|
|
|
if (unselected_id)
|
|
|
|
{
|
|
|
|
enum es_format_category_e cat = vlc_es_id_GetCat(unselected_id);
|
|
|
|
event.u.media_player_es_selection_changed.i_type = track_type_from_cat(cat);
|
|
|
|
}
|
2019-05-13 14:01:55 +02:00
|
|
|
if (selected_id)
|
2010-02-05 14:13:29 +01:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
enum es_format_category_e cat = vlc_es_id_GetCat(selected_id);
|
2020-06-04 23:13:49 +02:00
|
|
|
event.u.media_player_es_selection_changed.i_type = track_type_from_cat(cat);
|
2009-12-07 20:35:10 +01:00
|
|
|
}
|
2020-06-04 23:13:49 +02:00
|
|
|
|
|
|
|
event.u.media_player_es_selection_changed.psz_unselected_id =
|
|
|
|
unselected_id ? vlc_es_id_GetStrId(unselected_id) : NULL;
|
|
|
|
|
|
|
|
event.u.media_player_es_selection_changed.psz_selected_id =
|
|
|
|
selected_id ? vlc_es_id_GetStrId(selected_id) : NULL;
|
|
|
|
|
|
|
|
libvlc_event_send(&mp->event_manager, &event);
|
2009-12-07 20:35:10 +01:00
|
|
|
}
|
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
static void
|
|
|
|
on_program_list_changed(vlc_player_t *player,
|
|
|
|
enum vlc_player_list_action action,
|
|
|
|
const struct vlc_player_program *prgm, void* data)
|
|
|
|
{
|
2020-10-01 11:25:07 +02:00
|
|
|
(void) player;
|
2019-05-13 14:01:55 +02:00
|
|
|
libvlc_media_player_t *mp = data;
|
2008-02-28 00:45:10 +01:00
|
|
|
|
|
|
|
libvlc_event_t event;
|
2020-10-01 11:25:07 +02:00
|
|
|
switch (action)
|
|
|
|
{
|
|
|
|
case VLC_PLAYER_LIST_ADDED:
|
|
|
|
event.type = libvlc_MediaPlayerProgramAdded;
|
|
|
|
break;
|
|
|
|
case VLC_PLAYER_LIST_REMOVED:
|
|
|
|
event.type = libvlc_MediaPlayerProgramDeleted;
|
|
|
|
break;
|
|
|
|
case VLC_PLAYER_LIST_UPDATED:
|
|
|
|
event.type = libvlc_MediaPlayerProgramUpdated;
|
|
|
|
break;
|
|
|
|
}
|
2008-02-28 00:45:10 +01:00
|
|
|
|
2020-10-01 11:25:07 +02:00
|
|
|
event.u.media_player_program_changed.i_id = prgm->group_id;
|
2019-05-13 14:01:55 +02:00
|
|
|
libvlc_event_send(&mp->event_manager, &event);
|
2008-02-28 00:45:10 +01:00
|
|
|
}
|
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
static void
|
|
|
|
on_program_selection_changed(vlc_player_t *player, int unselected_id,
|
|
|
|
int selected_id, void *data)
|
|
|
|
{
|
2020-10-01 11:25:07 +02:00
|
|
|
(void) player;
|
2019-05-13 14:01:55 +02:00
|
|
|
libvlc_media_player_t *mp = data;
|
|
|
|
|
|
|
|
libvlc_event_t event;
|
2020-10-01 11:25:07 +02:00
|
|
|
event.type = libvlc_MediaPlayerProgramSelected;
|
|
|
|
event.u.media_player_program_selection_changed.i_unselected_id = unselected_id;
|
|
|
|
event.u.media_player_program_selection_changed.i_selected_id = selected_id;
|
2014-02-06 22:03:24 +01:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
libvlc_event_send(&mp->event_manager, &event);
|
2014-02-06 22:03:24 +01:00
|
|
|
}
|
|
|
|
|
2020-04-28 13:45:38 +02:00
|
|
|
static void
|
|
|
|
on_titles_changed(vlc_player_t *player,
|
|
|
|
vlc_player_title_list *titles, void *data)
|
|
|
|
{
|
|
|
|
(void) player;
|
|
|
|
(void) titles;
|
|
|
|
|
|
|
|
libvlc_media_player_t *mp = data;
|
|
|
|
|
|
|
|
libvlc_event_t event;
|
|
|
|
event.type = libvlc_MediaPlayerTitleListChanged;
|
|
|
|
|
|
|
|
libvlc_event_send(&mp->event_manager, &event);
|
|
|
|
}
|
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
static void
|
|
|
|
on_title_selection_changed(vlc_player_t *player,
|
|
|
|
const struct vlc_player_title *new_title,
|
|
|
|
size_t new_idx, void *data)
|
2007-08-20 06:43:48 +02:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
(void) player;
|
|
|
|
(void) new_title;
|
|
|
|
|
|
|
|
libvlc_media_player_t *mp = data;
|
|
|
|
|
2020-04-28 13:18:39 +02:00
|
|
|
const libvlc_title_description_t libtitle = {
|
|
|
|
.i_duration = MS_FROM_VLC_TICK(new_title->length),
|
|
|
|
.psz_name = (char *) new_title->name,
|
|
|
|
.i_flags = new_title->flags,
|
|
|
|
};
|
|
|
|
|
2008-11-23 15:21:12 +01:00
|
|
|
libvlc_event_t event;
|
2020-04-27 20:12:42 +02:00
|
|
|
event.type = libvlc_MediaPlayerTitleSelectionChanged;
|
2020-04-28 13:18:39 +02:00
|
|
|
event.u.media_player_title_selection_changed.title = &libtitle;
|
|
|
|
event.u.media_player_title_selection_changed.index = new_idx;
|
2007-12-29 02:29:48 +01:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
libvlc_event_send(&mp->event_manager, &event);
|
|
|
|
}
|
2007-12-29 02:29:48 +01:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
static void
|
|
|
|
on_chapter_selection_changed(vlc_player_t *player,
|
|
|
|
const struct vlc_player_title *title,
|
|
|
|
size_t title_idx,
|
|
|
|
const struct vlc_player_chapter *new_chapter,
|
|
|
|
size_t new_chapter_idx,
|
|
|
|
void *data)
|
|
|
|
{
|
|
|
|
(void) player;
|
|
|
|
(void) title;
|
|
|
|
(void) title_idx;
|
|
|
|
(void) new_chapter;
|
2008-12-11 23:03:32 +01:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
libvlc_media_player_t *mp = data;
|
2010-01-29 01:16:50 +01:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
libvlc_event_t event;
|
|
|
|
event.type = libvlc_MediaPlayerChapterChanged;
|
|
|
|
event.u.media_player_chapter_changed.new_chapter = new_chapter_idx;
|
2009-07-24 16:35:21 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
libvlc_event_send(&mp->event_manager, &event);
|
|
|
|
}
|
2011-09-05 19:37:35 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
static void
|
|
|
|
on_media_subitems_changed(vlc_player_t *player, input_item_t *media,
|
|
|
|
input_item_node_t *new_subitems, void *data)
|
|
|
|
{
|
|
|
|
(void) player;
|
2017-03-31 11:52:48 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
libvlc_media_player_t *mp = data;
|
2008-11-23 15:21:12 +01:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
input_item_t *current = mp->p_md ? mp->p_md->p_input_item : NULL;
|
|
|
|
if (media == current)
|
|
|
|
libvlc_media_add_subtree(mp->p_md, new_subitems);
|
2007-08-20 06:43:48 +02:00
|
|
|
}
|
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
static void
|
|
|
|
on_cork_changed(vlc_player_t *player, unsigned cork_count, void *data)
|
2014-08-04 12:07:25 +02:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
(void) player;
|
|
|
|
|
|
|
|
libvlc_media_player_t *mp = data;
|
|
|
|
|
|
|
|
libvlc_event_t event;
|
|
|
|
event.type = cork_count ? libvlc_MediaPlayerCorked
|
|
|
|
: libvlc_MediaPlayerUncorked;
|
|
|
|
|
|
|
|
libvlc_event_send(&mp->event_manager, &event);
|
2014-08-04 12:07:25 +02:00
|
|
|
}
|
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
static void
|
|
|
|
on_vout_changed(vlc_player_t *player, enum vlc_player_vout_action action,
|
2019-06-14 15:46:16 +02:00
|
|
|
vout_thread_t *vout, enum vlc_vout_order order,
|
|
|
|
vlc_es_id_t *es_id, void *data)
|
2014-08-04 12:07:25 +02:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
(void) action;
|
|
|
|
(void) vout;
|
2019-06-14 15:46:16 +02:00
|
|
|
(void) order;
|
|
|
|
|
|
|
|
if (vlc_es_id_GetCat(es_id) != VIDEO_ES)
|
|
|
|
return;
|
2019-05-13 14:01:55 +02:00
|
|
|
|
|
|
|
libvlc_media_player_t *mp = data;
|
|
|
|
|
|
|
|
size_t count;
|
|
|
|
vout_thread_t **vouts = vlc_player_vout_HoldAll(player, &count);
|
|
|
|
if (!vouts)
|
|
|
|
return;
|
|
|
|
for (size_t i = 0; i < count; ++i)
|
|
|
|
vout_Release(vouts[i]);
|
|
|
|
free(vouts);
|
|
|
|
|
2014-08-04 12:07:25 +02:00
|
|
|
libvlc_event_t event;
|
2019-05-13 14:01:55 +02:00
|
|
|
event.type = libvlc_MediaPlayerVout;
|
|
|
|
event.u.media_player_vout.new_count = count;
|
2014-08-04 12:07:25 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
libvlc_event_send(&mp->event_manager, &event);
|
|
|
|
}
|
2014-08-04 12:07:25 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
// player aout callbacks
|
2014-08-04 12:07:25 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
static void
|
2019-08-23 10:11:43 +02:00
|
|
|
on_volume_changed(audio_output_t *aout, float new_volume, void *data)
|
2019-05-13 14:01:55 +02:00
|
|
|
{
|
2019-08-23 10:11:43 +02:00
|
|
|
(void) aout;
|
2014-08-04 12:07:25 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
libvlc_media_player_t *mp = data;
|
|
|
|
|
|
|
|
libvlc_event_t event;
|
|
|
|
event.type = libvlc_MediaPlayerAudioVolume;
|
|
|
|
event.u.media_player_audio_volume.volume = new_volume;
|
2014-08-04 12:07:25 +02:00
|
|
|
|
2017-05-15 19:16:45 +02:00
|
|
|
libvlc_event_send(&mp->event_manager, &event);
|
2019-05-13 14:01:55 +02:00
|
|
|
}
|
2014-08-04 12:07:25 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
static void
|
2019-08-23 10:11:43 +02:00
|
|
|
on_mute_changed(audio_output_t *aout, bool new_muted, void *data)
|
2019-05-13 14:01:55 +02:00
|
|
|
{
|
2019-08-23 10:11:43 +02:00
|
|
|
(void) aout;
|
2019-05-13 14:01:55 +02:00
|
|
|
|
|
|
|
libvlc_media_player_t *mp = data;
|
|
|
|
|
|
|
|
libvlc_event_t event;
|
|
|
|
event.type = new_muted ? libvlc_MediaPlayerMuted
|
|
|
|
: libvlc_MediaPlayerUnmuted;
|
|
|
|
|
|
|
|
libvlc_event_send(&mp->event_manager, &event);
|
2014-08-04 12:07:25 +02:00
|
|
|
}
|
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
static void
|
2019-08-23 10:11:43 +02:00
|
|
|
on_audio_device_changed(audio_output_t *aout, const char *device, void *data)
|
2019-05-13 14:01:55 +02:00
|
|
|
{
|
2019-08-23 10:11:43 +02:00
|
|
|
(void) aout;
|
2019-05-13 14:01:55 +02:00
|
|
|
|
|
|
|
libvlc_media_player_t *mp = data;
|
|
|
|
|
|
|
|
libvlc_event_t event;
|
|
|
|
event.type = libvlc_MediaPlayerAudioDevice;
|
|
|
|
event.u.media_player_audio_device.device = device;
|
|
|
|
|
|
|
|
libvlc_event_send(&mp->event_manager, &event);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct vlc_player_cbs vlc_player_cbs = {
|
|
|
|
.on_current_media_changed = on_current_media_changed,
|
|
|
|
.on_state_changed = on_state_changed,
|
|
|
|
.on_error_changed = on_error_changed,
|
|
|
|
.on_buffering_changed = on_buffering_changed,
|
|
|
|
.on_capabilities_changed = on_capabilities_changed,
|
|
|
|
.on_position_changed = on_position_changed,
|
|
|
|
.on_length_changed = on_length_changed,
|
|
|
|
.on_track_list_changed = on_track_list_changed,
|
|
|
|
.on_track_selection_changed = on_track_selection_changed,
|
|
|
|
.on_program_list_changed = on_program_list_changed,
|
|
|
|
.on_program_selection_changed = on_program_selection_changed,
|
2020-04-28 13:45:38 +02:00
|
|
|
.on_titles_changed = on_titles_changed,
|
2019-05-13 14:01:55 +02:00
|
|
|
.on_title_selection_changed = on_title_selection_changed,
|
|
|
|
.on_chapter_selection_changed = on_chapter_selection_changed,
|
|
|
|
.on_media_subitems_changed = on_media_subitems_changed,
|
|
|
|
.on_cork_changed = on_cork_changed,
|
|
|
|
.on_vout_changed = on_vout_changed,
|
2018-09-27 18:40:39 +02:00
|
|
|
.on_recording_changed = on_recording_changed,
|
2019-05-13 14:01:55 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct vlc_player_aout_cbs vlc_player_aout_cbs = {
|
|
|
|
.on_volume_changed = on_volume_changed,
|
|
|
|
.on_mute_changed = on_mute_changed,
|
|
|
|
.on_device_changed = on_audio_device_changed,
|
|
|
|
};
|
|
|
|
|
2009-09-16 09:28:23 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* Snapshot Taken Event.
|
|
|
|
*
|
|
|
|
* FIXME: This snapshot API interface makes no sense in media_player.
|
|
|
|
*************************************************************************/
|
|
|
|
static int snapshot_was_taken(vlc_object_t *p_this, char const *psz_cmd,
|
|
|
|
vlc_value_t oldval, vlc_value_t newval, void *p_data )
|
|
|
|
{
|
|
|
|
VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_this);
|
|
|
|
|
|
|
|
libvlc_media_player_t *mp = p_data;
|
|
|
|
libvlc_event_t event;
|
|
|
|
event.type = libvlc_MediaPlayerSnapshotTaken;
|
|
|
|
event.u.media_player_snapshot_taken.psz_filename = newval.psz_string;
|
2017-05-15 19:16:45 +02:00
|
|
|
libvlc_event_send(&mp->event_manager, &event);
|
2009-09-16 09:28:23 +02:00
|
|
|
|
|
|
|
return VLC_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
static void input_item_preparsed_changed( const vlc_event_t *p_event,
|
|
|
|
void * user_data )
|
2015-07-27 12:42:38 +02:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
libvlc_media_t *p_md = user_data;
|
|
|
|
if( p_event->u.input_item_preparsed_changed.new_status & ITEM_PREPARSED )
|
2015-07-27 12:42:38 +02:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
/* Send the event */
|
2015-07-27 12:42:38 +02:00
|
|
|
libvlc_event_t event;
|
2019-05-13 14:01:55 +02:00
|
|
|
event.type = libvlc_MediaParsedChanged;
|
|
|
|
event.u.media_parsed_changed.new_status = libvlc_media_parsed_status_done;
|
|
|
|
libvlc_event_send( &p_md->event_manager, &event );
|
2015-07-27 12:42:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
static void media_attach_preparsed_event( libvlc_media_t *p_md )
|
2015-07-27 13:00:08 +02:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_event_attach( &p_md->p_input_item->event_manager,
|
|
|
|
vlc_InputItemPreparsedChanged,
|
|
|
|
input_item_preparsed_changed, p_md );
|
2015-07-27 13:00:08 +02:00
|
|
|
}
|
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
static void media_detach_preparsed_event( libvlc_media_t *p_md )
|
2015-07-27 13:05:37 +02:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_event_detach( &p_md->p_input_item->event_manager,
|
|
|
|
vlc_InputItemPreparsedChanged,
|
|
|
|
input_item_preparsed_changed,
|
|
|
|
p_md );
|
2015-07-27 13:05:37 +02:00
|
|
|
}
|
|
|
|
|
2007-06-17 22:54:32 +02:00
|
|
|
/**************************************************************************
|
2009-03-04 11:38:26 +01:00
|
|
|
* Create a Media Instance object.
|
|
|
|
*
|
|
|
|
* Refcount strategy:
|
|
|
|
* - All items created by _new start with a refcount set to 1.
|
|
|
|
* - Accessor _release decrease the refcount by 1, if after that
|
|
|
|
* operation the refcount is 0, the object is destroyed.
|
|
|
|
* - Accessor _retain increase the refcount by 1 (XXX: to implement)
|
|
|
|
*
|
|
|
|
* Object locking strategy:
|
|
|
|
* - No lock held while in constructor.
|
|
|
|
* - When accessing any member variable this lock is held. (XXX who locks?)
|
|
|
|
* - When attempting to destroy the object the lock is also held.
|
2007-06-17 22:54:32 +02:00
|
|
|
**************************************************************************/
|
2008-03-30 03:59:32 +02:00
|
|
|
libvlc_media_player_t *
|
2010-01-31 18:30:49 +01:00
|
|
|
libvlc_media_player_new( libvlc_instance_t *instance )
|
2007-06-24 15:19:21 +02:00
|
|
|
{
|
2009-09-16 09:28:23 +02:00
|
|
|
libvlc_media_player_t * mp;
|
2022-05-18 20:29:54 +02:00
|
|
|
int doinherit;
|
2007-06-24 15:19:21 +02:00
|
|
|
|
2009-09-16 09:28:23 +02:00
|
|
|
assert(instance);
|
2007-06-24 15:19:21 +02:00
|
|
|
|
2010-01-31 17:45:12 +01:00
|
|
|
mp = vlc_object_create (instance->p_libvlc_int, sizeof(*mp));
|
|
|
|
if (unlikely(mp == NULL))
|
2008-05-18 13:09:26 +02:00
|
|
|
{
|
2009-09-16 09:28:23 +02:00
|
|
|
libvlc_printerr("Not enough memory");
|
2008-05-18 13:09:26 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
2010-01-31 17:56:56 +01:00
|
|
|
|
2010-02-14 12:50:36 +01:00
|
|
|
/* Input */
|
|
|
|
var_Create (mp, "rate", VLC_VAR_FLOAT|VLC_VAR_DOINHERIT);
|
2016-09-19 19:01:50 +02:00
|
|
|
var_Create (mp, "sout", VLC_VAR_STRING);
|
|
|
|
var_Create (mp, "demux-filter", VLC_VAR_STRING);
|
2010-02-14 12:50:36 +01:00
|
|
|
|
2010-02-01 17:49:24 +01:00
|
|
|
/* Video */
|
2010-07-08 19:24:32 +02:00
|
|
|
var_Create (mp, "vout", VLC_VAR_STRING|VLC_VAR_DOINHERIT);
|
2010-07-08 18:52:30 +02:00
|
|
|
var_Create (mp, "window", VLC_VAR_STRING);
|
2018-07-25 15:41:08 +02:00
|
|
|
var_Create (mp, "gl", VLC_VAR_STRING);
|
|
|
|
var_Create (mp, "gles2", VLC_VAR_STRING);
|
2010-07-10 17:09:05 +02:00
|
|
|
var_Create (mp, "vmem-lock", VLC_VAR_ADDRESS);
|
|
|
|
var_Create (mp, "vmem-unlock", VLC_VAR_ADDRESS);
|
|
|
|
var_Create (mp, "vmem-display", VLC_VAR_ADDRESS);
|
|
|
|
var_Create (mp, "vmem-data", VLC_VAR_ADDRESS);
|
2010-11-21 14:54:13 +01:00
|
|
|
var_Create (mp, "vmem-setup", VLC_VAR_ADDRESS);
|
|
|
|
var_Create (mp, "vmem-cleanup", VLC_VAR_ADDRESS);
|
2022-04-27 17:30:30 +02:00
|
|
|
var_Create (mp, "vmem-chroma", VLC_VAR_STRING);
|
|
|
|
var_Create (mp, "vmem-width", VLC_VAR_INTEGER);
|
|
|
|
var_Create (mp, "vmem-height", VLC_VAR_INTEGER);
|
|
|
|
var_Create (mp, "vmem-pitch", VLC_VAR_INTEGER);
|
2018-07-25 15:41:08 +02:00
|
|
|
|
2020-02-11 15:29:02 +01:00
|
|
|
var_Create (mp, "vout-cb-type", VLC_VAR_INTEGER );
|
2018-11-20 09:45:51 +01:00
|
|
|
var_Create( mp, "vout-cb-opaque", VLC_VAR_ADDRESS );
|
|
|
|
var_Create( mp, "vout-cb-setup", VLC_VAR_ADDRESS );
|
|
|
|
var_Create( mp, "vout-cb-cleanup", VLC_VAR_ADDRESS );
|
2019-06-14 16:14:13 +02:00
|
|
|
var_Create( mp, "vout-cb-resize-cb", VLC_VAR_ADDRESS );
|
2018-11-20 09:29:51 +01:00
|
|
|
var_Create( mp, "vout-cb-update-output", VLC_VAR_ADDRESS );
|
2018-11-20 09:45:51 +01:00
|
|
|
var_Create( mp, "vout-cb-swap", VLC_VAR_ADDRESS );
|
|
|
|
var_Create( mp, "vout-cb-get-proc-address", VLC_VAR_ADDRESS );
|
|
|
|
var_Create( mp, "vout-cb-make-current", VLC_VAR_ADDRESS );
|
2020-02-05 13:37:29 +01:00
|
|
|
var_Create( mp, "vout-cb-metadata", VLC_VAR_ADDRESS );
|
2019-05-09 14:13:59 +02:00
|
|
|
var_Create( mp, "vout-cb-select-plane", VLC_VAR_ADDRESS );
|
2018-07-25 15:41:08 +02:00
|
|
|
|
2019-06-26 15:16:26 +02:00
|
|
|
var_Create (mp, "dec-dev", VLC_VAR_STRING);
|
2010-01-31 17:56:56 +01:00
|
|
|
var_Create (mp, "drawable-xid", VLC_VAR_INTEGER);
|
2013-06-05 15:41:18 +02:00
|
|
|
#if defined (_WIN32) || defined (__OS2__)
|
2011-04-11 17:21:34 +02:00
|
|
|
var_Create (mp, "drawable-hwnd", VLC_VAR_INTEGER);
|
2010-01-31 17:56:56 +01:00
|
|
|
#endif
|
|
|
|
#ifdef __APPLE__
|
|
|
|
var_Create (mp, "drawable-nsobject", VLC_VAR_ADDRESS);
|
|
|
|
#endif
|
2015-06-25 13:52:59 +02:00
|
|
|
#ifdef __ANDROID__
|
|
|
|
var_Create (mp, "drawable-androidwindow", VLC_VAR_ADDRESS);
|
|
|
|
#endif
|
2010-01-31 17:56:56 +01:00
|
|
|
|
|
|
|
var_Create (mp, "keyboard-events", VLC_VAR_BOOL);
|
|
|
|
var_SetBool (mp, "keyboard-events", true);
|
|
|
|
var_Create (mp, "mouse-events", VLC_VAR_BOOL);
|
2010-02-01 17:49:24 +01:00
|
|
|
var_SetBool (mp, "mouse-events", true);
|
2010-01-31 17:56:56 +01:00
|
|
|
|
2010-02-01 18:47:45 +01:00
|
|
|
var_Create (mp, "fullscreen", VLC_VAR_BOOL);
|
2014-10-23 20:06:26 +02:00
|
|
|
var_Create (mp, "autoscale", VLC_VAR_BOOL | VLC_VAR_DOINHERIT);
|
|
|
|
var_Create (mp, "zoom", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT);
|
2010-02-01 18:47:45 +01:00
|
|
|
var_Create (mp, "aspect-ratio", VLC_VAR_STRING);
|
|
|
|
var_Create (mp, "crop", VLC_VAR_STRING);
|
2017-01-24 13:32:14 +01:00
|
|
|
var_Create (mp, "deinterlace", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT);
|
|
|
|
var_Create (mp, "deinterlace-mode", VLC_VAR_STRING | VLC_VAR_DOINHERIT);
|
2010-02-06 19:18:35 +01:00
|
|
|
|
2015-01-15 20:21:53 +01:00
|
|
|
var_Create (mp, "vbi-page", VLC_VAR_INTEGER);
|
2017-08-04 15:05:02 +02:00
|
|
|
var_SetInteger (mp, "vbi-page", 100);
|
2010-02-01 18:47:45 +01:00
|
|
|
|
2017-03-14 14:23:51 +01:00
|
|
|
var_Create (mp, "video-filter", VLC_VAR_STRING | VLC_VAR_DOINHERIT);
|
|
|
|
var_Create (mp, "sub-source", VLC_VAR_STRING | VLC_VAR_DOINHERIT);
|
|
|
|
var_Create (mp, "sub-filter", VLC_VAR_STRING | VLC_VAR_DOINHERIT);
|
|
|
|
|
2022-03-04 11:31:42 +01:00
|
|
|
var_Create (mp, "osd", VLC_VAR_BOOL); // off
|
|
|
|
|
2022-05-18 20:29:54 +02:00
|
|
|
doinherit = module_exists("marq") ? VLC_VAR_DOINHERIT : 0;
|
|
|
|
var_Create(mp, "marq-marquee", VLC_VAR_STRING);
|
|
|
|
var_Create(mp, "marq-color", VLC_VAR_INTEGER | doinherit);
|
|
|
|
var_Create(mp, "marq-opacity", VLC_VAR_INTEGER | doinherit);
|
|
|
|
var_Create(mp, "marq-position", VLC_VAR_INTEGER | doinherit);
|
|
|
|
var_Create(mp, "marq-refresh", VLC_VAR_INTEGER | doinherit);
|
|
|
|
var_Create(mp, "marq-size", VLC_VAR_INTEGER | doinherit);
|
|
|
|
var_Create(mp, "marq-timeout", VLC_VAR_INTEGER | doinherit);
|
|
|
|
var_Create(mp, "marq-x", VLC_VAR_INTEGER | doinherit);
|
|
|
|
var_Create(mp, "marq-y", VLC_VAR_INTEGER | doinherit);
|
2010-02-06 19:18:35 +01:00
|
|
|
|
2022-05-18 20:29:54 +02:00
|
|
|
doinherit = module_exists("logo") ? VLC_VAR_DOINHERIT : 0;
|
|
|
|
var_Create(mp, "logo-file", VLC_VAR_STRING);
|
|
|
|
var_Create(mp, "logo-x", VLC_VAR_INTEGER | doinherit);
|
|
|
|
var_Create(mp, "logo-y", VLC_VAR_INTEGER | doinherit);
|
|
|
|
var_Create(mp, "logo-delay", VLC_VAR_INTEGER | doinherit);
|
|
|
|
var_Create(mp, "logo-repeat", VLC_VAR_INTEGER | doinherit);
|
|
|
|
var_Create(mp, "logo-opacity", VLC_VAR_INTEGER | doinherit);
|
|
|
|
var_Create(mp, "logo-position", VLC_VAR_INTEGER | doinherit);
|
2010-02-06 19:18:35 +01:00
|
|
|
|
2022-05-26 10:15:12 +02:00
|
|
|
var_Create(mp, "contrast", VLC_VAR_FLOAT);
|
2022-04-27 17:32:48 +02:00
|
|
|
var_SetFloat(mp, "contrast", 1.f);
|
2022-05-26 10:15:12 +02:00
|
|
|
var_Create(mp, "brightness", VLC_VAR_FLOAT);
|
2022-04-27 17:32:48 +02:00
|
|
|
var_SetFloat(mp, "brightness", 1.f);
|
2022-05-26 10:15:12 +02:00
|
|
|
var_Create(mp, "hue", VLC_VAR_FLOAT);
|
|
|
|
var_Create(mp, "saturation", VLC_VAR_FLOAT);
|
2022-04-27 17:32:48 +02:00
|
|
|
var_SetFloat(mp, "saturation", 1.f);
|
2022-05-26 10:15:12 +02:00
|
|
|
var_Create(mp, "gamma", VLC_VAR_FLOAT);
|
2022-04-27 17:32:48 +02:00
|
|
|
var_SetFloat(mp, "gamma", 1.f);
|
Add adjust filter features to libvlc_media_player/libvlc_video
This patch exposes the adjust module to libvlc_media_player/libvlc_video
and adds a frequently requested featureset: to manipulate brightness,
contrast, gamma, saturation and hue through libvlc. The patch introduces
a new set of functions analogous to
libvlc_video_{get,set}_{marq,logo}_*, hence the use of the function set
should be self explanatory.
New Functions:
* value = libvlc_video_get_adjust_int( p_mi, option );
* libvlc_video_set_adjust_int( p_mi, option, value );
* value = libvlc_video_get_adjust_float( p_mi, option );
* libvlc_video_set_adjust_float( p_mi, option, value );
New Options:
* libvlc_adjust_Enable
* libvlc_adjust_Contrast
* libvlc_adjust_Brightness
* libvlc_adjust_Hue
* libvlc_adjust_Saturation
* libvlc_adjust_Gamma
Signed-off-by: Rémi Denis-Courmont <remi@remlab.net>
2010-06-24 02:16:04 +02:00
|
|
|
|
2010-02-01 18:47:45 +01:00
|
|
|
/* Audio */
|
2010-01-31 19:54:18 +01:00
|
|
|
var_Create (mp, "aout", VLC_VAR_STRING | VLC_VAR_DOINHERIT);
|
2015-07-27 15:30:06 +02:00
|
|
|
var_Create (mp, "audio-device", VLC_VAR_STRING);
|
2011-04-07 22:08:37 +02:00
|
|
|
var_Create (mp, "mute", VLC_VAR_BOOL);
|
2012-07-21 16:36:08 +02:00
|
|
|
var_Create (mp, "volume", VLC_VAR_FLOAT);
|
2012-08-08 17:48:35 +02:00
|
|
|
var_Create (mp, "corks", VLC_VAR_INTEGER);
|
2014-05-24 06:55:30 +02:00
|
|
|
var_Create (mp, "audio-filter", VLC_VAR_STRING);
|
2016-06-04 17:02:05 +02:00
|
|
|
var_Create (mp, "role", VLC_VAR_STRING | VLC_VAR_DOINHERIT);
|
2011-05-10 19:56:21 +02:00
|
|
|
var_Create (mp, "amem-data", VLC_VAR_ADDRESS);
|
|
|
|
var_Create (mp, "amem-setup", VLC_VAR_ADDRESS);
|
2011-09-12 23:19:09 +02:00
|
|
|
var_Create (mp, "amem-cleanup", VLC_VAR_ADDRESS);
|
2011-05-10 19:56:21 +02:00
|
|
|
var_Create (mp, "amem-play", VLC_VAR_ADDRESS);
|
2011-08-04 18:40:53 +02:00
|
|
|
var_Create (mp, "amem-pause", VLC_VAR_ADDRESS);
|
|
|
|
var_Create (mp, "amem-resume", VLC_VAR_ADDRESS);
|
|
|
|
var_Create (mp, "amem-flush", VLC_VAR_ADDRESS);
|
|
|
|
var_Create (mp, "amem-drain", VLC_VAR_ADDRESS);
|
2011-05-10 19:56:21 +02:00
|
|
|
var_Create (mp, "amem-set-volume", VLC_VAR_ADDRESS);
|
2022-04-27 17:30:30 +02:00
|
|
|
var_Create (mp, "amem-format", VLC_VAR_STRING);
|
|
|
|
var_Create (mp, "amem-rate", VLC_VAR_INTEGER);
|
|
|
|
var_Create (mp, "amem-channels", VLC_VAR_INTEGER);
|
2010-01-31 19:54:18 +01:00
|
|
|
|
2013-07-03 18:24:57 +02:00
|
|
|
/* Video Title */
|
|
|
|
var_Create (mp, "video-title-show", VLC_VAR_BOOL);
|
|
|
|
var_Create (mp, "video-title-position", VLC_VAR_INTEGER);
|
|
|
|
var_Create (mp, "video-title-timeout", VLC_VAR_INTEGER);
|
|
|
|
|
2013-07-13 20:21:37 +02:00
|
|
|
/* Equalizer */
|
|
|
|
var_Create (mp, "equalizer-preamp", VLC_VAR_FLOAT);
|
2014-03-19 01:16:17 +01:00
|
|
|
var_Create (mp, "equalizer-vlcfreqs", VLC_VAR_BOOL);
|
2013-07-13 20:21:37 +02:00
|
|
|
var_Create (mp, "equalizer-bands", VLC_VAR_STRING);
|
2023-03-01 12:35:16 +01:00
|
|
|
var_Create (mp, "equalizer-preset", VLC_VAR_STRING);
|
2013-07-13 20:21:37 +02:00
|
|
|
|
2018-09-27 18:40:39 +02:00
|
|
|
/* variables for signalling creation of new files */
|
|
|
|
var_Create(mp, "record-file", VLC_VAR_STRING);
|
2022-08-01 14:07:48 +02:00
|
|
|
|
2018-09-27 18:40:39 +02:00
|
|
|
mp->timer.id = NULL;
|
2009-09-16 09:28:23 +02:00
|
|
|
mp->p_md = NULL;
|
|
|
|
mp->p_libvlc_instance = instance;
|
2019-05-13 14:01:55 +02:00
|
|
|
/* use a reentrant lock to allow calling libvlc functions from callbacks */
|
|
|
|
mp->player = vlc_player_New(VLC_OBJECT(mp), VLC_PLAYER_LOCK_REENTRANT,
|
|
|
|
NULL, NULL);
|
|
|
|
if (unlikely(!mp->player))
|
|
|
|
goto error1;
|
|
|
|
|
|
|
|
vlc_player_Lock(mp->player);
|
2015-06-26 09:08:46 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
mp->listener = vlc_player_AddListener(mp->player, &vlc_player_cbs, mp);
|
|
|
|
if (unlikely(!mp->listener))
|
|
|
|
goto error2;
|
|
|
|
|
|
|
|
mp->aout_listener =
|
|
|
|
vlc_player_aout_AddListener(mp->player, &vlc_player_aout_cbs, mp);
|
|
|
|
if (unlikely(!mp->aout_listener))
|
|
|
|
goto error3;
|
|
|
|
|
|
|
|
vlc_player_Unlock(mp->player);
|
2016-11-15 16:19:25 +01:00
|
|
|
|
2020-11-21 12:45:14 +01:00
|
|
|
vlc_atomic_rc_init(&mp->rc);
|
2017-05-15 19:16:45 +02:00
|
|
|
libvlc_event_manager_init(&mp->event_manager, mp);
|
2011-09-05 21:12:58 +02:00
|
|
|
|
2008-10-30 10:45:56 +01:00
|
|
|
/* Snapshot initialization */
|
|
|
|
/* Attach a var callback to the global object to provide the glue between
|
2009-09-16 09:28:23 +02:00
|
|
|
* vout_thread that generates the event and media_player that re-emits it
|
|
|
|
* with its own event manager
|
|
|
|
*
|
|
|
|
* FIXME: It's unclear why we want to put this in public API, and why we
|
|
|
|
* want to expose it in such a limiting and ugly way.
|
|
|
|
*/
|
2019-02-19 16:31:20 +01:00
|
|
|
var_AddCallback(vlc_object_instance(mp),
|
|
|
|
"snapshot-file", snapshot_was_taken, mp);
|
2009-09-16 09:28:23 +02:00
|
|
|
|
2010-02-06 17:43:14 +01:00
|
|
|
libvlc_retain(instance);
|
2009-09-16 09:28:23 +02:00
|
|
|
return mp;
|
2019-05-13 14:01:55 +02:00
|
|
|
|
|
|
|
error3:
|
|
|
|
vlc_player_RemoveListener(mp->player, mp->listener);
|
|
|
|
error2:
|
|
|
|
vlc_player_Unlock(mp->player);
|
|
|
|
vlc_player_Delete(mp->player);
|
|
|
|
error1:
|
|
|
|
vlc_object_delete(mp);
|
|
|
|
return NULL;
|
2007-06-24 15:19:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2009-03-04 11:38:26 +01:00
|
|
|
* Create a Media Instance object with a media descriptor.
|
2007-06-24 15:19:21 +02:00
|
|
|
**************************************************************************/
|
2008-03-30 03:59:32 +02:00
|
|
|
libvlc_media_player_t *
|
2022-06-14 17:41:12 +02:00
|
|
|
libvlc_media_player_new_from_media( libvlc_instance_t *inst,
|
|
|
|
libvlc_media_t * p_md )
|
2007-06-17 22:54:32 +02:00
|
|
|
{
|
2008-03-30 03:59:32 +02:00
|
|
|
libvlc_media_player_t * p_mi;
|
2007-06-17 22:54:32 +02:00
|
|
|
|
2022-06-14 17:41:12 +02:00
|
|
|
p_mi = libvlc_media_player_new( inst );
|
2007-08-07 20:59:45 +02:00
|
|
|
if( !p_mi )
|
2007-06-17 22:54:32 +02:00
|
|
|
return NULL;
|
|
|
|
|
2008-03-30 03:59:32 +02:00
|
|
|
libvlc_media_retain( p_md );
|
2007-08-25 16:35:40 +02:00
|
|
|
p_mi->p_md = p_md;
|
2019-05-13 14:01:55 +02:00
|
|
|
media_attach_preparsed_event(p_md);
|
|
|
|
|
|
|
|
vlc_player_Lock(p_mi->player);
|
|
|
|
int ret = vlc_player_SetCurrentMedia(p_mi->player, p_md->p_input_item);
|
|
|
|
vlc_player_Unlock(p_mi->player);
|
|
|
|
|
|
|
|
if (ret != VLC_SUCCESS)
|
|
|
|
{
|
|
|
|
media_detach_preparsed_event(p_md);
|
|
|
|
libvlc_media_release(p_md);
|
|
|
|
p_mi->p_md = NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
2007-06-17 22:54:32 +02:00
|
|
|
|
|
|
|
return p_mi;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2007-06-24 15:26:17 +02:00
|
|
|
* Destroy a Media Instance object (libvlc internal)
|
2007-07-08 17:22:53 +02:00
|
|
|
*
|
2009-03-04 11:38:26 +01:00
|
|
|
* Warning: No lock held here, but hey, this is internal. Caller must lock.
|
2007-06-17 22:54:32 +02:00
|
|
|
**************************************************************************/
|
2009-05-13 17:50:46 +02:00
|
|
|
static void libvlc_media_player_destroy( libvlc_media_player_t *p_mi )
|
2007-06-17 22:54:32 +02:00
|
|
|
{
|
2009-05-13 17:50:46 +02:00
|
|
|
assert( p_mi );
|
2009-05-09 21:57:51 +02:00
|
|
|
|
2009-05-13 17:50:46 +02:00
|
|
|
/* Detach Callback from the main libvlc object */
|
2019-02-19 16:31:20 +01:00
|
|
|
var_DelCallback( vlc_object_instance(p_mi),
|
2009-09-16 09:28:23 +02:00
|
|
|
"snapshot-file", snapshot_was_taken, p_mi );
|
2008-10-30 10:45:56 +01:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_Lock(p_mi->player);
|
|
|
|
vlc_player_aout_RemoveListener(p_mi->player, p_mi->aout_listener);
|
|
|
|
vlc_player_RemoveListener(p_mi->player, p_mi->listener);
|
|
|
|
vlc_player_Unlock(p_mi->player);
|
2017-12-01 15:06:07 +01:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_Delete(p_mi->player);
|
2009-08-25 19:11:06 +02:00
|
|
|
|
2019-06-17 11:44:00 +02:00
|
|
|
if (p_mi->p_md)
|
|
|
|
media_detach_preparsed_event(p_mi->p_md);
|
2017-05-15 19:16:45 +02:00
|
|
|
libvlc_event_manager_destroy(&p_mi->event_manager);
|
2009-05-20 20:55:55 +02:00
|
|
|
libvlc_media_release( p_mi->p_md );
|
2010-02-06 17:43:14 +01:00
|
|
|
|
|
|
|
libvlc_instance_t *instance = p_mi->p_libvlc_instance;
|
2019-03-06 19:15:18 +01:00
|
|
|
vlc_object_delete(p_mi);
|
2010-02-06 17:43:14 +01:00
|
|
|
libvlc_release(instance);
|
2007-06-17 22:54:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2009-03-04 11:38:26 +01:00
|
|
|
* Release a Media Instance object.
|
|
|
|
*
|
|
|
|
* Function does the locking.
|
2007-06-17 22:54:32 +02:00
|
|
|
**************************************************************************/
|
2008-03-30 03:59:32 +02:00
|
|
|
void libvlc_media_player_release( libvlc_media_player_t *p_mi )
|
2007-06-17 22:54:32 +02:00
|
|
|
{
|
2009-05-13 17:50:46 +02:00
|
|
|
assert( p_mi );
|
2020-11-21 12:45:14 +01:00
|
|
|
if( !vlc_atomic_rc_dec( &p_mi->rc ) )
|
|
|
|
return;
|
2009-05-10 16:05:07 +02:00
|
|
|
|
2020-11-21 12:45:14 +01:00
|
|
|
libvlc_media_player_destroy( p_mi );
|
2007-06-24 15:19:21 +02:00
|
|
|
}
|
2007-06-23 13:40:40 +02:00
|
|
|
|
2007-08-08 23:12:02 +02:00
|
|
|
/**************************************************************************
|
2009-03-04 11:38:26 +01:00
|
|
|
* Retain a Media Instance object.
|
|
|
|
*
|
|
|
|
* Caller must hold the lock.
|
2007-08-08 23:12:02 +02:00
|
|
|
**************************************************************************/
|
2023-03-23 11:04:35 +01:00
|
|
|
libvlc_media_player_t *libvlc_media_player_retain( libvlc_media_player_t *p_mi )
|
2007-08-08 23:12:02 +02:00
|
|
|
{
|
2009-05-13 17:51:01 +02:00
|
|
|
assert( p_mi );
|
2020-11-21 12:45:14 +01:00
|
|
|
vlc_atomic_rc_inc( &p_mi->rc );
|
2023-03-23 11:04:35 +01:00
|
|
|
return p_mi;
|
2007-08-08 23:12:02 +02:00
|
|
|
}
|
2007-10-02 13:29:20 +02:00
|
|
|
|
2007-06-24 15:19:21 +02:00
|
|
|
/**************************************************************************
|
2009-03-04 11:38:26 +01:00
|
|
|
* Set the Media descriptor associated with the instance.
|
|
|
|
*
|
|
|
|
* Enter without lock -- function will lock the object.
|
2007-06-24 15:19:21 +02:00
|
|
|
**************************************************************************/
|
2008-03-30 03:59:32 +02:00
|
|
|
void libvlc_media_player_set_media(
|
|
|
|
libvlc_media_player_t *p_mi,
|
2010-01-24 10:09:46 +01:00
|
|
|
libvlc_media_t *p_md )
|
2007-06-24 15:19:21 +02:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_Lock(p_mi->player);
|
2009-12-07 20:35:10 +01:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
if (p_mi->p_md)
|
|
|
|
media_detach_preparsed_event(p_mi->p_md);
|
2008-01-16 11:32:14 +01:00
|
|
|
|
2008-03-30 03:59:32 +02:00
|
|
|
libvlc_media_release( p_mi->p_md );
|
2007-06-17 22:54:32 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
if( p_md )
|
2007-06-24 15:19:21 +02:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
libvlc_media_retain( p_md );
|
|
|
|
media_attach_preparsed_event(p_md);
|
2007-06-24 15:19:21 +02:00
|
|
|
}
|
2007-08-25 16:35:40 +02:00
|
|
|
p_mi->p_md = p_md;
|
2008-05-18 13:09:26 +02:00
|
|
|
|
2021-11-02 08:09:19 +01:00
|
|
|
vlc_player_SetCurrentMedia(p_mi->player, p_md ? p_md->p_input_item : NULL);
|
2019-05-13 14:01:55 +02:00
|
|
|
|
|
|
|
vlc_player_Unlock(p_mi->player);
|
2007-06-24 15:19:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2009-03-04 11:38:26 +01:00
|
|
|
* Get the Media descriptor associated with the instance.
|
2007-06-24 15:19:21 +02:00
|
|
|
**************************************************************************/
|
2008-03-30 03:59:32 +02:00
|
|
|
libvlc_media_t *
|
2010-01-24 10:09:46 +01:00
|
|
|
libvlc_media_player_get_media( libvlc_media_player_t *p_mi )
|
2007-06-24 15:19:21 +02:00
|
|
|
{
|
2009-07-12 22:18:23 +02:00
|
|
|
libvlc_media_t *p_m;
|
2007-06-24 15:19:21 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_Lock(p_mi->player);
|
2009-07-12 22:18:23 +02:00
|
|
|
p_m = p_mi->p_md;
|
|
|
|
if( p_m )
|
2014-04-06 12:49:30 +02:00
|
|
|
libvlc_media_retain( p_m );
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_Unlock(p_mi->player);
|
2014-04-06 12:49:30 +02:00
|
|
|
|
|
|
|
return p_m;
|
2007-06-17 22:54:32 +02:00
|
|
|
}
|
|
|
|
|
2007-08-08 01:51:17 +02:00
|
|
|
/**************************************************************************
|
2009-03-04 11:38:26 +01:00
|
|
|
* Get the event Manager.
|
2007-08-08 01:51:17 +02:00
|
|
|
**************************************************************************/
|
|
|
|
libvlc_event_manager_t *
|
2010-01-24 10:09:46 +01:00
|
|
|
libvlc_media_player_event_manager( libvlc_media_player_t *p_mi )
|
2007-08-08 01:51:17 +02:00
|
|
|
{
|
2017-05-15 19:16:45 +02:00
|
|
|
return &p_mi->event_manager;
|
2007-08-08 01:51:17 +02:00
|
|
|
}
|
|
|
|
|
2007-06-17 22:54:32 +02:00
|
|
|
/**************************************************************************
|
2009-03-04 11:38:26 +01:00
|
|
|
* Tell media player to start playing.
|
2007-06-17 22:54:32 +02:00
|
|
|
**************************************************************************/
|
2010-01-31 18:30:49 +01:00
|
|
|
int libvlc_media_player_play( libvlc_media_player_t *p_mi )
|
2007-06-17 22:54:32 +02:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
vlc_player_Lock(player);
|
2007-06-17 22:54:32 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
int ret = vlc_player_Start(player);
|
|
|
|
if (ret == VLC_SUCCESS)
|
2007-06-17 22:54:32 +02:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
if (vlc_player_IsPaused(player))
|
|
|
|
vlc_player_Resume(player);
|
2007-06-17 22:54:32 +02:00
|
|
|
}
|
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_Unlock(player);
|
|
|
|
return ret;
|
2007-06-17 22:54:32 +02:00
|
|
|
}
|
|
|
|
|
2010-06-27 15:52:58 +02:00
|
|
|
void libvlc_media_player_set_pause( libvlc_media_player_t *p_mi, int paused )
|
2007-06-17 22:54:32 +02:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
vlc_player_Lock(player);
|
2007-06-17 22:54:32 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
if (paused)
|
2008-01-07 19:09:45 +01:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
if (vlc_player_CanPause(player))
|
|
|
|
vlc_player_Pause(player);
|
2017-09-28 04:34:20 +02:00
|
|
|
else
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_Stop(player);
|
2008-01-07 19:09:45 +01:00
|
|
|
}
|
2008-01-07 16:49:39 +01:00
|
|
|
else
|
2010-06-27 15:52:58 +02:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_Resume(player);
|
2010-06-27 15:52:58 +02:00
|
|
|
}
|
2008-01-07 19:09:45 +01:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_Unlock(player);
|
2007-06-17 22:54:32 +02:00
|
|
|
}
|
2006-06-05 20:23:56 +02:00
|
|
|
|
2010-06-27 15:52:58 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* Toggle pause.
|
|
|
|
**************************************************************************/
|
|
|
|
void libvlc_media_player_pause( libvlc_media_player_t *p_mi )
|
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
vlc_player_Lock(player);
|
|
|
|
|
|
|
|
vlc_player_TogglePause(player);
|
|
|
|
|
|
|
|
vlc_player_Unlock(player);
|
2010-06-27 15:52:58 +02:00
|
|
|
}
|
|
|
|
|
2009-01-06 22:48:03 +01:00
|
|
|
/**************************************************************************
|
2009-03-04 11:38:26 +01:00
|
|
|
* Tells whether the media player is currently playing.
|
2009-01-06 22:48:03 +01:00
|
|
|
**************************************************************************/
|
2019-05-19 09:44:21 +02:00
|
|
|
bool libvlc_media_player_is_playing(libvlc_media_player_t *p_mi)
|
2009-01-06 22:48:03 +01:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
vlc_player_Lock(player);
|
|
|
|
|
|
|
|
bool ret = vlc_player_IsStarted(player) && !vlc_player_IsPaused(player);
|
|
|
|
|
|
|
|
vlc_player_Unlock(player);
|
|
|
|
return ret;
|
2009-01-06 22:48:03 +01:00
|
|
|
}
|
|
|
|
|
2007-08-08 23:12:02 +02:00
|
|
|
/**************************************************************************
|
2009-03-04 11:38:26 +01:00
|
|
|
* Stop playing.
|
2007-08-08 23:12:02 +02:00
|
|
|
**************************************************************************/
|
2019-11-07 11:42:03 +01:00
|
|
|
int libvlc_media_player_stop_async( libvlc_media_player_t *p_mi )
|
2007-08-08 23:12:02 +02:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
vlc_player_Lock(player);
|
2008-05-30 05:12:38 +02:00
|
|
|
|
2019-11-07 11:42:03 +01:00
|
|
|
int ret = vlc_player_Stop(player);
|
2010-06-08 20:05:44 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_Unlock(player);
|
2019-11-07 11:42:03 +01:00
|
|
|
|
|
|
|
return ret;
|
2007-08-09 14:45:37 +02:00
|
|
|
}
|
|
|
|
|
2016-09-19 19:01:50 +02:00
|
|
|
int libvlc_media_player_set_renderer( libvlc_media_player_t *p_mi,
|
2017-12-01 15:06:07 +01:00
|
|
|
libvlc_renderer_item_t *p_litem )
|
2016-09-19 19:01:50 +02:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
vlc_player_Lock(player);
|
2017-12-01 15:06:07 +01:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_renderer_item_t *renderer = libvlc_renderer_item_to_vlc(p_litem);
|
|
|
|
vlc_player_SetRenderer(player, renderer);
|
2016-09-19 19:01:50 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_Unlock(player);
|
2016-09-19 19:01:50 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2010-07-10 17:09:05 +02:00
|
|
|
|
|
|
|
void libvlc_video_set_callbacks( libvlc_media_player_t *mp,
|
|
|
|
void *(*lock_cb) (void *, void **),
|
|
|
|
void (*unlock_cb) (void *, void *, void *const *),
|
|
|
|
void (*display_cb) (void *, void *),
|
|
|
|
void *opaque )
|
|
|
|
{
|
|
|
|
var_SetAddress( mp, "vmem-lock", lock_cb );
|
|
|
|
var_SetAddress( mp, "vmem-unlock", unlock_cb );
|
|
|
|
var_SetAddress( mp, "vmem-display", display_cb );
|
|
|
|
var_SetAddress( mp, "vmem-data", opaque );
|
2019-07-22 13:58:20 +02:00
|
|
|
var_SetString( mp, "dec-dev", "none" );
|
2015-04-15 17:41:20 +02:00
|
|
|
var_SetString( mp, "vout", "vmem" );
|
2018-05-21 18:10:26 +02:00
|
|
|
var_SetString( mp, "window", "dummy" );
|
2010-07-10 17:09:05 +02:00
|
|
|
}
|
|
|
|
|
2010-11-21 14:54:13 +01:00
|
|
|
void libvlc_video_set_format_callbacks( libvlc_media_player_t *mp,
|
|
|
|
libvlc_video_format_cb setup,
|
|
|
|
libvlc_video_cleanup_cb cleanup )
|
|
|
|
{
|
|
|
|
var_SetAddress( mp, "vmem-setup", setup );
|
|
|
|
var_SetAddress( mp, "vmem-cleanup", cleanup );
|
|
|
|
}
|
|
|
|
|
2010-07-10 17:09:05 +02:00
|
|
|
void libvlc_video_set_format( libvlc_media_player_t *mp, const char *chroma,
|
|
|
|
unsigned width, unsigned height, unsigned pitch )
|
|
|
|
{
|
|
|
|
var_SetString( mp, "vmem-chroma", chroma );
|
|
|
|
var_SetInteger( mp, "vmem-width", width );
|
|
|
|
var_SetInteger( mp, "vmem-height", height );
|
|
|
|
var_SetInteger( mp, "vmem-pitch", pitch );
|
|
|
|
}
|
|
|
|
|
2019-05-19 09:44:21 +02:00
|
|
|
bool libvlc_video_set_output_callbacks(libvlc_media_player_t *mp,
|
|
|
|
libvlc_video_engine_t engine,
|
2020-02-05 15:18:35 +01:00
|
|
|
libvlc_video_output_setup_cb setup_cb,
|
2020-02-04 14:27:53 +01:00
|
|
|
libvlc_video_output_cleanup_cb cleanup_cb,
|
2020-02-04 15:31:42 +01:00
|
|
|
libvlc_video_output_set_resize_cb resize_cb,
|
2019-05-19 09:44:21 +02:00
|
|
|
libvlc_video_update_output_cb update_output_cb,
|
|
|
|
libvlc_video_swap_cb swap_cb,
|
|
|
|
libvlc_video_makeCurrent_cb makeCurrent_cb,
|
|
|
|
libvlc_video_getProcAddress_cb getProcAddress_cb,
|
2020-02-04 15:40:02 +01:00
|
|
|
libvlc_video_frameMetadata_cb metadata_cb,
|
|
|
|
libvlc_video_output_select_plane_cb select_plane_cb,
|
2019-05-19 09:44:21 +02:00
|
|
|
void *opaque)
|
2018-07-25 15:41:08 +02:00
|
|
|
{
|
2020-02-11 15:29:02 +01:00
|
|
|
static_assert(libvlc_video_engine_disable == 0, "No engine set must default to 0");
|
2020-02-04 15:31:42 +01:00
|
|
|
var_SetString( mp, "window", "wextern");
|
2018-07-25 15:41:08 +02:00
|
|
|
|
2018-11-20 09:34:25 +01:00
|
|
|
if( engine == libvlc_video_engine_gles2 )
|
2018-07-25 15:41:08 +02:00
|
|
|
{
|
|
|
|
var_SetString ( mp, "vout", "gles2" );
|
|
|
|
var_SetString ( mp, "gles2", "vgl" );
|
|
|
|
}
|
2018-11-20 11:18:25 +01:00
|
|
|
else if( engine == libvlc_video_engine_opengl )
|
2018-07-25 15:41:08 +02:00
|
|
|
{
|
|
|
|
var_SetString ( mp, "vout", "gl" );
|
|
|
|
var_SetString ( mp, "gl", "vgl");
|
|
|
|
}
|
2020-02-11 13:59:10 +01:00
|
|
|
else if ( engine == libvlc_video_engine_d3d11 )
|
2019-03-20 15:10:52 +01:00
|
|
|
{
|
|
|
|
var_SetString ( mp, "vout", "direct3d11" );
|
2020-02-13 16:02:40 +01:00
|
|
|
var_SetString ( mp, "dec-dev", "d3d11" );
|
2019-03-20 15:10:52 +01:00
|
|
|
}
|
2020-02-11 13:59:49 +01:00
|
|
|
else if ( engine == libvlc_video_engine_d3d9 )
|
2019-03-20 15:10:52 +01:00
|
|
|
{
|
|
|
|
var_SetString ( mp, "vout", "direct3d9" );
|
2020-02-13 16:03:47 +01:00
|
|
|
var_SetString ( mp, "dec-dev", "d3d9" );
|
2019-03-20 15:10:52 +01:00
|
|
|
}
|
2020-02-11 15:29:02 +01:00
|
|
|
else if ( engine == libvlc_video_engine_disable )
|
|
|
|
{
|
|
|
|
// use the default display module
|
2022-01-31 20:32:38 +01:00
|
|
|
var_SetString ( mp, "vout", "any" );
|
2020-02-11 15:29:02 +01:00
|
|
|
// use the default window
|
2022-01-31 20:32:38 +01:00
|
|
|
var_SetString( mp, "window", "any" );
|
2020-02-11 15:29:02 +01:00
|
|
|
}
|
2019-03-20 15:10:52 +01:00
|
|
|
else
|
2019-05-19 09:44:21 +02:00
|
|
|
return false;
|
2019-03-20 15:10:52 +01:00
|
|
|
|
2020-02-11 15:29:02 +01:00
|
|
|
var_SetInteger( mp, "vout-cb-type", engine );
|
2019-03-20 15:10:52 +01:00
|
|
|
var_SetAddress( mp, "vout-cb-opaque", opaque );
|
|
|
|
var_SetAddress( mp, "vout-cb-setup", setup_cb );
|
|
|
|
var_SetAddress( mp, "vout-cb-cleanup", cleanup_cb );
|
2019-06-14 16:14:13 +02:00
|
|
|
var_SetAddress( mp, "vout-cb-resize-cb", resize_cb );
|
2019-03-20 15:10:52 +01:00
|
|
|
var_SetAddress( mp, "vout-cb-update-output", update_output_cb );
|
|
|
|
var_SetAddress( mp, "vout-cb-swap", swap_cb );
|
2020-02-04 15:52:04 +01:00
|
|
|
var_SetAddress( mp, "vout-cb-get-proc-address", getProcAddress_cb );
|
2019-03-20 15:10:52 +01:00
|
|
|
var_SetAddress( mp, "vout-cb-make-current", makeCurrent_cb );
|
2020-02-05 13:37:29 +01:00
|
|
|
var_SetAddress( mp, "vout-cb-metadata", metadata_cb );
|
2019-05-09 14:13:59 +02:00
|
|
|
var_SetAddress( mp, "vout-cb-select-plane", select_plane_cb );
|
2019-05-19 09:44:21 +02:00
|
|
|
return true;
|
2019-03-20 15:10:52 +01:00
|
|
|
}
|
|
|
|
|
2009-04-11 19:29:35 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* set_nsobject
|
|
|
|
**************************************************************************/
|
|
|
|
void libvlc_media_player_set_nsobject( libvlc_media_player_t *p_mi,
|
2010-01-24 10:09:46 +01:00
|
|
|
void * drawable )
|
2009-04-11 19:29:35 +02:00
|
|
|
{
|
2010-01-31 17:56:56 +01:00
|
|
|
assert (p_mi != NULL);
|
|
|
|
#ifdef __APPLE__
|
2022-01-31 20:32:38 +01:00
|
|
|
var_SetString (p_mi, "dec-dev", "any");
|
|
|
|
var_SetString (p_mi, "vout", "any");
|
|
|
|
var_SetString (p_mi, "window", "any");
|
2010-01-31 17:56:56 +01:00
|
|
|
var_SetAddress (p_mi, "drawable-nsobject", drawable);
|
|
|
|
#else
|
2015-10-15 14:05:38 +02:00
|
|
|
(void)drawable;
|
|
|
|
libvlc_printerr ("can't set nsobject: APPLE build required");
|
|
|
|
assert(false);
|
|
|
|
var_SetString (p_mi, "window", "none");
|
2010-01-31 17:56:56 +01:00
|
|
|
#endif
|
2009-04-11 19:29:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2009-05-01 16:31:37 +02:00
|
|
|
* get_nsobject
|
2009-04-11 19:29:35 +02:00
|
|
|
**************************************************************************/
|
2009-05-25 12:04:23 +02:00
|
|
|
void * libvlc_media_player_get_nsobject( libvlc_media_player_t *p_mi )
|
2009-04-11 19:29:35 +02:00
|
|
|
{
|
2010-01-31 17:56:56 +01:00
|
|
|
assert (p_mi != NULL);
|
|
|
|
#ifdef __APPLE__
|
|
|
|
return var_GetAddress (p_mi, "drawable-nsobject");
|
|
|
|
#else
|
2015-10-15 14:02:55 +02:00
|
|
|
(void) p_mi;
|
2010-01-31 17:56:56 +01:00
|
|
|
return NULL;
|
|
|
|
#endif
|
2009-04-11 19:29:35 +02:00
|
|
|
}
|
|
|
|
|
2009-03-04 11:38:26 +01:00
|
|
|
/**************************************************************************
|
|
|
|
* set_xwindow
|
|
|
|
**************************************************************************/
|
2009-02-09 17:28:20 +01:00
|
|
|
void libvlc_media_player_set_xwindow( libvlc_media_player_t *p_mi,
|
2010-01-24 10:09:46 +01:00
|
|
|
uint32_t drawable )
|
2009-02-07 18:21:01 +01:00
|
|
|
{
|
2010-01-31 17:56:56 +01:00
|
|
|
assert (p_mi != NULL);
|
2010-07-08 19:24:32 +02:00
|
|
|
|
2022-01-31 20:32:38 +01:00
|
|
|
var_SetString (p_mi, "dec-dev", "any");
|
|
|
|
var_SetString (p_mi, "vout", "any");
|
|
|
|
var_SetString (p_mi, "window", drawable ? "embed-xid,any" : "any");
|
2010-01-31 17:56:56 +01:00
|
|
|
var_SetInteger (p_mi, "drawable-xid", drawable);
|
2009-02-07 18:21:01 +01:00
|
|
|
}
|
|
|
|
|
2009-03-04 11:38:26 +01:00
|
|
|
/**************************************************************************
|
|
|
|
* get_xwindow
|
|
|
|
**************************************************************************/
|
2009-02-12 21:22:34 +01:00
|
|
|
uint32_t libvlc_media_player_get_xwindow( libvlc_media_player_t *p_mi )
|
|
|
|
{
|
2010-01-31 17:56:56 +01:00
|
|
|
return var_GetInteger (p_mi, "drawable-xid");
|
2009-02-12 21:22:34 +01:00
|
|
|
}
|
|
|
|
|
2009-03-04 11:38:26 +01:00
|
|
|
/**************************************************************************
|
|
|
|
* set_hwnd
|
|
|
|
**************************************************************************/
|
2009-02-07 18:21:01 +01:00
|
|
|
void libvlc_media_player_set_hwnd( libvlc_media_player_t *p_mi,
|
2010-01-24 10:09:46 +01:00
|
|
|
void *drawable )
|
2009-02-07 18:21:01 +01:00
|
|
|
{
|
2010-01-31 17:56:56 +01:00
|
|
|
assert (p_mi != NULL);
|
2013-06-05 15:41:18 +02:00
|
|
|
#if defined (_WIN32) || defined (__OS2__)
|
2022-01-31 20:32:38 +01:00
|
|
|
var_SetString (p_mi, "dec-dev", "any");
|
|
|
|
var_SetString (p_mi, "vout", "any");
|
2010-07-08 19:19:49 +02:00
|
|
|
var_SetString (p_mi, "window",
|
2022-01-31 20:32:38 +01:00
|
|
|
(drawable != NULL) ? "embed-hwnd,any" : "any");
|
2011-04-11 17:21:34 +02:00
|
|
|
var_SetInteger (p_mi, "drawable-hwnd", (uintptr_t)drawable);
|
2010-01-31 17:56:56 +01:00
|
|
|
#else
|
2015-10-15 14:05:38 +02:00
|
|
|
(void) drawable;
|
2018-10-12 19:38:45 +02:00
|
|
|
libvlc_printerr ("can't set hwnd: WIN32 build required");
|
2015-10-15 14:05:38 +02:00
|
|
|
assert(false);
|
|
|
|
var_SetString (p_mi, "window", "none");
|
2010-01-31 17:56:56 +01:00
|
|
|
#endif
|
2009-02-07 18:21:01 +01:00
|
|
|
}
|
|
|
|
|
2009-03-04 11:38:26 +01:00
|
|
|
/**************************************************************************
|
|
|
|
* get_hwnd
|
|
|
|
**************************************************************************/
|
2009-02-12 21:22:34 +01:00
|
|
|
void *libvlc_media_player_get_hwnd( libvlc_media_player_t *p_mi )
|
|
|
|
{
|
2010-01-31 17:56:56 +01:00
|
|
|
assert (p_mi != NULL);
|
2013-06-05 15:41:18 +02:00
|
|
|
#if defined (_WIN32) || defined (__OS2__)
|
2011-04-11 17:21:34 +02:00
|
|
|
return (void *)(uintptr_t)var_GetInteger (p_mi, "drawable-hwnd");
|
2010-01-31 17:56:56 +01:00
|
|
|
#else
|
2015-10-15 14:02:55 +02:00
|
|
|
(void) p_mi;
|
2010-01-31 17:56:56 +01:00
|
|
|
return NULL;
|
|
|
|
#endif
|
2009-02-12 21:22:34 +01:00
|
|
|
}
|
|
|
|
|
2015-06-25 13:52:59 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* set_android_context
|
|
|
|
**************************************************************************/
|
|
|
|
void libvlc_media_player_set_android_context( libvlc_media_player_t *p_mi,
|
|
|
|
void *p_awindow_handler )
|
|
|
|
{
|
|
|
|
assert (p_mi != NULL);
|
|
|
|
#ifdef __ANDROID__
|
|
|
|
var_SetAddress (p_mi, "drawable-androidwindow", p_awindow_handler);
|
|
|
|
#else
|
2016-02-23 16:16:28 +01:00
|
|
|
(void) p_awindow_handler;
|
2015-10-15 14:05:38 +02:00
|
|
|
libvlc_printerr ("can't set android context: ANDROID build required");
|
|
|
|
assert(false);
|
|
|
|
var_SetString (p_mi, "window", "none");
|
2015-06-25 13:52:59 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2011-05-10 19:56:21 +02:00
|
|
|
void libvlc_audio_set_callbacks( libvlc_media_player_t *mp,
|
|
|
|
libvlc_audio_play_cb play_cb,
|
2011-08-04 15:42:31 +02:00
|
|
|
libvlc_audio_pause_cb pause_cb,
|
|
|
|
libvlc_audio_resume_cb resume_cb,
|
|
|
|
libvlc_audio_flush_cb flush_cb,
|
|
|
|
libvlc_audio_drain_cb drain_cb,
|
2011-05-10 19:56:21 +02:00
|
|
|
void *opaque )
|
|
|
|
{
|
|
|
|
var_SetAddress( mp, "amem-play", play_cb );
|
2011-08-04 15:42:31 +02:00
|
|
|
var_SetAddress( mp, "amem-pause", pause_cb );
|
|
|
|
var_SetAddress( mp, "amem-resume", resume_cb );
|
|
|
|
var_SetAddress( mp, "amem-flush", flush_cb );
|
|
|
|
var_SetAddress( mp, "amem-drain", drain_cb );
|
2011-05-10 19:56:21 +02:00
|
|
|
var_SetAddress( mp, "amem-data", opaque );
|
2011-08-04 18:41:07 +02:00
|
|
|
var_SetString( mp, "aout", "amem,none" );
|
2020-07-22 15:48:42 +02:00
|
|
|
|
|
|
|
vlc_player_aout_Reset( mp->player );
|
2011-05-10 19:56:21 +02:00
|
|
|
}
|
|
|
|
|
2011-08-04 15:42:31 +02:00
|
|
|
void libvlc_audio_set_volume_callback( libvlc_media_player_t *mp,
|
|
|
|
libvlc_audio_set_volume_cb cb )
|
|
|
|
{
|
|
|
|
var_SetAddress( mp, "amem-set-volume", cb );
|
2020-07-22 15:48:42 +02:00
|
|
|
|
|
|
|
vlc_player_aout_Reset( mp->player );
|
2011-08-04 15:42:31 +02:00
|
|
|
}
|
|
|
|
|
2011-05-10 19:56:21 +02:00
|
|
|
void libvlc_audio_set_format_callbacks( libvlc_media_player_t *mp,
|
|
|
|
libvlc_audio_setup_cb setup,
|
|
|
|
libvlc_audio_cleanup_cb cleanup )
|
|
|
|
{
|
|
|
|
var_SetAddress( mp, "amem-setup", setup );
|
|
|
|
var_SetAddress( mp, "amem-cleanup", cleanup );
|
2020-07-22 15:48:42 +02:00
|
|
|
|
|
|
|
vlc_player_aout_Reset( mp->player );
|
2011-05-10 19:56:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void libvlc_audio_set_format( libvlc_media_player_t *mp, const char *format,
|
|
|
|
unsigned rate, unsigned channels )
|
|
|
|
{
|
|
|
|
var_SetString( mp, "amem-format", format );
|
|
|
|
var_SetInteger( mp, "amem-rate", rate );
|
|
|
|
var_SetInteger( mp, "amem-channels", channels );
|
2020-07-22 15:48:42 +02:00
|
|
|
|
|
|
|
vlc_player_aout_Reset( mp->player );
|
2011-05-10 19:56:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-05 20:23:56 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* Getters for stream information
|
|
|
|
**************************************************************************/
|
2008-03-30 03:59:32 +02:00
|
|
|
libvlc_time_t libvlc_media_player_get_length(
|
2010-01-31 18:30:49 +01:00
|
|
|
libvlc_media_player_t *p_mi )
|
2006-06-05 20:23:56 +02:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
vlc_player_Lock(player);
|
2006-06-05 20:23:56 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_tick_t length = vlc_player_GetLength(player);
|
2022-08-12 06:17:42 +02:00
|
|
|
libvlc_time_t i_time = libvlc_time_from_vlc_tick(length);
|
2006-01-08 17:32:33 +01:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_Unlock(player);
|
2010-01-16 16:11:08 +01:00
|
|
|
return i_time;
|
2006-01-08 17:32:33 +01:00
|
|
|
}
|
|
|
|
|
2010-01-31 18:30:49 +01:00
|
|
|
libvlc_time_t libvlc_media_player_get_time( libvlc_media_player_t *p_mi )
|
2006-01-08 17:32:33 +01:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
vlc_player_Lock(player);
|
2006-01-08 17:32:33 +01:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_tick_t tick = vlc_player_GetTime(player);
|
2022-08-12 06:17:42 +02:00
|
|
|
libvlc_time_t i_time = libvlc_time_from_vlc_tick(tick);
|
2006-06-05 20:23:56 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_Unlock(player);
|
2010-01-16 16:11:08 +01:00
|
|
|
return i_time;
|
2006-01-08 17:32:33 +01:00
|
|
|
}
|
|
|
|
|
2018-06-25 10:03:50 +02:00
|
|
|
int libvlc_media_player_set_time( libvlc_media_player_t *p_mi,
|
|
|
|
libvlc_time_t i_time, bool b_fast )
|
2006-07-31 11:31:35 +02:00
|
|
|
{
|
2022-08-12 06:17:42 +02:00
|
|
|
vlc_tick_t tick = vlc_tick_from_libvlc_time(i_time);
|
2019-05-13 14:01:55 +02:00
|
|
|
|
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
vlc_player_Lock(player);
|
|
|
|
|
|
|
|
enum vlc_player_seek_speed speed = b_fast ? VLC_PLAYER_SEEK_FAST
|
|
|
|
: VLC_PLAYER_SEEK_PRECISE;
|
|
|
|
vlc_player_SeekByTime(player, tick, speed, VLC_PLAYER_WHENCE_ABSOLUTE);
|
2006-07-31 11:31:35 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_Unlock(player);
|
2006-10-29 10:35:43 +01:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
/* may not fail anymore, keep int not to break the API */
|
2018-06-25 10:03:50 +02:00
|
|
|
return 0;
|
2006-07-31 11:31:35 +02:00
|
|
|
}
|
|
|
|
|
2018-06-25 10:03:50 +02:00
|
|
|
int libvlc_media_player_set_position( libvlc_media_player_t *p_mi,
|
2022-08-08 09:37:13 +02:00
|
|
|
double position, bool b_fast )
|
2006-07-31 11:31:35 +02:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
vlc_player_Lock(player);
|
2006-10-29 10:35:43 +01:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
enum vlc_player_seek_speed speed = b_fast ? VLC_PLAYER_SEEK_FAST
|
|
|
|
: VLC_PLAYER_SEEK_PRECISE;
|
|
|
|
vlc_player_SeekByPos(player, position, speed, VLC_PLAYER_WHENCE_ABSOLUTE);
|
2006-07-31 11:31:35 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_Unlock(player);
|
|
|
|
|
|
|
|
/* may not fail anymore, keep int not to break the API */
|
2018-06-25 10:03:50 +02:00
|
|
|
return 0;
|
2006-07-31 11:31:35 +02:00
|
|
|
}
|
|
|
|
|
2022-08-03 13:07:39 +02:00
|
|
|
double libvlc_media_player_get_position( libvlc_media_player_t *p_mi )
|
2006-01-08 17:32:33 +01:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
vlc_player_Lock(player);
|
2006-06-05 20:23:56 +02:00
|
|
|
|
2022-08-03 13:07:39 +02:00
|
|
|
double f_position = vlc_player_GetPosition(player);
|
2006-01-08 17:32:33 +01:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_Unlock(player);
|
2009-08-17 15:21:44 +02:00
|
|
|
return f_position;
|
2006-01-08 17:32:33 +01:00
|
|
|
}
|
2006-06-02 13:27:30 +02:00
|
|
|
|
2010-01-31 18:30:49 +01:00
|
|
|
void libvlc_media_player_set_chapter( libvlc_media_player_t *p_mi,
|
|
|
|
int chapter )
|
2007-10-25 14:28:04 +02:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
vlc_player_Lock(player);
|
2007-10-25 14:28:04 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_SelectChapterIdx(player, chapter);
|
2007-10-25 14:28:04 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_Unlock(player);
|
2007-10-25 14:28:04 +02:00
|
|
|
}
|
|
|
|
|
2010-01-31 18:30:49 +01:00
|
|
|
int libvlc_media_player_get_chapter( libvlc_media_player_t *p_mi )
|
2007-10-25 14:28:04 +02:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
vlc_player_Lock(player);
|
2007-10-25 14:28:04 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
ssize_t i_chapter = vlc_player_GetSelectedChapterIdx(player);
|
2007-10-25 14:28:04 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_Unlock(player);
|
2009-08-17 15:21:44 +02:00
|
|
|
return i_chapter;
|
2007-10-25 14:28:04 +02:00
|
|
|
}
|
|
|
|
|
2010-01-31 18:30:49 +01:00
|
|
|
int libvlc_media_player_get_chapter_count( libvlc_media_player_t *p_mi )
|
2007-10-25 14:28:04 +02:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
vlc_player_Lock(player);
|
2007-10-25 14:28:04 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
const struct vlc_player_title *title = vlc_player_GetSelectedTitle(player);
|
|
|
|
int ret = title ? (int) title->chapter_count : -1;
|
2007-10-25 14:28:04 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_Unlock(player);
|
|
|
|
return ret;
|
2007-10-25 14:28:04 +02:00
|
|
|
}
|
|
|
|
|
2008-10-04 22:00:52 +02:00
|
|
|
int libvlc_media_player_get_chapter_count_for_title(
|
|
|
|
libvlc_media_player_t *p_mi,
|
2010-01-31 18:30:49 +01:00
|
|
|
int i_title )
|
2008-10-04 22:00:52 +02:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
assert(i_title >= 0);
|
|
|
|
size_t idx = i_title;
|
|
|
|
int ret = -1;
|
2008-10-04 22:00:52 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
vlc_player_Lock(player);
|
2008-10-04 22:00:52 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_title_list *titles = vlc_player_GetTitleList(player);
|
|
|
|
if (!titles)
|
|
|
|
goto end;
|
2015-05-23 18:08:27 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
size_t titles_count = vlc_player_title_list_GetCount(titles);
|
2021-04-08 19:30:53 +02:00
|
|
|
if (idx >= titles_count)
|
2019-05-13 14:01:55 +02:00
|
|
|
goto end;
|
2008-10-04 22:00:52 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
const struct vlc_player_title *title =
|
|
|
|
vlc_player_title_list_GetAt(titles, idx);
|
|
|
|
assert(title);
|
|
|
|
|
|
|
|
ret = title->chapter_count;
|
|
|
|
|
|
|
|
end:
|
|
|
|
vlc_player_Unlock(player);
|
|
|
|
return ret;
|
2008-10-04 22:00:52 +02:00
|
|
|
}
|
|
|
|
|
2010-01-31 18:30:49 +01:00
|
|
|
void libvlc_media_player_set_title( libvlc_media_player_t *p_mi,
|
|
|
|
int i_title )
|
2008-10-04 22:00:52 +02:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
vlc_player_Lock(player);
|
2008-10-04 22:00:52 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_SelectTitleIdx(player, i_title);
|
2008-10-04 22:00:52 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_Unlock(player);
|
2008-10-04 22:00:52 +02:00
|
|
|
}
|
|
|
|
|
2010-01-31 18:30:49 +01:00
|
|
|
int libvlc_media_player_get_title( libvlc_media_player_t *p_mi )
|
2008-10-04 22:00:52 +02:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
vlc_player_Lock(player);
|
2008-10-04 22:00:52 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
ssize_t i_title = vlc_player_GetSelectedTitleIdx(player);
|
2008-10-04 22:00:52 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_Unlock(player);
|
2009-08-17 15:21:44 +02:00
|
|
|
return i_title;
|
2008-10-04 22:00:52 +02:00
|
|
|
}
|
|
|
|
|
2010-01-31 18:30:49 +01:00
|
|
|
int libvlc_media_player_get_title_count( libvlc_media_player_t *p_mi )
|
2008-10-04 22:00:52 +02:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
vlc_player_Lock(player);
|
2008-10-04 22:00:52 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_title_list *titles = vlc_player_GetTitleList(player);
|
|
|
|
int ret = titles ? (int) vlc_player_title_list_GetCount(titles) : -1;
|
2008-10-04 22:00:52 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_Unlock(player);
|
|
|
|
return ret;
|
2008-10-04 22:00:52 +02:00
|
|
|
}
|
|
|
|
|
2015-01-26 20:37:02 +01:00
|
|
|
int libvlc_media_player_get_full_title_descriptions( libvlc_media_player_t *p_mi,
|
|
|
|
libvlc_title_description_t *** pp_titles )
|
|
|
|
{
|
|
|
|
assert( p_mi );
|
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
int ret = -1;
|
2015-01-26 20:37:02 +01:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
vlc_player_Lock(player);
|
2015-01-26 20:37:02 +01:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_title_list *titles = vlc_player_GetTitleList(player);
|
|
|
|
if (!titles)
|
|
|
|
goto end;
|
2015-01-26 20:37:02 +01:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
size_t count = vlc_player_title_list_GetCount(titles);
|
2015-01-26 20:37:02 +01:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
libvlc_title_description_t **descs = vlc_alloc(count, sizeof(*descs));
|
|
|
|
if (count > 0 && !descs)
|
|
|
|
goto end;
|
2015-01-26 20:37:02 +01:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
for (size_t i = 0; i < count; i++)
|
2015-01-26 20:37:02 +01:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
const struct vlc_player_title *title =
|
|
|
|
vlc_player_title_list_GetAt(titles, i);
|
|
|
|
libvlc_title_description_t *desc = malloc(sizeof(*desc));
|
|
|
|
if (!desc)
|
2015-01-26 20:37:02 +01:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
libvlc_title_descriptions_release(descs, i);
|
|
|
|
goto end;
|
2015-01-26 20:37:02 +01:00
|
|
|
}
|
2019-05-13 14:01:55 +02:00
|
|
|
|
|
|
|
descs[i] = desc;
|
2015-01-26 20:37:02 +01:00
|
|
|
|
|
|
|
/* we want to return milliseconds to match the rest of the API */
|
2019-05-13 14:01:55 +02:00
|
|
|
desc->i_duration = MS_FROM_VLC_TICK(title->length);
|
|
|
|
desc->i_flags = title->flags;
|
|
|
|
desc->psz_name = title->name ? strdup(title->name) : NULL;
|
2015-01-26 20:37:02 +01:00
|
|
|
}
|
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
ret = count;
|
|
|
|
*pp_titles = descs;
|
|
|
|
|
|
|
|
end:
|
|
|
|
vlc_player_Unlock(player);
|
|
|
|
return ret;
|
2015-01-26 20:37:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void libvlc_title_descriptions_release( libvlc_title_description_t **p_titles,
|
|
|
|
unsigned i_count )
|
|
|
|
{
|
|
|
|
for (unsigned i = 0; i < i_count; i++ )
|
|
|
|
{
|
|
|
|
if ( !p_titles[i] )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
free( p_titles[i]->psz_name );
|
|
|
|
free( p_titles[i] );
|
|
|
|
}
|
|
|
|
free( p_titles );
|
|
|
|
}
|
|
|
|
|
2015-06-04 14:02:44 +02:00
|
|
|
int libvlc_media_player_get_full_chapter_descriptions( libvlc_media_player_t *p_mi,
|
|
|
|
int i_chapters_of_title,
|
|
|
|
libvlc_chapter_description_t *** pp_chapters )
|
|
|
|
{
|
|
|
|
assert( p_mi );
|
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
int ret = -1;
|
2015-06-04 14:02:44 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
vlc_player_Lock(player);
|
2015-06-04 14:02:44 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_title_list *titles = vlc_player_GetTitleList(player);
|
|
|
|
if (!titles)
|
|
|
|
goto end;
|
2015-06-04 14:02:44 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
size_t titles_count = vlc_player_title_list_GetCount(titles);
|
2022-07-28 16:32:48 +02:00
|
|
|
|
|
|
|
ssize_t title_idx;
|
|
|
|
if (i_chapters_of_title < 0)
|
|
|
|
{
|
|
|
|
title_idx = vlc_player_GetSelectedTitleIdx(player);
|
|
|
|
if (title_idx == -1)
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
assert((size_t)title_idx < titles_count);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
title_idx = i_chapters_of_title;
|
|
|
|
|
|
|
|
if ((size_t) title_idx >= titles_count)
|
|
|
|
goto end;
|
|
|
|
}
|
2015-06-04 14:02:44 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
const struct vlc_player_title *title =
|
2022-07-28 16:32:48 +02:00
|
|
|
vlc_player_title_list_GetAt(titles, title_idx);
|
2019-05-13 14:01:55 +02:00
|
|
|
assert(title);
|
2015-06-04 14:02:44 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
size_t i_chapter_count = title->chapter_count;
|
2015-06-04 14:02:44 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
libvlc_chapter_description_t **descs =
|
|
|
|
vlc_alloc(i_chapter_count, sizeof(*descs));
|
|
|
|
if (i_chapter_count > 0 && !descs)
|
|
|
|
goto end;
|
2015-06-04 14:02:44 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
for (size_t i = 0; i < i_chapter_count; i++)
|
2015-06-04 14:02:44 +02:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
const struct vlc_player_chapter *chapter = &title->chapters[i];
|
|
|
|
libvlc_chapter_description_t *desc = malloc(sizeof(*desc));
|
|
|
|
if (!desc)
|
2015-06-04 14:02:44 +02:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
libvlc_chapter_descriptions_release(descs, i);
|
|
|
|
goto end;
|
2015-06-04 14:02:44 +02:00
|
|
|
}
|
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
descs[i] = desc;
|
2015-06-04 14:02:44 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_tick_t chapter_end = i < i_chapter_count - 1
|
|
|
|
? title->chapters[i + 1].time
|
|
|
|
: title->length;
|
|
|
|
desc->i_time_offset = MS_FROM_VLC_TICK(chapter->time);
|
|
|
|
desc->psz_name = chapter->name ? strdup(chapter->name) : NULL;
|
|
|
|
desc->i_duration = MS_FROM_VLC_TICK(chapter_end) - desc->i_time_offset;
|
2015-06-04 14:02:44 +02:00
|
|
|
}
|
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
ret = i_chapter_count;
|
|
|
|
*pp_chapters = descs;
|
2018-01-02 14:14:14 +01:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
end:
|
|
|
|
vlc_player_Unlock(player);
|
|
|
|
return ret;
|
2015-06-04 14:02:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void libvlc_chapter_descriptions_release( libvlc_chapter_description_t **p_chapters,
|
|
|
|
unsigned i_count )
|
|
|
|
{
|
|
|
|
for (unsigned i = 0; i < i_count; i++ )
|
|
|
|
{
|
|
|
|
if ( !p_chapters[i] )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
free( p_chapters[i]->psz_name );
|
|
|
|
free( p_chapters[i] );
|
|
|
|
}
|
|
|
|
free( p_chapters );
|
|
|
|
}
|
|
|
|
|
2010-01-31 18:30:49 +01:00
|
|
|
void libvlc_media_player_next_chapter( libvlc_media_player_t *p_mi )
|
2008-10-04 22:00:52 +02:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
vlc_player_Lock(player);
|
2008-10-04 22:00:52 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_SelectNextChapter(player);
|
2008-10-04 22:00:52 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_Unlock(player);
|
2008-10-04 22:00:52 +02:00
|
|
|
}
|
|
|
|
|
2010-01-31 18:30:49 +01:00
|
|
|
void libvlc_media_player_previous_chapter( libvlc_media_player_t *p_mi )
|
2008-10-04 22:00:52 +02:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
vlc_player_Lock(player);
|
2008-10-04 22:00:52 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_SelectPrevChapter(player);
|
2008-10-04 22:00:52 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_Unlock(player);
|
2008-10-04 22:00:52 +02:00
|
|
|
}
|
|
|
|
|
2010-01-31 18:30:49 +01:00
|
|
|
int libvlc_media_player_set_rate( libvlc_media_player_t *p_mi, float rate )
|
2006-09-04 19:51:10 +02:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
vlc_player_Lock(player);
|
2010-02-14 12:50:36 +01:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_ChangeRate(player, rate);
|
|
|
|
|
|
|
|
vlc_player_Unlock(player);
|
2010-01-31 18:30:49 +01:00
|
|
|
return 0;
|
2006-09-04 19:51:10 +02:00
|
|
|
}
|
|
|
|
|
2010-01-31 18:30:49 +01:00
|
|
|
float libvlc_media_player_get_rate( libvlc_media_player_t *p_mi )
|
2006-09-04 19:51:10 +02:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
vlc_player_Lock(player);
|
|
|
|
|
|
|
|
float rate = vlc_player_GetRate(player);
|
|
|
|
|
|
|
|
vlc_player_Unlock(player);
|
|
|
|
return rate;
|
2006-09-04 19:51:10 +02:00
|
|
|
}
|
|
|
|
|
2010-01-24 10:09:46 +01:00
|
|
|
libvlc_state_t libvlc_media_player_get_state( libvlc_media_player_t *p_mi )
|
2006-09-04 19:51:10 +02:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
vlc_player_Lock(player);
|
|
|
|
|
|
|
|
enum vlc_player_error error = vlc_player_GetError(player);
|
|
|
|
enum vlc_player_state state = vlc_player_GetState(player);
|
|
|
|
|
|
|
|
vlc_player_Unlock(player);
|
|
|
|
|
|
|
|
if (error != VLC_PLAYER_ERROR_NONE)
|
|
|
|
return libvlc_Error;
|
|
|
|
switch (state) {
|
|
|
|
case VLC_PLAYER_STATE_STOPPED:
|
|
|
|
return libvlc_Stopped;
|
|
|
|
case VLC_PLAYER_STATE_STOPPING:
|
2022-03-10 12:01:46 +01:00
|
|
|
return libvlc_Stopping;
|
2019-05-13 14:01:55 +02:00
|
|
|
case VLC_PLAYER_STATE_STARTED:
|
|
|
|
return libvlc_Opening;
|
|
|
|
case VLC_PLAYER_STATE_PLAYING:
|
|
|
|
return libvlc_Playing;
|
|
|
|
case VLC_PLAYER_STATE_PAUSED:
|
|
|
|
return libvlc_Paused;
|
|
|
|
default:
|
|
|
|
vlc_assert_unreachable();
|
|
|
|
}
|
2006-09-04 19:51:10 +02:00
|
|
|
}
|
2007-12-29 04:29:10 +01:00
|
|
|
|
2019-05-19 09:44:21 +02:00
|
|
|
bool libvlc_media_player_is_seekable(libvlc_media_player_t *p_mi)
|
2007-12-29 04:29:10 +01:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
vlc_player_Lock(player);
|
2007-12-29 04:29:10 +01:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
bool b_seekable = vlc_player_CanSeek(player);
|
2007-12-29 04:29:10 +01:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_Unlock(player);
|
2009-08-17 15:21:44 +02:00
|
|
|
return b_seekable;
|
2007-12-29 04:29:10 +01:00
|
|
|
}
|
2008-01-07 15:46:08 +01:00
|
|
|
|
2010-09-10 08:47:10 +02:00
|
|
|
void libvlc_media_player_navigate( libvlc_media_player_t* p_mi,
|
2011-09-15 15:59:21 +02:00
|
|
|
unsigned navigate )
|
2010-09-10 08:47:10 +02:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
static const enum vlc_player_nav map[] =
|
2013-02-01 16:58:31 +01:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
VLC_PLAYER_NAV_ACTIVATE, VLC_PLAYER_NAV_UP, VLC_PLAYER_NAV_DOWN,
|
|
|
|
VLC_PLAYER_NAV_LEFT, VLC_PLAYER_NAV_RIGHT, VLC_PLAYER_NAV_POPUP,
|
2013-02-01 16:58:31 +01:00
|
|
|
};
|
2010-09-10 08:47:10 +02:00
|
|
|
|
2013-02-01 16:58:31 +01:00
|
|
|
if( navigate >= sizeof(map) / sizeof(map[0]) )
|
2010-09-10 08:47:10 +02:00
|
|
|
return;
|
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
vlc_player_Lock(player);
|
2010-09-10 08:47:10 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_Navigate(player, map[navigate]);
|
|
|
|
|
|
|
|
vlc_player_Unlock(player);
|
2010-09-10 08:47:10 +02:00
|
|
|
}
|
|
|
|
|
2008-10-12 16:40:30 +02:00
|
|
|
/* internal function, used by audio, video */
|
|
|
|
libvlc_track_description_t *
|
|
|
|
libvlc_get_track_description( libvlc_media_player_t *p_mi,
|
2019-05-13 14:01:55 +02:00
|
|
|
enum es_format_category_e cat )
|
2008-10-12 16:40:30 +02:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
vlc_player_Lock(player);
|
2008-10-12 16:40:30 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
libvlc_track_description_t *ret, **pp = &ret;
|
2008-10-12 16:40:30 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
size_t count = vlc_player_GetTrackCount(player, cat);
|
2018-06-10 10:11:57 +02:00
|
|
|
for (size_t i = 0; i < count; i++)
|
2008-10-12 16:40:30 +02:00
|
|
|
{
|
2018-06-10 10:11:57 +02:00
|
|
|
libvlc_track_description_t *tr = malloc(sizeof (*tr));
|
|
|
|
if (unlikely(tr == NULL))
|
2008-10-12 16:40:30 +02:00
|
|
|
{
|
2018-06-10 10:11:57 +02:00
|
|
|
libvlc_printerr("Not enough memory");
|
|
|
|
continue;
|
2008-10-12 16:40:30 +02:00
|
|
|
}
|
2018-06-10 10:11:57 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
const struct vlc_player_track *track =
|
|
|
|
vlc_player_GetTrackAt(player, cat, i);
|
|
|
|
|
2018-06-10 10:11:57 +02:00
|
|
|
*pp = tr;
|
2019-05-13 14:01:55 +02:00
|
|
|
tr->i_id = vlc_es_id_GetInputId(track->es_id);
|
|
|
|
tr->psz_name = strdup(track->name);
|
|
|
|
if (unlikely(!tr->psz_name))
|
|
|
|
{
|
|
|
|
free(tr);
|
|
|
|
continue;
|
|
|
|
}
|
2018-06-10 10:11:57 +02:00
|
|
|
pp = &tr->p_next;
|
2008-10-12 16:40:30 +02:00
|
|
|
}
|
2009-05-20 22:06:07 +02:00
|
|
|
|
2018-06-10 10:11:57 +02:00
|
|
|
*pp = NULL;
|
2008-10-12 16:40:30 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_Unlock(player);
|
2018-06-10 10:11:57 +02:00
|
|
|
return ret;
|
2008-10-12 16:40:30 +02:00
|
|
|
}
|
|
|
|
|
2011-09-21 18:13:00 +02:00
|
|
|
void libvlc_track_description_list_release( libvlc_track_description_t *p_td )
|
2008-10-12 16:40:30 +02:00
|
|
|
{
|
|
|
|
libvlc_track_description_t *p_actual, *p_before;
|
2009-03-04 11:38:26 +01:00
|
|
|
p_actual = p_td;
|
2008-10-12 16:40:30 +02:00
|
|
|
|
|
|
|
while ( p_actual )
|
|
|
|
{
|
|
|
|
free( p_actual->psz_name );
|
|
|
|
p_before = p_actual;
|
|
|
|
p_actual = p_before->p_next;
|
|
|
|
free( p_before );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-19 09:44:21 +02:00
|
|
|
bool libvlc_media_player_can_pause(libvlc_media_player_t *p_mi)
|
2008-01-07 15:46:08 +01:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
vlc_player_Lock(player);
|
2008-01-07 15:46:08 +01:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
bool b_can_pause = vlc_player_CanPause(player);
|
2008-01-07 15:46:08 +01:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_Unlock(player);
|
2009-08-17 15:21:44 +02:00
|
|
|
return b_can_pause;
|
2008-01-07 15:46:08 +01:00
|
|
|
}
|
2009-08-13 14:17:07 +02:00
|
|
|
|
2019-05-19 09:44:21 +02:00
|
|
|
bool libvlc_media_player_program_scrambled(libvlc_media_player_t *p_mi)
|
2014-02-06 22:03:24 +01:00
|
|
|
{
|
2022-02-19 21:27:30 +01:00
|
|
|
const struct vlc_player_program *program;
|
2019-05-13 14:01:55 +02:00
|
|
|
bool b_program_scrambled = false;
|
2014-02-06 22:03:24 +01:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
vlc_player_Lock(player);
|
2022-02-19 21:27:30 +01:00
|
|
|
program = vlc_player_GetSelectedProgram(player);
|
|
|
|
if (program != NULL)
|
|
|
|
b_program_scrambled = program->scrambled;
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_Unlock(player);
|
2014-02-06 22:03:24 +01:00
|
|
|
return b_program_scrambled;
|
|
|
|
}
|
|
|
|
|
2010-01-31 18:30:49 +01:00
|
|
|
void libvlc_media_player_next_frame( libvlc_media_player_t *p_mi )
|
2009-08-13 14:17:07 +02:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
vlc_player_Lock(player);
|
|
|
|
|
|
|
|
vlc_player_NextVideoFrame(player);
|
|
|
|
|
|
|
|
vlc_player_Unlock(player);
|
2009-08-13 14:17:07 +02:00
|
|
|
}
|
2013-07-03 18:24:57 +02:00
|
|
|
|
2014-05-24 08:41:47 +02:00
|
|
|
/**
|
|
|
|
* Private lookup table to get subpicture alignment flag values corresponding
|
|
|
|
* to a libvlc_position_t enumerated value.
|
|
|
|
*/
|
2014-05-24 14:00:24 +02:00
|
|
|
static const unsigned char position_subpicture_alignment[] = {
|
|
|
|
[libvlc_position_center] = 0,
|
|
|
|
[libvlc_position_left] = SUBPICTURE_ALIGN_LEFT,
|
|
|
|
[libvlc_position_right] = SUBPICTURE_ALIGN_RIGHT,
|
|
|
|
[libvlc_position_top] = SUBPICTURE_ALIGN_TOP,
|
|
|
|
[libvlc_position_top_left] = SUBPICTURE_ALIGN_TOP | SUBPICTURE_ALIGN_LEFT,
|
|
|
|
[libvlc_position_top_right] = SUBPICTURE_ALIGN_TOP | SUBPICTURE_ALIGN_RIGHT,
|
|
|
|
[libvlc_position_bottom] = SUBPICTURE_ALIGN_BOTTOM,
|
|
|
|
[libvlc_position_bottom_left] = SUBPICTURE_ALIGN_BOTTOM | SUBPICTURE_ALIGN_LEFT,
|
|
|
|
[libvlc_position_bottom_right] = SUBPICTURE_ALIGN_BOTTOM | SUBPICTURE_ALIGN_RIGHT
|
2014-05-24 08:41:47 +02:00
|
|
|
};
|
|
|
|
|
2013-07-03 18:24:57 +02:00
|
|
|
void libvlc_media_player_set_video_title_display( libvlc_media_player_t *p_mi, libvlc_position_t position, unsigned timeout )
|
|
|
|
{
|
2014-05-24 08:41:47 +02:00
|
|
|
assert( position >= libvlc_position_disable && position <= libvlc_position_bottom_right );
|
|
|
|
|
2013-07-03 18:24:57 +02:00
|
|
|
if ( position != libvlc_position_disable )
|
|
|
|
{
|
|
|
|
var_SetBool( p_mi, "video-title-show", true );
|
2014-05-24 08:41:47 +02:00
|
|
|
var_SetInteger( p_mi, "video-title-position", position_subpicture_alignment[position] );
|
2013-07-03 18:24:57 +02:00
|
|
|
var_SetInteger( p_mi, "video-title-timeout", timeout );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var_SetBool( p_mi, "video-title-show", false );
|
|
|
|
}
|
|
|
|
}
|
2013-07-13 20:21:37 +02:00
|
|
|
|
2020-06-04 19:59:51 +02:00
|
|
|
libvlc_media_tracklist_t *
|
|
|
|
libvlc_media_player_get_tracklist(libvlc_media_player_t *p_mi,
|
2022-07-25 09:55:25 +02:00
|
|
|
libvlc_track_type_t type, bool selected)
|
2020-06-04 19:59:51 +02:00
|
|
|
{
|
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
|
|
|
|
vlc_player_Lock(player);
|
|
|
|
|
|
|
|
libvlc_media_tracklist_t *list =
|
2022-07-25 09:55:25 +02:00
|
|
|
libvlc_media_tracklist_from_player(player, type, selected);
|
2020-06-04 19:59:51 +02:00
|
|
|
|
|
|
|
vlc_player_Unlock(player);
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
libvlc_media_track_t *
|
|
|
|
libvlc_media_player_get_selected_track(libvlc_media_player_t *p_mi,
|
|
|
|
libvlc_track_type_t type)
|
|
|
|
{
|
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
|
|
|
|
vlc_player_Lock(player);
|
|
|
|
|
|
|
|
const enum es_format_category_e cat = libvlc_track_type_to_escat(type);
|
|
|
|
const struct vlc_player_track *track =
|
|
|
|
vlc_player_GetSelectedTrack(player, cat);
|
|
|
|
|
|
|
|
if (track == NULL)
|
|
|
|
{
|
|
|
|
vlc_player_Unlock(player);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
libvlc_media_track_t *libtrack =
|
|
|
|
libvlc_media_track_create_from_player_track(track);
|
|
|
|
vlc_player_Unlock(player);
|
|
|
|
|
|
|
|
return libtrack;
|
|
|
|
}
|
|
|
|
|
|
|
|
libvlc_media_track_t *
|
|
|
|
libvlc_media_player_get_track_from_id( libvlc_media_player_t *p_mi,
|
|
|
|
const char *psz_id )
|
|
|
|
{
|
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
|
|
|
|
vlc_player_Lock(player);
|
|
|
|
|
|
|
|
enum es_format_category_e cats[] = { VIDEO_ES, AUDIO_ES, SPU_ES };
|
|
|
|
for (size_t i = 0; i < ARRAY_SIZE(cats); ++i)
|
|
|
|
{
|
|
|
|
enum es_format_category_e cat = cats[i];
|
2020-07-02 18:32:55 +02:00
|
|
|
size_t count = vlc_player_GetTrackCount(player, cat);
|
2020-06-04 19:59:51 +02:00
|
|
|
|
|
|
|
for (size_t j = 0; j < count; ++j)
|
|
|
|
{
|
|
|
|
const struct vlc_player_track *track =
|
|
|
|
vlc_player_GetTrackAt(player, cat, j);
|
|
|
|
if (strcmp(psz_id, vlc_es_id_GetStrId(track->es_id)) == 0)
|
|
|
|
{
|
|
|
|
libvlc_media_track_t *libtrack =
|
|
|
|
libvlc_media_track_create_from_player_track(track);
|
|
|
|
vlc_player_Unlock(player);
|
|
|
|
return libtrack;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
vlc_player_Unlock(player);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
libvlc_media_player_select_track(libvlc_media_player_t *p_mi,
|
|
|
|
const libvlc_media_track_t *track)
|
|
|
|
{
|
2020-09-09 13:56:37 +02:00
|
|
|
assert( track != NULL );
|
2020-06-04 19:59:51 +02:00
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
|
|
|
|
vlc_player_Lock(player);
|
|
|
|
|
2020-09-09 13:56:37 +02:00
|
|
|
const libvlc_media_trackpriv_t *trackpriv =
|
|
|
|
libvlc_media_track_to_priv(track);
|
2022-08-12 06:17:42 +02:00
|
|
|
|
2021-07-06 09:17:14 +02:00
|
|
|
// It must be a player track
|
|
|
|
assert(trackpriv->es_id);
|
|
|
|
|
2020-09-09 13:56:37 +02:00
|
|
|
vlc_player_SelectEsId(player, trackpriv->es_id,
|
|
|
|
VLC_PLAYER_SELECT_EXCLUSIVE);
|
|
|
|
|
|
|
|
vlc_player_Unlock(player);
|
|
|
|
}
|
2020-06-04 19:59:51 +02:00
|
|
|
|
2020-09-09 13:56:37 +02:00
|
|
|
void
|
|
|
|
libvlc_media_player_unselect_track_type( libvlc_media_player_t *p_mi,
|
|
|
|
libvlc_track_type_t type )
|
|
|
|
{
|
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
const enum es_format_category_e cat = libvlc_track_type_to_escat(type);
|
|
|
|
|
|
|
|
vlc_player_Lock(player);
|
|
|
|
vlc_player_UnselectTrackCategory(player, cat);
|
2020-06-04 19:59:51 +02:00
|
|
|
vlc_player_Unlock(player);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2020-06-15 15:02:18 +02:00
|
|
|
libvlc_media_player_select_tracks(libvlc_media_player_t *p_mi,
|
|
|
|
libvlc_track_type_t type,
|
|
|
|
const libvlc_media_track_t **tracks,
|
|
|
|
size_t track_count)
|
2020-06-04 19:59:51 +02:00
|
|
|
{
|
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
|
2020-06-15 15:02:18 +02:00
|
|
|
vlc_es_id_t **es_id_list = vlc_alloc(track_count + 1, sizeof(vlc_es_id_t *));
|
2020-06-04 19:59:51 +02:00
|
|
|
size_t es_id_idx = 0;
|
|
|
|
|
|
|
|
if (es_id_list == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
const enum es_format_category_e cat = libvlc_track_type_to_escat(type);
|
|
|
|
|
|
|
|
vlc_player_Lock(player);
|
|
|
|
|
2020-06-15 15:02:18 +02:00
|
|
|
for (size_t i = 0; i < track_count; ++i)
|
2020-06-04 19:59:51 +02:00
|
|
|
{
|
2020-06-15 15:02:18 +02:00
|
|
|
const libvlc_media_track_t *track = tracks[i];
|
|
|
|
const libvlc_media_trackpriv_t *trackpriv =
|
|
|
|
libvlc_media_track_to_priv(track);
|
|
|
|
|
2021-07-06 09:17:14 +02:00
|
|
|
// It must be a player track
|
|
|
|
assert(trackpriv->es_id);
|
|
|
|
|
2020-06-15 15:02:18 +02:00
|
|
|
es_id_list[es_id_idx++] = trackpriv->es_id;
|
2020-06-04 19:59:51 +02:00
|
|
|
}
|
|
|
|
es_id_list[es_id_idx++] = NULL;
|
|
|
|
vlc_player_SelectEsIdList(player, cat, es_id_list);
|
|
|
|
|
|
|
|
vlc_player_Unlock(player);
|
|
|
|
|
|
|
|
free(es_id_list);
|
|
|
|
}
|
|
|
|
|
2020-06-15 15:02:18 +02:00
|
|
|
void
|
|
|
|
libvlc_media_player_select_tracks_by_ids( libvlc_media_player_t *p_mi,
|
|
|
|
libvlc_track_type_t type,
|
|
|
|
const char *psz_ids )
|
|
|
|
{
|
|
|
|
const enum es_format_category_e cat = libvlc_track_type_to_escat(type);
|
|
|
|
|
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
|
|
|
|
vlc_player_Lock(player);
|
|
|
|
|
|
|
|
vlc_player_SelectTracksByStringIds(player, cat, psz_ids);
|
|
|
|
|
|
|
|
vlc_player_Unlock(player);
|
|
|
|
}
|
2020-06-04 19:59:51 +02:00
|
|
|
|
2016-05-27 12:05:33 +02:00
|
|
|
int libvlc_media_player_add_slave( libvlc_media_player_t *p_mi,
|
|
|
|
libvlc_media_slave_type_t i_type,
|
2016-06-07 18:18:00 +02:00
|
|
|
const char *psz_uri, bool b_select )
|
2016-05-27 12:05:33 +02:00
|
|
|
{
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
vlc_player_Lock(player);
|
2016-05-27 12:05:33 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
enum es_format_category_e cat = i_type == libvlc_media_slave_type_subtitle
|
|
|
|
? SPU_ES
|
|
|
|
: AUDIO_ES;
|
2016-05-27 12:05:33 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
int ret = vlc_player_AddAssociatedMedia(player, cat, psz_uri, b_select,
|
|
|
|
false, false);
|
2016-05-27 12:05:33 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
vlc_player_Unlock(player);
|
|
|
|
return ret;
|
2016-05-27 12:05:33 +02:00
|
|
|
}
|
|
|
|
|
2013-07-13 20:21:37 +02:00
|
|
|
/**
|
|
|
|
* Maximum size of a formatted equalizer amplification band frequency value.
|
|
|
|
*
|
|
|
|
* The allowed value range is supposed to be constrained from -20.0 to 20.0.
|
|
|
|
*
|
|
|
|
* The format string " %.07f" with a minimum value of "-20" gives a maximum
|
|
|
|
* string length of e.g. " -19.1234567", i.e. 12 bytes (not including the null
|
|
|
|
* terminator).
|
|
|
|
*/
|
|
|
|
#define EQZ_BAND_VALUE_SIZE 12
|
|
|
|
|
|
|
|
int libvlc_media_player_set_equalizer( libvlc_media_player_t *p_mi, libvlc_equalizer_t *p_equalizer )
|
|
|
|
{
|
2014-05-24 06:55:30 +02:00
|
|
|
char bands[EQZ_BANDS_MAX * EQZ_BAND_VALUE_SIZE + 1];
|
2013-07-13 20:21:37 +02:00
|
|
|
|
2014-05-24 06:55:30 +02:00
|
|
|
if( p_equalizer != NULL )
|
2013-07-13 20:21:37 +02:00
|
|
|
{
|
2014-05-24 06:55:30 +02:00
|
|
|
for( unsigned i = 0, c = 0; i < EQZ_BANDS_MAX; i++ )
|
2013-07-13 20:21:37 +02:00
|
|
|
{
|
2014-06-16 16:47:44 +02:00
|
|
|
c += snprintf( bands + c, sizeof(bands) - c, " %.07f",
|
2014-05-24 06:55:30 +02:00
|
|
|
p_equalizer->f_amp[i] );
|
|
|
|
if( unlikely(c >= sizeof(bands)) )
|
2013-07-13 20:21:37 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-05-24 06:55:30 +02:00
|
|
|
var_SetFloat( p_mi, "equalizer-preamp", p_equalizer->f_preamp );
|
|
|
|
var_SetString( p_mi, "equalizer-bands", bands );
|
|
|
|
}
|
|
|
|
var_SetString( p_mi, "audio-filter", p_equalizer ? "equalizer" : "" );
|
2013-07-13 20:21:37 +02:00
|
|
|
|
2019-05-13 14:01:55 +02:00
|
|
|
audio_output_t *p_aout = vlc_player_aout_Hold( p_mi->player );
|
2014-05-24 06:55:30 +02:00
|
|
|
if( p_aout != NULL )
|
2013-07-13 20:21:37 +02:00
|
|
|
{
|
2014-05-24 06:55:30 +02:00
|
|
|
if( p_equalizer != NULL )
|
|
|
|
{
|
|
|
|
var_SetFloat( p_aout, "equalizer-preamp", p_equalizer->f_preamp );
|
|
|
|
var_SetString( p_aout, "equalizer-bands", bands );
|
|
|
|
}
|
2013-07-13 20:21:37 +02:00
|
|
|
|
2014-06-16 16:47:44 +02:00
|
|
|
var_SetString( p_aout, "audio-filter", p_equalizer ? "equalizer" : "" );
|
2019-03-06 19:03:08 +01:00
|
|
|
aout_Release(p_aout);
|
2013-07-13 20:21:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2016-06-04 17:02:05 +02:00
|
|
|
|
2020-10-01 11:25:07 +02:00
|
|
|
|
|
|
|
static libvlc_player_program_t *
|
|
|
|
libvlc_player_program_new(const struct vlc_player_program *program)
|
|
|
|
{
|
|
|
|
libvlc_player_program_t *libprogram = malloc(sizeof(*libprogram));
|
|
|
|
if (libprogram == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
libprogram->i_group_id = program->group_id;
|
|
|
|
libprogram->psz_name = strdup(program->name);
|
|
|
|
libprogram->b_selected = program->selected;
|
|
|
|
libprogram->b_scrambled = program->scrambled;
|
|
|
|
|
|
|
|
return libprogram;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
libvlc_player_program_delete( libvlc_player_program_t *program )
|
|
|
|
{
|
|
|
|
free( program->psz_name );
|
|
|
|
free( program );
|
|
|
|
}
|
|
|
|
|
|
|
|
void libvlc_media_player_select_program_id( libvlc_media_player_t *p_mi,
|
|
|
|
int program_id)
|
|
|
|
{
|
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
|
|
|
|
vlc_player_Lock(player);
|
|
|
|
|
|
|
|
vlc_player_SelectProgram(player, program_id);
|
|
|
|
|
|
|
|
vlc_player_Unlock(player);
|
|
|
|
}
|
|
|
|
|
|
|
|
libvlc_player_program_t *
|
|
|
|
libvlc_media_player_get_selected_program( libvlc_media_player_t *p_mi)
|
|
|
|
{
|
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
|
|
|
|
vlc_player_Lock(player);
|
|
|
|
|
|
|
|
const struct vlc_player_program *program = vlc_player_GetSelectedProgram( player );
|
|
|
|
if( program == NULL )
|
|
|
|
{
|
|
|
|
vlc_player_Unlock(player);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
libvlc_player_program_t *libprogram = libvlc_player_program_new(program);
|
|
|
|
|
|
|
|
vlc_player_Unlock(player);
|
|
|
|
|
|
|
|
return libprogram;
|
|
|
|
}
|
|
|
|
|
|
|
|
libvlc_player_program_t *
|
|
|
|
libvlc_media_player_get_program_from_id( libvlc_media_player_t *p_mi, int i_group_id )
|
|
|
|
{
|
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
|
|
|
|
vlc_player_Lock(player);
|
|
|
|
|
|
|
|
libvlc_player_program_t *libprogram = NULL;
|
|
|
|
|
|
|
|
size_t count = vlc_player_GetProgramCount(player);
|
|
|
|
for (size_t i = 0; i < count; ++i)
|
|
|
|
{
|
|
|
|
const struct vlc_player_program *program =
|
|
|
|
vlc_player_GetProgramAt(player, i);
|
|
|
|
assert(program);
|
|
|
|
if (program->group_id == i_group_id)
|
|
|
|
{
|
|
|
|
libprogram = libvlc_player_program_new(program);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
vlc_player_Unlock(player);
|
|
|
|
|
|
|
|
return libprogram;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct libvlc_player_programlist_t
|
|
|
|
{
|
|
|
|
size_t count;
|
|
|
|
libvlc_player_program_t *programs[];
|
|
|
|
};
|
|
|
|
|
|
|
|
size_t
|
|
|
|
libvlc_player_programlist_count( const libvlc_player_programlist_t *list )
|
|
|
|
{
|
|
|
|
return list->count;
|
|
|
|
}
|
|
|
|
|
|
|
|
libvlc_player_program_t *
|
|
|
|
libvlc_player_programlist_at( libvlc_player_programlist_t *list, size_t index )
|
|
|
|
{
|
|
|
|
assert(index < list->count);
|
|
|
|
return list->programs[index];
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
libvlc_player_programlist_delete( libvlc_player_programlist_t *list )
|
|
|
|
{
|
|
|
|
for (size_t i = 0; i < list->count; ++i)
|
|
|
|
libvlc_player_program_delete(list->programs[i]);
|
|
|
|
free(list);
|
|
|
|
}
|
|
|
|
|
|
|
|
libvlc_player_programlist_t *
|
|
|
|
libvlc_media_player_get_programlist( libvlc_media_player_t *p_mi )
|
|
|
|
{
|
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
|
|
|
|
vlc_player_Lock(player);
|
|
|
|
|
|
|
|
size_t count = vlc_player_GetProgramCount(player);
|
|
|
|
if (count == 0)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
size_t size;
|
|
|
|
if( mul_overflow( count, sizeof(libvlc_player_program_t *), &size) )
|
|
|
|
goto error;
|
|
|
|
if( add_overflow( size, sizeof(libvlc_player_programlist_t), &size) )
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
libvlc_player_programlist_t *list = malloc( size );
|
|
|
|
if( list == NULL )
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
list->count = 0;
|
|
|
|
for (size_t i = 0; i < count; ++i)
|
|
|
|
{
|
|
|
|
const struct vlc_player_program *program =
|
|
|
|
vlc_player_GetProgramAt(player, i);
|
|
|
|
assert(program);
|
|
|
|
list->programs[i] = libvlc_player_program_new(program);
|
|
|
|
if (list->programs[i] == NULL)
|
|
|
|
{
|
|
|
|
libvlc_player_programlist_delete(list);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
list->count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
vlc_player_Unlock(player);
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
|
|
|
error:
|
|
|
|
vlc_player_Unlock(player);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2016-06-04 17:02:05 +02:00
|
|
|
static const char roles[][16] =
|
|
|
|
{
|
|
|
|
[libvlc_role_Music] = "music",
|
|
|
|
[libvlc_role_Video] = "video",
|
|
|
|
[libvlc_role_Communication] = "communication",
|
|
|
|
[libvlc_role_Game] = "game",
|
2017-09-19 11:03:56 +02:00
|
|
|
[libvlc_role_Notification] = "notification",
|
2016-06-04 17:02:05 +02:00
|
|
|
[libvlc_role_Animation] = "animation",
|
|
|
|
[libvlc_role_Production] = "production",
|
|
|
|
[libvlc_role_Accessibility] = "accessibility",
|
|
|
|
[libvlc_role_Test] = "test",
|
|
|
|
};
|
|
|
|
|
|
|
|
int libvlc_media_player_set_role(libvlc_media_player_t *mp, unsigned role)
|
|
|
|
{
|
|
|
|
if (role >= ARRAY_SIZE(roles)
|
|
|
|
|| var_SetString(mp, "role", roles[role]) != VLC_SUCCESS)
|
|
|
|
return -1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int libvlc_media_player_get_role(libvlc_media_player_t *mp)
|
|
|
|
{
|
|
|
|
int ret = -1;
|
|
|
|
char *str = var_GetString(mp, "role");
|
|
|
|
if (str == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
for (size_t i = 0; i < ARRAY_SIZE(roles); i++)
|
|
|
|
if (!strcmp(roles[i], str))
|
|
|
|
{
|
|
|
|
ret = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
free(str);
|
|
|
|
return ret;
|
|
|
|
}
|
2019-03-20 15:10:52 +01:00
|
|
|
|
2018-09-27 18:40:39 +02:00
|
|
|
void libvlc_media_player_record( libvlc_media_player_t *p_mi,
|
|
|
|
bool enable,
|
|
|
|
const char *path)
|
|
|
|
{
|
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
|
|
|
|
vlc_player_Lock(player);
|
|
|
|
vlc_player_SetRecordingEnabled(player, enable, path);
|
|
|
|
vlc_player_Unlock(player);
|
|
|
|
}
|
|
|
|
|
2022-08-01 14:07:48 +02:00
|
|
|
#define PLAYER_TIME_CORE_TO_LIB(point) { \
|
|
|
|
.position = point->position, \
|
|
|
|
.rate = point->rate, \
|
2022-08-11 14:26:10 +02:00
|
|
|
.ts_us = US_FROM_VLC_TICK(point->ts), \
|
|
|
|
.length_us = US_FROM_VLC_TICK(point->length), \
|
|
|
|
.system_date_us = US_FROM_VLC_TICK(point->system_date), \
|
2022-08-01 14:07:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#define PLAYER_TIME_LIB_TO_CORE(point) { \
|
|
|
|
.position = point->position, \
|
|
|
|
.rate = point->rate, \
|
2022-08-11 14:26:10 +02:00
|
|
|
.ts = VLC_TICK_FROM_US(point->ts_us), \
|
|
|
|
.length = VLC_TICK_FROM_US(point->length_us), \
|
|
|
|
.system_date = VLC_TICK_FROM_US(point->system_date_us), \
|
2022-08-01 14:07:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void player_timer_on_update(const struct vlc_player_timer_point *point,
|
|
|
|
void *data)
|
|
|
|
{
|
|
|
|
libvlc_media_player_t *p_mi = data;
|
|
|
|
|
|
|
|
const libvlc_media_player_time_point_t libpoint = PLAYER_TIME_CORE_TO_LIB(point);
|
|
|
|
|
|
|
|
p_mi->timer.on_update(&libpoint, p_mi->timer.cbs_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void player_timer_on_discontinuity(vlc_tick_t system_date, void *data)
|
|
|
|
{
|
|
|
|
libvlc_media_player_t *p_mi = data;
|
|
|
|
|
|
|
|
if (p_mi->timer.on_discontinuity == NULL)
|
|
|
|
return;
|
|
|
|
|
2022-08-11 14:26:10 +02:00
|
|
|
p_mi->timer.on_discontinuity(US_FROM_VLC_TICK(system_date),
|
|
|
|
p_mi->timer.cbs_data);
|
2022-08-01 14:07:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
libvlc_media_player_watch_time(libvlc_media_player_t *p_mi,
|
2022-08-11 14:26:10 +02:00
|
|
|
int64_t min_period_us,
|
2022-08-01 14:07:48 +02:00
|
|
|
libvlc_media_player_watch_time_on_update on_update,
|
|
|
|
libvlc_media_player_watch_time_on_discontinuity on_discontinuity,
|
|
|
|
void *cbs_data)
|
|
|
|
{
|
|
|
|
assert(on_update != NULL);
|
|
|
|
|
|
|
|
static const struct vlc_player_timer_cbs player_timer_cbs = {
|
|
|
|
.on_update = player_timer_on_update,
|
|
|
|
.on_discontinuity = player_timer_on_discontinuity,
|
|
|
|
};
|
|
|
|
|
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
vlc_player_Lock(player);
|
|
|
|
|
|
|
|
if (p_mi->timer.id != NULL)
|
|
|
|
{
|
|
|
|
libvlc_printerr("libvlc_media_player_watch_time error:"
|
|
|
|
"already watching for events");
|
|
|
|
vlc_player_Unlock(player);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
p_mi->timer.on_update = on_update;
|
|
|
|
p_mi->timer.on_discontinuity = on_discontinuity;
|
|
|
|
p_mi->timer.cbs_data = cbs_data;
|
|
|
|
|
2022-08-11 14:26:10 +02:00
|
|
|
p_mi->timer.id = vlc_player_AddTimer(player, VLC_TICK_FROM_US(min_period_us),
|
|
|
|
&player_timer_cbs, p_mi);
|
2022-08-01 14:07:48 +02:00
|
|
|
vlc_player_Unlock(player);
|
|
|
|
|
|
|
|
if (unlikely(p_mi->timer.id == NULL))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
libvlc_media_player_unwatch_time(libvlc_media_player_t *p_mi)
|
|
|
|
{
|
|
|
|
vlc_player_t *player = p_mi->player;
|
|
|
|
|
|
|
|
vlc_player_Lock(player);
|
|
|
|
|
|
|
|
assert(p_mi->timer.id != NULL);
|
|
|
|
vlc_player_RemoveTimer(player, p_mi->timer.id);
|
|
|
|
p_mi->timer.id = NULL;
|
|
|
|
|
|
|
|
vlc_player_Unlock(player);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
libvlc_media_player_time_point_interpolate(const libvlc_media_player_time_point_t *libpoint,
|
2022-08-11 14:26:10 +02:00
|
|
|
int64_t system_now_us,
|
|
|
|
int64_t *out_ts_us, double *out_pos)
|
2022-08-01 14:07:48 +02:00
|
|
|
{
|
|
|
|
const struct vlc_player_timer_point point = PLAYER_TIME_LIB_TO_CORE(libpoint);
|
|
|
|
|
2022-08-11 14:26:10 +02:00
|
|
|
vlc_tick_t out_ts;
|
|
|
|
int ret = vlc_player_timer_point_Interpolate(&point,
|
|
|
|
VLC_TICK_FROM_US(system_now_us),
|
|
|
|
&out_ts, out_pos);
|
|
|
|
*out_ts_us = US_FROM_VLC_TICK(out_ts);
|
|
|
|
return ret;
|
2022-08-01 14:07:48 +02:00
|
|
|
}
|
|
|
|
|
2022-08-11 14:26:10 +02:00
|
|
|
int64_t
|
2022-08-01 14:07:48 +02:00
|
|
|
libvlc_media_player_time_point_get_next_date(const libvlc_media_player_time_point_t *libpoint,
|
2022-08-11 14:26:10 +02:00
|
|
|
int64_t system_now_us,
|
|
|
|
int64_t interpolated_ts_us,
|
|
|
|
int64_t next_interval_us)
|
2022-08-01 14:07:48 +02:00
|
|
|
{
|
|
|
|
const struct vlc_player_timer_point point = PLAYER_TIME_LIB_TO_CORE(libpoint);
|
|
|
|
|
2022-08-11 14:26:10 +02:00
|
|
|
vlc_tick_t date =
|
|
|
|
vlc_player_timer_point_GetNextIntervalDate(&point,
|
|
|
|
VLC_TICK_FROM_US(system_now_us),
|
|
|
|
VLC_TICK_FROM_US(interpolated_ts_us),
|
|
|
|
VLC_TICK_FROM_US(next_interval_us));
|
|
|
|
return US_FROM_VLC_TICK(date);
|
2022-08-01 14:07:48 +02:00
|
|
|
}
|
|
|
|
|
2019-03-20 15:10:52 +01:00
|
|
|
#include <vlc_vout_display.h>
|
|
|
|
|
|
|
|
/* make sure surface structures from libvlc can be passed as such to vlc
|
|
|
|
otherwise we will need wrappers between what libvlc understands and what vlc uses */
|
2019-05-13 14:01:41 +02:00
|
|
|
#define cast_ libvlc_video_color_space_t
|
|
|
|
static_assert(libvlc_video_colorspace_BT601 == (cast_)COLOR_SPACE_BT601 &&
|
|
|
|
libvlc_video_colorspace_BT709 == (cast_)COLOR_SPACE_BT709 &&
|
|
|
|
libvlc_video_colorspace_BT2020 == (cast_)COLOR_SPACE_BT2020
|
2019-03-20 15:10:52 +01:00
|
|
|
, "libvlc video colorspace mismatch");
|
2019-05-13 14:01:41 +02:00
|
|
|
#undef cast_
|
|
|
|
|
|
|
|
#define cast_ libvlc_video_transfer_func_t
|
|
|
|
static_assert(libvlc_video_transfer_func_LINEAR == (cast_)TRANSFER_FUNC_LINEAR &&
|
|
|
|
libvlc_video_transfer_func_SRGB == (cast_)TRANSFER_FUNC_SRGB &&
|
|
|
|
libvlc_video_transfer_func_BT470_BG == (cast_)TRANSFER_FUNC_BT470_BG &&
|
|
|
|
libvlc_video_transfer_func_BT470_M == (cast_)TRANSFER_FUNC_BT470_M &&
|
|
|
|
libvlc_video_transfer_func_BT709 == (cast_)TRANSFER_FUNC_BT709 &&
|
|
|
|
libvlc_video_transfer_func_PQ == (cast_)TRANSFER_FUNC_SMPTE_ST2084 &&
|
|
|
|
libvlc_video_transfer_func_SMPTE_240 == (cast_)TRANSFER_FUNC_SMPTE_240 &&
|
|
|
|
libvlc_video_transfer_func_HLG == (cast_)TRANSFER_FUNC_HLG
|
2019-03-20 15:10:52 +01:00
|
|
|
, "libvlc video transfer function mismatch");
|
2019-05-13 14:01:41 +02:00
|
|
|
#undef cast_
|
|
|
|
|
|
|
|
#define cast_ libvlc_video_color_primaries_t
|
|
|
|
static_assert(libvlc_video_primaries_BT601_525 == (cast_)COLOR_PRIMARIES_BT601_525 &&
|
|
|
|
libvlc_video_primaries_BT601_625 == (cast_)COLOR_PRIMARIES_BT601_625 &&
|
|
|
|
libvlc_video_primaries_BT709 == (cast_)COLOR_PRIMARIES_BT709 &&
|
|
|
|
libvlc_video_primaries_BT2020 == (cast_)COLOR_PRIMARIES_BT2020 &&
|
|
|
|
libvlc_video_primaries_DCI_P3 == (cast_)COLOR_PRIMARIES_DCI_P3 &&
|
|
|
|
libvlc_video_primaries_BT470_M == (cast_)COLOR_PRIMARIES_BT470_M
|
2019-03-20 15:10:52 +01:00
|
|
|
, "libvlc video color primaries mismatch");
|
2019-05-13 14:01:41 +02:00
|
|
|
#undef cast_
|