| 272 | } |
| 273 | |
| 274 | bool Stream::update(int clientID, bool start) { |
| 275 | base::MutexLock lock(_mutex); |
| 276 | |
| 277 | // first time streaming? |
| 278 | if (!_streaming && start) { |
| 279 | switch (_streamingType) { |
| 280 | case StreamingType::NONE: |
| 281 | _streaming.reset(nullptr); |
| 282 | SI_LOG_ERROR("Stream: %d, No streaming type found!!", _streamID); |
| 283 | break; |
| 284 | case StreamingType::HTTP: |
| 285 | SI_LOG_DEBUG("Stream: %d, Found Streaming type: HTTP", _streamID); |
| 286 | _streaming.reset(new output::StreamThreadHttp(*this)); |
| 287 | break; |
| 288 | case StreamingType::RTSP_UNICAST: |
| 289 | SI_LOG_DEBUG("Stream: %d, Found Streaming type: RTSP Unicast", _streamID); |
| 290 | _streaming.reset(new output::StreamThreadRtp(*this)); |
| 291 | break; |
| 292 | case StreamingType::RTSP_MULTICAST: |
| 293 | SI_LOG_DEBUG("Stream: %d, Found Streaming type: RTSP Multicast", _streamID); |
| 294 | _streaming.reset(new output::StreamThreadRtp(*this)); |
| 295 | break; |
| 296 | case StreamingType::RTP_TCP: |
| 297 | SI_LOG_DEBUG("Stream: %d, Found Streaming type: RTP/TCP", _streamID); |
| 298 | _streaming.reset(new output::StreamThreadRtpTcp(*this)); |
| 299 | break; |
| 300 | case StreamingType::FILE: |
| 301 | SI_LOG_DEBUG("Stream: %d, Found Streaming type: FILE", _streamID); |
| 302 | _streaming.reset(new output::StreamThreadTSWriter(*this, "test.ts")); |
| 303 | break; |
| 304 | default: |
| 305 | _streaming.reset(nullptr); |
| 306 | SI_LOG_ERROR("Stream: %d, Unknown streaming type!", _streamID); |
| 307 | }; |
| 308 | if (!_streaming) { |
| 309 | return false; |
| 310 | } |
| 311 | } |
| 312 | // Get changed flag, before device update, because it resets it |
| 313 | const bool changed = _device->hasDeviceDataChanged(); |
| 314 | |
| 315 | if (!_device->update()) { |
| 316 | return false; |
| 317 | } |
| 318 | |
| 319 | // start or restart streaming again |
| 320 | if (_streaming) { |
| 321 | if (!_streamActive) { |
| 322 | _streamActive = _streaming->startStreaming(clientID); |
| 323 | } else if (changed) { |
| 324 | _streaming->restartStreaming(clientID); |
| 325 | } |
| 326 | } |
| 327 | return true; |
| 328 | } |
| 329 | |
| 330 | bool Stream::teardown(int clientID) { |
| 331 | base::MutexLock lock(_mutex); |
no test coverage detected