2007-08-17 10:10:42 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* media_discoverer.c: libvlc new API media discoverer functions
|
|
|
|
*****************************************************************************
|
LGPL
Re-license almost all of libVLC and libVLCcore to LGPLv2.1+
This move was authorized by the developers, either:
- by e-mail,
- by vote at the VideoLAN Dev Days 2011,
- on the license website,
- in a contract, oral or written.
No objection was raised, so far.
The developers agreeing are:
Justus Piater
Alexis Ballier
Alexander Bethke
Mohammed Adnène Trojette
Alex Converse
Alexey Sokolov
Alexis de Lattre
Andre Pang
Anthony Loiseau
Cyril Deguet
André Weber
Boris Dorès
Brieuc Jeunhomme
Benjamin Drung
Hugo Beauzée-Luyssen
Benoit Steiner
Benjamin Pracht
Bernie Purcell
Przemyslaw Fiala
Arnaud de Bossoreille de Ribou
Brad Smith
Nick Briggs
Christopher Rath
Christophe Courtaut
Christopher Mueller
Clement Chesnin
Andres Krapf
Damien Fouilleul
David Flynn
Sebastien Zwickert
Antoine Cellerier
Jérôme Decoodt
Jérome Decoodt
Dylan Yudaken
Eduard Babayan
Eugenio Jarosiewicz
Elliot Murphy
Eric Petit
Erwan Tulou
Etienne Membrives
Ludovic Fauvet
Fabio Ritrovato
Tobias Güntner
Jakub Wieczorek
Frédéric Crozat
Francois Cartegnie
Laurent Aimar
Florian G. Pflug
Felix Paul Kühne
Frank Enderle
Rafaël Carré
Simon Latapie
Gildas Bazin
Geoffroy Couprie
Julien / Gellule
Gildas Bazin
Arnaud Schauly
Toralf Niebuhr
Vicente Jimenez Aguilar
Derk-Jan Hartman
Henri Fallon
Ilkka Ollakka
Olivier Teulière
Rémi Duraffort
Jakob Leben
Jean-Baptiste Kempf
Jean-Paul Saman
Jean-Philippe Grimaldi
Jean-François Massol
Gaël Hendryckx
Jakob Leben
Jean-Marc Dressler
Jai Menon
Johan Bilien
Johann Ransay
Joris van Rooij
JP Dinger
Jean-Philippe André
Adrien Grand
Juha Jeronen
Juho Vähä-Herttua
Kaarlo Raiha
Kaarlo Raiha
Kamil Baldyga
Keary Griffin
Ken Self
KO Myung-Hun
Pierre Ynard
Filippo Carone
Loïc Minier
Luca Barbato
Lucas C. Villa Real
Lukas Durfina
Adrien Maglo
Marc Ariberti
Mark Lee
Mark Moriarty
Martin Storsjö
Christophe Massiot
Michel Kaempf
Marian Ďurkovič
Mirsal Ennaime
Carlo Calabrò
Damien Lucas
Naohiro Koriyama
Basos G
Pierre Baillet
Vincent Penquerc'h
Olivier Aubert
Pankaj Yadav
Paul Corke
Pierre d'Herbemont
Philippe Morin
Antoine Lejeune
Michael Ploujnikov
Jean-Marc Dressler
Michael Hanselmann
Rafaël Carré
Ramiro Polla
Rémi Denis-Courmont
Renaud Dartus
Richard Shepherd
Faustino Osuna
Arnaud Vallat
Rob Jonson
Robert Jedrzejczyk
Steve Lhomme
Rocky Bernstein
Romain Goyet
Rov Juvano
Sam Hocevar
Martin T. H. Sandsmark
Sebastian Birk
Sébastien Escudier
Vincent Seguin
Fabio Ritrovato
Sigmund Augdal Helberg
Casian Andrei
Srikanth Raju
Hannes Domani
Stéphane Borel
Stephan Krempel
Stephan Assmus
Tony Castley
Pavlov Konstantin
Eric Petit
Tanguy Krotoff
Dennis van Amerongen
Michel Lespinasse
Can Wu
Xavier Marchesini
Sébastien Toque
Christophe Mutricy
Yoann Peronneau
Yohann Martineau
Yuval Tze
Scott Caudle
Clément Stenac
It is possible, that some minor piece of code was badly tracked, for
some reasons (SVN, mainly) or that some small developers did not answer.
However, as an "œuvre collective", defined as in "CPI 113-2 alinéa 3",
and seeing "Cour. Cass. 17 Mai 1978", and seeing that the editor and
the very vast majority of developers have agreed (> 99.99% of the code,
> 99% of developers), we are fine here.
2011-11-27 21:44:15 +01:00
|
|
|
* Copyright (C) 2007 VLC authors and VideoLAN
|
2007-08-17 10:10:42 +02:00
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
|
|
|
|
*
|
LGPL
Re-license almost all of libVLC and libVLCcore to LGPLv2.1+
This move was authorized by the developers, either:
- by e-mail,
- by vote at the VideoLAN Dev Days 2011,
- on the license website,
- in a contract, oral or written.
No objection was raised, so far.
The developers agreeing are:
Justus Piater
Alexis Ballier
Alexander Bethke
Mohammed Adnène Trojette
Alex Converse
Alexey Sokolov
Alexis de Lattre
Andre Pang
Anthony Loiseau
Cyril Deguet
André Weber
Boris Dorès
Brieuc Jeunhomme
Benjamin Drung
Hugo Beauzée-Luyssen
Benoit Steiner
Benjamin Pracht
Bernie Purcell
Przemyslaw Fiala
Arnaud de Bossoreille de Ribou
Brad Smith
Nick Briggs
Christopher Rath
Christophe Courtaut
Christopher Mueller
Clement Chesnin
Andres Krapf
Damien Fouilleul
David Flynn
Sebastien Zwickert
Antoine Cellerier
Jérôme Decoodt
Jérome Decoodt
Dylan Yudaken
Eduard Babayan
Eugenio Jarosiewicz
Elliot Murphy
Eric Petit
Erwan Tulou
Etienne Membrives
Ludovic Fauvet
Fabio Ritrovato
Tobias Güntner
Jakub Wieczorek
Frédéric Crozat
Francois Cartegnie
Laurent Aimar
Florian G. Pflug
Felix Paul Kühne
Frank Enderle
Rafaël Carré
Simon Latapie
Gildas Bazin
Geoffroy Couprie
Julien / Gellule
Gildas Bazin
Arnaud Schauly
Toralf Niebuhr
Vicente Jimenez Aguilar
Derk-Jan Hartman
Henri Fallon
Ilkka Ollakka
Olivier Teulière
Rémi Duraffort
Jakob Leben
Jean-Baptiste Kempf
Jean-Paul Saman
Jean-Philippe Grimaldi
Jean-François Massol
Gaël Hendryckx
Jakob Leben
Jean-Marc Dressler
Jai Menon
Johan Bilien
Johann Ransay
Joris van Rooij
JP Dinger
Jean-Philippe André
Adrien Grand
Juha Jeronen
Juho Vähä-Herttua
Kaarlo Raiha
Kaarlo Raiha
Kamil Baldyga
Keary Griffin
Ken Self
KO Myung-Hun
Pierre Ynard
Filippo Carone
Loïc Minier
Luca Barbato
Lucas C. Villa Real
Lukas Durfina
Adrien Maglo
Marc Ariberti
Mark Lee
Mark Moriarty
Martin Storsjö
Christophe Massiot
Michel Kaempf
Marian Ďurkovič
Mirsal Ennaime
Carlo Calabrò
Damien Lucas
Naohiro Koriyama
Basos G
Pierre Baillet
Vincent Penquerc'h
Olivier Aubert
Pankaj Yadav
Paul Corke
Pierre d'Herbemont
Philippe Morin
Antoine Lejeune
Michael Ploujnikov
Jean-Marc Dressler
Michael Hanselmann
Rafaël Carré
Ramiro Polla
Rémi Denis-Courmont
Renaud Dartus
Richard Shepherd
Faustino Osuna
Arnaud Vallat
Rob Jonson
Robert Jedrzejczyk
Steve Lhomme
Rocky Bernstein
Romain Goyet
Rov Juvano
Sam Hocevar
Martin T. H. Sandsmark
Sebastian Birk
Sébastien Escudier
Vincent Seguin
Fabio Ritrovato
Sigmund Augdal Helberg
Casian Andrei
Srikanth Raju
Hannes Domani
Stéphane Borel
Stephan Krempel
Stephan Assmus
Tony Castley
Pavlov Konstantin
Eric Petit
Tanguy Krotoff
Dennis van Amerongen
Michel Lespinasse
Can Wu
Xavier Marchesini
Sébastien Toque
Christophe Mutricy
Yoann Peronneau
Yohann Martineau
Yuval Tze
Scott Caudle
Clément Stenac
It is possible, that some minor piece of code was badly tracked, for
some reasons (SVN, mainly) or that some small developers did not answer.
However, as an "œuvre collective", defined as in "CPI 113-2 alinéa 3",
and seeing "Cour. Cass. 17 Mai 1978", and seeing that the editor and
the very vast majority of developers have agreed (> 99.99% of the code,
> 99% of developers), we are fine here.
2011-11-27 21:44:15 +01:00
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU Lesser General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2.1 of the License, or
|
2007-08-17 10:10:42 +02:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
LGPL
Re-license almost all of libVLC and libVLCcore to LGPLv2.1+
This move was authorized by the developers, either:
- by e-mail,
- by vote at the VideoLAN Dev Days 2011,
- on the license website,
- in a contract, oral or written.
No objection was raised, so far.
The developers agreeing are:
Justus Piater
Alexis Ballier
Alexander Bethke
Mohammed Adnène Trojette
Alex Converse
Alexey Sokolov
Alexis de Lattre
Andre Pang
Anthony Loiseau
Cyril Deguet
André Weber
Boris Dorès
Brieuc Jeunhomme
Benjamin Drung
Hugo Beauzée-Luyssen
Benoit Steiner
Benjamin Pracht
Bernie Purcell
Przemyslaw Fiala
Arnaud de Bossoreille de Ribou
Brad Smith
Nick Briggs
Christopher Rath
Christophe Courtaut
Christopher Mueller
Clement Chesnin
Andres Krapf
Damien Fouilleul
David Flynn
Sebastien Zwickert
Antoine Cellerier
Jérôme Decoodt
Jérome Decoodt
Dylan Yudaken
Eduard Babayan
Eugenio Jarosiewicz
Elliot Murphy
Eric Petit
Erwan Tulou
Etienne Membrives
Ludovic Fauvet
Fabio Ritrovato
Tobias Güntner
Jakub Wieczorek
Frédéric Crozat
Francois Cartegnie
Laurent Aimar
Florian G. Pflug
Felix Paul Kühne
Frank Enderle
Rafaël Carré
Simon Latapie
Gildas Bazin
Geoffroy Couprie
Julien / Gellule
Gildas Bazin
Arnaud Schauly
Toralf Niebuhr
Vicente Jimenez Aguilar
Derk-Jan Hartman
Henri Fallon
Ilkka Ollakka
Olivier Teulière
Rémi Duraffort
Jakob Leben
Jean-Baptiste Kempf
Jean-Paul Saman
Jean-Philippe Grimaldi
Jean-François Massol
Gaël Hendryckx
Jakob Leben
Jean-Marc Dressler
Jai Menon
Johan Bilien
Johann Ransay
Joris van Rooij
JP Dinger
Jean-Philippe André
Adrien Grand
Juha Jeronen
Juho Vähä-Herttua
Kaarlo Raiha
Kaarlo Raiha
Kamil Baldyga
Keary Griffin
Ken Self
KO Myung-Hun
Pierre Ynard
Filippo Carone
Loïc Minier
Luca Barbato
Lucas C. Villa Real
Lukas Durfina
Adrien Maglo
Marc Ariberti
Mark Lee
Mark Moriarty
Martin Storsjö
Christophe Massiot
Michel Kaempf
Marian Ďurkovič
Mirsal Ennaime
Carlo Calabrò
Damien Lucas
Naohiro Koriyama
Basos G
Pierre Baillet
Vincent Penquerc'h
Olivier Aubert
Pankaj Yadav
Paul Corke
Pierre d'Herbemont
Philippe Morin
Antoine Lejeune
Michael Ploujnikov
Jean-Marc Dressler
Michael Hanselmann
Rafaël Carré
Ramiro Polla
Rémi Denis-Courmont
Renaud Dartus
Richard Shepherd
Faustino Osuna
Arnaud Vallat
Rob Jonson
Robert Jedrzejczyk
Steve Lhomme
Rocky Bernstein
Romain Goyet
Rov Juvano
Sam Hocevar
Martin T. H. Sandsmark
Sebastian Birk
Sébastien Escudier
Vincent Seguin
Fabio Ritrovato
Sigmund Augdal Helberg
Casian Andrei
Srikanth Raju
Hannes Domani
Stéphane Borel
Stephan Krempel
Stephan Assmus
Tony Castley
Pavlov Konstantin
Eric Petit
Tanguy Krotoff
Dennis van Amerongen
Michel Lespinasse
Can Wu
Xavier Marchesini
Sébastien Toque
Christophe Mutricy
Yoann Peronneau
Yohann Martineau
Yuval Tze
Scott Caudle
Clément Stenac
It is possible, that some minor piece of code was badly tracked, for
some reasons (SVN, mainly) or that some small developers did not answer.
However, as an "œuvre collective", defined as in "CPI 113-2 alinéa 3",
and seeing "Cour. Cass. 17 Mai 1978", and seeing that the editor and
the very vast majority of developers have agreed (> 99.99% of the code,
> 99% of developers), we are fine here.
2011-11-27 21:44:15 +01:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License for more details.
|
2007-08-17 10:10:42 +02:00
|
|
|
*
|
LGPL
Re-license almost all of libVLC and libVLCcore to LGPLv2.1+
This move was authorized by the developers, either:
- by e-mail,
- by vote at the VideoLAN Dev Days 2011,
- on the license website,
- in a contract, oral or written.
No objection was raised, so far.
The developers agreeing are:
Justus Piater
Alexis Ballier
Alexander Bethke
Mohammed Adnène Trojette
Alex Converse
Alexey Sokolov
Alexis de Lattre
Andre Pang
Anthony Loiseau
Cyril Deguet
André Weber
Boris Dorès
Brieuc Jeunhomme
Benjamin Drung
Hugo Beauzée-Luyssen
Benoit Steiner
Benjamin Pracht
Bernie Purcell
Przemyslaw Fiala
Arnaud de Bossoreille de Ribou
Brad Smith
Nick Briggs
Christopher Rath
Christophe Courtaut
Christopher Mueller
Clement Chesnin
Andres Krapf
Damien Fouilleul
David Flynn
Sebastien Zwickert
Antoine Cellerier
Jérôme Decoodt
Jérome Decoodt
Dylan Yudaken
Eduard Babayan
Eugenio Jarosiewicz
Elliot Murphy
Eric Petit
Erwan Tulou
Etienne Membrives
Ludovic Fauvet
Fabio Ritrovato
Tobias Güntner
Jakub Wieczorek
Frédéric Crozat
Francois Cartegnie
Laurent Aimar
Florian G. Pflug
Felix Paul Kühne
Frank Enderle
Rafaël Carré
Simon Latapie
Gildas Bazin
Geoffroy Couprie
Julien / Gellule
Gildas Bazin
Arnaud Schauly
Toralf Niebuhr
Vicente Jimenez Aguilar
Derk-Jan Hartman
Henri Fallon
Ilkka Ollakka
Olivier Teulière
Rémi Duraffort
Jakob Leben
Jean-Baptiste Kempf
Jean-Paul Saman
Jean-Philippe Grimaldi
Jean-François Massol
Gaël Hendryckx
Jakob Leben
Jean-Marc Dressler
Jai Menon
Johan Bilien
Johann Ransay
Joris van Rooij
JP Dinger
Jean-Philippe André
Adrien Grand
Juha Jeronen
Juho Vähä-Herttua
Kaarlo Raiha
Kaarlo Raiha
Kamil Baldyga
Keary Griffin
Ken Self
KO Myung-Hun
Pierre Ynard
Filippo Carone
Loïc Minier
Luca Barbato
Lucas C. Villa Real
Lukas Durfina
Adrien Maglo
Marc Ariberti
Mark Lee
Mark Moriarty
Martin Storsjö
Christophe Massiot
Michel Kaempf
Marian Ďurkovič
Mirsal Ennaime
Carlo Calabrò
Damien Lucas
Naohiro Koriyama
Basos G
Pierre Baillet
Vincent Penquerc'h
Olivier Aubert
Pankaj Yadav
Paul Corke
Pierre d'Herbemont
Philippe Morin
Antoine Lejeune
Michael Ploujnikov
Jean-Marc Dressler
Michael Hanselmann
Rafaël Carré
Ramiro Polla
Rémi Denis-Courmont
Renaud Dartus
Richard Shepherd
Faustino Osuna
Arnaud Vallat
Rob Jonson
Robert Jedrzejczyk
Steve Lhomme
Rocky Bernstein
Romain Goyet
Rov Juvano
Sam Hocevar
Martin T. H. Sandsmark
Sebastian Birk
Sébastien Escudier
Vincent Seguin
Fabio Ritrovato
Sigmund Augdal Helberg
Casian Andrei
Srikanth Raju
Hannes Domani
Stéphane Borel
Stephan Krempel
Stephan Assmus
Tony Castley
Pavlov Konstantin
Eric Petit
Tanguy Krotoff
Dennis van Amerongen
Michel Lespinasse
Can Wu
Xavier Marchesini
Sébastien Toque
Christophe Mutricy
Yoann Peronneau
Yohann Martineau
Yuval Tze
Scott Caudle
Clément Stenac
It is possible, that some minor piece of code was badly tracked, for
some reasons (SVN, mainly) or that some small developers did not answer.
However, as an "œuvre collective", defined as in "CPI 113-2 alinéa 3",
and seeing "Cour. Cass. 17 Mai 1978", and seeing that the editor and
the very vast majority of developers have agreed (> 99.99% of the code,
> 99% of developers), we are fine here.
2011-11-27 21:44:15 +01:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
|
2007-08-17 10:10:42 +02:00
|
|
|
*****************************************************************************/
|
|
|
|
|
2009-08-31 15:14:05 +02:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2007-08-17 10:10:42 +02:00
|
|
|
#include <assert.h>
|
2009-05-25 10:47:38 +02:00
|
|
|
|
|
|
|
#include <vlc/libvlc.h>
|
|
|
|
#include <vlc/libvlc_media.h>
|
|
|
|
#include <vlc/libvlc_media_list.h>
|
|
|
|
#include <vlc/libvlc_media_discoverer.h>
|
|
|
|
#include <vlc/libvlc_events.h>
|
|
|
|
|
|
|
|
#include <vlc_services_discovery.h>
|
|
|
|
|
|
|
|
#include "libvlc_internal.h"
|
|
|
|
#include "media_internal.h" // libvlc_media_new_from_input_item()
|
|
|
|
#include "media_list_internal.h" // _libvlc_media_list_add_media()
|
|
|
|
|
|
|
|
struct libvlc_media_discoverer_t
|
|
|
|
{
|
|
|
|
libvlc_event_manager_t * p_event_manager;
|
|
|
|
libvlc_instance_t * p_libvlc_instance;
|
|
|
|
services_discovery_t * p_sd;
|
|
|
|
libvlc_media_list_t * p_mlist;
|
|
|
|
bool running;
|
|
|
|
vlc_dictionary_t catname_to_submedialist;
|
|
|
|
};
|
2007-08-17 10:10:42 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Private functions
|
|
|
|
*/
|
2007-12-25 22:29:49 +01:00
|
|
|
|
2007-08-17 10:10:42 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* services_discovery_item_added (Private) (VLC event callback)
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
static void services_discovery_item_added( const vlc_event_t * p_event,
|
|
|
|
void * user_data )
|
|
|
|
{
|
|
|
|
input_item_t * p_item = p_event->u.services_discovery_item_added.p_new_item;
|
2008-02-13 18:10:18 +01:00
|
|
|
const char * psz_cat = p_event->u.services_discovery_item_added.psz_category;
|
2008-03-30 03:59:32 +02:00
|
|
|
libvlc_media_t * p_md;
|
2007-08-17 10:10:42 +02:00
|
|
|
libvlc_media_discoverer_t * p_mdis = user_data;
|
2008-02-13 18:10:18 +01:00
|
|
|
libvlc_media_list_t * p_mlist = p_mdis->p_mlist;
|
2007-08-17 10:10:42 +02:00
|
|
|
|
2010-02-02 22:44:43 +01:00
|
|
|
p_md = libvlc_media_new_from_input_item( p_mdis->p_libvlc_instance,
|
|
|
|
p_item );
|
2008-02-13 18:35:32 +01:00
|
|
|
|
2008-02-13 18:10:18 +01:00
|
|
|
/* If we have a category, that mean we have to group the items having
|
|
|
|
* that category in a media_list. */
|
|
|
|
if( psz_cat )
|
|
|
|
{
|
|
|
|
p_mlist = vlc_dictionary_value_for_key( &p_mdis->catname_to_submedialist, psz_cat );
|
2008-02-14 01:00:52 +01:00
|
|
|
|
2008-02-13 18:10:18 +01:00
|
|
|
if( p_mlist == kVLCDictionaryNotFound )
|
|
|
|
{
|
2008-03-30 03:59:32 +02:00
|
|
|
libvlc_media_t * p_catmd;
|
2010-02-02 22:44:43 +01:00
|
|
|
p_catmd = libvlc_media_new_as_node( p_mdis->p_libvlc_instance, psz_cat );
|
2009-10-05 20:52:49 +02:00
|
|
|
p_mlist = libvlc_media_subitems( p_catmd );
|
2008-04-14 00:08:29 +02:00
|
|
|
p_mlist->b_read_only = true;
|
2008-02-13 18:35:32 +01:00
|
|
|
|
2008-02-13 18:10:18 +01:00
|
|
|
/* Insert the newly created mlist in our dictionary */
|
2008-04-17 00:37:02 +02:00
|
|
|
vlc_dictionary_insert( &p_mdis->catname_to_submedialist, psz_cat, p_mlist );
|
2008-05-18 13:09:26 +02:00
|
|
|
|
2008-02-13 18:10:18 +01:00
|
|
|
/* Insert the md into the root list */
|
2008-02-14 01:00:52 +01:00
|
|
|
libvlc_media_list_lock( p_mdis->p_mlist );
|
2010-01-24 10:45:14 +01:00
|
|
|
_libvlc_media_list_add_media( p_mdis->p_mlist, p_catmd );
|
2008-02-14 01:00:52 +01:00
|
|
|
libvlc_media_list_unlock( p_mdis->p_mlist );
|
2008-02-13 18:10:18 +01:00
|
|
|
|
|
|
|
/* We don't release the mlist cause the dictionary
|
|
|
|
* doesn't retain the object. But we release the md. */
|
2008-03-30 03:59:32 +02:00
|
|
|
libvlc_media_release( p_catmd );
|
2008-02-13 18:10:18 +01:00
|
|
|
}
|
|
|
|
}
|
2009-12-03 12:11:05 +01:00
|
|
|
|
|
|
|
libvlc_media_list_lock( p_mlist );
|
2010-01-24 10:45:14 +01:00
|
|
|
_libvlc_media_list_add_media( p_mlist, p_md );
|
2009-12-03 12:11:05 +01:00
|
|
|
libvlc_media_list_unlock( p_mlist );
|
2009-12-11 19:45:59 +01:00
|
|
|
|
|
|
|
libvlc_media_release( p_md );
|
2007-08-17 10:10:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* services_discovery_item_removed (Private) (VLC event callback)
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
static void services_discovery_item_removed( const vlc_event_t * p_event,
|
|
|
|
void * user_data )
|
|
|
|
{
|
2007-12-25 22:29:49 +01:00
|
|
|
input_item_t * p_item = p_event->u.services_discovery_item_added.p_new_item;
|
2008-03-30 03:59:32 +02:00
|
|
|
libvlc_media_t * p_md;
|
2007-12-25 22:29:49 +01:00
|
|
|
libvlc_media_discoverer_t * p_mdis = user_data;
|
|
|
|
|
2010-01-24 10:45:14 +01:00
|
|
|
int i, count = libvlc_media_list_count( p_mdis->p_mlist );
|
2007-12-25 22:29:49 +01:00
|
|
|
libvlc_media_list_lock( p_mdis->p_mlist );
|
|
|
|
for( i = 0; i < count; i++ )
|
|
|
|
{
|
2010-02-03 19:06:21 +01:00
|
|
|
p_md = libvlc_media_list_item_at_index( p_mdis->p_mlist, i );
|
2007-12-25 22:29:49 +01:00
|
|
|
if( p_md->p_input_item == p_item )
|
|
|
|
{
|
2010-02-03 19:06:21 +01:00
|
|
|
_libvlc_media_list_remove_index( p_mdis->p_mlist, i );
|
2007-12-25 22:29:49 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
libvlc_media_list_unlock( p_mdis->p_mlist );
|
|
|
|
}
|
|
|
|
|
2012-01-11 03:10:41 +01:00
|
|
|
/**************************************************************************
|
|
|
|
* services_discovery_removeall (Private) (VLC event callback)
|
|
|
|
**************************************************************************/
|
|
|
|
static void services_discovery_removeall( const vlc_event_t * p_event,
|
|
|
|
void * user_data )
|
|
|
|
{
|
2012-09-15 15:17:10 +02:00
|
|
|
VLC_UNUSED(p_event);
|
2012-01-11 03:10:41 +01:00
|
|
|
libvlc_media_discoverer_t * p_mdis = user_data;
|
|
|
|
|
|
|
|
libvlc_media_list_lock( p_mdis->p_mlist );
|
|
|
|
for( int i = 0; i < libvlc_media_list_count( p_mdis->p_mlist ); i++ )
|
|
|
|
{
|
|
|
|
_libvlc_media_list_remove_index( p_mdis->p_mlist, i );
|
|
|
|
}
|
|
|
|
libvlc_media_list_unlock( p_mdis->p_mlist );
|
|
|
|
}
|
|
|
|
|
2007-12-25 22:29:49 +01:00
|
|
|
/**************************************************************************
|
|
|
|
* services_discovery_started (Private) (VLC event callback)
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
static void services_discovery_started( const vlc_event_t * p_event,
|
|
|
|
void * user_data )
|
|
|
|
{
|
2008-05-18 13:09:26 +02:00
|
|
|
VLC_UNUSED(p_event);
|
2007-12-25 22:29:49 +01:00
|
|
|
libvlc_media_discoverer_t * p_mdis = user_data;
|
|
|
|
libvlc_event_t event;
|
2008-04-14 00:08:29 +02:00
|
|
|
p_mdis->running = true;
|
2007-12-25 22:29:49 +01:00
|
|
|
event.type = libvlc_MediaDiscovererStarted;
|
|
|
|
libvlc_event_send( p_mdis->p_event_manager, &event );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* services_discovery_ended (Private) (VLC event callback)
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
static void services_discovery_ended( const vlc_event_t * p_event,
|
|
|
|
void * user_data )
|
|
|
|
{
|
2008-05-18 13:09:26 +02:00
|
|
|
VLC_UNUSED(p_event);
|
2007-12-25 22:29:49 +01:00
|
|
|
libvlc_media_discoverer_t * p_mdis = user_data;
|
|
|
|
libvlc_event_t event;
|
2008-04-14 00:08:29 +02:00
|
|
|
p_mdis->running = false;
|
2007-12-25 22:29:49 +01:00
|
|
|
event.type = libvlc_MediaDiscovererEnded;
|
|
|
|
libvlc_event_send( p_mdis->p_event_manager, &event );
|
2007-08-17 10:10:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Public libvlc functions
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* new (Public)
|
|
|
|
*
|
|
|
|
* Init an object.
|
|
|
|
**************************************************************************/
|
|
|
|
libvlc_media_discoverer_t *
|
|
|
|
libvlc_media_discoverer_new_from_name( libvlc_instance_t * p_inst,
|
2010-02-02 22:36:24 +01:00
|
|
|
const char * psz_name )
|
2007-08-17 10:10:42 +02:00
|
|
|
{
|
|
|
|
libvlc_media_discoverer_t * p_mdis;
|
2008-05-18 13:09:26 +02:00
|
|
|
|
2007-08-17 10:10:42 +02:00
|
|
|
p_mdis = malloc(sizeof(libvlc_media_discoverer_t));
|
2010-02-02 22:36:24 +01:00
|
|
|
if( unlikely(!p_mdis) )
|
2007-08-17 10:10:42 +02:00
|
|
|
{
|
2009-09-07 21:13:49 +02:00
|
|
|
libvlc_printerr( "Not enough memory" );
|
2007-08-17 10:10:42 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
p_mdis->p_libvlc_instance = p_inst;
|
2010-01-28 21:49:15 +01:00
|
|
|
p_mdis->p_mlist = libvlc_media_list_new( p_inst );
|
2008-04-14 00:08:29 +02:00
|
|
|
p_mdis->p_mlist->b_read_only = true;
|
|
|
|
p_mdis->running = false;
|
2007-12-25 22:29:49 +01:00
|
|
|
|
2008-02-13 18:10:18 +01:00
|
|
|
vlc_dictionary_init( &p_mdis->catname_to_submedialist, 0 );
|
|
|
|
|
2010-01-25 18:19:19 +01:00
|
|
|
p_mdis->p_event_manager = libvlc_event_manager_new( p_mdis, p_inst );
|
|
|
|
if( unlikely(p_mdis->p_event_manager == NULL) )
|
|
|
|
{
|
|
|
|
free( p_mdis );
|
|
|
|
return NULL;
|
|
|
|
}
|
2007-12-25 22:29:49 +01:00
|
|
|
|
|
|
|
libvlc_event_manager_register_event_type( p_mdis->p_event_manager,
|
2010-01-25 18:19:19 +01:00
|
|
|
libvlc_MediaDiscovererStarted );
|
2007-12-25 22:29:49 +01:00
|
|
|
libvlc_event_manager_register_event_type( p_mdis->p_event_manager,
|
2010-01-25 18:19:19 +01:00
|
|
|
libvlc_MediaDiscovererEnded );
|
2007-12-25 22:29:49 +01:00
|
|
|
|
2010-02-04 17:50:08 +01:00
|
|
|
p_mdis->p_sd = vlc_sd_Create( (vlc_object_t*)p_inst->p_libvlc_int,
|
|
|
|
psz_name );
|
|
|
|
if( unlikely(p_mdis->p_sd == NULL) )
|
2007-08-17 10:10:42 +02:00
|
|
|
{
|
2009-09-07 21:13:49 +02:00
|
|
|
libvlc_printerr( "%s: no such discovery module found", psz_name );
|
2010-02-02 22:36:24 +01:00
|
|
|
libvlc_media_list_release( p_mdis->p_mlist );
|
|
|
|
libvlc_event_manager_release( p_mdis->p_event_manager );
|
2008-10-01 20:01:12 +02:00
|
|
|
free( p_mdis );
|
2007-08-17 10:10:42 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
vlc_event_attach( services_discovery_EventManager( p_mdis->p_sd ),
|
|
|
|
vlc_ServicesDiscoveryItemAdded,
|
|
|
|
services_discovery_item_added,
|
|
|
|
p_mdis );
|
|
|
|
vlc_event_attach( services_discovery_EventManager( p_mdis->p_sd ),
|
|
|
|
vlc_ServicesDiscoveryItemRemoved,
|
|
|
|
services_discovery_item_removed,
|
|
|
|
p_mdis );
|
2007-12-25 22:29:49 +01:00
|
|
|
vlc_event_attach( services_discovery_EventManager( p_mdis->p_sd ),
|
|
|
|
vlc_ServicesDiscoveryStarted,
|
|
|
|
services_discovery_started,
|
|
|
|
p_mdis );
|
|
|
|
vlc_event_attach( services_discovery_EventManager( p_mdis->p_sd ),
|
|
|
|
vlc_ServicesDiscoveryEnded,
|
|
|
|
services_discovery_ended,
|
|
|
|
p_mdis );
|
2012-01-11 03:10:41 +01:00
|
|
|
vlc_event_attach( services_discovery_EventManager( p_mdis->p_sd ),
|
|
|
|
vlc_ServicesDiscoveryItemRemoveAll,
|
|
|
|
services_discovery_removeall,
|
|
|
|
p_mdis );
|
2008-02-14 01:00:52 +01:00
|
|
|
|
2007-08-17 10:10:42 +02:00
|
|
|
/* Here we go */
|
2010-02-04 17:50:08 +01:00
|
|
|
if( !vlc_sd_Start( p_mdis->p_sd ) )
|
2008-09-20 23:02:13 +02:00
|
|
|
{
|
2010-02-04 17:50:08 +01:00
|
|
|
libvlc_printerr( "%s: internal module error",
|
2010-02-24 16:55:05 +01:00
|
|
|
p_mdis->p_sd->psz_name );
|
2010-02-02 22:36:24 +01:00
|
|
|
libvlc_media_list_release( p_mdis->p_mlist );
|
|
|
|
libvlc_event_manager_release( p_mdis->p_event_manager );
|
2008-10-01 20:01:12 +02:00
|
|
|
free( p_mdis );
|
2008-09-20 23:02:13 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
2007-08-17 10:10:42 +02:00
|
|
|
|
|
|
|
return p_mdis;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* release (Public)
|
|
|
|
**************************************************************************/
|
|
|
|
void
|
|
|
|
libvlc_media_discoverer_release( libvlc_media_discoverer_t * p_mdis )
|
|
|
|
{
|
2008-02-13 18:10:18 +01:00
|
|
|
int i;
|
|
|
|
|
2009-12-16 20:29:53 +01:00
|
|
|
vlc_event_detach( services_discovery_EventManager( p_mdis->p_sd ),
|
|
|
|
vlc_ServicesDiscoveryItemAdded,
|
|
|
|
services_discovery_item_added,
|
|
|
|
p_mdis );
|
|
|
|
vlc_event_detach( services_discovery_EventManager( p_mdis->p_sd ),
|
|
|
|
vlc_ServicesDiscoveryItemRemoved,
|
|
|
|
services_discovery_item_removed,
|
|
|
|
p_mdis );
|
|
|
|
vlc_event_detach( services_discovery_EventManager( p_mdis->p_sd ),
|
|
|
|
vlc_ServicesDiscoveryStarted,
|
|
|
|
services_discovery_started,
|
|
|
|
p_mdis );
|
|
|
|
vlc_event_detach( services_discovery_EventManager( p_mdis->p_sd ),
|
|
|
|
vlc_ServicesDiscoveryEnded,
|
|
|
|
services_discovery_ended,
|
|
|
|
p_mdis );
|
2012-01-11 03:10:41 +01:00
|
|
|
vlc_event_detach( services_discovery_EventManager( p_mdis->p_sd ),
|
|
|
|
vlc_ServicesDiscoveryItemRemoveAll,
|
|
|
|
services_discovery_removeall,
|
|
|
|
p_mdis );
|
2009-12-16 20:29:53 +01:00
|
|
|
|
2007-08-17 10:10:42 +02:00
|
|
|
libvlc_media_list_release( p_mdis->p_mlist );
|
2009-12-16 20:29:53 +01:00
|
|
|
|
2009-01-10 18:28:34 +01:00
|
|
|
vlc_sd_StopAndDestroy( p_mdis->p_sd );
|
2008-02-13 18:10:18 +01:00
|
|
|
|
|
|
|
/* Free catname_to_submedialist and all the mlist */
|
|
|
|
char ** all_keys = vlc_dictionary_all_keys( &p_mdis->catname_to_submedialist );
|
|
|
|
for( i = 0; all_keys[i]; i++ )
|
|
|
|
{
|
|
|
|
libvlc_media_list_t * p_catmlist = vlc_dictionary_value_for_key( &p_mdis->catname_to_submedialist, all_keys[i] );
|
|
|
|
libvlc_media_list_release( p_catmlist );
|
|
|
|
free( all_keys[i] );
|
|
|
|
}
|
|
|
|
free( all_keys );
|
|
|
|
|
2008-09-30 09:10:25 +02:00
|
|
|
vlc_dictionary_clear( &p_mdis->catname_to_submedialist, NULL, NULL );
|
2008-12-06 20:41:39 +01:00
|
|
|
libvlc_event_manager_release( p_mdis->p_event_manager );
|
2008-02-13 18:10:18 +01:00
|
|
|
|
2007-08-17 10:10:42 +02:00
|
|
|
free( p_mdis );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* localized_name (Public)
|
|
|
|
**************************************************************************/
|
|
|
|
char *
|
|
|
|
libvlc_media_discoverer_localized_name( libvlc_media_discoverer_t * p_mdis )
|
|
|
|
{
|
|
|
|
return services_discovery_GetLocalizedName( p_mdis->p_sd );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* media_list (Public)
|
|
|
|
**************************************************************************/
|
|
|
|
libvlc_media_list_t *
|
|
|
|
libvlc_media_discoverer_media_list( libvlc_media_discoverer_t * p_mdis )
|
|
|
|
{
|
2007-08-19 23:45:00 +02:00
|
|
|
libvlc_media_list_retain( p_mdis->p_mlist );
|
|
|
|
return p_mdis->p_mlist;
|
2007-08-17 10:10:42 +02:00
|
|
|
}
|
|
|
|
|
2007-12-25 23:33:56 +01:00
|
|
|
/**************************************************************************
|
|
|
|
* event_manager (Public)
|
|
|
|
**************************************************************************/
|
|
|
|
libvlc_event_manager_t *
|
|
|
|
libvlc_media_discoverer_event_manager( libvlc_media_discoverer_t * p_mdis )
|
|
|
|
{
|
|
|
|
return p_mdis->p_event_manager;
|
|
|
|
}
|
|
|
|
|
2007-12-25 23:51:13 +01:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* running (Public)
|
|
|
|
**************************************************************************/
|
2008-03-17 20:20:33 +01:00
|
|
|
int
|
2007-12-25 23:51:13 +01:00
|
|
|
libvlc_media_discoverer_is_running( libvlc_media_discoverer_t * p_mdis )
|
|
|
|
{
|
|
|
|
return p_mdis->running;
|
|
|
|
}
|