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