Commit ae749fcd authored by Rémi Duraffort's avatar 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.
parent d66c2593
......@@ -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
......@@ -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;
}
......@@ -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;
};
};
......
......@@ -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;
}
......@@ -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;
};
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment