Stefan Schuermans commited on 2011-12-04 12:58:57
Showing 19 changed files, with 90 additions and 272 deletions.
... | ... |
@@ -90,7 +90,7 @@ void Canvas::createCanvas() |
90 | 90 |
// create frame |
91 | 91 |
m_pCanvas = BlinkenFrameNew(m_format.m_height, m_format.m_width, |
92 | 92 |
m_format.m_channels, m_format.m_maxval, 1); |
93 |
- m_canvasHasFrame = 0; |
|
93 |
+ m_canvasHasFrame = false; |
|
94 | 94 |
} |
95 | 95 |
|
96 | 96 |
/// tear down canvas |
... | ... |
@@ -99,7 +99,7 @@ void Canvas::destroyCanvas() |
99 | 99 |
if (m_pCanvas) { |
100 | 100 |
BlinkenFrameFree(m_pCanvas); |
101 | 101 |
m_pCanvas = NULL; |
102 |
- m_canvasHasFrame = 0; |
|
102 |
+ m_canvasHasFrame = false; |
|
103 | 103 |
} |
104 | 104 |
} |
105 | 105 |
|
... | ... |
@@ -176,7 +176,7 @@ void Canvas::releaseOutStream() |
176 | 176 |
{ |
177 | 177 |
// send no frame information |
178 | 178 |
if (m_pOutStream) |
179 |
- m_pOutStream->setNoFrame(); |
|
179 |
+ m_pOutStream->setFrame(NULL); |
|
180 | 180 |
|
181 | 181 |
// unreference output stream |
182 | 182 |
m_pOutStream = NULL; |
... | ... |
@@ -213,7 +213,7 @@ void Canvas::sendFrame() |
213 | 213 |
m_pOutStream->setFrame(m_pCanvas); |
214 | 214 |
// no frame available -> send this information |
215 | 215 |
else |
216 |
- m_pOutStream->setNoFrame(); |
|
216 |
+ m_pOutStream->setFrame(NULL); |
|
217 | 217 |
} |
218 | 218 |
} |
219 | 219 |
|
... | ... |
@@ -70,7 +70,7 @@ void Canvas::Input::updateConfig() |
70 | 70 |
/** |
71 | 71 |
* @brief set current frame |
72 | 72 |
* @param[in] stream stream name |
73 |
- * @param[in] pFrame current frame |
|
73 |
+ * @param[in] pFrame current frame (NULL for none) |
|
74 | 74 |
*/ |
75 | 75 |
void Canvas::Input::setFrame(const std::string &stream, stBlinkenFrame *pFrame) |
76 | 76 |
{ |
... | ... |
@@ -81,18 +81,6 @@ void Canvas::Input::setFrame(const std::string &stream, stBlinkenFrame *pFrame) |
81 | 81 |
(void)stream; // unused |
82 | 82 |
} |
83 | 83 |
|
84 |
-/** |
|
85 |
- * @brief set current frame to none |
|
86 |
- * @param[in] stream stream name |
|
87 |
- */ |
|
88 |
-void Canvas::Input::setNoFrame(const std::string &stream) |
|
89 |
-{ |
|
90 |
- // notify canvas to redraw |
|
91 |
- m_canvas.redraw(); |
|
92 |
- |
|
93 |
- (void)stream; // unused |
|
94 |
-} |
|
95 |
- |
|
96 | 84 |
/** |
97 | 85 |
* @brief draw current frame to canvas |
98 | 86 |
* @return if a frame was available and it was drawn |
... | ... |
@@ -105,8 +93,11 @@ bool Canvas::Input::draw() |
105 | 93 |
if (!m_haveDestPos || !m_canvas.m_pCanvas) |
106 | 94 |
return false; |
107 | 95 |
|
108 |
- // get current frame from stream (levae if no stream or no frame) |
|
109 |
- if (!m_pInStream || !m_pInStream->getCurFrame(pFrame)) |
|
96 |
+ // get current frame from stream (leave if no stream or no frame) |
|
97 |
+ if (!m_pInStream) |
|
98 |
+ return false; |
|
99 |
+ m_pInStream->getCurFrame(pFrame); |
|
100 |
+ if (!pFrame) |
|
110 | 101 |
return false; |
111 | 102 |
|
112 | 103 |
// no source position -> use top left |
... | ... |
@@ -49,16 +49,10 @@ public: |
49 | 49 |
/** |
50 | 50 |
* @brief set current frame |
51 | 51 |
* @param[in] stream stream name |
52 |
- * @param[in] pFrame current frame |
|
52 |
+ * @param[in] pFrame current frame (NULL for none) |
|
53 | 53 |
*/ |
54 | 54 |
virtual void setFrame(const std::string &stream, stBlinkenFrame *pFrame); |
55 | 55 |
|
56 |
- /** |
|
57 |
- * @brief set current frame to none |
|
58 |
- * @param[in] stream stream name |
|
59 |
- */ |
|
60 |
- virtual void setNoFrame(const std::string &stream); |
|
61 |
- |
|
62 | 56 |
/** |
63 | 57 |
* @brief draw current frame to canvas |
64 | 58 |
* @return if a frame was available and it was drawn |
... | ... |
@@ -212,7 +212,7 @@ void Player::releaseOutStream() |
212 | 212 |
{ |
213 | 213 |
// send no frame information |
214 | 214 |
if (m_pOutStream) |
215 |
- m_pOutStream->setNoFrame(); |
|
215 |
+ m_pOutStream->setFrame(NULL); |
|
216 | 216 |
|
217 | 217 |
// unreference output stream |
218 | 218 |
m_pOutStream = NULL; |
... | ... |
@@ -276,7 +276,7 @@ void Player::sendFrame() |
276 | 276 |
} |
277 | 277 |
// no frame available -> send this information |
278 | 278 |
else |
279 |
- m_pOutStream->setNoFrame(); |
|
279 |
+ m_pOutStream->setFrame(NULL); |
|
280 | 280 |
} |
281 | 281 |
} |
282 | 282 |
|
... | ... |
@@ -6,6 +6,7 @@ |
6 | 6 |
#include <iostream> |
7 | 7 |
#include <stdlib.h> |
8 | 8 |
#include <string> |
9 |
+#include <string.h> |
|
9 | 10 |
|
10 | 11 |
#include <BlinkenLib/BlinkenFrame.h> |
11 | 12 |
|
... | ... |
@@ -56,23 +57,19 @@ void Printer::updateConfig() |
56 | 57 |
/** |
57 | 58 |
* @brief set current frame |
58 | 59 |
* @param[in] stream stream name |
59 |
- * @param[in] pFrame current frame |
|
60 |
+ * @param[in] pFrame current frame (NULL for none) |
|
60 | 61 |
*/ |
61 | 62 |
void Printer::setFrame(const std::string &stream, stBlinkenFrame *pFrame) |
62 | 63 |
{ |
64 |
+ if (pFrame) { |
|
63 | 65 |
char *str = BlinkenFrameToString(pFrame); |
64 |
- std::cout << str; |
|
66 |
+ for (int i = strlen(str) - 2; i >= 0 && str[i] != '\n'; --i) |
|
67 |
+ str[i] = 0; // remove last line (delay) |
|
68 |
+ std::cout << "frame" << std::endl << str; |
|
65 | 69 |
free(str); |
66 |
- (void)stream; // unused |
|
67 |
-} |
|
68 |
- |
|
69 |
-/** |
|
70 |
- * @brief set current frame to none |
|
71 |
- * @param[in] stream stream name |
|
72 |
- */ |
|
73 |
-void Printer::setNoFrame(const std::string &stream) |
|
74 |
-{ |
|
70 |
+ } else { |
|
75 | 71 |
std::cout << "no frame" << std::endl; |
72 |
+ } |
|
76 | 73 |
(void)stream; // unused |
77 | 74 |
} |
78 | 75 |
|
... | ... |
@@ -49,16 +49,10 @@ public: |
49 | 49 |
/** |
50 | 50 |
* @brief set current frame |
51 | 51 |
* @param[in] stream stream name |
52 |
- * @param[in] pFrame current frame |
|
52 |
+ * @param[in] pFrame current frame (NULL for none) |
|
53 | 53 |
*/ |
54 | 54 |
virtual void setFrame(const std::string &stream, stBlinkenFrame *pFrame); |
55 | 55 |
|
56 |
- /** |
|
57 |
- * @brief set current frame to none |
|
58 |
- * @param[in] stream stream name |
|
59 |
- */ |
|
60 |
- virtual void setNoFrame(const std::string &stream); |
|
61 |
- |
|
62 | 56 |
protected: |
63 | 57 |
/// get input stream and attach to it |
64 | 58 |
void getInStream(); |
... | ... |
@@ -139,7 +139,7 @@ void Priority::releaseOutStream() |
139 | 139 |
{ |
140 | 140 |
// send no frame information |
141 | 141 |
if (m_pOutStream) |
142 |
- m_pOutStream->setNoFrame(); |
|
142 |
+ m_pOutStream->setFrame(NULL); |
|
143 | 143 |
|
144 | 144 |
// unreference output stream |
145 | 145 |
m_pOutStream = NULL; |
... | ... |
@@ -179,7 +179,7 @@ void Priority::selectLower() |
179 | 179 |
} |
180 | 180 |
|
181 | 181 |
// no input has got a frame -> send no frame |
182 |
- noFrame(); |
|
182 |
+ frame(NULL); |
|
183 | 183 |
} |
184 | 184 |
|
185 | 185 |
/// send current frame to output stream |
... | ... |
@@ -193,12 +193,12 @@ void Priority::curFrame() |
193 | 193 |
frame(pFrame); |
194 | 194 |
// no frame available -> send this information |
195 | 195 |
else |
196 |
- noFrame(); |
|
196 |
+ frame(NULL); |
|
197 | 197 |
} |
198 | 198 |
|
199 | 199 |
/** |
200 | 200 |
* @brief set current frame (also called by inputs) |
201 |
- * @param[in] pFrame new frame to use |
|
201 |
+ * @param[in] pFrame new frame to use (NULL for none) |
|
202 | 202 |
*/ |
203 | 203 |
void Priority::frame(stBlinkenFrame *pFrame) |
204 | 204 |
{ |
... | ... |
@@ -206,13 +206,6 @@ void Priority::frame(stBlinkenFrame *pFrame) |
206 | 206 |
m_pOutStream->setFrame(pFrame); |
207 | 207 |
} |
208 | 208 |
|
209 |
-/// set current frame to "no frame" |
|
210 |
-void Priority::noFrame() |
|
211 |
-{ |
|
212 |
- if (m_pOutStream) |
|
213 |
- m_pOutStream->setNoFrame(); |
|
214 |
-} |
|
215 |
- |
|
216 | 209 |
/* ##################### |
217 | 210 |
# Priority::InEntry # |
218 | 211 |
##################### */ |
... | ... |
@@ -90,13 +90,10 @@ protected: |
90 | 90 |
|
91 | 91 |
/** |
92 | 92 |
* @brief set current frame (also called by inputs) |
93 |
- * @param[in] pFrame new frame to use |
|
93 |
+ * @param[in] pFrame new frame to use (NULL for none) |
|
94 | 94 |
*/ |
95 | 95 |
void frame(stBlinkenFrame *pFrame); |
96 | 96 |
|
97 |
- /// set current frame to "no frame" |
|
98 |
- void noFrame(); |
|
99 |
- |
|
100 | 97 |
protected: |
101 | 98 |
Directory m_dirInputs; ///< input stream directory |
102 | 99 |
SettingFile m_fileOutStream; ///< output stream name file |
... | ... |
@@ -55,7 +55,7 @@ void Priority::Input::updateConfig() |
55 | 55 |
/** |
56 | 56 |
* @brief set current frame |
57 | 57 |
* @param[in] stream stream name |
58 |
- * @param[in] pFrame current frame |
|
58 |
+ * @param[in] pFrame current frame (NULL for none) |
|
59 | 59 |
*/ |
60 | 60 |
void Priority::Input::setFrame(const std::string &stream, stBlinkenFrame *pFrame) |
61 | 61 |
{ |
... | ... |
@@ -63,16 +63,6 @@ void Priority::Input::setFrame(const std::string &stream, stBlinkenFrame *pFrame |
63 | 63 |
(void)stream; // unused |
64 | 64 |
} |
65 | 65 |
|
66 |
-/** |
|
67 |
- * @brief set current frame to none |
|
68 |
- * @param[in] stream stream name |
|
69 |
- */ |
|
70 |
-void Priority::Input::setNoFrame(const std::string &stream) |
|
71 |
-{ |
|
72 |
- noFrame(); |
|
73 |
- (void)stream; // unused |
|
74 |
-} |
|
75 |
- |
|
76 | 66 |
/** |
77 | 67 |
* @brief get current frame |
78 | 68 |
* @param[out] pFrame current frame |
... | ... |
@@ -102,7 +92,7 @@ void Priority::Input::getInStream() |
102 | 92 |
void Priority::Input::releaseInStream() |
103 | 93 |
{ |
104 | 94 |
// set current frame to none |
105 |
- noFrame(); |
|
95 |
+ frame(NULL); |
|
106 | 96 |
|
107 | 97 |
// detach from input stream |
108 | 98 |
if (m_pInStream) |
... | ... |
@@ -115,13 +105,16 @@ void Priority::Input::releaseInStream() |
115 | 105 |
|
116 | 106 |
/** |
117 | 107 |
* @brief set current frame |
118 |
- * @param[in] pFrame current frame |
|
108 |
+ * @param[in] pFrame current frame (NULL for none) |
|
119 | 109 |
*/ |
120 | 110 |
void Priority::Input::frame(stBlinkenFrame *pFrame) |
121 | 111 |
{ |
122 | 112 |
// save new frame |
123 | 113 |
m_pFrame = pFrame; |
124 | 114 |
|
115 |
+ // there is a frame now |
|
116 |
+ if (pFrame) { |
|
117 |
+ |
|
125 | 118 |
// if we are current input |
126 | 119 |
if (m_priority.m_itCurIn != m_priority.m_inList.rend() && |
127 | 120 |
m_priority.m_itCurIn->m_pInput == this) |
... | ... |
@@ -133,19 +126,18 @@ void Priority::Input::frame(stBlinkenFrame *pFrame) |
133 | 126 |
m_priority.m_itCurIn->m_name < m_name) |
134 | 127 |
// tell priority based selector to select us as input |
135 | 128 |
m_priority.select(this); |
136 |
-} |
|
137 | 129 |
|
138 |
-/// set current frame to none |
|
139 |
-void Priority::Input::noFrame() |
|
140 |
-{ |
|
141 |
- // forget frame |
|
142 |
- m_pFrame = NULL; |
|
130 |
+ } |
|
131 |
+ // there is no frame |
|
132 |
+ else { |
|
143 | 133 |
|
144 | 134 |
// if we are current input |
145 | 135 |
if (m_priority.m_itCurIn != m_priority.m_inList.rend() && |
146 | 136 |
m_priority.m_itCurIn->m_pInput == this) |
147 | 137 |
// tell priority based selector to select lower priority input |
148 | 138 |
m_priority.selectLower(); |
139 |
+ |
|
140 |
+ } |
|
149 | 141 |
} |
150 | 142 |
|
151 | 143 |
} // namespace Blinker |
... | ... |
@@ -48,16 +48,10 @@ public: |
48 | 48 |
/** |
49 | 49 |
* @brief set current frame |
50 | 50 |
* @param[in] stream stream name |
51 |
- * @param[in] pFrame current frame |
|
51 |
+ * @param[in] pFrame current frame (NULL for none) |
|
52 | 52 |
*/ |
53 | 53 |
virtual void setFrame(const std::string &stream, stBlinkenFrame *pFrame); |
54 | 54 |
|
55 |
- /** |
|
56 |
- * @brief set current frame to none |
|
57 |
- * @param[in] stream stream name |
|
58 |
- */ |
|
59 |
- virtual void setNoFrame(const std::string &stream); |
|
60 |
- |
|
61 | 55 |
/** |
62 | 56 |
* @brief get current frame |
63 | 57 |
* @param[out] pFrame current frame |
... | ... |
@@ -74,13 +68,10 @@ protected: |
74 | 68 |
|
75 | 69 |
/** |
76 | 70 |
* @brief set current frame |
77 |
- * @param[in] pFrame current frame |
|
71 |
+ * @param[in] pFrame current frame (NULL for none) |
|
78 | 72 |
*/ |
79 | 73 |
void frame(stBlinkenFrame *pFrame); |
80 | 74 |
|
81 |
- /// set current frame to none |
|
82 |
- void noFrame(); |
|
83 |
- |
|
84 | 75 |
protected: |
85 | 76 |
Priority &m_priority; ///< owning priority based selector |
86 | 77 |
std::string m_name; ///< name of input (i.e. priority) |
... | ... |
@@ -71,7 +71,7 @@ void Resizer::updateConfig() |
71 | 71 |
/** |
72 | 72 |
* @brief set current frame |
73 | 73 |
* @param[in] stream stream name |
74 |
- * @param[in] pFrame current frame |
|
74 |
+ * @param[in] pFrame current frame (NULL for none) |
|
75 | 75 |
*/ |
76 | 76 |
void Resizer::setFrame(const std::string &stream, stBlinkenFrame *pFrame) |
77 | 77 |
{ |
... | ... |
@@ -79,16 +79,6 @@ void Resizer::setFrame(const std::string &stream, stBlinkenFrame *pFrame) |
79 | 79 |
(void)stream; // unused |
80 | 80 |
} |
81 | 81 |
|
82 |
-/** |
|
83 |
- * @brief set current frame to none |
|
84 |
- * @param[in] stream stream name |
|
85 |
- */ |
|
86 |
-void Resizer::setNoFrame(const std::string &stream) |
|
87 |
-{ |
|
88 |
- procNoFrame(); |
|
89 |
- (void)stream; // unused |
|
90 |
-} |
|
91 |
- |
|
92 | 82 |
/// get input stream and attach to it |
93 | 83 |
void Resizer::getInStream() |
94 | 84 |
{ |
... | ... |
@@ -141,7 +131,7 @@ void Resizer::releaseOutStream() |
141 | 131 |
{ |
142 | 132 |
// send no frame information |
143 | 133 |
if (m_pOutStream) |
144 |
- m_pOutStream->setNoFrame(); |
|
134 |
+ m_pOutStream->setFrame(NULL); |
|
145 | 135 |
|
146 | 136 |
// unreference stream |
147 | 137 |
m_pOutStream = NULL; |
... | ... |
@@ -151,18 +141,17 @@ void Resizer::releaseOutStream() |
151 | 141 |
/// send current frame to output stream |
152 | 142 |
void Resizer::sendFrame() |
153 | 143 |
{ |
154 |
- stBlinkenFrame *pFrame; |
|
144 |
+ stBlinkenFrame *pFrame = NULL; |
|
155 | 145 |
|
156 | 146 |
// get current frame from input stream and process it |
157 |
- if (m_pInStream && m_pInStream->getCurFrame(pFrame)) |
|
147 |
+ if (m_pInStream) |
|
148 |
+ m_pInStream->getCurFrame(pFrame); |
|
158 | 149 |
procFrame(pFrame); |
159 |
- else |
|
160 |
- procNoFrame(); |
|
161 | 150 |
} |
162 | 151 |
|
163 | 152 |
/** |
164 | 153 |
* @brief process frame |
165 |
- * @param[in] pFrame frame to process |
|
154 |
+ * @param[in] pFrame frame to process (NULL for none) |
|
166 | 155 |
*/ |
167 | 156 |
void Resizer::procFrame(stBlinkenFrame *pFrame) |
168 | 157 |
{ |
... | ... |
@@ -172,9 +161,9 @@ void Resizer::procFrame(stBlinkenFrame *pFrame) |
172 | 161 |
if (!m_pOutStream) |
173 | 162 |
return; |
174 | 163 |
|
175 |
- // no format -> pass "no frame" |
|
176 |
- if (!m_haveFormat) { |
|
177 |
- m_pOutStream->setNoFrame(); |
|
164 |
+ // no frame or no format -> pass "no frame" |
|
165 |
+ if (!pFrame || !m_haveFormat) { |
|
166 |
+ m_pOutStream->setFrame(NULL); |
|
178 | 167 |
return; |
179 | 168 |
} |
180 | 169 |
|
... | ... |
@@ -190,7 +179,7 @@ void Resizer::procFrame(stBlinkenFrame *pFrame) |
190 | 179 |
// clone frame |
191 | 180 |
pProcFrame = BlinkenFrameClone(pFrame); |
192 | 181 |
if (!pProcFrame){ |
193 |
- m_pOutStream->setNoFrame(); |
|
182 |
+ m_pOutStream->setFrame(NULL); |
|
194 | 183 |
return; |
195 | 184 |
} |
196 | 185 |
|
... | ... |
@@ -205,13 +194,5 @@ void Resizer::procFrame(stBlinkenFrame *pFrame) |
205 | 194 |
BlinkenFrameFree(pProcFrame); |
206 | 195 |
} |
207 | 196 |
|
208 |
-/// process "no frame" |
|
209 |
-void Resizer::procNoFrame() |
|
210 |
-{ |
|
211 |
- // pass "no frame" to output stream |
|
212 |
- if (m_pOutStream) |
|
213 |
- m_pOutStream->setNoFrame(); |
|
214 |
-} |
|
215 |
- |
|
216 | 197 |
} // namespace Blinker |
217 | 198 |
|
... | ... |
@@ -50,16 +50,10 @@ public: |
50 | 50 |
/** |
51 | 51 |
* @brief set current frame |
52 | 52 |
* @param[in] stream stream name |
53 |
- * @param[in] pFrame current frame |
|
53 |
+ * @param[in] pFrame current frame (NULL for none) |
|
54 | 54 |
*/ |
55 | 55 |
virtual void setFrame(const std::string &stream, stBlinkenFrame *pFrame); |
56 | 56 |
|
57 |
- /** |
|
58 |
- * @brief set current frame to none |
|
59 |
- * @param[in] stream stream name |
|
60 |
- */ |
|
61 |
- virtual void setNoFrame(const std::string &stream); |
|
62 |
- |
|
63 | 57 |
protected: |
64 | 58 |
/// get input stream and attach to it |
65 | 59 |
void getInStream(); |
... | ... |
@@ -81,13 +75,10 @@ protected: |
81 | 75 |
|
82 | 76 |
/** |
83 | 77 |
* @brief process frame |
84 |
- * @param[in] pFrame frame to process |
|
78 |
+ * @param[in] pFrame frame to process (NULL for none) |
|
85 | 79 |
*/ |
86 | 80 |
void procFrame(stBlinkenFrame *pFrame); |
87 | 81 |
|
88 |
- /// process "no frame" |
|
89 |
- void procNoFrame(); |
|
90 |
- |
|
91 | 82 |
protected: |
92 | 83 |
SettingFile m_fileInStream; ///< input stream name file |
93 | 84 |
SettingFile m_fileFormat; ///< format file |
... | ... |
@@ -71,7 +71,7 @@ void Scaler::updateConfig() |
71 | 71 |
/** |
72 | 72 |
* @brief set current frame |
73 | 73 |
* @param[in] stream stream name |
74 |
- * @param[in] pFrame current frame |
|
74 |
+ * @param[in] pFrame current frame (NULL for none) |
|
75 | 75 |
*/ |
76 | 76 |
void Scaler::setFrame(const std::string &stream, stBlinkenFrame *pFrame) |
77 | 77 |
{ |
... | ... |
@@ -79,16 +79,6 @@ void Scaler::setFrame(const std::string &stream, stBlinkenFrame *pFrame) |
79 | 79 |
(void)stream; // unused |
80 | 80 |
} |
81 | 81 |
|
82 |
-/** |
|
83 |
- * @brief set current frame to none |
|
84 |
- * @param[in] stream stream name |
|
85 |
- */ |
|
86 |
-void Scaler::setNoFrame(const std::string &stream) |
|
87 |
-{ |
|
88 |
- procNoFrame(); |
|
89 |
- (void)stream; // unused |
|
90 |
-} |
|
91 |
- |
|
92 | 82 |
/// get input stream and attach to it |
93 | 83 |
void Scaler::getInStream() |
94 | 84 |
{ |
... | ... |
@@ -141,7 +131,7 @@ void Scaler::releaseOutStream() |
141 | 131 |
{ |
142 | 132 |
// send no frame information |
143 | 133 |
if (m_pOutStream) |
144 |
- m_pOutStream->setNoFrame(); |
|
134 |
+ m_pOutStream->setFrame(NULL); |
|
145 | 135 |
|
146 | 136 |
// unreference stream |
147 | 137 |
m_pOutStream = NULL; |
... | ... |
@@ -151,18 +141,17 @@ void Scaler::releaseOutStream() |
151 | 141 |
/// send current frame to output stream |
152 | 142 |
void Scaler::sendFrame() |
153 | 143 |
{ |
154 |
- stBlinkenFrame *pFrame; |
|
144 |
+ stBlinkenFrame *pFrame = NULL; |
|
155 | 145 |
|
156 | 146 |
// get current frame from input stream and process it |
157 |
- if (m_pInStream && m_pInStream->getCurFrame(pFrame)) |
|
147 |
+ if (m_pInStream) |
|
148 |
+ m_pInStream->getCurFrame(pFrame); |
|
158 | 149 |
procFrame(pFrame); |
159 |
- else |
|
160 |
- procNoFrame(); |
|
161 | 150 |
} |
162 | 151 |
|
163 | 152 |
/** |
164 | 153 |
* @brief process frame |
165 |
- * @param[in] pFrame frame to process |
|
154 |
+ * @param[in] pFrame frame to process (NULL for none) |
|
166 | 155 |
*/ |
167 | 156 |
void Scaler::procFrame(stBlinkenFrame *pFrame) |
168 | 157 |
{ |
... | ... |
@@ -172,9 +161,9 @@ void Scaler::procFrame(stBlinkenFrame *pFrame) |
172 | 161 |
if (!m_pOutStream) |
173 | 162 |
return; |
174 | 163 |
|
175 |
- // no size -> pass "no frame" |
|
176 |
- if (!m_haveSize) { |
|
177 |
- m_pOutStream->setNoFrame(); |
|
164 |
+ // no frame or no size -> pass "no frame" |
|
165 |
+ if (!pFrame || !m_haveSize) { |
|
166 |
+ m_pOutStream->setFrame(NULL); |
|
178 | 167 |
return; |
179 | 168 |
} |
180 | 169 |
|
... | ... |
@@ -188,7 +177,7 @@ void Scaler::procFrame(stBlinkenFrame *pFrame) |
188 | 177 |
// clone frame |
189 | 178 |
pProcFrame = BlinkenFrameClone(pFrame); |
190 | 179 |
if (!pProcFrame) { |
191 |
- m_pOutStream->setNoFrame(); |
|
180 |
+ m_pOutStream->setFrame(NULL); |
|
192 | 181 |
return; |
193 | 182 |
} |
194 | 183 |
|
... | ... |
@@ -202,13 +191,5 @@ void Scaler::procFrame(stBlinkenFrame *pFrame) |
202 | 191 |
BlinkenFrameFree(pProcFrame); |
203 | 192 |
} |
204 | 193 |
|
205 |
-/// process "no frame" |
|
206 |
-void Scaler::procNoFrame() |
|
207 |
-{ |
|
208 |
- // pass "no frame" to output stream |
|
209 |
- if (m_pOutStream) |
|
210 |
- m_pOutStream->setNoFrame(); |
|
211 |
-} |
|
212 |
- |
|
213 | 194 |
} // namespace Blinker |
214 | 195 |
|
... | ... |
@@ -50,16 +50,10 @@ public: |
50 | 50 |
/** |
51 | 51 |
* @brief set current frame |
52 | 52 |
* @param[in] stream stream name |
53 |
- * @param[in] pFrame current frame |
|
53 |
+ * @param[in] pFrame current frame (NULL for none) |
|
54 | 54 |
*/ |
55 | 55 |
virtual void setFrame(const std::string &stream, stBlinkenFrame *pFrame); |
56 | 56 |
|
57 |
- /** |
|
58 |
- * @brief set current frame to none |
|
59 |
- * @param[in] stream stream name |
|
60 |
- */ |
|
61 |
- virtual void setNoFrame(const std::string &stream); |
|
62 |
- |
|
63 | 57 |
protected: |
64 | 58 |
/// get input stream and attach to it |
65 | 59 |
void getInStream(); |
... | ... |
@@ -81,13 +75,10 @@ protected: |
81 | 75 |
|
82 | 76 |
/** |
83 | 77 |
* @brief process frame |
84 |
- * @param[in] pFrame frame to process |
|
78 |
+ * @param[in] pFrame frame to process (NULL for none) |
|
85 | 79 |
*/ |
86 | 80 |
void procFrame(stBlinkenFrame *pFrame); |
87 | 81 |
|
88 |
- /// process "no frame" |
|
89 |
- void procNoFrame(); |
|
90 |
- |
|
91 | 82 |
protected: |
92 | 83 |
SettingFile m_fileInStream; ///< input stream name file |
93 | 84 |
SettingFile m_fileSize; ///< size file |
... | ... |
@@ -74,16 +74,10 @@ public: |
74 | 74 |
/** |
75 | 75 |
* @brief set current frame |
76 | 76 |
* @param[in] stream stream name |
77 |
- * @param[in] pFrame current frame |
|
77 |
+ * @param[in] pFrame current frame (NULL for none) |
|
78 | 78 |
*/ |
79 | 79 |
virtual void setFrame(const std::string &stream, stBlinkenFrame *pFrame); |
80 | 80 |
|
81 |
- /** |
|
82 |
- * @brief set current frame to none |
|
83 |
- * @param[in] stream stream name |
|
84 |
- */ |
|
85 |
- virtual void setNoFrame(const std::string &stream); |
|
86 |
- |
|
87 | 81 |
/// callback when requsted time reached |
88 | 82 |
virtual void timeCall(); |
89 | 83 |
|
... | ... |
@@ -130,7 +124,7 @@ protected: |
130 | 124 |
* i.e. scan files in playlist directory |
131 | 125 |
* @param[in] dirDests static destinations directory for protocol |
132 | 126 |
* @param[in] destList static destinations for protocol |
133 |
- * @param[in] pNoFrameData "no frame" protocaol data |
|
127 |
+ * @param[in] pNoFrameData "no frame" protocol data |
|
134 | 128 |
*/ |
135 | 129 |
void updateDestsFull(Directory &dirDests, DestList &destList, |
136 | 130 |
const std::string *pNoFrameData); |
... | ... |
@@ -162,20 +156,13 @@ protected: |
162 | 156 |
|
163 | 157 |
/** |
164 | 158 |
* @brief convert frame to protocol data |
165 |
- * @param[in] pFrame frame |
|
159 |
+ * @param[in] pFrame frame (NULL for none) |
|
166 | 160 |
* @param[in] proto Blinken protocol identifier |
167 | 161 |
* @param[out] data protcol data |
168 | 162 |
*/ |
169 | 163 |
static void frame2data(stBlinkenFrame *pFrame, etBlinkenProto proto, |
170 | 164 |
std::string &data); |
171 | 165 |
|
172 |
- /** |
|
173 |
- * @brief get "no frame" protocol data |
|
174 |
- * @param[in] proto Blinken protocol identifier |
|
175 |
- * @param[out] data protcol data |
|
176 |
- */ |
|
177 |
- static void noFrame2data(etBlinkenProto proto, std::string &data); |
|
178 |
- |
|
179 | 166 |
/// receive data from socket |
180 | 167 |
void receiveFromSock(); |
181 | 168 |
|
... | ... |
@@ -48,9 +48,9 @@ Sender<ADDR, SOCK>::Sender(CallMgr &callMgr, StreamMgr &streamMgr, |
48 | 48 |
m_pSock(NULL) |
49 | 49 |
{ |
50 | 50 |
// initialize protocol data buffers |
51 |
- noFrame2data(BlinkenProtoBlp, m_noFrameDataBlp); |
|
52 |
- noFrame2data(BlinkenProtoEblp, m_noFrameDataEblp); |
|
53 |
- noFrame2data(BlinkenProtoMcuf, m_noFrameDataMcuf); |
|
51 |
+ frame2data(NULL, BlinkenProtoBlp, m_noFrameDataBlp); |
|
52 |
+ frame2data(NULL, BlinkenProtoEblp, m_noFrameDataEblp); |
|
53 |
+ frame2data(NULL, BlinkenProtoMcuf, m_noFrameDataMcuf); |
|
54 | 54 |
m_dataBlp = m_noFrameDataBlp; |
55 | 55 |
m_dataEblp = m_noFrameDataEblp; |
56 | 56 |
m_dataMcuf = m_noFrameDataMcuf; |
... | ... |
@@ -121,7 +121,7 @@ void Sender<ADDR, SOCK>::updateConfig() |
121 | 121 |
/** |
122 | 122 |
* @brief set current frame |
123 | 123 |
* @param[in] stream stream name |
124 |
- * @param[in] pFrame current frame |
|
124 |
+ * @param[in] pFrame current frame (NULL for none) |
|
125 | 125 |
*/ |
126 | 126 |
template<typename ADDR, typename SOCK> |
127 | 127 |
void Sender<ADDR, SOCK>::setFrame(const std::string &stream, |
... | ... |
@@ -138,24 +138,6 @@ void Sender<ADDR, SOCK>::setFrame(const std::string &stream, |
138 | 138 |
(void)stream; // unused |
139 | 139 |
} |
140 | 140 |
|
141 |
-/** |
|
142 |
- * @brief set current frame to none |
|
143 |
- * @param[in] stream stream name |
|
144 |
- */ |
|
145 |
-template<typename ADDR, typename SOCK> |
|
146 |
-void Sender<ADDR, SOCK>::setNoFrame(const std::string &stream) |
|
147 |
-{ |
|
148 |
- // set protocol data |
|
149 |
- m_dataBlp = m_noFrameDataBlp; |
|
150 |
- m_dataEblp = m_noFrameDataEblp; |
|
151 |
- m_dataMcuf = m_noFrameDataMcuf; |
|
152 |
- |
|
153 |
- // send new protocol data to all destinations |
|
154 |
- sendAllProto(); |
|
155 |
- |
|
156 |
- (void)stream; // unused |
|
157 |
-} |
|
158 |
- |
|
159 | 141 |
/// callback when requsted time reached |
160 | 142 |
template<typename ADDR, typename SOCK> |
161 | 143 |
void Sender<ADDR, SOCK>::timeCall() |
... | ... |
@@ -448,7 +430,7 @@ void Sender<ADDR, SOCK>::sendProto(const std::string &data, |
448 | 430 |
|
449 | 431 |
/** |
450 | 432 |
* @brief convert frame to protocol data |
451 |
- * @param[in] pFrame frame |
|
433 |
+ * @param[in] pFrame frame (NULL for none) |
|
452 | 434 |
* @param[in] proto Blinken protocol identifier |
453 | 435 |
* @param[out] data protocol data |
454 | 436 |
*/ |
... | ... |
@@ -460,24 +442,9 @@ void Sender<ADDR, SOCK>::frame2data(stBlinkenFrame *pFrame, |
460 | 442 |
int len; |
461 | 443 |
|
462 | 444 |
// convert frame to protcol data |
445 |
+ if (pFrame) |
|
463 | 446 |
len = BlinkenFrameToNetwork(pFrame, proto, buf, sizeof(buf)); |
464 |
- if (len < 0) |
|
465 |
- len = 0; |
|
466 |
- data.assign(buf, len); |
|
467 |
-} |
|
468 |
- |
|
469 |
-/** |
|
470 |
- * @brief get "no frame" protocol data |
|
471 |
- * @param[in] proto Blinken protocol identifier |
|
472 |
- * @param[out] data protcol data |
|
473 |
- */ |
|
474 |
-template<typename ADDR, typename SOCK> |
|
475 |
-void Sender<ADDR, SOCK>::noFrame2data(etBlinkenProto proto, std::string &data) |
|
476 |
-{ |
|
477 |
- char buf[16]; |
|
478 |
- int len; |
|
479 |
- |
|
480 |
- // obtain "no frame" protcol data |
|
447 |
+ else |
|
481 | 448 |
len = BlinkenProtoMakePacket(proto, BlinkenPacketStreamEnd, |
482 | 449 |
buf, sizeof(buf)); |
483 | 450 |
if (len < 0) |
... | ... |
@@ -35,10 +35,7 @@ void Stream::attach(StreamRecv *recv) |
35 | 35 |
m_recvs.insert(recv); |
36 | 36 |
|
37 | 37 |
// send current frame to receiver |
38 |
- if (m_pFrame) |
|
39 | 38 |
recv->setFrame(m_name, m_pFrame); |
40 |
- else |
|
41 |
- recv->setNoFrame(m_name); |
|
42 | 39 |
} |
43 | 40 |
|
44 | 41 |
/** |
... | ... |
@@ -52,55 +49,39 @@ void Stream::detach(StreamRecv *recv) |
52 | 49 |
|
53 | 50 |
/** |
54 | 51 |
* @brief set current frame |
55 |
- * @param[in] pFrame current frame |
|
52 |
+ * @param[in] pFrame current frame (NULL for none) |
|
56 | 53 |
*/ |
57 | 54 |
void Stream::setFrame(stBlinkenFrame *pFrame) |
58 | 55 |
{ |
59 | 56 |
// leave if frame is already set to an identical one |
60 |
- if (m_pFrame && !BlinkenFrameCompare(pFrame, m_pFrame)) |
|
57 |
+ if (pFrame && m_pFrame && !BlinkenFrameCompare(pFrame, m_pFrame)) |
|
61 | 58 |
return; |
62 |
- |
|
63 |
- // update local copy of current frame |
|
64 |
- if (m_pFrame) |
|
65 |
- BlinkenFrameFree(m_pFrame); |
|
66 |
- m_pFrame = BlinkenFrameClone(pFrame); |
|
67 |
- if (!m_pFrame) |
|
68 |
- return; // out of memory: do not pass NULL pointer to receivers |
|
69 |
- |
|
70 |
- // pass frame to all receivers |
|
71 |
- Recvs::iterator it; |
|
72 |
- for (it = m_recvs.begin(); it != m_recvs.end(); ++it) |
|
73 |
- (*it)->setFrame(m_name, m_pFrame); |
|
74 |
-} |
|
75 |
- |
|
76 |
-/// set current frame to none |
|
77 |
-void Stream::setNoFrame() |
|
78 |
-{ |
|
79 |
- // leave if frame is already set to none |
|
80 |
- if (!m_pFrame) |
|
59 |
+ if (!pFrame && !m_pFrame) |
|
81 | 60 |
return; |
82 | 61 |
|
83 |
- // set current frame to none |
|
62 |
+ // update local copy of current frame |
|
84 | 63 |
if (m_pFrame) { |
85 | 64 |
BlinkenFrameFree(m_pFrame); |
86 | 65 |
m_pFrame = NULL; |
87 | 66 |
} |
67 |
+ if (pFrame) { |
|
68 |
+ m_pFrame = BlinkenFrameClone(pFrame); |
|
69 |
+ // in case of NULL returned: out of memory - got on without frame |
|
70 |
+ } |
|
88 | 71 |
|
89 |
- // pass "no frame" to all receivers |
|
72 |
+ // pass frame to all receivers |
|
90 | 73 |
Recvs::iterator it; |
91 | 74 |
for (it = m_recvs.begin(); it != m_recvs.end(); ++it) |
92 |
- (*it)->setNoFrame(m_name); |
|
75 |
+ (*it)->setFrame(m_name, m_pFrame); |
|
93 | 76 |
} |
94 | 77 |
|
95 | 78 |
/** |
96 | 79 |
* @brief get current frame |
97 |
- * @param[out] pFrame current frame |
|
98 |
- * @return if a current frame exists |
|
80 |
+ * @param[out] pFrame current frame (NULL for none) |
|
99 | 81 |
*/ |
100 |
-bool Stream::getCurFrame(stBlinkenFrame *&pFrame) |
|
82 |
+void Stream::getCurFrame(stBlinkenFrame *&pFrame) |
|
101 | 83 |
{ |
102 | 84 |
pFrame = m_pFrame; |
103 |
- return m_pFrame; |
|
104 | 85 |
} |
105 | 86 |
|
106 | 87 |
} // namespace Blinker |
... | ... |
@@ -44,19 +44,15 @@ public: |
44 | 44 |
|
45 | 45 |
/** |
46 | 46 |
* @brief set current frame |
47 |
- * @param[in] pFrame current frame |
|
47 |
+ * @param[in] pFrame current frame (NULL for none) |
|
48 | 48 |
*/ |
49 | 49 |
virtual void setFrame(stBlinkenFrame *pFrame); |
50 | 50 |
|
51 |
- /// set current frame to none |
|
52 |
- virtual void setNoFrame(); |
|
53 |
- |
|
54 | 51 |
/** |
55 | 52 |
* @brief get current frame |
56 |
- * @param[out] pFrame current frame |
|
57 |
- * @return if a current frame exists |
|
53 |
+ * @param[out] pFrame current frame (NULL for none) |
|
58 | 54 |
*/ |
59 |
- bool getCurFrame(stBlinkenFrame *&pFrame); |
|
55 |
+ void getCurFrame(stBlinkenFrame *&pFrame); |
|
60 | 56 |
|
61 | 57 |
protected: |
62 | 58 |
/// stream name |
... | ... |
@@ -26,15 +26,9 @@ public: |
26 | 26 |
/** |
27 | 27 |
* @brief set current frame |
28 | 28 |
* @param[in] stream stream name |
29 |
- * @param[in] pFrame current frame |
|
29 |
+ * @param[in] pFrame current frame (NULL for none) |
|
30 | 30 |
*/ |
31 | 31 |
virtual void setFrame(const std::string &stream, stBlinkenFrame *pFrame) = 0; |
32 |
- |
|
33 |
- /** |
|
34 |
- * @brief set current frame to none |
|
35 |
- * @param[in] stream stream name |
|
36 |
- */ |
|
37 |
- virtual void setNoFrame(const std::string &stream) = 0; |
|
38 | 32 |
}; // class StreamRecv |
39 | 33 |
|
40 | 34 |
} // namespace Blinker |
41 | 35 |