]> git.sesse.net Git - vlc/commitdiff
libvlcpp: add a function to get the audio infromations from the media player.
authorRémi Duraffort <ivoire@videolan.org>
Tue, 2 Feb 2010 09:22:00 +0000 (10:22 +0100)
committerRémi Duraffort <ivoire@videolan.org>
Tue, 2 Feb 2010 10:07:19 +0000 (11:07 +0100)
The Audio class can only be created/destroyed by the associated MediaPlayer
class. I will add some copy constructor later on.

bindings/libvlcpp/src/Makefile.am
bindings/libvlcpp/src/audio.cpp
bindings/libvlcpp/src/audio.hpp
bindings/libvlcpp/src/media_player.cpp
bindings/libvlcpp/src/media_player.hpp

index d68526afc25ff894166e7aaf3b5f9e130f86eb17..6b5ef6c3220aeae6226c5ae06e32a4d39f2a726e 100644 (file)
@@ -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
index 01bb812a0d807ffd72886cde05a1543c0f9e57e8..d829ec1f9c5ca8e68245ca5e33544f1e48aa8c47 100644 (file)
 
 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;
+}
index f7c98f036938bc17af8957de8cd18bc81a2f80be..7c1683ec8d35f3717136cb780de7b5fd5f4f4ab6 100644 (file)
 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;
 };
 
 };
index 4b953b45961d0d4ec17eb05b8b832f0dd3bf293a..34504b24950a0496bf8f24d47bf5c66b1bcb7625 100644 (file)
@@ -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;
+}
index 7a893254ff0bb8e03f9825a3abd55d83ebd328dc..1704bb63233553887bffc5146ca1e771bb489e1e 100644 (file)
@@ -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;
 };
 
 };