| 126 | } |
| 127 | |
| 128 | bool StreamThreadBase::pauseStreaming(const int clientID) { |
| 129 | bool paused = true; |
| 130 | // Check if thread is running |
| 131 | if (running()) { |
| 132 | doPauseStreaming(clientID); |
| 133 | |
| 134 | _state = State::Pause; |
| 135 | const StreamClient &client = _stream.getStreamClient(clientID); |
| 136 | const double payload = _stream.getRtpPayload() / (1024.0 * 1024.0); |
| 137 | // try waiting on pause |
| 138 | auto timeout = 0; |
| 139 | while (_state != State::Paused) { |
| 140 | std::this_thread::sleep_for(std::chrono::milliseconds(50)); |
| 141 | ++timeout; |
| 142 | if (timeout > 50) { |
| 143 | SI_LOG_ERROR("Stream: %d, Pause %s stream to %s:%d TIMEOUT (Streamed %.3f MBytes)", |
| 144 | _stream.getStreamID(), _protocol.c_str(), client.getIPAddressOfStream().c_str(), |
| 145 | getStreamSocketPort(clientID), payload); |
| 146 | paused = false; |
| 147 | break; |
| 148 | } |
| 149 | } |
| 150 | if (paused) { |
| 151 | SI_LOG_INFO("Stream: %d, Pause %s stream to %s:%d (Streamed %.3f MBytes)", |
| 152 | _stream.getStreamID(), _protocol.c_str(), client.getIPAddressOfStream().c_str(), |
| 153 | getStreamSocketPort(clientID), payload); |
| 154 | } |
| 155 | #ifdef LIBDVBCSA |
| 156 | decrypt::dvbapi::SpClient decrypt = _stream.getDecryptDevice(); |
| 157 | if (decrypt != nullptr) { |
| 158 | decrypt->stopDecrypt(_stream.getStreamID()); |
| 159 | } |
| 160 | #endif |
| 161 | } |
| 162 | return paused; |
| 163 | } |
| 164 | |
| 165 | bool StreamThreadBase::restartStreaming(const int clientID) { |
| 166 | // Check if thread is running |
no test coverage detected