From 46761435a82b978809e0e18e45df9b6ab9bf7d18 Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Duraffort?= Date: Tue, 2 Feb 2010 21:28:09 +0100 Subject: [PATCH] libvlcpp: add a function to handle video. --- bindings/libvlcpp/src/media_player.cpp | 6 ++++++ bindings/libvlcpp/src/media_player.hpp | 10 ++++++++++ bindings/libvlcpp/src/video.cpp | 10 +++++++--- bindings/libvlcpp/src/video.hpp | 27 +++++++++++++++++--------- 4 files changed, 41 insertions(+), 12 deletions(-) diff --git a/bindings/libvlcpp/src/media_player.cpp b/bindings/libvlcpp/src/media_player.cpp index e6355630c8..420c4ace0c 100644 --- a/bindings/libvlcpp/src/media_player.cpp +++ b/bindings/libvlcpp/src/media_player.cpp @@ -29,6 +29,7 @@ MediaPlayer::MediaPlayer( libVLC &libvlcInstance ) { m_player = libvlc_media_player_new( libvlcInstance.m_instance ); m_audio.setMediaPlayer( m_player ); + m_video.setMediaPlayer( m_player ); } MediaPlayer::MediaPlayer( Media &media ) @@ -246,3 +247,8 @@ Audio &MediaPlayer::audio() { return m_audio; } + +Video &MediaPlayer::video() +{ + return m_video; +} diff --git a/bindings/libvlcpp/src/media_player.hpp b/bindings/libvlcpp/src/media_player.hpp index 1704bb6323..a4c9bd47d1 100644 --- a/bindings/libvlcpp/src/media_player.hpp +++ b/bindings/libvlcpp/src/media_player.hpp @@ -31,6 +31,7 @@ #include "libvlc.hpp" #include "media.hpp" #include "audio.hpp" +#include "video.hpp" namespace libvlc { @@ -311,12 +312,21 @@ public: */ Audio &audio(); + /** + * Get the class that handle the Video + * @return the instance of the Video associated with this MediaPlayer + */ + Video &video(); + private: /** The media player instance of libvlc */ libvlc_media_player_t *m_player; /** The Audio part of the media player */ Audio m_audio; + + /** The Video part of the media player */ + Video m_video; }; }; diff --git a/bindings/libvlcpp/src/video.cpp b/bindings/libvlcpp/src/video.cpp index 58cc3cfd2f..83fed5243b 100644 --- a/bindings/libvlcpp/src/video.cpp +++ b/bindings/libvlcpp/src/video.cpp @@ -28,10 +28,8 @@ using namespace libvlc; -Video::Video( libvlc_media_player_t *player ) +Video::Video() { - m_player = player; - libvlc_media_player_retain( m_player ); } Video::~Video() @@ -111,3 +109,9 @@ void Video::deinterlace( int enable, const char *mode ) else libvlc_video_set_deinterlace( m_player, NULL ); } + +void Video::setMediaPlayer( libvlc_media_player_t *player ) +{ + libvlc_media_player_retain( player ); + m_player = player; +} diff --git a/bindings/libvlcpp/src/video.hpp b/bindings/libvlcpp/src/video.hpp index fb7310313f..72f403265d 100644 --- a/bindings/libvlcpp/src/video.hpp +++ b/bindings/libvlcpp/src/video.hpp @@ -36,15 +36,6 @@ namespace libvlc class Video { public: - /** - * Constructor - * @param player: the player handling the video - */ - Video( libvlc_media_player_t *player ); - - /** Destructor */ - ~Video(); - /** * Get the height of the video * @return the height of the video @@ -163,6 +154,24 @@ 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 + */ + Video(); + + /** Destructor only used by the MediaPlayer associated with this class */ + ~Video(); + + /** + * 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; }; }; -- 2.39.5