MythTV
master
mythtv
libs
libmythtv
mythplayervisualiserui.cpp
Go to the documentation of this file.
1
// MythTV
2
#include "
libmythbase/mythcorecontext.h
"
3
#include "
libmythui/mythmainwindow.h
"
4
5
#include "
audioplayer.h
"
6
#include "
mythplayervisualiserui.h
"
7
#include "
tv_play.h
"
8
9
#define LOC QString("PlayerVis: ")
10
11
MythPlayerVisualiserUI::MythPlayerVisualiserUI
(
MythMainWindow
*MainWindow,
TV
*Tv,
12
PlayerContext
*Context,
PlayerFlags
Flags)
13
:
MythPlayerVideoUI
(MainWindow, Tv, Context, Flags)
14
{
15
// Register our state type for signalling
16
qRegisterMetaType<MythVisualiserState>();
17
18
// Connect signals and slots
19
connect(&
m_audio
, &
AudioPlayer::AudioPlayerStateChanged
,
this
, &
MythPlayerVisualiserUI::AudioPlayerStateChanged
);
20
connect(
m_mainWindow
, &
MythMainWindow::UIScreenRectChanged
,
this
, &
MythPlayerVisualiserUI::UIScreenRectChanged
);
21
connect(
m_tv
, &
TV::EnableVisualiser
,
this
, &
MythPlayerVisualiserUI::EnableVisualiser
);
22
connect(
m_tv
, &
TV::EmbedPlayback
,
this
, &
MythPlayerVisualiserUI::EmbedVisualiser
);
23
connect(
this
, &
MythPlayerVisualiserUI::VisualiserStateChanged
,
m_tv
, &
TV::VisualiserStateChanged
);
24
25
26
m_defaultVisualiser
=
gCoreContext
->
GetSetting
(
"AudioVisualiser"
,
""
);
27
m_uiScreenRect
=
m_mainWindow
->
GetUIScreenRect
();
28
if
(
m_render
)
29
{
30
m_visualiserState
.
m_visualiserList
=
VideoVisual::GetVisualiserList
(
m_render
->
Type
());
31
}
32
else
33
{
34
LOG
(VB_GENERAL, LOG_ERR,
LOC
+
"Failed to initialise m_visualiserList, m_render null"
);
35
}
36
}
37
39
void
MythPlayerVisualiserUI::InitialiseState
()
40
{
41
LOG
(VB_GENERAL, LOG_INFO,
LOC
+
"Initialising visualiser"
);
42
emit
VisualiserStateChanged
(
m_visualiserState
);
43
MythPlayerVideoUI::InitialiseState
();
44
}
45
46
MythPlayerVisualiserUI::~MythPlayerVisualiserUI
()
47
{
48
MythPlayerVisualiserUI::DestroyVisualiser
();
49
}
50
51
void
MythPlayerVisualiserUI::AudioPlayerStateChanged
(
const
MythAudioPlayerState
&
State
)
52
{
53
m_visualiserState
.
m_canVisualise
=
State
.m_channels == 1 ||
State
.m_channels == 2;
54
emit
VisualiserStateChanged
(
m_visualiserState
);
55
}
56
57
void
MythPlayerVisualiserUI::UIScreenRectChanged
(QRect Rect)
58
{
59
m_uiScreenRect
= Rect;
60
}
61
62
void
MythPlayerVisualiserUI::DestroyVisualiser
()
63
{
64
delete
m_visual
;
65
m_visual
=
nullptr
;
66
m_visualiserState
.
m_visualiserName
= QString();
67
m_visualiserState
.
m_visualising
=
false
;
68
}
69
70
void
MythPlayerVisualiserUI::EnableVisualiser
(
bool
Enable,
bool
Toggle,
const
QString &
Name
)
71
{
72
bool
osd =
true
;
73
QString visualiser =
Name
;
74
if
(visualiser.startsWith(
"_AUTO_"
))
75
{
76
visualiser = visualiser.mid(6);
77
osd =
false
;
78
}
79
80
bool
want = Enable || !visualiser.isEmpty();
81
if
(Toggle)
82
want = !
m_visualiserState
.
m_visualising
;
83
84
if
(!want || !
m_visualiserState
.
m_canVisualise
)
85
{
86
DestroyVisualiser
();
87
}
88
else
if
(
m_visualiserState
.
m_canVisualise
)
89
{
90
if
(visualiser.isEmpty())
91
visualiser =
m_defaultVisualiser
;
92
93
if
(
m_visualiserState
.
m_visualiserName
!= visualiser)
94
{
95
DestroyVisualiser
();
96
m_visual
=
VideoVisual::Create
(visualiser, &
m_audio
,
m_render
);
97
if
(
m_visual
)
98
{
99
m_visualiserState
.
m_visualiserName
=
m_visual
->
Name
();
100
m_visualiserState
.
m_visualising
=
true
;
101
}
102
}
103
}
104
105
if
(osd)
106
UpdateOSDMessage
(
m_visual
?
m_visualiserState
.
m_visualiserName
: tr(
"Visualisation Off"
));
107
emit
VisualiserStateChanged
(
m_visualiserState
);
108
}
109
112
void
MythPlayerVisualiserUI::AutoVisualise
(
bool
HaveVideo)
113
{
114
m_checkAutoVisualise
=
false
;
115
116
if
(HaveVideo || !
m_audio
.
HasAudioIn
() ||
m_defaultVisualiser
.isEmpty())
117
return
;
118
119
if
(!
m_visualiserState
.
m_canVisualise
||
m_visualiserState
.
m_visualising
)
120
return
;
121
122
EnableVisualiser
(
true
,
false
,
"_AUTO_"
+
m_defaultVisualiser
);
123
}
124
125
void
MythPlayerVisualiserUI::EmbedVisualiser
(
bool
Embed, QRect Rect)
126
{
127
m_embedRect
= Rect;
128
m_visualiserState
.
m_embedding
= Embed;
129
emit
VisualiserStateChanged
(
m_visualiserState
);
130
}
131
132
void
MythPlayerVisualiserUI::PrepareVisualiser
()
133
{
134
// Note - we must call the visualiser to drain its buffers even if it is not
135
// to be displayed (otherwise it fails). So do not check for output rect
136
// size (embedding) etc
137
if
(!
m_visual
)
138
return
;
139
if
(
m_visual
->
NeedsPrepare
())
140
m_visual
->
Prepare
(
m_visualiserState
.
m_embedding
?
m_embedRect
:
m_uiScreenRect
);
141
}
142
143
void
MythPlayerVisualiserUI::RenderVisualiser
()
144
{
145
// As for PrepareVisualiser - always call the visualiser if it is present
146
if
(!
m_visual
)
147
return
;
148
m_visual
->
Draw
(
m_visualiserState
.
m_embedding
?
m_embedRect
:
m_uiScreenRect
,
m_painter
,
nullptr
);
149
}
MythUIScreenBounds::GetUIScreenRect
QRect GetUIScreenRect()
Definition:
mythuiscreenbounds.cpp:198
MythPlayerVisualiserUI::m_checkAutoVisualise
bool m_checkAutoVisualise
Definition:
mythplayervisualiserui.h:31
MythPlayerVisualiserUI::~MythPlayerVisualiserUI
~MythPlayerVisualiserUI() override
Definition:
mythplayervisualiserui.cpp:46
MythPlayerVisualiserUI::m_visual
VideoVisual * m_visual
Definition:
mythplayervisualiserui.h:38
MythPlayerVisualiserUI::PrepareVisualiser
void PrepareVisualiser()
Definition:
mythplayervisualiserui.cpp:132
MythVisualiserState::m_embedding
bool m_embedding
Definition:
mythplayerstate.h:136
MythPlayerVisualiserUI::m_embedRect
QRect m_embedRect
Definition:
mythplayervisualiserui.h:40
MythVisualiserState::m_visualising
bool m_visualising
Definition:
mythplayerstate.h:137
VideoVisual::Create
static VideoVisual * Create(const QString &name, AudioPlayer *audio, MythRender *render)
Definition:
videovisual.cpp:22
VideoVisual::NeedsPrepare
bool NeedsPrepare() const
Definition:
videovisual.h:53
MythPlayerVisualiserUI::m_uiScreenRect
QRect m_uiScreenRect
Definition:
mythplayervisualiserui.h:39
TVPlaybackState::EnableVisualiser
void EnableVisualiser(bool Enable, bool Toggle=false, const QString &Name=QString())
AudioPlayer::AudioPlayerStateChanged
void AudioPlayerStateChanged(MythAudioPlayerState State)
MythVisualiserState::m_visualiserList
QStringList m_visualiserList
Definition:
mythplayerstate.h:139
MythPlayerVisualiserUI::EmbedVisualiser
void EmbedVisualiser(bool Embed, QRect Rect={})
Definition:
mythplayervisualiserui.cpp:125
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition:
mythlogging.h:39
PlayerFlags
PlayerFlags
Definition:
mythplayer.h:64
MythPlayerVisualiserUI::RenderVisualiser
void RenderVisualiser()
Definition:
mythplayervisualiserui.cpp:143
VideoVisual::Name
virtual QString Name(void)=0
MythPlayerCaptionsUI::InitialiseState
void InitialiseState() override
Definition:
mythplayercaptionsui.cpp:61
State
State
Definition:
zmserver.h:68
MythPlayer::m_audio
AudioPlayer m_audio
Definition:
mythplayer.h:471
MythPlayerOverlayUI::UpdateOSDMessage
void UpdateOSDMessage(const QString &Message)
Definition:
mythplayeroverlayui.cpp:76
MythVisualiserState::m_canVisualise
bool m_canVisualise
Definition:
mythplayerstate.h:135
MythVisualiserState::m_visualiserName
QString m_visualiserName
Definition:
mythplayerstate.h:138
MythPlayerUIBase::m_painter
MythPainter * m_painter
Definition:
mythplayeruibase.h:20
VideoVisual::Draw
virtual void Draw(QRect area, MythPainter *painter, QPaintDevice *device)=0
AudioPlayer::HasAudioIn
bool HasAudioIn(void) const
Definition:
audioplayer.h:51
TVPlaybackState::VisualiserStateChanged
void VisualiserStateChanged(const MythVisualiserState &VisualiserState)
Definition:
tvplaybackstate.cpp:48
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition:
mythcorecontext.cpp:55
VideoVisual::GetVisualiserList
static QStringList GetVisualiserList(RenderType type)
Definition:
videovisual.cpp:9
MythPlayerVisualiserUI::m_visualiserState
MythVisualiserState m_visualiserState
Definition:
mythplayervisualiserui.h:37
mythplayervisualiserui.h
MythPlayerVisualiserUI::EnableVisualiser
void EnableVisualiser(bool Enable, bool Toggle, const QString &Name)
Definition:
mythplayervisualiserui.cpp:70
MythPlayerVisualiserUI::InitialiseState
void InitialiseState() override
Set initial state and update player.
Definition:
mythplayervisualiserui.cpp:39
mythcorecontext.h
LOC
#define LOC
Definition:
mythplayervisualiserui.cpp:9
MythPlayerVisualiserUI::VisualiserStateChanged
void VisualiserStateChanged(MythVisualiserState VisualiserState)
Name
Definition:
channelsettings.cpp:71
MythUIScreenBounds::UIScreenRectChanged
void UIScreenRectChanged(const QRect &Rect)
MythPlayerVisualiserUI::UIScreenRectChanged
void UIScreenRectChanged(QRect Rect)
Definition:
mythplayervisualiserui.cpp:57
MythPlayerUIBase::m_mainWindow
MythMainWindow * m_mainWindow
Definition:
mythplayeruibase.h:17
MythPlayerUIBase::m_tv
TV * m_tv
Definition:
mythplayeruibase.h:18
MythPlayerVisualiserUI::AutoVisualise
void AutoVisualise(bool HaveVideo)
Enable visualisation if possible, there is no video and user has requested.
Definition:
mythplayervisualiserui.cpp:112
MythPlayerVisualiserUI::DestroyVisualiser
void DestroyVisualiser()
Definition:
mythplayervisualiserui.cpp:62
MythPlayerVisualiserUI::MythPlayerVisualiserUI
MythPlayerVisualiserUI(MythMainWindow *MainWindow, TV *Tv, PlayerContext *Context, PlayerFlags Flags)
Definition:
mythplayervisualiserui.cpp:11
TVPlaybackState::EmbedPlayback
void EmbedPlayback(bool Embed, const QRect &Rect={})
MythPlayerVisualiserUI::m_defaultVisualiser
QString m_defaultVisualiser
Definition:
mythplayervisualiserui.h:36
PlayerContext
Definition:
playercontext.h:49
audioplayer.h
MythPlayerVisualiserUI::AudioPlayerStateChanged
void AudioPlayerStateChanged(const MythAudioPlayerState &State)
Definition:
mythplayervisualiserui.cpp:51
MythRender::Type
RenderType Type(void) const
Definition:
mythrender_base.h:32
VideoVisual::Prepare
virtual void Prepare(const QRect)
Definition:
videovisual.h:54
MythPlayerUIBase::m_render
MythRender * m_render
Definition:
mythplayeruibase.h:19
MythPlayerVideoUI
Definition:
mythplayervideoui.h:33
mythmainwindow.h
MythMainWindow
Definition:
mythmainwindow.h:28
MythCoreContext::GetSetting
QString GetSetting(const QString &key, const QString &defaultval="")
Definition:
mythcorecontext.cpp:902
tv_play.h
TV
Control TV playback.
Definition:
tv_play.h:154
MythAudioPlayerState
Definition:
mythplayerstate.h:31
Generated on Sat Jan 4 2025 03:16:42 for MythTV by
1.8.17