Changeset View
Changeset View
Standalone View
Standalone View
src/screencaststream.cpp
Show First 20 Lines • Show All 522 Lines • ▼ Show 20 Line(s) | 522 | if (!(buffer = pw_stream_dequeue_buffer(pwStream))) { | |||
---|---|---|---|---|---|
523 | qCWarning(XdgDesktopPortalKdeScreenCastStream) << "Failed to record frame: couldn't obtain PipeWire buffer"; | 523 | qCWarning(XdgDesktopPortalKdeScreenCastStream) << "Failed to record frame: couldn't obtain PipeWire buffer"; | ||
524 | return false; | 524 | return false; | ||
525 | } | 525 | } | ||
526 | 526 | | |||
527 | spa_buffer = buffer->buffer; | 527 | spa_buffer = buffer->buffer; | ||
528 | 528 | | |||
529 | if (!(data = (uint8_t *) spa_buffer->datas[0].data)) { | 529 | if (!(data = (uint8_t *) spa_buffer->datas[0].data)) { | ||
530 | qCWarning(XdgDesktopPortalKdeScreenCastStream) << "Failed to record frame: invalid buffer data"; | 530 | qCWarning(XdgDesktopPortalKdeScreenCastStream) << "Failed to record frame: invalid buffer data"; | ||
531 | pw_stream_queue_buffer(pwStream, buffer); | ||||
531 | return false; | 532 | return false; | ||
532 | } | 533 | } | ||
533 | 534 | | |||
534 | const quint32 destStride = SPA_ROUND_UP_N(videoFormat.size.width * BITS_PER_PIXEL, 4); | 535 | const quint32 destStride = SPA_ROUND_UP_N(videoFormat.size.width * BITS_PER_PIXEL, 4); | ||
535 | const quint32 destSize = BITS_PER_PIXEL * width * height * sizeof(uint8_t); | 536 | const quint32 destSize = BITS_PER_PIXEL * width * height * sizeof(uint8_t); | ||
536 | const quint32 srcSize = spa_buffer->datas[0].maxsize; | 537 | const quint32 srcSize = spa_buffer->datas[0].maxsize; | ||
537 | 538 | | |||
538 | if (destSize != srcSize || stride != destStride) { | 539 | if (destSize != srcSize || stride != destStride) { | ||
539 | qCWarning(XdgDesktopPortalKdeScreenCastStream) << "Failed to record frame: different stride"; | 540 | qCWarning(XdgDesktopPortalKdeScreenCastStream) << "Failed to record frame: different stride"; | ||
541 | pw_stream_queue_buffer(pwStream, buffer); | ||||
540 | return false; | 542 | return false; | ||
541 | } | 543 | } | ||
542 | 544 | | |||
543 | // bind context to render thread | 545 | // bind context to render thread | ||
544 | eglMakeCurrent(WaylandIntegration::egl().display, EGL_NO_SURFACE, EGL_NO_SURFACE, WaylandIntegration::egl().context); | 546 | eglMakeCurrent(WaylandIntegration::egl().display, EGL_NO_SURFACE, EGL_NO_SURFACE, WaylandIntegration::egl().context); | ||
545 | 547 | | |||
546 | // create EGL image from imported BO | 548 | // create EGL image from imported BO | ||
547 | EGLImageKHR image = eglCreateImageKHR(WaylandIntegration::egl().display, nullptr, EGL_NATIVE_PIXMAP_KHR, bo, nullptr); | 549 | EGLImageKHR image = eglCreateImageKHR(WaylandIntegration::egl().display, nullptr, EGL_NATIVE_PIXMAP_KHR, bo, nullptr); | ||
548 | 550 | | |||
549 | if (image == EGL_NO_IMAGE_KHR) { | 551 | if (image == EGL_NO_IMAGE_KHR) { | ||
550 | qCWarning(XdgDesktopPortalKdeScreenCastStream) << "Failed to record frame: Error creating EGLImageKHR - " << WaylandIntegration::formatGLError(glGetError()); | 552 | qCWarning(XdgDesktopPortalKdeScreenCastStream) << "Failed to record frame: Error creating EGLImageKHR - " << WaylandIntegration::formatGLError(glGetError()); | ||
553 | pw_stream_queue_buffer(pwStream, buffer); | ||||
551 | return false; | 554 | return false; | ||
552 | } | 555 | } | ||
553 | 556 | | |||
554 | // create GL 2D texture for framebuffer | 557 | // create GL 2D texture for framebuffer | ||
555 | GLuint texture; | 558 | GLuint texture; | ||
556 | glGenTextures(1, &texture); | 559 | glGenTextures(1, &texture); | ||
557 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | 560 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | ||
558 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | 561 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | ||
Show All 40 Lines |