[vlc-devel] [PATCH 07/12] common/win32_fullscreen: switch to using vlc_player
Sergey Radionov
rsatom at gmail.com
Sat Apr 21 18:07:48 CEST 2012
---
activex/plugin.cpp | 2 +-
common/win32_fullscreen.cpp | 80 ++++++++++++++++++++----------------------
common/win32_fullscreen.h | 30 ++++++++--------
npapi/vlcplugin_win.cpp | 4 +-
4 files changed, 56 insertions(+), 60 deletions(-)
diff --git a/activex/plugin.cpp b/activex/plugin.cpp
index 9a8fc65..fe5c5b8 100644
--- a/activex/plugin.cpp
+++ b/activex/plugin.cpp
@@ -1239,7 +1239,7 @@ static void handle_pausable_changed_event(const libvlc_event_t* event, void *par
void VLCPlugin::set_player_window()
{
- _WindowsManager.LibVlcAttach(vlc_player::get_mp());
+ _WindowsManager.LibVlcAttach( &get_player() );
}
void VLCPlugin::on_player_action(vlc_player_action_e pa)
diff --git a/common/win32_fullscreen.cpp b/common/win32_fullscreen.cpp
index c0d8ab3..2fb9d30 100644
--- a/common/win32_fullscreen.cpp
+++ b/common/win32_fullscreen.cpp
@@ -285,19 +285,17 @@ LRESULT VLCControlsWnd::WindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
WM().ToggleFullScreen();
break;
case ID_FS_PLAY_PAUSE:{
- libvlc_media_player_t* mp = MP();
- if( mp ){
+ if( VP() ){
if( IsPlaying() )
- libvlc_media_player_pause(mp);
+ VP()->pause();
else
- libvlc_media_player_play(mp);
+ VP()->play();
}
break;
}
case ID_FS_MUTE:{
- libvlc_media_player_t* mp = MP();
- if( mp ){
- libvlc_audio_set_mute(mp, IsDlgButtonChecked(hWnd(), ID_FS_MUTE));
+ if( VP() ){
+ VP()->set_mute( IsDlgButtonChecked(hWnd(), ID_FS_MUTE) != FALSE );
SyncVolumeSliderWithVLCVolume();
}
break;
@@ -397,8 +395,7 @@ LRESULT VLCControlsWnd::WindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
}
case WM_HSCROLL:
case WM_VSCROLL: {
- libvlc_media_player_t* mp = MP();
- if( mp ){
+ if( VP() ){
if(hVolumeSlider==(HWND)lParam){
LRESULT SliderPos = SendMessage(hVolumeSlider, (UINT) TBM_GETPOS, 0, 0);
SetVLCVolumeBySliderPos(SliderPos);
@@ -475,18 +472,16 @@ void VLCControlsWnd::NeedHideControls()
void VLCControlsWnd::SyncVideoPosScrollPosWithVideoPos()
{
- libvlc_media_player_t* mp = MP();
- if( mp ){
- libvlc_time_t pos = libvlc_media_player_get_time(mp);
+ if( VP() ){
+ libvlc_time_t pos = VP()->get_time();
SetVideoPosScrollPosByVideoPos(pos);
}
}
void VLCControlsWnd::SetVideoPosScrollRangeByVideoLen()
{
- libvlc_media_player_t* mp = MP();
- if( mp ){
- libvlc_time_t MaxLen = libvlc_media_player_get_length(mp);
+ if( VP() ){
+ libvlc_time_t MaxLen = VP()->get_length();
VideoPosShiftBits = 0;
while(MaxLen>0xffff){
MaxLen >>= 1;
@@ -503,23 +498,23 @@ void VLCControlsWnd::SetVideoPosScrollPosByVideoPos(libvlc_time_t CurScrollPos)
void VLCControlsWnd::SetVideoPos(float Pos) //0-start, 1-end
{
- libvlc_media_player_t* mp = MP();
- if( mp ){
- libvlc_media_player_set_time(mp, static_cast<libvlc_time_t>(libvlc_media_player_get_length(mp)*Pos));
+ if( VP() ){
+ vlc_player& vp = *VP();
+ vp.set_time( static_cast<libvlc_time_t>( vp.get_length()*Pos ) );
SyncVideoPosScrollPosWithVideoPos();
}
}
void VLCControlsWnd::SyncVolumeSliderWithVLCVolume()
{
- libvlc_media_player_t* mp = MP();
- if( mp ){
- int vol = libvlc_audio_get_volume(mp);
+ if( VP() ){
+ vlc_player& vp = *VP();
+ unsigned int vol = vp.get_volume();
const LRESULT SliderPos = SendMessage(hVolumeSlider, (UINT) TBM_GETPOS, 0, 0);
if(SliderPos!=vol)
SendMessage(hVolumeSlider, (UINT) TBM_SETPOS, (WPARAM) TRUE, (LPARAM) vol);
- bool muted = libvlc_audio_get_mute(mp)!=0;
+ bool muted = vp.is_muted();
int MuteButtonState = SendMessage(hMuteButton, (UINT) BM_GETCHECK, 0, 0);
if((muted&&(BST_UNCHECKED==MuteButtonState))||(!muted&&(BST_CHECKED==MuteButtonState))){
SendMessage(hMuteButton, BM_SETCHECK, (WPARAM)(muted?BST_CHECKED:BST_UNCHECKED), 0);
@@ -537,11 +532,11 @@ void VLCControlsWnd::SyncVolumeSliderWithVLCVolume()
void VLCControlsWnd::SetVLCVolumeBySliderPos(int CurPos)
{
- libvlc_media_player_t* mp = MP();
- if( mp ){
- libvlc_audio_set_volume(mp, CurPos);
+ if( VP() ){
+ vlc_player& vp = *VP();
+ vp.set_volume(CurPos);
if(0==CurPos){
- libvlc_audio_set_mute(mp, IsDlgButtonChecked( hWnd(), ID_FS_MUTE) );
+ vp.set_mute( IsDlgButtonChecked( hWnd(), ID_FS_MUTE) != FALSE );
}
SyncVolumeSliderWithVLCVolume();
}
@@ -808,14 +803,14 @@ void VLCHolderWnd::OnLibVlcEvent(const libvlc_event_t* event)
void VLCHolderWnd::LibVlcAttach()
{
- libvlc_media_player_set_hwnd(MP(), hWnd());
+ if( VP() )
+ libvlc_media_player_set_hwnd( VP()->get_mp(), hWnd() );
}
void VLCHolderWnd::LibVlcDetach()
{
- libvlc_media_player_t* p_md = MP();
- if(p_md)
- libvlc_media_player_set_hwnd(p_md, 0);
+ if( VP() )
+ libvlc_media_player_set_hwnd( VP()->get_mp(), 0);
MouseHook(false);
}
@@ -931,7 +926,7 @@ VLCFullScreenWnd* VLCFullScreenWnd::CreateFSWindow(VLCWindowsManager* WM)
///////////////////////
VLCWindowsManager::VLCWindowsManager(HMODULE hModule, const VLCViewResources& rc,
const vlc_player_options* po)
- :_rc(rc), _hModule(hModule), _po(po), _hWindowedParentWnd(0), _p_md(0),
+ :_rc(rc), _hModule(hModule), _po(po), _hWindowedParentWnd(0), _vp(0),
_HolderWnd(0), _FSWnd(0), _b_new_messages_flag(false), Last_WM_MOUSEMOVE_Pos(0)
{
VLCFullScreenWnd::RegisterWndClassName(hModule);
@@ -967,17 +962,17 @@ void VLCWindowsManager::DestroyWindows()
_FSWnd = 0;
}
-void VLCWindowsManager::LibVlcAttach(libvlc_media_player_t* p_md)
+void VLCWindowsManager::LibVlcAttach(vlc_player* vp)
{
if(!_HolderWnd)
return;//VLCWindowsManager::CreateWindows was not called
- if(_p_md && _p_md != p_md){
+ if( vp && _vp != vp ){
LibVlcDetach();
}
- if(!_p_md){
- _p_md = p_md;
+ if( !_vp ){
+ _vp = vp;
VlcEvents(true);
}
@@ -989,9 +984,9 @@ void VLCWindowsManager::LibVlcDetach()
if(_HolderWnd)
_HolderWnd->LibVlcDetach();
- if(_p_md){
+ if(_vp){
VlcEvents(false);
- _p_md = 0;
+ _vp = 0;
}
}
@@ -1000,8 +995,8 @@ void VLCWindowsManager::StartFullScreen()
if( !_HolderWnd || ( PO() && !PO()->get_enable_fs() ) )
return;//VLCWindowsManager::CreateWindows was not called
- if(getMD()&&!IsFullScreen()){
- if(!_FSWnd){
+ if( VP() && !IsFullScreen() ){
+ if( !_FSWnd ){
_FSWnd= VLCFullScreenWnd::CreateFSWindow(this);
}
@@ -1095,12 +1090,13 @@ void VLCWindowsManager::OnLibVlcEvent_proxy(const libvlc_event_t* event, void *p
void VLCWindowsManager::VlcEvents(bool Attach)
{
- libvlc_media_player_t* p_md = getMD();
- if( !p_md )
+ if( !VP() )
return;
+ vlc_player& vp = *VP();
+
libvlc_event_manager_t* em =
- libvlc_media_player_event_manager(p_md);
+ libvlc_media_player_event_manager( vp.get_mp() );
if(!em)
return;
diff --git a/common/win32_fullscreen.h b/common/win32_fullscreen.h
index 8faf2b9..d60800d 100644
--- a/common/win32_fullscreen.h
+++ b/common/win32_fullscreen.h
@@ -30,6 +30,7 @@
#include "win32_vlcwnd.h"
#include "vlc_player_options.h"
+#include "vlc_player.h"
struct VLCViewResources
{
@@ -103,9 +104,8 @@ private:
bool IsPlaying()
{
- libvlc_media_player_t* mp = MP();
- if( mp )
- return libvlc_media_player_is_playing(mp) != 0;
+ if( VP() )
+ return VP()->is_playing();
return false;
}
@@ -114,7 +114,7 @@ private:
VLCWindowsManager& WM() {return *_wm;}
inline const VLCViewResources& RC();
- inline libvlc_media_player_t* MP() const;
+ inline vlc_player* VP() const;
inline const vlc_player_options* PO() const;
void CreateToolTip();
@@ -174,7 +174,7 @@ private:
VLCWindowsManager& WM()
{return *_wm;}
- inline libvlc_media_player_t* MP() const;
+ inline vlc_player* VP() const;
inline const VLCViewResources& RC() const;
inline const vlc_player_options* PO() const;
@@ -217,7 +217,7 @@ private:
private:
VLCWindowsManager& WM()
{return *_WindowsManager;}
- inline libvlc_media_player_t* getMD() const;
+ inline vlc_player* VP() const;
inline const VLCViewResources& RC() const;
public:
@@ -255,7 +255,7 @@ public:
void CreateWindows(HWND hWindowedParentWnd);
void DestroyWindows();
- void LibVlcAttach(libvlc_media_player_t* p_md);
+ void LibVlcAttach(vlc_player*);
void LibVlcDetach();
void StartFullScreen();
@@ -266,7 +266,7 @@ public:
HMODULE getHModule() const {return _hModule;};
VLCHolderWnd* getHolderWnd() const {return _HolderWnd;}
VLCFullScreenWnd* getFullScreenWnd() const {return _FSWnd;}
- libvlc_media_player_t* getMD() const {return _p_md;}
+ vlc_player* VP() const {return _vp;}
const VLCViewResources& RC() const {return _rc;}
const vlc_player_options* PO() const {return _po;}
@@ -291,7 +291,7 @@ private:
HWND _hWindowedParentWnd;
- libvlc_media_player_t* _p_md;
+ vlc_player* _vp;
VLCHolderWnd* _HolderWnd;
VLCFullScreenWnd* _FSWnd;
@@ -305,9 +305,9 @@ private:
////////////////////////////
//inlines
////////////////////////////
-inline libvlc_media_player_t* VLCControlsWnd::MP() const
+inline vlc_player* VLCControlsWnd::VP() const
{
- return _wm->getMD();
+ return _wm->VP();
}
inline const VLCViewResources& VLCControlsWnd::RC()
@@ -320,9 +320,9 @@ inline const vlc_player_options* VLCControlsWnd::PO() const
return _wm->PO();
}
-inline libvlc_media_player_t* VLCHolderWnd::MP() const
+inline vlc_player* VLCHolderWnd::VP() const
{
- return _wm->getMD();
+ return _wm->VP();
}
inline const VLCViewResources& VLCHolderWnd::RC() const
@@ -335,9 +335,9 @@ inline const vlc_player_options* VLCHolderWnd::PO() const
return _wm->PO();
}
-inline libvlc_media_player_t* VLCFullScreenWnd::getMD() const
+inline vlc_player* VLCFullScreenWnd::VP() const
{
- return _WindowsManager->getMD();
+ return _WindowsManager->VP();
}
inline const VLCViewResources& VLCFullScreenWnd::RC() const
diff --git a/npapi/vlcplugin_win.cpp b/npapi/vlcplugin_win.cpp
index cb78b84..2964ff1 100644
--- a/npapi/vlcplugin_win.cpp
+++ b/npapi/vlcplugin_win.cpp
@@ -185,7 +185,7 @@ bool VlcPluginWin::create_windows()
_WindowsManager.CreateWindows(drawable);
if( get_player().is_open() )
- _WindowsManager.LibVlcAttach(get_player().get_mp());
+ _WindowsManager.LibVlcAttach(&get_player());
return true;
}
@@ -220,7 +220,7 @@ bool VlcPluginWin::destroy_windows()
void VlcPluginWin::on_media_player_new()
{
- _WindowsManager.LibVlcAttach(get_player().get_mp());
+ _WindowsManager.LibVlcAttach(&get_player());
}
void VlcPluginWin::on_media_player_release()
--
1.7.7.1.msysgit.0
More information about the vlc-devel
mailing list