From: RĂ©mi Duraffort Date: Tue, 2 Feb 2010 09:22:00 +0000 (+0100) Subject: libvlcpp: add a function to get the audio infromations from the media player. X-Git-Tag: 1.1.0-ff~542 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=ae749fcdc0e2a5a1a174daebd60632ccc12ae639;p=vlc libvlcpp: add a function to get the audio infromations from the media player. The Audio class can only be created/destroyed by the associated MediaPlayer class. I will add some copy constructor later on. --- diff --git a/bindings/libvlcpp/src/Makefile.am b/bindings/libvlcpp/src/Makefile.am index d68526afc2..6b5ef6c322 100644 --- a/bindings/libvlcpp/src/Makefile.am +++ b/bindings/libvlcpp/src/Makefile.am @@ -17,7 +17,7 @@ libvlcpp_la_SOURCES = \ libvlcpp_la_CXXFLAGS = @libvlc_CFLAGS@ libvlcpp_la_LDFLAGS = @libvlc_LIBS@ -version-info 1:0:0 library_includedir=$(includedir)/libvlcpp -library_include_HEADERS = exception.hpp libvlc.hpp media.hpp media_player.hpp video.hpp +library_include_HEADERS = exception.hpp libvlc.hpp media.hpp media_player.hpp video.hpp audio.hpp pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libvlcpp.pc diff --git a/bindings/libvlcpp/src/audio.cpp b/bindings/libvlcpp/src/audio.cpp index 01bb812a0d..d829ec1f9c 100644 --- a/bindings/libvlcpp/src/audio.cpp +++ b/bindings/libvlcpp/src/audio.cpp @@ -26,10 +26,8 @@ using namespace libvlc; -Audio::Audio( libvlc_media_player_t *player ) +Audio::Audio() { - m_player = player; - libvlc_media_player_retain( m_player ); } Audio::~Audio() @@ -77,3 +75,8 @@ void Audio::setTrack( int track ) libvlc_audio_set_track( m_player, track ); } +void Audio::setMediaPlayer( libvlc_media_player_t *player ) +{ + libvlc_media_player_retain( player ); + m_player = player; +} diff --git a/bindings/libvlcpp/src/audio.hpp b/bindings/libvlcpp/src/audio.hpp index f7c98f0369..7c1683ec8d 100644 --- a/bindings/libvlcpp/src/audio.hpp +++ b/bindings/libvlcpp/src/audio.hpp @@ -33,18 +33,11 @@ namespace libvlc { +class MediaPlayer; + class Audio { public: - /** - * Constructor - * @param player: the player handling the audio - */ - Audio( libvlc_media_player_t *player ); - - /** Destructor */ - ~Audio(); - /** * Toggle mute status */ @@ -110,6 +103,23 @@ public: private: /** The media player instance of libvlc */ libvlc_media_player_t *m_player; + + /** + * The constructor is private so only the MediaPlayer can create an instance of this class + */ + Audio(); + + /** Destructor only used by the MediaPlayer associated with this class */ + ~Audio(); + + /** + * Set the media player. This function can only be used by the MediaPlayer class + * @param player: the media player + */ + void setMediaPlayer( libvlc_media_player_t *player); + + /** Friend class */ + friend class MediaPlayer; }; }; diff --git a/bindings/libvlcpp/src/media_player.cpp b/bindings/libvlcpp/src/media_player.cpp index 4b953b4596..34504b2495 100644 --- a/bindings/libvlcpp/src/media_player.cpp +++ b/bindings/libvlcpp/src/media_player.cpp @@ -28,11 +28,13 @@ using namespace libvlc; MediaPlayer::MediaPlayer( libVLC &libvlcInstance ) { m_player = libvlc_media_player_new( libvlcInstance.m_instance ); + m_audio.setMediaPlayer( m_player ); } MediaPlayer::MediaPlayer( Media &media ) { m_player = libvlc_media_player_new_from_media( media.m_media ); + m_audio.setMediaPlayer( m_player ); } MediaPlayer::~MediaPlayer() @@ -238,3 +240,8 @@ int MediaPlayer::fullscreen() { return libvlc_get_fullscreen( m_player ); } + +Audio &MediaPlayer::audio() +{ + return m_audio; +} diff --git a/bindings/libvlcpp/src/media_player.hpp b/bindings/libvlcpp/src/media_player.hpp index 7a893254ff..1704bb6323 100644 --- a/bindings/libvlcpp/src/media_player.hpp +++ b/bindings/libvlcpp/src/media_player.hpp @@ -30,6 +30,7 @@ #include "libvlc.hpp" #include "media.hpp" +#include "audio.hpp" namespace libvlc { @@ -47,7 +48,7 @@ public: * Create a media player with a media associated * @param media: the associated media (the media can be safely destroy afterward) */ - MediaPlayer( Media &media); + MediaPlayer( Media &media ); /** * Destructor @@ -304,9 +305,18 @@ public: */ int fullscreen(); + /** + * Get the class that handle the Audio + * @return the instance of Audio associated with this MediaPlayer + */ + Audio &audio(); + private: /** The media player instance of libvlc */ libvlc_media_player_t *m_player; + + /** The Audio part of the media player */ + Audio m_audio; }; };