Commit fac7a2326bde311c5ec53d707e91d77dba9cf1c9

Authored by Charles Otto
1 parent db273407

Drop exlicit stream modes, just use galleries for everything. This simplifies st…

…ream.cpp a little, and allows us to use less indirection.
Showing 1 changed file with 11 additions and 98 deletions
openbr/plugins/stream.cpp
@@ -19,17 +19,6 @@ using namespace std; @@ -19,17 +19,6 @@ using namespace std;
19 namespace br 19 namespace br
20 { 20 {
21 21
22 -class Idiocy : public QObject  
23 -{  
24 - Q_OBJECT  
25 -public:  
26 - enum StreamModes { DistributeFrames,  
27 - StreamGallery  
28 - };  
29 -  
30 - Q_ENUMS(StreamModes)  
31 -};  
32 -  
33 class FrameData 22 class FrameData
34 { 23 {
35 public: 24 public:
@@ -194,21 +183,9 @@ private: @@ -194,21 +183,9 @@ private:
194 QList<FrameData *> buffer2; 183 QList<FrameData *> buffer2;
195 }; 184 };
196 185
197 -// Given a template as input, return N templates as output, one at a time on subsequent  
198 -// calls to getNext  
199 -class TemplateProcessor  
200 -{  
201 -public:  
202 - virtual ~TemplateProcessor() {}  
203 - virtual bool open(Template &input)=0;  
204 - virtual bool isOpen()=0;  
205 - virtual void close()=0;  
206 - virtual bool getNextTemplate(Template &output)=0;  
207 -protected:  
208 - Template basis;  
209 -};  
210 -  
211 -struct StreamGallery : public TemplateProcessor 186 +// Given a template as input, open the file contained as a gallery, and return templates one at a time on
  187 +// calls to getNextTemplate
  188 +struct StreamGallery
212 { 189 {
213 bool open(Template &input) 190 bool open(Template &input)
214 { 191 {
@@ -265,45 +242,6 @@ protected: @@ -265,45 +242,6 @@ protected:
265 242
266 TemplateList currentData; 243 TemplateList currentData;
267 int nextIdx; 244 int nextIdx;
268 -  
269 -};  
270 -  
271 -class DirectReturn : public TemplateProcessor  
272 -{  
273 -public:  
274 - DirectReturn()  
275 - {  
276 - data_ok = false;  
277 - }  
278 -  
279 - // We don't do anything, just prepare to return input when getNext is called.  
280 - bool open(Template &input)  
281 - {  
282 - basis = input;  
283 - data_ok =true;  
284 - return data_ok;  
285 - }  
286 -  
287 - bool isOpen() { return data_ok; }  
288 -  
289 - void close()  
290 - {  
291 - data_ok = false;  
292 - basis.clear();  
293 - }  
294 -  
295 - bool getNextTemplate(Template &output)  
296 - {  
297 - if (!data_ok)  
298 - return false;  
299 - output = basis;  
300 - data_ok = false;  
301 - return true;  
302 - }  
303 -  
304 -protected:  
305 - // Have we sent our template yet?  
306 - bool data_ok;  
307 }; 245 };
308 246
309 // Interface for sequentially getting data from some data source. 247 // Interface for sequentially getting data from some data source.
@@ -320,7 +258,6 @@ public: @@ -320,7 +258,6 @@ public:
320 { 258 {
321 allFrames.addItem(new FrameData()); 259 allFrames.addItem(new FrameData());
322 } 260 }
323 - frameSource = NULL;  
324 } 261 }
325 262
326 virtual ~DataSource() 263 virtual ~DataSource()
@@ -336,12 +273,7 @@ public: @@ -336,12 +273,7 @@ public:
336 273
337 void close() 274 void close()
338 { 275 {
339 - if (this->frameSource)  
340 - {  
341 - frameSource->close();  
342 - delete frameSource;  
343 - frameSource = NULL;  
344 - } 276 + frameSource.close();
345 } 277 }
346 278
347 int size() 279 int size()
@@ -349,12 +281,11 @@ public: @@ -349,12 +281,11 @@ public:
349 return this->templates.size(); 281 return this->templates.size();
350 } 282 }
351 283
352 - bool open(const TemplateList &input, br::Idiocy::StreamModes _mode) 284 + bool open(const TemplateList &input)
353 { 285 {
354 // Set up variables specific to us 286 // Set up variables specific to us
355 current_template_idx = 0; 287 current_template_idx = 0;
356 templates = input; 288 templates = input;
357 - mode = _mode;  
358 289
359 is_broken = false; 290 is_broken = false;
360 allReturned = false; 291 allReturned = false;
@@ -465,21 +396,11 @@ protected: @@ -465,21 +396,11 @@ protected:
465 bool open_res = false; 396 bool open_res = false;
466 while (!open_res) 397 while (!open_res)
467 { 398 {
468 - if (frameSource)  
469 - frameSource->close(); 399 + frameSource.close();
470 400
471 Template curr = this->templates[current_template_idx]; 401 Template curr = this->templates[current_template_idx];
472 - if (mode == br::Idiocy::DistributeFrames)  
473 - {  
474 - if (!frameSource)  
475 - frameSource = new DirectReturn();  
476 - }  
477 - else if (mode == br::Idiocy::StreamGallery)  
478 - {  
479 - if (!frameSource)  
480 - frameSource = new StreamGallery();  
481 - }  
482 - open_res = frameSource->open(curr); 402 +
  403 + open_res = frameSource.open(curr);
483 if (!open_res) 404 if (!open_res)
484 { 405 {
485 current_template_idx++; 406 current_template_idx++;
@@ -498,7 +419,7 @@ protected: @@ -498,7 +419,7 @@ protected:
498 419
499 while (!got_frame) 420 while (!got_frame)
500 { 421 {
501 - got_frame = frameSource->getNextTemplate(aTemplate); 422 + got_frame = frameSource.getNextTemplate(aTemplate);
502 423
503 // OK we got a frame 424 // OK we got a frame
504 if (got_frame) { 425 if (got_frame) {
@@ -529,14 +450,11 @@ protected: @@ -529,14 +450,11 @@ protected:
529 // Index of the template in the templatelist we are currently reading from 450 // Index of the template in the templatelist we are currently reading from
530 int current_template_idx; 451 int current_template_idx;
531 452
532 - // What do we do to each template  
533 - br::Idiocy::StreamModes mode;  
534 -  
535 // list of templates we are workign from 453 // list of templates we are workign from
536 TemplateList templates; 454 TemplateList templates;
537 455
538 // processor for the current template 456 // processor for the current template
539 - TemplateProcessor *frameSource; 457 + StreamGallery frameSource;
540 458
541 int next_sequence_number; 459 int next_sequence_number;
542 int final_frame; 460 int final_frame;
@@ -972,10 +890,8 @@ class DirectStreamTransform : public CompositeTransform @@ -972,10 +890,8 @@ class DirectStreamTransform : public CompositeTransform
972 890
973 public: 891 public:
974 Q_PROPERTY(int activeFrames READ get_activeFrames WRITE set_activeFrames RESET reset_activeFrames) 892 Q_PROPERTY(int activeFrames READ get_activeFrames WRITE set_activeFrames RESET reset_activeFrames)
975 - Q_PROPERTY(br::Idiocy::StreamModes readMode READ get_readMode WRITE set_readMode RESET reset_readMode)  
976 Q_PROPERTY(br::Transform* endPoint READ get_endPoint WRITE set_endPoint RESET reset_endPoint STORED true) 893 Q_PROPERTY(br::Transform* endPoint READ get_endPoint WRITE set_endPoint RESET reset_endPoint STORED true)
977 BR_PROPERTY(int, activeFrames, 100) 894 BR_PROPERTY(int, activeFrames, 100)
978 - BR_PROPERTY(br::Idiocy::StreamModes, readMode, br::Idiocy::StreamGallery)  
979 BR_PROPERTY(br::Transform*, endPoint, make("CollectOutput")) 895 BR_PROPERTY(br::Transform*, endPoint, make("CollectOutput"))
980 896
981 friend class StreamTransfrom; 897 friend class StreamTransfrom;
@@ -1079,7 +995,7 @@ public: @@ -1079,7 +995,7 @@ public:
1079 if (src.empty()) 995 if (src.empty())
1080 return; 996 return;
1081 997
1082 - bool res = readStage->dataSource.open(src,readMode); 998 + bool res = readStage->dataSource.open(src);
1083 if (!res) { 999 if (!res) {
1084 qDebug("stream failed to open %s", qPrintable(dst[0].file.name)); 1000 qDebug("stream failed to open %s", qPrintable(dst[0].file.name));
1085 return; 1001 return;
@@ -1290,10 +1206,8 @@ public: @@ -1290,10 +1206,8 @@ public:
1290 1206
1291 Q_PROPERTY(br::Transform* endPoint READ get_endPoint WRITE set_endPoint RESET reset_endPoint STORED true) 1207 Q_PROPERTY(br::Transform* endPoint READ get_endPoint WRITE set_endPoint RESET reset_endPoint STORED true)
1292 Q_PROPERTY(int activeFrames READ get_activeFrames WRITE set_activeFrames RESET reset_activeFrames) 1208 Q_PROPERTY(int activeFrames READ get_activeFrames WRITE set_activeFrames RESET reset_activeFrames)
1293 - Q_PROPERTY(br::Idiocy::StreamModes readMode READ get_readMode WRITE set_readMode RESET reset_readMode)  
1294 1209
1295 BR_PROPERTY(int, activeFrames, 100) 1210 BR_PROPERTY(int, activeFrames, 100)
1296 - BR_PROPERTY(br::Idiocy::StreamModes, readMode, br::Idiocy::StreamGallery)  
1297 BR_PROPERTY(br::Transform*, endPoint, make("CollectOutput")) 1211 BR_PROPERTY(br::Transform*, endPoint, make("CollectOutput"))
1298 1212
1299 bool timeVarying() const { return true; } 1213 bool timeVarying() const { return true; }
@@ -1335,7 +1249,6 @@ public: @@ -1335,7 +1249,6 @@ public:
1335 basis = QSharedPointer<DirectStreamTransform>((DirectStreamTransform *) Transform::make("DirectStream",this)); 1249 basis = QSharedPointer<DirectStreamTransform>((DirectStreamTransform *) Transform::make("DirectStream",this));
1336 basis->transforms.clear(); 1250 basis->transforms.clear();
1337 basis->activeFrames = this->activeFrames; 1251 basis->activeFrames = this->activeFrames;
1338 - basis->readMode = this->readMode;  
1339 basis->endPoint = this->endPoint; 1252 basis->endPoint = this->endPoint;
1340 1253
1341 // We need at least a CompositeTransform * to acess transform's children. 1254 // We need at least a CompositeTransform * to acess transform's children.