f87ca9819b41e4c91cd3f8597d76cf0f065bb9f0
Stefan Schuermans first version, plays videos...

Stefan Schuermans authored 13 years ago

1) /* Blinker
2)    Copyright 2011 Stefan Schuermans <stefan@blinkenarea.org>
3)    Copyleft GNU public license - http://www.gnu.org/copyleft/gpl.html
4)    a blinkenarea.org project */
5) 
6) #include <set>
7) 
8) #include <BlinkenLib/BlinkenFrame.h>
9) 
10) #include "Stream.h"
11) #include "StreamRecv.h"
12) 
13) namespace Blinker {
14) 
15) /// constructor
Stefan Schuermans implemented stream printer...

Stefan Schuermans authored 13 years ago

16) Stream::Stream():
17)   m_pFrame(NULL)
Stefan Schuermans first version, plays videos...

Stefan Schuermans authored 13 years ago

18) {
19) }
20) 
21) /// virtual destructor
22) Stream::~Stream()
23) {
Stefan Schuermans implemented stream printer...

Stefan Schuermans authored 13 years ago

24)   // free current frame
25)   if (m_pFrame)
26)     BlinkenFrameFree(m_pFrame);
Stefan Schuermans first version, plays videos...

Stefan Schuermans authored 13 years ago

27) }
28) 
29) /**
30)  * @brief attach a stream receiver
31)  * @param[in] recv stream receiver to attach
32)  */
33) void Stream::attach(StreamRecv *recv)
34) {
35)   m_recvs.insert(recv);
Stefan Schuermans implemented stream printer...

Stefan Schuermans authored 13 years ago

36) 
37)   // send current frame to receiver
Stefan Schuermans merged frame processing wit...

Stefan Schuermans authored 13 years ago

38)   recv->setFrame(m_name, m_pFrame);
Stefan Schuermans first version, plays videos...

Stefan Schuermans authored 13 years ago

39) }
40) 
41) /**
42)  * @brief detach a stream receiver
43)  * @param[in] recv stream receiver to detach
44)  */
45) void Stream::detach(StreamRecv *recv)
46) {
47)   m_recvs.erase(recv);
48) }
49) 
50) /**
51)  * @brief set current frame
Stefan Schuermans merged frame processing wit...

Stefan Schuermans authored 13 years ago

52)  * @param[in] pFrame current frame (NULL for none)
Stefan Schuermans first version, plays videos...

Stefan Schuermans authored 13 years ago

53)  */
54) void Stream::setFrame(stBlinkenFrame *pFrame)
55) {
Stefan Schuermans avoid passing on same frame...

Stefan Schuermans authored 13 years ago

56)   // leave if frame is already set to an identical one
Stefan Schuermans merged frame processing wit...

Stefan Schuermans authored 13 years ago

57)   if (pFrame && m_pFrame && !BlinkenFrameCompare(pFrame, m_pFrame))
Stefan Schuermans avoid passing on same frame...

Stefan Schuermans authored 13 years ago

58)     return;
Stefan Schuermans merged frame processing wit...

Stefan Schuermans authored 13 years ago

59)   if (!pFrame && !m_pFrame)
Stefan Schuermans avoid passing on same frame...

Stefan Schuermans authored 13 years ago

60)     return;
61) 
Stefan Schuermans merged frame processing wit...

Stefan Schuermans authored 13 years ago

62)   // update local copy of current frame
Stefan Schuermans implemented stream printer...

Stefan Schuermans authored 13 years ago

63)   if (m_pFrame) {
64)     BlinkenFrameFree(m_pFrame);
65)     m_pFrame = NULL;
66)   }
Stefan Schuermans merged frame processing wit...

Stefan Schuermans authored 13 years ago

67)   if (pFrame) {
68)     m_pFrame = BlinkenFrameClone(pFrame);
69)     // in case of NULL returned: out of memory - got on without frame
70)   }
Stefan Schuermans first version, plays videos...

Stefan Schuermans authored 13 years ago

71) 
Stefan Schuermans merged frame processing wit...

Stefan Schuermans authored 13 years ago

72)   // pass frame to all receivers
Stefan Schuermans first version, plays videos...

Stefan Schuermans authored 13 years ago

73)   Recvs::iterator it;
74)   for (it = m_recvs.begin(); it != m_recvs.end(); ++it)
Stefan Schuermans merged frame processing wit...

Stefan Schuermans authored 13 years ago

75)     (*it)->setFrame(m_name, m_pFrame);
Stefan Schuermans first version, plays videos...

Stefan Schuermans authored 13 years ago

76) }
77) 
Stefan Schuermans add function to get current...

Stefan Schuermans authored 13 years ago

78) /**
79)  * @brief get current frame
Stefan Schuermans merged frame processing wit...

Stefan Schuermans authored 13 years ago

80)  * @param[out] pFrame current frame (NULL for none)
Stefan Schuermans add function to get current...

Stefan Schuermans authored 13 years ago

81)  */
Stefan Schuermans merged frame processing wit...

Stefan Schuermans authored 13 years ago

82) void Stream::getCurFrame(stBlinkenFrame *&pFrame)
Stefan Schuermans add function to get current...

Stefan Schuermans authored 13 years ago

83) {
84)   pFrame = m_pFrame;
85) }
86)