| 74 | } |
| 75 | |
| 76 | void RasterStreamView::onSocketReadyRead() { |
| 77 | while (socket_->bytesAvailable() >= pj_raster::kMessageBytes) { |
| 78 | const QByteArray bytes = socket_->read(pj_raster::kMessageBytes); |
| 79 | const pj_raster::Message msg = pj_raster::decodeMessage(reinterpret_cast<const uint8_t*>(bytes.constData())); |
| 80 | if (msg.type == pj_raster::MsgType::kFrameReady && shm_ != nullptr) { |
| 81 | if (!shm_->lock()) { |
| 82 | continue; |
| 83 | } |
| 84 | const QImage view = imageForActiveFrame(static_cast<const unsigned char*>(shm_->constData()), shm_->size()); |
| 85 | frame_ = view.copy(); |
| 86 | shm_->unlock(); |
| 87 | if (!frame_.isNull()) { |
| 88 | scaled_ = QImage(); // invalidate the cached scale; recomputed on next paint |
| 89 | update(); |
| 90 | } |
| 91 | } else if (msg.type == pj_raster::MsgType::kBye) { |
| 92 | endSession(); |
| 93 | } |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | void RasterStreamView::paintEvent(QPaintEvent* /*event*/) { |
| 98 | QPainter painter(this); |
nothing calls this directly
no test coverage detected