MythTV  master
mythplayervisualiserui.cpp
Go to the documentation of this file.
1 // MythTV
4 
5 #include "audioplayer.h"
7 #include "tv_play.h"
8 
9 #define LOC QString("PlayerVis: ")
10 
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
24 
25 
26  m_defaultVisualiser = gCoreContext->GetSetting("AudioVisualiser", "");
28  if (m_render)
29  {
31  }
32  else
33  {
34  LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to initialise m_visualiserList, m_render null");
35  }
36 }
37 
40 {
41  LOG(VB_GENERAL, LOG_INFO, LOC + "Initialising visualiser");
44 }
45 
47 {
49 }
50 
52 {
53  m_visualiserState.m_canVisualise = State.m_channels == 1 || State.m_channels == 2;
55 }
56 
58 {
59  m_uiScreenRect = Rect;
60 }
61 
63 {
64  delete m_visual;
65  m_visual = nullptr;
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)
83 
84  if (!want || !m_visualiserState.m_canVisualise)
85  {
87  }
89  {
90  if (visualiser.isEmpty())
91  visualiser = m_defaultVisualiser;
92 
93  if (m_visualiserState.m_visualiserName != visualiser)
94  {
97  if (m_visual)
98  {
101  }
102  }
103  }
104 
105  if (osd)
106  UpdateOSDMessage(m_visual ? m_visualiserState.m_visualiserName : tr("Visualisation Off"));
108 }
109 
113 {
114  m_checkAutoVisualise = false;
115 
116  if (HaveVideo || !m_audio.HasAudioIn() || m_defaultVisualiser.isEmpty())
117  return;
118 
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;
130 }
131 
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())
141 }
142 
144 {
145  // As for PrepareVisualiser - always call the visualiser if it is present
146  if (!m_visual)
147  return;
149 }
MythUIScreenBounds::GetUIScreenRect
QRect GetUIScreenRect()
Definition: mythuiscreenbounds.cpp:196
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:20
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:65
MythPlayerVisualiserUI::RenderVisualiser
void RenderVisualiser()
Definition: mythplayervisualiserui.cpp:143
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:479
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
State
State
Definition: zmserver.h:68
AudioPlayer::HasAudioIn
bool HasAudioIn(void) const
Definition: audioplayer.h:55
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: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: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:47
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:53
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:898
tv_play.h
TV
Control TV playback.
Definition: tv_play.h:154
MythAudioPlayerState
Definition: mythplayerstate.h:31