void render::VCWnd::RemoteFrameRenderer() { VideoRenderer* remote_renderer = UI_->remote_renderer_.get(); if (remote_renderer) { AutoLock<VideoRenderer> remote_lock(remote_renderer); const BITMAPINFO& bmi = remote_renderer->bmi(); int height = abs(bmi.bmiHeader.biHeight); int width = bmi.bmiHeader.biWidth; const uint8* image = remote_renderer->image(); if (image != NULL) { QImage *remote_video = new QImage(image, bmi.bmiHeader.biWidth, abs(bmi.bmiHeader.biHeight), QImage::Format_RGB32); QPainter painter(this); QRect rect = this->rect(); painter.drawImage(rect, *remote_video); } else { QImage img(600, 400, QImage::Format_RGB32); img.fill(QColor(0, 0, 0, 255)); QPainter painter(this); painter.drawImage(this->rect(), img); } } }
void StreamingUIWidget::paintEvent(QPaintEvent *event) { // RECT rc; // ::GetClientRect(handle(), &rc); QPainter painter(this); QRect tmpRect = this->rect(); VideoRenderer* local_renderer = local_renderer_.get(); VideoRenderer* remote_renderer = remote_renderer_.get(); if (remote_renderer && local_renderer) { AutoLock<VideoRenderer> local_lock(local_renderer); AutoLock<VideoRenderer> remote_lock(remote_renderer); const BITMAPINFO& bmi = remote_renderer->bmi(); int height = abs(bmi.bmiHeader.biHeight); int width = bmi.bmiHeader.biWidth; //this->resize(width,height); const uint8* image = remote_renderer->image(); if (image != NULL) { QByteArray bmpData; //make bmp BITMAPFILEHEADER fileHead; fileHead.bfType = 0x4D42;//bmp类型 fileHead.bfSize= sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFO) + bmi.bmiHeader.biSizeImage; fileHead.bfOffBits=sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFO); bmpData.append((char *)&fileHead,sizeof(BITMAPFILEHEADER)); bmpData.append((char *)&bmi,sizeof(BITMAPINFO)); bmpData.append((char *)image,bmi.bmiHeader.biSizeImage); QImage tmpImage = QImage::fromData(bmpData,"BMP"); painter.drawPixmap(0,0,width,height,QPixmap::fromImage(tmpImage)); } else { QString text(kConnecting); if (!local_renderer->image()) { text += kNoVideoStreams; } else { text += kNoIncomingStream; } painter.drawText(10,10,text); } } }
static void dispatch(struct lock_msg *mp, daemonaddr_t *host) { int message = mp->message; int localhost; localhost = islocalhost(host); if (msgtrace && debugfile) { time_t t = time(0); if (localhost) { (void) fprintf(debugfile, "%19.19s recv %-9.9s from %s (%ld)\n", ctime(&t), lockd_msg(message), dp_addr(host), mp->pid); } else { (void) fprintf(debugfile, "%19.19s recv %-9.9s from %s order %d (%ld)\n", ctime(&t), lockd_msg(message), dp_addr(host), mp->order, mp->pid); } } DPF((stderr, "received message %d\n", message)); DPF((stderr, "from %s port %hu\n", dp_addr(host), host->sin_port)); if (!localhost) daemon_alive(host, mp->order); else mp->order = order; switch (message) { case ALIVE: DPF((stderr, "received ALIVE %s\n", dp_addr(host))); /* do nothing, general "not localhost" code above does this */ break; case UNLOCK: DPF((stderr, "received UNLOCK\n")); remote_unlock(mp->order, host); break; case GRANTED: DPF((stderr, "received GRANTED\n")); lock_granted(host); break; case WRITE_LOCK: DPF((stderr, "received WRITE_LOCK\n")); assert(!localhost); remote_lock(host, mp); break; case READ_LOCK: case LOCK_READ: DPF((stderr, "received READ_LOCK\n")); assert(localhost); local_lock(LOCK_READ, mp, host); break; case LOCK_WRITE: DPF((stderr, "received LOCK_WRITE\n")); assert(localhost); local_lock(LOCK_WRITE, mp, host); break; case LOCK_NOTLOCKED: DPF((stderr, "received LOCK_NOTLOCKED\n")); send_lockmsg(LOCK_ACK, (pid_t)0, host, mp->seq); if (the_lock.type != LOCK_NOTLOCKED) { local_unlock(mp->pid, mp->seq, NORMAL_UNLOCK); } break; case LOCK_LOCKEDBY: lockedby(host, mp->seq); break; case LOCK_STAT: lock_stat(); break; case LOCK_ACK: /* throw message away -- this is an error to receive */ break; } }