MythTV  master
Stream.h
Go to the documentation of this file.
1 /* Stream.h
2 
3  Copyright (C) David C. J. Matthews 2004 dm at prolingua.co.uk
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public License
7  as published by the Free Software Foundation; either version 2
8  of the License, or (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
18  Or, point your browser to http://www.gnu.org/copyleft/gpl.html
19 
20 */
21 
22 #if !defined(STREAM_H)
23 #define STREAM_H
24 
25 #include "Presentable.h"
26 // Dependencies
27 #include "Ingredients.h"
28 #include "Root.h"
29 #include "BaseClasses.h"
30 #include "Actions.h"
31 
32 class MHStream : public MHPresentable
33 {
34  public:
35  MHStream() = default;
36  const char *ClassName() override // MHRoot
37  { return "Stream"; }
38  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHIngredient
39  void PrintMe(FILE *fd, int nTabs) const override; // MHIngredient
40 
41  void Preparation(MHEngine *engine) override; // MHIngredient
42  void Activation(MHEngine *engine) override; // MHRoot
43  void Deactivation(MHEngine *engine) override; // MHRoot
44  void Destruction(MHEngine *engine) override; // MHIngredient
45  void ContentPreparation(MHEngine *engine) override; // MHIngredient
46 
47  MHRoot *FindByObjectNo(int n) override; // MHRoot
48 
49  void BeginPlaying(MHEngine *engine) override; // MHPresentable
50  void StopPlaying(MHEngine *engine) override; // MHPresentable
51 
52  // Actions
53  void GetCounterPosition(MHRoot *pResult, MHEngine *engine) override; // MHRoot
54  void GetCounterMaxPosition(MHRoot *pResult, MHEngine *engine) override; // MHRoot
55  void SetCounterPosition(int /*pos*/, MHEngine *engine) override; // MHRoot
56  void SetSpeed(int speed, MHEngine *engine) override; // MHRoot
57 
58  protected:
60  enum Storage : std::uint8_t
61  { ST_Mem = 1, ST_Stream = 2 } m_nStorage {ST_Stream};
62  int m_nLooping {0}; // Infinity
63 };
64 
65 
66 class MHAudio : public MHPresentable
67 {
68  public:
69  MHAudio() = default;
70  const char *ClassName() override // MHRoot
71  { return "Audio"; }
72  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHIngredient
73  void PrintMe(FILE *fd, int nTabs) const override; // MHIngredient
74 
75  void Activation(MHEngine *engine) override; // MHRoot
76  void Deactivation(MHEngine *engine) override; // MHRoot
77 
78  void BeginPlaying(MHEngine *engine) override; // MHPresentable
79  void StopPlaying(MHEngine *engine) override; // MHPresentable
80 
81  protected:
82  int m_nComponentTag {0};
83  int m_nOriginalVol {0};
84 
85  bool m_fStreamPlaying {false};
86 };
87 
88 class MHVideo : public MHVisible
89 {
90  public:
91  MHVideo() = default;
92  const char *ClassName() override // MHRoot
93  { return "Video"; }
94  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHVisible
95  void PrintMe(FILE *fd, int nTabs) const override; // MHVisible
96 
97  void Preparation(MHEngine *engine) override; // MHVisible
98  void ContentPreparation(MHEngine *engine) override; // MHIngredient
99 
100  void Activation(MHEngine *engine) override; // MHVisible
101  void Deactivation(MHEngine *engine) override; // MHVisible
102 
103  void Display(MHEngine *engine) override; // MHVisible
104  QRegion GetVisibleArea() override; // MHVisible
105  QRegion GetOpaqueArea() override // MHVisible
106  { return GetVisibleArea(); } // Fully opaque.
107 
108  // Actions.
109  void ScaleVideo(int xScale, int yScale, MHEngine *engine) override; // MHRoot
110  void SetVideoDecodeOffset(int newXOffset, int newYOffset, MHEngine *engine) override; // MHRoot
111  void GetVideoDecodeOffset(MHRoot *pXOffset, MHRoot *pYOffset, MHEngine *engine) override; // MHRoot
112 
113  void BeginPlaying(MHEngine *engine) override; // MHPresentable
114  void StopPlaying(MHEngine *engine) override; // MHPresentable
115 
116  protected:
118  enum Termination : std::uint8_t
119  { VI_Freeze = 1, VI_Disappear } m_termination {VI_Disappear};
120  // Added in UK MHEG
123  int m_nDecodeWidth {0};
125 
126  bool m_fStreamPlaying {false};
127 };
128 
129 // Real-time graphics - not needed for UK MHEG.
130 class MHRTGraphics : public MHVisible
131 {
132  public:
133  MHRTGraphics() = default;
134  const char *ClassName() override // MHRoot
135  { return "RTGraphics"; }
136  ~MHRTGraphics() override = default;
137  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHVisible
138  void PrintMe(FILE *fd, int nTabs) const override; // MHVisible
139  void Display(MHEngine */*engine*/) override {} // MHVisible - Not supported
140 };
141 
142 
144  public:
145  MHScaleVideo(): MHActionIntInt(":ScaleVideo") {}
146  void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg1, int nArg2) override // MHActionIntInt
147  { pTarget->ScaleVideo(nArg1, nArg2, engine); }
148 };
149 
150 // Actions added in the UK MHEG profile.
152 {
153  public:
154  MHSetVideoDecodeOffset(): MHActionIntInt(":SetVideoDecodeOffset") {}
155  void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg1, int nArg2) override // MHActionIntInt
156  { pTarget->SetVideoDecodeOffset(nArg1, nArg2, engine); }
157 };
158 
160 {
161  public:
162  MHGetVideoDecodeOffset(): MHActionObjectRef2(":GetVideoDecodeOffset") {}
163  void CallAction(MHEngine *engine, MHRoot *pTarget, MHRoot *pArg1, MHRoot *pArg2) override // MHActionObjectRef2
164  { pTarget->GetVideoDecodeOffset(pArg1, pArg2, engine); }
165 };
166 
168 {
169 public:
170  explicit MHActionGenericObjectRefFix(const char *name) : MHActionGenericObjectRef(name) {}
171  void Perform(MHEngine *engine) override; // MHActionGenericObjectRef
172 };
173 
175 {
176 public:
178  void CallAction(MHEngine *engine, MHRoot *pTarget, MHRoot *pArg) override // MHActionGenericObjectRef
179  { pTarget->GetCounterPosition(pArg, engine); }
180 };
181 
183 {
184 public:
185  MHGetCounterMaxPosition(): MHActionGenericObjectRefFix(":GetCounterMaxPosition") {}
186  void CallAction(MHEngine *engine, MHRoot *pTarget, MHRoot *pArg) override // MHActionGenericObjectRef
187  { pTarget->GetCounterMaxPosition(pArg, engine); }
188 };
189 
191 {
192 public:
193  MHSetCounterPosition(): MHActionInt(":SetCounterPosition") {}
194  void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg) override // MHActionInt
195  { pTarget->SetCounterPosition(nArg, engine); }
196 };
197 
198 
200 {
202 public:
203  MHSetSpeed(): base(":SetSpeed") {}
204  void Initialise(MHParseNode *p, MHEngine *engine) override { // MHElemAction
205  //printf("SetSpeed Initialise args: "); p->PrintMe(stdout);
206  base::Initialise(p, engine);
207  MHParseNode *pn = p->GetArgN(1);
208  if (pn->m_nNodeType == MHParseNode::PNSeq) pn = pn->GetArgN(0);
209  m_argument.Initialise(pn, engine);
210  }
211  void Perform(MHEngine *engine) override { // MHElemAction
212  Target(engine)->SetSpeed(m_argument.GetValue(engine), engine);
213  }
214 protected:
215  void PrintArgs(FILE *fd, int /*nTabs*/) const override // MHElemAction
216  { m_argument.PrintMe(fd, 0); }
218 };
219 
220 
221 #endif
MHVideo::m_nDecodeHeight
int m_nDecodeHeight
Definition: Stream.h:124
MHStream::StopPlaying
void StopPlaying(MHEngine *engine) override
Definition: Stream.cpp:221
MHStream::m_nLooping
int m_nLooping
Definition: Stream.h:62
MHActionGenericObjectRef
Definition: BaseActions.h:146
MHParseNode::m_nNodeType
enum NodeType m_nNodeType
Definition: ParseNode.h:46
MHRTGraphics::ClassName
const char * ClassName() override
Definition: Stream.h:134
Presentable.h
MHRTGraphics::MHRTGraphics
MHRTGraphics()=default
MHStream::PrintMe
void PrintMe(FILE *fd, int nTabs) const override
Definition: Stream.cpp:86
MHSetCounterPosition::CallAction
void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg) override
Definition: Stream.h:194
MHPresentable
Definition: Presentable.h:34
MHAudio::m_nComponentTag
int m_nComponentTag
Definition: Stream.h:82
MHActionGenericObjectRefFix
Definition: Stream.h:167
MHStream
Definition: Stream.h:32
MHSetCounterPosition::MHSetCounterPosition
MHSetCounterPosition()
Definition: Stream.h:193
MHVideo::StopPlaying
void StopPlaying(MHEngine *engine) override
Definition: Stream.cpp:501
MHSetVideoDecodeOffset::CallAction
void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg1, int nArg2) override
Definition: Stream.h:155
MHVideo::Display
void Display(MHEngine *engine) override
Definition: Stream.cpp:399
MHEngine
Definition: Engine.h:72
MHAudio::Initialise
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Stream.cpp:253
MHVideo::m_nDecodeWidth
int m_nDecodeWidth
Definition: Stream.h:123
MHVideo::VI_Disappear
enum MHVideo::Termination VI_Disappear
MHStream::Activation
void Activation(MHEngine *engine) override
Definition: Stream.cpp:149
MHScaleVideo
Definition: Stream.h:143
MHVideo::m_nComponentTag
int m_nComponentTag
Definition: Stream.h:117
MHAudio::Activation
void Activation(MHEngine *engine) override
Definition: Stream.cpp:290
MHGenericInteger::Initialise
void Initialise(MHParseNode *p, MHEngine *engine)
Definition: BaseClasses.cpp:382
MHGenericInteger
Definition: BaseClasses.h:213
MHRoot::SetSpeed
virtual void SetSpeed(int, MHEngine *)
Definition: Root.h:222
MHElemAction::Initialise
virtual void Initialise(MHParseNode *p, MHEngine *engine)
Definition: BaseActions.cpp:31
MHAudio::Deactivation
void Deactivation(MHEngine *engine) override
Definition: Stream.cpp:307
MHGetVideoDecodeOffset::CallAction
void CallAction(MHEngine *engine, MHRoot *pTarget, MHRoot *pArg1, MHRoot *pArg2) override
Definition: Stream.h:163
MHStream::ClassName
const char * ClassName() override
Definition: Stream.h:36
Actions.h
MHVideo::GetOpaqueArea
QRegion GetOpaqueArea() override
Definition: Stream.h:105
MHStream::GetCounterMaxPosition
void GetCounterMaxPosition(MHRoot *pResult, MHEngine *engine) override
Definition: Stream.cpp:236
mythburn.FILE
int FILE
Definition: mythburn.py:139
MHGetCounterMaxPosition::MHGetCounterMaxPosition
MHGetCounterMaxPosition()
Definition: Stream.h:185
MHSetSpeed::m_argument
MHGenericInteger m_argument
Definition: Stream.h:217
MHVideo::m_fStreamPlaying
bool m_fStreamPlaying
Definition: Stream.h:126
MHVideo::Preparation
void Preparation(MHEngine *engine) override
Definition: Stream.cpp:379
MHSetSpeed::Initialise
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Stream.h:204
MHAudio::StopPlaying
void StopPlaying(MHEngine *engine) override
Definition: Stream.cpp:332
MHGetCounterPosition::MHGetCounterPosition
MHGetCounterPosition()
Definition: Stream.h:177
MHGetCounterPosition
Definition: Stream.h:174
MHGetCounterPosition::CallAction
void CallAction(MHEngine *engine, MHRoot *pTarget, MHRoot *pArg) override
Definition: Stream.h:178
MHSetSpeed::MHSetSpeed
MHSetSpeed()
Definition: Stream.h:203
MHVideo::GetVisibleArea
QRegion GetVisibleArea() override
Definition: Stream.cpp:452
hardwareprofile.config.p
p
Definition: config.py:33
MHVideo::Deactivation
void Deactivation(MHEngine *engine) override
Definition: Stream.cpp:479
MHSetSpeed
Definition: Stream.h:199
MHStream::Preparation
void Preparation(MHEngine *engine) override
Definition: Stream.cpp:118
MHGetVideoDecodeOffset::MHGetVideoDecodeOffset
MHGetVideoDecodeOffset()
Definition: Stream.h:162
MHVideo::ScaleVideo
void ScaleVideo(int xScale, int yScale, MHEngine *engine) override
Definition: Stream.cpp:420
MHStream::Destruction
void Destruction(MHEngine *engine) override
Definition: Stream.cpp:138
MHStream::Deactivation
void Deactivation(MHEngine *engine) override
Definition: Stream.cpp:165
MHVideo::BeginPlaying
void BeginPlaying(MHEngine *engine) override
Definition: Stream.cpp:494
MHScaleVideo::CallAction
void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg1, int nArg2) override
Definition: Stream.h:146
MHSetVideoDecodeOffset::MHSetVideoDecodeOffset
MHSetVideoDecodeOffset()
Definition: Stream.h:154
MHParseNode::GetArgN
MHParseNode * GetArgN(int n)
Definition: ParseNode.cpp:78
MHStream::GetCounterPosition
void GetCounterPosition(MHRoot *pResult, MHEngine *engine) override
Definition: Stream.cpp:230
MHVideo::m_nYDecodeOffset
int m_nYDecodeOffset
Definition: Stream.h:122
MHStream::SetCounterPosition
void SetCounterPosition(int, MHEngine *engine) override
Definition: Stream.cpp:242
MHAudio::ClassName
const char * ClassName() override
Definition: Stream.h:70
MHAudio::MHAudio
MHAudio()=default
MHActionIntInt
Definition: BaseActions.h:65
MHRTGraphics::PrintMe
void PrintMe(FILE *fd, int nTabs) const override
Definition: Stream.cpp:518
MHStream::ContentPreparation
void ContentPreparation(MHEngine *engine) override
Definition: Stream.cpp:178
MHActionGenericObjectRefFix::MHActionGenericObjectRefFix
MHActionGenericObjectRefFix(const char *name)
Definition: Stream.h:170
Ingredients.h
MHStream::ST_Stream
enum MHStream::Storage ST_Stream
MHAudio::BeginPlaying
void BeginPlaying(MHEngine *engine) override
Definition: Stream.cpp:325
MHActionInt
Definition: BaseActions.h:51
MHStream::FindByObjectNo
MHRoot * FindByObjectNo(int n) override
Definition: Stream.cpp:186
MHActionObjectRef2
Definition: BaseActions.h:133
MHElemAction::Target
MHRoot * Target(MHEngine *engine)
Definition: BaseActions.cpp:46
MHSetCounterPosition
Definition: Stream.h:190
MHVideo::GetVideoDecodeOffset
void GetVideoDecodeOffset(MHRoot *pXOffset, MHRoot *pYOffset, MHEngine *engine) override
Definition: Stream.cpp:445
Root.h
MHVideo
Definition: Stream.h:88
MHStream::Initialise
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Stream.cpp:33
MHStream::SetSpeed
void SetSpeed(int speed, MHEngine *engine) override
Definition: Stream.cpp:248
MHStream::BeginPlaying
void BeginPlaying(MHEngine *engine) override
Definition: Stream.cpp:206
MHGetVideoDecodeOffset
Definition: Stream.h:159
MHVisible
Definition: Visible.h:35
MHVideo::Activation
void Activation(MHEngine *engine) override
Definition: Stream.cpp:467
MHRTGraphics::~MHRTGraphics
~MHRTGraphics() override=default
MHVideo::Termination
Termination
Definition: Stream.h:118
MHSetSpeed::Perform
void Perform(MHEngine *engine) override
Definition: Stream.h:211
MHRTGraphics::Display
void Display(MHEngine *) override
Definition: Stream.h:139
BaseClasses.h
MHVideo::ContentPreparation
void ContentPreparation(MHEngine *engine) override
Definition: Stream.cpp:392
MHVideo::SetVideoDecodeOffset
void SetVideoDecodeOffset(int newXOffset, int newYOffset, MHEngine *engine) override
Definition: Stream.cpp:435
MHParseNode
Definition: ParseNode.h:38
MHVideo::ClassName
const char * ClassName() override
Definition: Stream.h:92
MHGenericInteger::GetValue
int GetValue(MHEngine *engine) const
Definition: BaseClasses.cpp:411
MHVideo::PrintMe
void PrintMe(FILE *fd, int nTabs) const override
Definition: Stream.cpp:361
MHScaleVideo::MHScaleVideo
MHScaleVideo()
Definition: Stream.h:145
MHGenericInteger::PrintMe
void PrintMe(FILE *fd, int nTabs) const
Definition: BaseClasses.cpp:397
MHStream::m_multiplex
MHOwnPtrSequence< MHPresentable > m_multiplex
Definition: Stream.h:59
MHStream::MHStream
MHStream()=default
MHRTGraphics
Definition: Stream.h:130
MHStream::ST_Mem
@ ST_Mem
Definition: Stream.h:61
MHActionGenericObjectRefFix::Perform
void Perform(MHEngine *engine) override
Definition: Stream.cpp:525
MHElemAction
Definition: BaseActions.h:34
MHRTGraphics::Initialise
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Stream.cpp:512
MHSetVideoDecodeOffset
Definition: Stream.h:151
MHAudio::PrintMe
void PrintMe(FILE *fd, int nTabs) const override
Definition: Stream.cpp:271
MHAudio::m_nOriginalVol
int m_nOriginalVol
Definition: Stream.h:83
MHParseNode::PNSeq
@ PNSeq
Definition: ParseNode.h:41
MHVideo::m_nXDecodeOffset
int m_nXDecodeOffset
Definition: Stream.h:121
MHGetCounterMaxPosition
Definition: Stream.h:182
MHSetSpeed::PrintArgs
void PrintArgs(FILE *fd, int) const override
Definition: Stream.h:215
MHGetCounterMaxPosition::CallAction
void CallAction(MHEngine *engine, MHRoot *pTarget, MHRoot *pArg) override
Definition: Stream.h:186
MHOwnPtrSequence< MHPresentable >
MHVideo::MHVideo
MHVideo()=default
MHElemAction::MHElemAction
MHElemAction(const char *name)
Definition: BaseActions.h:37
MHAudio::m_fStreamPlaying
bool m_fStreamPlaying
Definition: Stream.h:85
MHStream::Storage
Storage
Definition: Stream.h:60
MHAudio
Definition: Stream.h:66
MHVideo::Initialise
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Stream.cpp:343
MHRoot
Definition: Root.h:44
MHVideo::VI_Freeze
@ VI_Freeze
Definition: Stream.h:119