f670ca05dd608c9d5b0300ca1dc493f6ffd8afa1
Stefan Schuermans first version, plays videos...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp   1) /* Blinker
Stefan Schuermans update copyright years

Stefan Schuermans authored 10 years ago

src/noarch/Player.cpp   2)    Copyright 2011-2014 Stefan Schuermans <stefan@blinkenarea.org>
Stefan Schuermans first version, plays videos...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp   3)    Copyleft GNU public license - http://www.gnu.org/copyleft/gpl.html
src/noarch/Player.cpp   4)    a blinkenarea.org project */
src/noarch/Player.cpp   5) 
src/noarch/Player.cpp   6) #include <list>
src/noarch/Player.cpp   7) #include <string>
src/noarch/Player.cpp   8) 
src/noarch/Player.cpp   9) #include <BlinkenLib/BlinkenFrame.h>
src/noarch/Player.cpp  10) #include <BlinkenLib/BlinkenMovie.h>
src/noarch/Player.cpp  11) 
src/noarch/Player.cpp  12) #include "Directory.h"
src/noarch/Player.cpp  13) #include "File.h"
Stefan Schuermans implemented halting player...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp  14) #include "InStreamFile.h"
Stefan Schuermans converted player module to...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp  15) #include "ListTracker.h"
src/noarch/Player.cpp  16) #include "ListTracker_impl.h"
Stefan Schuermans put all managers in one str...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp  17) #include "Mgrs.h"
Stefan Schuermans implemented halting player...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp  18) #include "Module.h"
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp  19) #include "OutStreamFile.h"
Stefan Schuermans first version, plays videos...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp  20) #include "Player.h"
Stefan Schuermans converted player module to...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp  21) #include "PlayerMovie.h"
Stefan Schuermans implemented halting player...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp  22) #include "StreamRecv.h"
Stefan Schuermans first version, plays videos...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp  23) #include "Time.h"
src/noarch/Player.cpp  24) #include "TimeCallee.h"
src/noarch/Player.cpp  25) 
src/noarch/Player.cpp  26) namespace Blinker {
src/noarch/Player.cpp  27) 
src/noarch/Player.cpp  28) /**
src/noarch/Player.cpp  29)  * @brief constructor
Stefan Schuermans make modules know their name

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp  30)  * @param[in] name module name
Stefan Schuermans put all managers in one str...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp  31)  * @param[in] mgrs managers
Stefan Schuermans first version, plays videos...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp  32)  * @param[in] dirBase base directory
src/noarch/Player.cpp  33)  */
Stefan Schuermans make modules know their name

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp  34) Player::Player(const std::string &name, Mgrs &mgrs,
Stefan Schuermans first version, plays videos...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp  35)                const Directory &dirBase):
Stefan Schuermans make modules know their name

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp  36)   Module(name, mgrs, dirBase),
Stefan Schuermans put all managers in one str...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp  37)   m_fileOutStream(dirBase.getFile("outstream"), mgrs.m_streamMgr),
src/noarch/Player.cpp  38)   m_fileHaltStream(dirBase.getFile("haltstream"), mgrs.m_streamMgr),
Stefan Schuermans converted player module to...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp  39)   m_playlistTracker(*this, dirBase.getSubdir("playlist")),
Stefan Schuermans implemented automatic check...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp  40)   m_curValid(false),
Stefan Schuermans converted player module to...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp  41)   m_curEntry(m_playlistTracker.m_list.begin()),
src/noarch/Player.cpp  42)   m_curFrame(0),
Stefan Schuermans implemented halting player...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp  43)   m_curChange(false),
src/noarch/Player.cpp  44)   m_halted(false)
Stefan Schuermans first version, plays videos...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp  45) {
src/noarch/Player.cpp  46)   // load playlist
Stefan Schuermans implemented halting player...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp  47)   m_fileHaltStream.setStreamRecv(this);
Stefan Schuermans converted player module to...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp  48)   m_playlistTracker.init();
src/noarch/Player.cpp  49)   checkCurChanged();
Stefan Schuermans first version, plays videos...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp  50) }
src/noarch/Player.cpp  51) 
src/noarch/Player.cpp  52) /// virtual destructor
src/noarch/Player.cpp  53) Player::~Player()
src/noarch/Player.cpp  54) {
Stefan Schuermans cancel time callback reques...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp  55)   // cancel time callback request
Stefan Schuermans put all managers in one str...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp  56)   m_mgrs.m_callMgr.cancelTimeCall(this);
Stefan Schuermans cancel time callback reques...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp  57) 
Stefan Schuermans first version, plays videos...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp  58)   // free all movies
Stefan Schuermans converted player module to...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp  59)   m_playlistTracker.clear();
Stefan Schuermans implemented halting player...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp  60)   m_fileHaltStream.setStreamRecv(NULL);
Stefan Schuermans first version, plays videos...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp  61) }
src/noarch/Player.cpp  62) 
Stefan Schuermans implemented base class for...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp  63) /// check for update of configuration
src/noarch/Player.cpp  64) void Player::updateConfig()
src/noarch/Player.cpp  65) {
Stefan Schuermans implemented automatic check...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp  66)   // output stream name file was modified -> re-get output stream
src/noarch/Player.cpp  67)   if (m_fileOutStream.checkModified()) {
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp  68)     m_fileOutStream.update();
src/noarch/Player.cpp  69)     sendFrame();
Stefan Schuermans implemented automatic check...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp  70)   }
src/noarch/Player.cpp  71) 
Stefan Schuermans implemented halting player...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp  72)   // halt stream name file was modified -> re-get halt stream
src/noarch/Player.cpp  73)   if (m_fileHaltStream.checkModified())
src/noarch/Player.cpp  74)     m_fileHaltStream.update();
src/noarch/Player.cpp  75) 
Stefan Schuermans converted player module to...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp  76)   // playlist update
src/noarch/Player.cpp  77)   m_playlistTracker.updateConfig();
src/noarch/Player.cpp  78)   checkCurChanged();
Stefan Schuermans implemented base class for...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp  79) }
src/noarch/Player.cpp  80) 
Stefan Schuermans implemented halting player...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp  81) /**
src/noarch/Player.cpp  82)  * @brief set current frame
src/noarch/Player.cpp  83)  * @param[in] stream stream name
src/noarch/Player.cpp  84)  * @param[in] pFrame current frame (NULL for none)
src/noarch/Player.cpp  85)  */
src/noarch/Player.cpp  86) void Player::setFrame(const std::string &stream, stBlinkenFrame *pFrame)
src/noarch/Player.cpp  87) {
src/noarch/Player.cpp  88)   // this is coming from the halt stream, which will halt the player
src/noarch/Player.cpp  89)   // whenever a frame is available on this halt stream
src/noarch/Player.cpp  90) 
src/noarch/Player.cpp  91)   // halt stream came to life -> halt player
src/noarch/Player.cpp  92)   if (pFrame && !m_halted) {
src/noarch/Player.cpp  93)     m_halted = true;
src/noarch/Player.cpp  94)     if (m_curValid) {
src/noarch/Player.cpp  95)       // store remaining frame time
src/noarch/Player.cpp  96)       m_remainTime = m_nextTime - Time::now();
src/noarch/Player.cpp  97)       if (m_remainTime < Time::zero)
src/noarch/Player.cpp  98)         m_remainTime = Time::zero;
src/noarch/Player.cpp  99)     }
src/noarch/Player.cpp 100)     // cancel time call
Stefan Schuermans put all managers in one str...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp 101)     m_mgrs.m_callMgr.cancelTimeCall(this);
Stefan Schuermans implemented halting player...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp 102)   }
src/noarch/Player.cpp 103) 
src/noarch/Player.cpp 104)   // halt stream ended -> continue playing
src/noarch/Player.cpp 105)   else if (!pFrame && m_halted) {
src/noarch/Player.cpp 106)     m_halted = false;
src/noarch/Player.cpp 107)     if (m_curValid) {
src/noarch/Player.cpp 108)       // determine time for next frame
src/noarch/Player.cpp 109)       m_nextTime = Time::now() + m_remainTime;
src/noarch/Player.cpp 110)       // schedule time call
Stefan Schuermans put all managers in one str...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp 111)       m_mgrs.m_callMgr.requestTimeCall(this, m_nextTime);
Stefan Schuermans implemented halting player...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp 112)     }
src/noarch/Player.cpp 113)   }
src/noarch/Player.cpp 114) 
src/noarch/Player.cpp 115)   (void)stream; // unused
src/noarch/Player.cpp 116) }
src/noarch/Player.cpp 117) 
Stefan Schuermans fixed comment typo

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp 118) /// callback when requested time reached
Stefan Schuermans first version, plays videos...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp 119) void Player::timeCall()
src/noarch/Player.cpp 120) {
Stefan Schuermans implemented halting player...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp 121)   // leave if halted
src/noarch/Player.cpp 122)   if (m_halted)
src/noarch/Player.cpp 123)     return;
src/noarch/Player.cpp 124) 
Stefan Schuermans implemented automatic check...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp 125)   // leave if time is not yet ready to next frame
src/noarch/Player.cpp 126)   if (Time::now() < m_nextTime) {
src/noarch/Player.cpp 127)     // request call at time for next frame
Stefan Schuermans put all managers in one str...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp 128)     m_mgrs.m_callMgr.requestTimeCall(this, m_nextTime);
Stefan Schuermans implemented automatic check...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp 129)     return;
src/noarch/Player.cpp 130)   }
src/noarch/Player.cpp 131) 
src/noarch/Player.cpp 132)   // go to next frame
src/noarch/Player.cpp 133)   ++m_curFrame;
src/noarch/Player.cpp 134) 
src/noarch/Player.cpp 135)   // process new current frame
src/noarch/Player.cpp 136)   procFrame();
Stefan Schuermans first version, plays videos...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp 137) }
src/noarch/Player.cpp 138) 
Stefan Schuermans converted player module to...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp 139) /// check if current movie changed and react
src/noarch/Player.cpp 140) void Player::checkCurChanged()
Stefan Schuermans implemented automatic check...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp 141) {
Stefan Schuermans converted player module to...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp 142)   // current movie changed
src/noarch/Player.cpp 143)   if (m_curChange) {
src/noarch/Player.cpp 144)     m_curChange = false;
Stefan Schuermans implemented automatic check...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp 145) 
src/noarch/Player.cpp 146)     // go to begin of new current movie and start playing now
src/noarch/Player.cpp 147)     m_curFrame = 0;
Stefan Schuermans implemented halting player...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp 148)     m_remainTime = Time::zero;
Stefan Schuermans implemented automatic check...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp 149)     m_nextTime = Time::now();
src/noarch/Player.cpp 150)     procFrame();
src/noarch/Player.cpp 151) 
Stefan Schuermans converted player module to...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp 152)   } // if (m_curChange)
Stefan Schuermans first version, plays videos...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp 153) }
src/noarch/Player.cpp 154) 
Stefan Schuermans implemented automatic check...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp 155) /// process current frame
src/noarch/Player.cpp 156) void Player::procFrame()
src/noarch/Player.cpp 157) {
Stefan Schuermans first version, plays videos...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp 158)   // movie finished -> next movie
src/noarch/Player.cpp 159)   //   use while loops to handle empty movies / empty playlist
Stefan Schuermans implemented automatic check...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp 160)   m_curValid = true;
Stefan Schuermans first version, plays videos...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp 161)   bool wrapped = false;
src/noarch/Player.cpp 162)   while (true) {
src/noarch/Player.cpp 163)     // playlist finished -> re-start from beginning
Stefan Schuermans converted player module to...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp 164)     while (m_curEntry == m_playlistTracker.m_list.end()) {
src/noarch/Player.cpp 165)       m_curEntry = m_playlistTracker.m_list.begin();
Stefan Schuermans first version, plays videos...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp 166)       m_curFrame = 0;
src/noarch/Player.cpp 167)       // detect empty playlist or playlist with only empty movies
src/noarch/Player.cpp 168)       if (wrapped) {
Stefan Schuermans implemented automatic check...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp 169)         m_curValid = false;
src/noarch/Player.cpp 170)         break;
Stefan Schuermans first version, plays videos...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp 171)       }
src/noarch/Player.cpp 172)       wrapped = true;
src/noarch/Player.cpp 173)     }
Stefan Schuermans implemented automatic check...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp 174)     if (!m_curValid)
src/noarch/Player.cpp 175)       break;
Stefan Schuermans first version, plays videos...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp 176)     // movie not yet finished -> done
Stefan Schuermans fix bug in player module: c...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp 177)     if (m_curEntry->m_pObj->m_pMovie &&
src/noarch/Player.cpp 178)         m_curFrame < BlinkenMovieGetFrameCnt(m_curEntry->m_pObj->m_pMovie))
Stefan Schuermans first version, plays videos...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp 179)       break;
src/noarch/Player.cpp 180)     // movie finished -> next movie
src/noarch/Player.cpp 181)     ++m_curEntry;
src/noarch/Player.cpp 182)     m_curFrame = 0;
src/noarch/Player.cpp 183)   }
src/noarch/Player.cpp 184) 
Stefan Schuermans implemented automatic check...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp 185)   // send new frame to stream
src/noarch/Player.cpp 186)   sendFrame();
Stefan Schuermans first version, plays videos...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp 187) 
Stefan Schuermans implemented automatic check...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp 188)   // if a frame is there
src/noarch/Player.cpp 189)   if (m_curValid) {
Stefan Schuermans implemented halting player...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp 190)     // get frame time and calculate absolute time for next frame
Stefan Schuermans implemented automatic check...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp 191)     stBlinkenFrame *pFrame =
Stefan Schuermans converted player module to...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp 192)       BlinkenMovieGetFrame(m_curEntry->m_pObj->m_pMovie, m_curFrame);
Stefan Schuermans implemented halting player...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp 193)     m_remainTime.fromMs(BlinkenFrameGetDuration(pFrame));
src/noarch/Player.cpp 194)     m_nextTime += m_remainTime;
Stefan Schuermans implemented automatic check...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp 195)     // request call at time for next frame
Stefan Schuermans implemented halting player...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp 196)     if (!m_halted)
Stefan Schuermans put all managers in one str...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp 197)       m_mgrs.m_callMgr.requestTimeCall(this, m_nextTime);
Stefan Schuermans implemented automatic check...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp 198)   }
src/noarch/Player.cpp 199) }
Stefan Schuermans first version, plays videos...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp 200) 
Stefan Schuermans implemented automatic check...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp 201) /// send current frame to output stream
src/noarch/Player.cpp 202) void Player::sendFrame()
src/noarch/Player.cpp 203) {
Stefan Schuermans typo

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp 204)   // frame available -> send it
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp 205)   if (m_curValid) {
src/noarch/Player.cpp 206)     stBlinkenFrame *pFrame =
Stefan Schuermans converted player module to...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp 207)       BlinkenMovieGetFrame(m_curEntry->m_pObj->m_pMovie, m_curFrame);
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp 208)     m_fileOutStream.setFrame(pFrame);
Stefan Schuermans implemented automatic check...

Stefan Schuermans authored 13 years ago

src/noarch/Player.cpp 209)   }
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

src/noarch/Player.cpp 210)   // no frame available -> send this information
src/noarch/Player.cpp 211)   else
src/noarch/Player.cpp 212)     m_fileOutStream.setFrame(NULL);