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 
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", "");
28 }
29 
32 {
33  LOG(VB_GENERAL, LOG_INFO, LOC + "Initialising visualiser");
36 }
37 
39 {
41 }
42 
44 {
45  m_visualiserState.m_canVisualise = State.m_channels == 1 || State.m_channels == 2;
47 }
48 
50 {
51  m_uiScreenRect = Rect;
52 }
53 
55 {
56  delete m_visual;
57  m_visual = nullptr;
60 }
61 
62 void MythPlayerVisualiserUI::EnableVisualiser(bool Enable, bool Toggle, const QString &Name)
63 {
64  bool osd = true;
65  QString visualiser = Name;
66  if (visualiser.startsWith("_AUTO_"))
67  {
68  visualiser = visualiser.mid(6);
69  osd = false;
70  }
71 
72  bool want = Enable || !visualiser.isEmpty();
73  if (Toggle)
75 
76  if (!want || !m_visualiserState.m_canVisualise)
77  {
79  }
81  {
82  if (visualiser.isEmpty())
83  visualiser = m_defaultVisualiser;
84 
85  if (m_visualiserState.m_visualiserName != visualiser)
86  {
89  if (m_visual)
90  {
93  }
94  }
95  }
96 
97  if (osd)
98  UpdateOSDMessage(m_visual ? m_visualiserState.m_visualiserName : tr("Visualisation Off"));
100 }
101 
105 {
106  m_checkAutoVisualise = false;
107 
108  if (HaveVideo || !m_audio.HasAudioIn() || m_defaultVisualiser.isEmpty())
109  return;
110 
112  return;
113 
114  EnableVisualiser(true, false, "_AUTO_" + m_defaultVisualiser);
115 }
116 
117 void MythPlayerVisualiserUI::EmbedVisualiser(bool Embed, QRect Rect)
118 {
119  m_embedRect = Rect;
122 }
123 
125 {
126  // Note - we must call the visualiser to drain its buffers even if it is not
127  // to be displayed (otherwise it fails). So do not check for output rect
128  // size (embedding) etc
129  if (!m_visual)
130  return;
131  if (m_visual->NeedsPrepare())
133 }
134 
136 {
137  // As for PrepareVisualiser - always call the visualiser if it is present
138  if (!m_visual)
139  return;
141 }
MythUIScreenBounds::GetUIScreenRect
QRect GetUIScreenRect()
Definition: mythuiscreenbounds.cpp:192
MythPlayerVisualiserUI::m_checkAutoVisualise
bool m_checkAutoVisualise
Definition: mythplayervisualiserui.h:31
MythPlayerVisualiserUI::~MythPlayerVisualiserUI
~MythPlayerVisualiserUI() override
Definition: mythplayervisualiserui.cpp:38
MythPlayerVisualiserUI::m_visual
VideoVisual * m_visual
Definition: mythplayervisualiserui.h:38
MythPlayerVisualiserUI::PrepareVisualiser
void PrepareVisualiser()
Definition: mythplayervisualiserui.cpp:124
MythVisualiserState::m_embedding
bool m_embedding
Definition: mythplayerstate.h:119
MythPlayerVisualiserUI::m_embedRect
QRect m_embedRect
Definition: mythplayervisualiserui.h:40
MythVisualiserState::m_visualising
bool m_visualising
Definition: mythplayerstate.h:120
VideoVisual::Create
static VideoVisual * Create(const QString &name, AudioPlayer *audio, MythRender *render)
Definition: videovisual.cpp:20
VideoVisual::NeedsPrepare
bool NeedsPrepare() const
Definition: videovisual.h:50
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:122
MythPlayerVisualiserUI::EmbedVisualiser
void EmbedVisualiser(bool Embed, QRect Rect={})
Definition: mythplayervisualiserui.cpp:117
Context
QHash< QString, Action * > Context
Definition: action.h:77
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
PlayerFlags
PlayerFlags
Definition: mythplayer.h:62
MythPlayerVisualiserUI::RenderVisualiser
void RenderVisualiser()
Definition: mythplayervisualiserui.cpp:135
VideoVisual::Name
virtual QString Name(void)=0
MythPlayerCaptionsUI::InitialiseState
void InitialiseState() override
Definition: mythplayercaptionsui.cpp:60
MythPlayer::m_audio
AudioPlayer m_audio
Definition: mythplayer.h:477
MythPlayerOverlayUI::UpdateOSDMessage
void UpdateOSDMessage(const QString &Message)
Definition: mythplayeroverlayui.cpp:71
MythVisualiserState::m_canVisualise
bool m_canVisualise
Definition: mythplayerstate.h:118
MythVisualiserState::m_visualiserName
QString m_visualiserName
Definition: mythplayerstate.h:121
MythPlayerUIBase::m_painter
MythPainter * m_painter
Definition: mythplayeruibase.h:17
VideoVisual::Draw
virtual void Draw(QRect area, MythPainter *painter, QPaintDevice *device)=0
State
State
Definition: zmserver.h:65
AudioPlayer::HasAudioIn
bool HasAudioIn(void) const
Definition: audioplayer.h:53
TVPlaybackState::VisualiserStateChanged
void VisualiserStateChanged(const MythVisualiserState &VisualiserState)
Definition: tvplaybackstate.cpp:43
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:62
MythPlayerVisualiserUI::InitialiseState
void InitialiseState() override
Set initial state and update player.
Definition: mythplayervisualiserui.cpp:31
mythcorecontext.h
LOC
#define LOC
Definition: mythplayervisualiserui.cpp:8
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:49
MythPlayerUIBase::m_mainWindow
MythMainWindow * m_mainWindow
Definition: mythplayeruibase.h:14
MythPlayerUIBase::m_tv
TV * m_tv
Definition: mythplayeruibase.h:15
MythPlayerVisualiserUI::AutoVisualise
void AutoVisualise(bool HaveVideo)
Enable visualisation if possible, there is no video and user has requested.
Definition: mythplayervisualiserui.cpp:104
MythPlayerVisualiserUI::DestroyVisualiser
void DestroyVisualiser()
Definition: mythplayervisualiserui.cpp:54
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:49
audioplayer.h
MythPlayerVisualiserUI::AudioPlayerStateChanged
void AudioPlayerStateChanged(const MythAudioPlayerState &State)
Definition: mythplayervisualiserui.cpp:43
MythRender::Type
RenderType Type(void) const
Definition: mythrender_base.h:32
VideoVisual::Prepare
virtual void Prepare(const QRect)
Definition: videovisual.h:51
MythPlayerUIBase::m_render
MythRender * m_render
Definition: mythplayeruibase.h:16
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:919
tv_play.h
TV
Control TV playback.
Definition: tv_play.h:153
MythAudioPlayerState
Definition: mythplayerstate.h:31