[vlc-devel] commit: libvlcpp: add a function to get the audio infromations from the media player. ( Rémi Duraffort )
git version control
git at videolan.org
Tue Feb 2 11:20:19 CET 2010
vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Tue Feb 2 10:22:00 2010 +0100| [ae749fcdc0e2a5a1a174daebd60632ccc12ae639] | committer: Rémi Duraffort
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.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ae749fcdc0e2a5a1a174daebd60632ccc12ae639
---
bindings/libvlcpp/src/Makefile.am | 2 +-
bindings/libvlcpp/src/audio.cpp | 9 ++++++---
bindings/libvlcpp/src/audio.hpp | 28 +++++++++++++++++++---------
bindings/libvlcpp/src/media_player.cpp | 7 +++++++
bindings/libvlcpp/src/media_player.hpp | 12 +++++++++++-
5 files changed, 44 insertions(+), 14 deletions(-)
diff --git a/bindings/libvlcpp/src/Makefile.am b/bindings/libvlcpp/src/Makefile.am
index d68526a..6b5ef6c 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 01bb812..d829ec1 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 f7c98f0..7c1683e 100644
--- a/bindings/libvlcpp/src/audio.hpp
+++ b/bindings/libvlcpp/src/audio.hpp
@@ -33,19 +33,12 @@
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
*/
void toggleMute();
@@ -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 4b953b4..34504b2 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 7a89325..1704bb6 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;
};
};
More information about the vlc-devel
mailing list