| 157 | } |
| 158 | |
| 159 | void MinicapStream::pulling() |
| 160 | { |
| 161 | LogFunc; |
| 162 | |
| 163 | while (!quit_) { |
| 164 | auto size_opt = read(4); |
| 165 | if (!size_opt) { |
| 166 | LogError << "read size failed"; |
| 167 | std::unique_lock locker(mutex_); |
| 168 | image_ = cv::Mat(); |
| 169 | continue; |
| 170 | } |
| 171 | auto size = *reinterpret_cast<const uint32_t*>(size_opt->data()); |
| 172 | |
| 173 | auto data_opt = read(size); |
| 174 | if (!data_opt) { |
| 175 | LogError << "read data failed"; |
| 176 | std::unique_lock locker(mutex_); |
| 177 | image_ = cv::Mat(); |
| 178 | continue; |
| 179 | } |
| 180 | |
| 181 | auto img_opt = screencap_helper_.decode_jpg(*data_opt); |
| 182 | |
| 183 | if (!img_opt || img_opt->empty()) { |
| 184 | LogError << "decode jpg failed"; |
| 185 | std::unique_lock locker(mutex_); |
| 186 | image_ = cv::Mat(); |
| 187 | continue; |
| 188 | } |
| 189 | |
| 190 | std::unique_lock locker(mutex_); |
| 191 | image_ = std::move(*img_opt); |
| 192 | cond_.notify_all(); |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | MAA_CTRL_UNIT_NS_END |
nothing calls this directly
no test coverage detected