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 *, MHEngine *) override; // MHRoot
54  void GetCounterMaxPosition(MHRoot *, MHEngine *) override; // MHRoot
55  void SetCounterPosition(int /*pos*/, MHEngine *) override; // MHRoot
56  void SetSpeed(int, MHEngine *engine) override; // MHRoot
57 
58  protected:
60  enum Storage { ST_Mem = 1, ST_Stream = 2 } m_nStorage {ST_Stream};
61  int m_nLooping {0}; // Infinity
62 };
63 
64 
65 class MHAudio : public MHPresentable
66 {
67  public:
68  MHAudio() = default;
69  const char *ClassName() override // MHRoot
70  { return "Audio"; }
71  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHIngredient
72  void PrintMe(FILE *fd, int nTabs) const override; // MHIngredient
73 
74  void Activation(MHEngine *engine) override; // MHRoot
75  void Deactivation(MHEngine *engine) override; // MHRoot
76 
77  void BeginPlaying(MHEngine *engine) override; // MHPresentable
78  void StopPlaying(MHEngine *engine) override; // MHPresentable
79 
80  protected:
81  int m_nComponentTag {0};
82  int m_nOriginalVol {0};
83 
84  bool m_fStreamPlaying {false};
85 };
86 
87 class MHVideo : public MHVisible
88 {
89  public:
90  MHVideo() = default;
91  const char *ClassName() override // MHRoot
92  { return "Video"; }
93  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHVisible
94  void PrintMe(FILE *fd, int nTabs) const override; // MHVisible
95 
96  void Preparation(MHEngine *engine) override; // MHVisible
97  void ContentPreparation(MHEngine *engine) override; // MHIngredient
98 
99  void Activation(MHEngine *engine) override; // MHVisible
100  void Deactivation(MHEngine *engine) override; // MHVisible
101 
102  void Display(MHEngine *) override; // MHVisible
103  QRegion GetVisibleArea() override; // MHVisible
104  QRegion GetOpaqueArea() override // MHVisible
105  { return GetVisibleArea(); } // Fully opaque.
106 
107  // Actions.
108  void ScaleVideo(int xScale, int yScale, MHEngine *) override; // MHRoot
109  void SetVideoDecodeOffset(int newXOffset, int newYOffset, MHEngine *) override; // MHRoot
110  void GetVideoDecodeOffset(MHRoot *pXOffset, MHRoot *pYOffset, MHEngine *) override; // MHRoot
111 
112  void BeginPlaying(MHEngine *engine) override; // MHPresentable
113  void StopPlaying(MHEngine *engine) override; // MHPresentable
114 
115  protected:
117  enum Termination { VI_Freeze = 1, VI_Disappear } m_Termination {VI_Disappear};
118  // Added in UK MHEG
121  int m_nDecodeWidth {0};
123 
124  bool m_fStreamPlaying {false};
125 };
126 
127 // Real-time graphics - not needed for UK MHEG.
128 class MHRTGraphics : public MHVisible
129 {
130  public:
131  MHRTGraphics() = default;
132  const char *ClassName() override // MHRoot
133  { return "RTGraphics"; }
134  virtual ~MHRTGraphics() = default;
135  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHVisible
136  void PrintMe(FILE *fd, int nTabs) const override; // MHVisible
137  void Display(MHEngine *) override {} // MHVisible - Not supported
138 };
139 
140 
142  public:
143  MHScaleVideo(): MHActionIntInt(":ScaleVideo") {}
144  void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg1, int nArg2) override // MHActionIntInt
145  { pTarget->ScaleVideo(nArg1, nArg2, engine); }
146 };
147 
148 // Actions added in the UK MHEG profile.
150 {
151  public:
152  MHSetVideoDecodeOffset(): MHActionIntInt(":SetVideoDecodeOffset") {}
153  void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg1, int nArg2) override // MHActionIntInt
154  { pTarget->SetVideoDecodeOffset(nArg1, nArg2, engine); }
155 };
156 
158 {
159  public:
160  MHGetVideoDecodeOffset(): MHActionObjectRef2(":GetVideoDecodeOffset") {}
161  void CallAction(MHEngine *engine, MHRoot *pTarget, MHRoot *pArg1, MHRoot *pArg2) override // MHActionObjectRef2
162  { pTarget->GetVideoDecodeOffset(pArg1, pArg2, engine); }
163 };
164 
166 {
167 public:
169  void Perform(MHEngine *engine) override; // MHActionGenericObjectRef
170 };
171 
173 {
174 public:
176  void CallAction(MHEngine *engine, MHRoot *pTarget, MHRoot *pArg) override // MHActionGenericObjectRef
177  { pTarget->GetCounterPosition(pArg, engine); }
178 };
179 
181 {
182 public:
183  MHGetCounterMaxPosition(): MHActionGenericObjectRefFix(":GetCounterMaxPosition") {}
184  void CallAction(MHEngine *engine, MHRoot *pTarget, MHRoot *pArg) override // MHActionGenericObjectRef
185  { pTarget->GetCounterMaxPosition(pArg, engine); }
186 };
187 
189 {
190 public:
191  MHSetCounterPosition(): MHActionInt(":SetCounterPosition") {}
192  void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg) override // MHActionInt
193  { pTarget->SetCounterPosition(nArg, engine); }
194 };
195 
196 
198 {
200 public:
201  MHSetSpeed(): base(":SetSpeed") {}
202  void Initialise(MHParseNode *p, MHEngine *engine) override { // MHElemAction
203  //printf("SetSpeed Initialise args: "); p->PrintMe(stdout);
204  base::Initialise(p, engine);
205  MHParseNode *pn = p->GetArgN(1);
206  if (pn->m_nNodeType == MHParseNode::PNSeq) pn = pn->GetArgN(0);
207  m_Argument.Initialise(pn, engine);
208  }
209  void Perform(MHEngine *engine) override { // MHElemAction
210  Target(engine)->SetSpeed(m_Argument.GetValue(engine), engine);
211  }
212 protected:
213  void PrintArgs(FILE *fd, int) const override // MHElemAction
214  { m_Argument.PrintMe(fd, 0); }
216 };
217 
218 
219 #endif
void Destruction(MHEngine *engine) override
Definition: Stream.cpp:138
void Initialise(MHParseNode *p, MHEngine *engine)
void ContentPreparation(MHEngine *engine) override
Definition: Stream.cpp:178
MHOwnPtrSequence< MHPresentable > m_Multiplex
Definition: Stream.h:59
void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg1, int nArg2) override
Definition: Stream.h:144
int m_nDecodeWidth
Definition: Stream.h:121
enum MHStream::Storage ST_Stream
void Deactivation(MHEngine *engine) override
Definition: Stream.cpp:307
int m_nDecodeHeight
Definition: Stream.h:122
void Preparation(MHEngine *engine) override
Definition: Stream.cpp:118
void Activation(MHEngine *engine) override
Definition: Stream.cpp:149
void Deactivation(MHEngine *engine) override
Definition: Stream.cpp:479
void Activation(MHEngine *engine) override
Definition: Stream.cpp:290
void CallAction(MHEngine *engine, MHRoot *pTarget, MHRoot *pArg) override
Definition: Stream.h:176
void Display(MHEngine *) override
Definition: Stream.cpp:399
MHRoot * Target(MHEngine *engine)
Definition: BaseActions.cpp:46
void SetCounterPosition(int, MHEngine *) override
Definition: Stream.cpp:242
void BeginPlaying(MHEngine *engine) override
Definition: Stream.cpp:325
enum NodeType m_nNodeType
Definition: ParseNode.h:46
Definition: Stream.h:87
void Perform(MHEngine *engine) override
Definition: Stream.cpp:525
int m_nYDecodeOffset
Definition: Stream.h:120
int m_nOriginalVol
Definition: Stream.h:82
MHActionGenericObjectRefFix(const char *name)
Definition: Stream.h:168
const char * ClassName() override
Definition: Stream.h:91
void Preparation(MHEngine *engine) override
Definition: Stream.cpp:379
int GetValue(MHEngine *engine) const
void Perform(MHEngine *engine) override
Definition: Stream.h:209
MHScaleVideo()
Definition: Stream.h:143
void ContentPreparation(MHEngine *engine) override
Definition: Stream.cpp:392
void StopPlaying(MHEngine *engine) override
Definition: Stream.cpp:332
const char * ClassName() override
Definition: Stream.h:36
void StopPlaying(MHEngine *engine) override
Definition: Stream.cpp:501
void Activation(MHEngine *engine) override
Definition: Stream.cpp:467
MHElemAction(const char *name)
Definition: BaseActions.h:37
void PrintArgs(FILE *fd, int) const override
Definition: Stream.h:213
void PrintMe(FILE *fd, int nTabs) const override
Definition: Stream.cpp:271
void PrintMe(FILE *fd, int nTabs) const override
Definition: Stream.cpp:86
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Stream.cpp:512
Definition: Stream.h:65
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Stream.cpp:253
void GetVideoDecodeOffset(MHRoot *pXOffset, MHRoot *pYOffset, MHEngine *) override
Definition: Stream.cpp:445
void ScaleVideo(int xScale, int yScale, MHEngine *) override
Definition: Stream.cpp:420
void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg1, int nArg2) override
Definition: Stream.h:153
MHRTGraphics()=default
Definition: Root.h:43
void SetVideoDecodeOffset(int newXOffset, int newYOffset, MHEngine *) override
Definition: Stream.cpp:435
int m_nXDecodeOffset
Definition: Stream.h:119
MHGenericInteger m_Argument
Definition: Stream.h:215
const char * ClassName() override
Definition: Stream.h:132
void StopPlaying(MHEngine *engine) override
Definition: Stream.cpp:221
int FILE
Definition: mythburn.py:110
int m_nLooping
Definition: Stream.h:61
MHVideo()=default
Termination
Definition: Stream.h:117
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Stream.cpp:343
bool m_fStreamPlaying
Definition: Stream.h:124
void PrintMe(FILE *fd, int nTabs) const override
Definition: Stream.cpp:518
enum MHVideo::Termination VI_Disappear
int m_nComponentTag
Definition: Stream.h:116
void CallAction(MHEngine *engine, MHRoot *pTarget, MHRoot *pArg1, MHRoot *pArg2) override
Definition: Stream.h:161
virtual void Initialise(MHParseNode *p, MHEngine *engine)
Definition: BaseActions.cpp:31
void BeginPlaying(MHEngine *engine) override
Definition: Stream.cpp:206
QRegion GetVisibleArea() override
Definition: Stream.cpp:452
void SetSpeed(int, MHEngine *engine) override
Definition: Stream.cpp:248
const char * ClassName() override
Definition: Stream.h:69
void CallAction(MHEngine *engine, MHRoot *pTarget, MHRoot *pArg) override
Definition: Stream.h:184
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Stream.h:202
void Deactivation(MHEngine *engine) override
Definition: Stream.cpp:165
void Display(MHEngine *) override
Definition: Stream.h:137
MHRoot * FindByObjectNo(int n) override
Definition: Stream.cpp:186
virtual void SetSpeed(int, MHEngine *)
Definition: Root.h:181
void GetCounterMaxPosition(MHRoot *, MHEngine *) override
Definition: Stream.cpp:236
MHParseNode * GetArgN(int n)
Definition: ParseNode.cpp:78
int m_nComponentTag
Definition: Stream.h:81
MHAudio()=default
bool m_fStreamPlaying
Definition: Stream.h:84
QRegion GetOpaqueArea() override
Definition: Stream.h:104
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Stream.cpp:33
MHStream()=default
void GetCounterPosition(MHRoot *, MHEngine *) override
Definition: Stream.cpp:230
void PrintMe(FILE *fd, int nTabs) const
void BeginPlaying(MHEngine *engine) override
Definition: Stream.cpp:494
virtual ~MHRTGraphics()=default
void PrintMe(FILE *fd, int nTabs) const override
Definition: Stream.cpp:361
void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg) override
Definition: Stream.h:192
MHSetSpeed()
Definition: Stream.h:201