[vlc-devel] commit: libvlcpp: add an audio class to handle audio functions. ( Rémi Duraffort )

git version control git at videolan.org
Fri Jan 29 17:14:15 CET 2010


vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Thu Jan 28 12:39:04 2010 +0100| [3a34857997c67db1000766c8f85c9b03ff095ccf] | committer: Rémi Duraffort 

libvlcpp: add an audio class to handle audio functions.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3a34857997c67db1000766c8f85c9b03ff095ccf
---

 bindings/libvlcpp/src/Makefile.am |    2 +
 bindings/libvlcpp/src/audio.cpp   |   88 ++++++++++++++++++++++++++
 bindings/libvlcpp/src/audio.hpp   |  122 +++++++++++++++++++++++++++++++++++++
 bindings/libvlcpp/src/video.cpp   |    2 +-
 bindings/libvlcpp/src/video.hpp   |    2 +-
 5 files changed, 214 insertions(+), 2 deletions(-)

diff --git a/bindings/libvlcpp/src/Makefile.am b/bindings/libvlcpp/src/Makefile.am
index e6df5df..d68526a 100644
--- a/bindings/libvlcpp/src/Makefile.am
+++ b/bindings/libvlcpp/src/Makefile.am
@@ -1,6 +1,8 @@
 lib_LTLIBRARIES = libvlcpp.la
 
 libvlcpp_la_SOURCES =   \
+    audio.cpp           \
+    audio.hpp           \
     exception.cpp       \
     exception.hpp       \
     libvlc.cpp          \
diff --git a/bindings/libvlcpp/src/audio.cpp b/bindings/libvlcpp/src/audio.cpp
new file mode 100644
index 0000000..e0fb46f
--- /dev/null
+++ b/bindings/libvlcpp/src/audio.cpp
@@ -0,0 +1,88 @@
+/*****************************************************************************
+ * audio.cpp: audio part of the media player
+ *****************************************************************************
+ * Copyright (C) 2010 the VideoLAN team
+ * $Id$
+ *
+ * Authors: Rémi Duraffort <ivoire at videolan.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (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
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU 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.
+ *****************************************************************************/
+
+#include "audio.hpp"
+#include "exception.hpp"
+
+
+using namespace libvlc;
+
+Audio::Audio( libvlc_instance_t *libvlcInstance, libvlc_media_player_t *player )
+{
+    m_libvlcInstance = libvlcInstance;
+    libvlc_retain( m_libvlcInstance );
+
+    m_player = player;
+    libvlc_media_player_retain( m_player );
+}
+
+Audio::~Audio()
+{
+    libvlc_media_player_release( m_player );
+    libvlc_release( m_libvlcInstance );
+}
+
+void Audio::toggleMute()
+{
+    libvlc_audio_toggle_mute( m_libvlcInstance );
+}
+
+int Audio::mute()
+{
+    return libvlc_audio_get_mute( m_libvlcInstance );
+}
+
+void Audio::setMute( int mute )
+{
+    libvlc_audio_set_mute( m_libvlcInstance, mute );
+}
+
+int Audio::volume()
+{
+    return libvlc_audio_get_volume( m_libvlcInstance );
+}
+
+void Audio::setVolume( int volume )
+{
+    Exception ex;
+    libvlc_audio_set_volume( m_libvlcInstance, volume, &ex.ex );
+}
+
+int Audio::track()
+{
+    Exception ex;
+    return libvlc_audio_get_track( m_player, &ex.ex );
+}
+
+int Audio::trackCount()
+{
+    Exception ex;
+    return libvlc_audio_get_track_count( m_player, &ex.ex );
+}
+
+void Audio::setTrack( int track )
+{
+    Exception ex;
+    libvlc_audio_set_track( m_player, track, &ex.ex );
+}
+
diff --git a/bindings/libvlcpp/src/audio.hpp b/bindings/libvlcpp/src/audio.hpp
new file mode 100644
index 0000000..7f7bb40
--- /dev/null
+++ b/bindings/libvlcpp/src/audio.hpp
@@ -0,0 +1,122 @@
+/*****************************************************************************
+ * audio.hpp: audio part of the media player
+ *****************************************************************************
+ * Copyright (C) 2010 the VideoLAN team
+ * $Id$
+ *
+ * Authors: Rémi Duraffort <ivoire at videolan.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (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
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU 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.
+ *****************************************************************************/
+
+#ifndef LIBVLCPP_AUDIO_HPP
+#define LIBVLCPP_AUDIO_HPP
+
+#include <vlc/libvlc.h>
+#include <vlc/libvlc_media.h>
+#include <vlc/libvlc_media_player.h>
+
+#include "libvlc.hpp"
+
+namespace libvlc
+{
+
+class Audio
+{
+public:
+    /**
+     * Constructor
+     * @param libvlcInstance: the libvlc instance
+     * @param player: the player handling the audio
+     */
+    Audio( libvlc_instance_t *libvlcInstance, libvlc_media_player_t *player );
+
+    /** Destructor */
+    ~Audio();
+
+    /**
+     * Toggle mute status
+     */
+    void toggleMute();
+
+    /**
+     * Get the mute status
+     * @return true if the sound is muted
+     */
+    int mute();
+
+    /**
+     * Set the mute status
+     * @param mute: true to mute, otherwise unmute
+     */
+    void setMute( int mute );
+
+    /**
+     * Get the current volume
+     * @return the current volume
+     */
+    int volume();
+
+    /**
+     * Set the volume
+     * @param volume: the new volume
+     */
+    void setVolume( int volume );
+
+
+    /**
+     * Get the current track
+     * @return the current audio track
+     */
+    int track();
+
+    /**
+     * Get the number of audio tracks
+     * @return the number of audio tracks
+     */
+    int trackCount();
+
+    /**
+     * Set the audio track
+     * @param track: the audio track
+     */
+    void setTrack( int track );
+
+    /**
+     * Get the current audio channel
+     * @return the current audio channel
+     */
+    int channel();
+
+    /**
+     * Set the audio channel
+     * @param channel: the new audio channel
+     */
+    void setChannel( int channel );
+
+    /** trackDescription */
+
+private:
+    /** The media player instance of libvlc */
+    libvlc_media_player_t *m_player;
+
+    /** The instance of libvlc */
+    libvlc_instance_t *m_libvlcInstance;
+};
+
+};
+
+#endif // LIBVLCPP_AUDIO_HPP
+
diff --git a/bindings/libvlcpp/src/video.cpp b/bindings/libvlcpp/src/video.cpp
index eecadc8..97b2d67 100644
--- a/bindings/libvlcpp/src/video.cpp
+++ b/bindings/libvlcpp/src/video.cpp
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * video.cpp: video part of an media player
+ * video.cpp: video part of the media player
  *****************************************************************************
  * Copyright (C) 2010 the VideoLAN team
  * $Id$
diff --git a/bindings/libvlcpp/src/video.hpp b/bindings/libvlcpp/src/video.hpp
index 1f7f15d..8602674 100644
--- a/bindings/libvlcpp/src/video.hpp
+++ b/bindings/libvlcpp/src/video.hpp
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * video.hpp: video part of an media player
+ * video.hpp: video part of the media player
  *****************************************************************************
  * Copyright (C) 2010 the VideoLAN team
  * $Id$




More information about the vlc-devel mailing list