Changeset View
Changeset View
Standalone View
Standalone View
src/screencaststream.cpp
Show First 20 Lines • Show All 243 Lines • ▼ Show 20 Line(s) | 243 | { | |||
---|---|---|---|---|---|
244 | qCDebug(XdgDesktopPortalKdeScreenCastStream) << "Stream format changed"; | 244 | qCDebug(XdgDesktopPortalKdeScreenCastStream) << "Stream format changed"; | ||
245 | 245 | | |||
246 | ScreenCastStream *pw = static_cast<ScreenCastStream*>(data); | 246 | ScreenCastStream *pw = static_cast<ScreenCastStream*>(data); | ||
247 | 247 | | |||
248 | uint8_t paramsBuffer[1024]; | 248 | uint8_t paramsBuffer[1024]; | ||
249 | int32_t width, height, stride, size; | 249 | int32_t width, height, stride, size; | ||
250 | struct spa_pod_builder pod_builder; | 250 | struct spa_pod_builder pod_builder; | ||
251 | const struct spa_pod *params[1]; | 251 | const struct spa_pod *params[1]; | ||
252 | const int bpp = 4; | | |||
253 | 252 | | |||
254 | #if PW_CHECK_VERSION(0, 2, 90) | 253 | #if PW_CHECK_VERSION(0, 2, 90) | ||
255 | if (!format || id != SPA_PARAM_Format) { | 254 | if (!format || id != SPA_PARAM_Format) { | ||
256 | #else | 255 | #else | ||
257 | if (!format) { | 256 | if (!format) { | ||
258 | pw_stream_finish_format(pw->pwStream, 0, nullptr, 0); | 257 | pw_stream_finish_format(pw->pwStream, 0, nullptr, 0); | ||
259 | #endif | 258 | #endif | ||
260 | return; | 259 | return; | ||
261 | } | 260 | } | ||
262 | 261 | | |||
263 | #if PW_CHECK_VERSION(0, 2, 90) | 262 | #if PW_CHECK_VERSION(0, 2, 90) | ||
264 | spa_format_video_raw_parse (format, &pw->videoFormat); | 263 | spa_format_video_raw_parse (format, &pw->videoFormat); | ||
265 | #else | 264 | #else | ||
266 | spa_format_video_raw_parse (format, &pw->videoFormat, &pw->pwType->format_video); | 265 | spa_format_video_raw_parse (format, &pw->videoFormat, &pw->pwType->format_video); | ||
267 | #endif | 266 | #endif | ||
268 | 267 | | |||
269 | width = pw->videoFormat.size.width; | 268 | width = pw->videoFormat.size.width; | ||
270 | height =pw->videoFormat.size.height; | 269 | height =pw->videoFormat.size.height; | ||
271 | stride = SPA_ROUND_UP_N (width * bpp, 4); | 270 | stride = SPA_ROUND_UP_N (width * BITS_PER_PIXEL, 4); | ||
272 | size = height * stride; | 271 | size = height * stride; | ||
273 | 272 | | |||
274 | pod_builder = SPA_POD_BUILDER_INIT (paramsBuffer, sizeof (paramsBuffer)); | 273 | pod_builder = SPA_POD_BUILDER_INIT (paramsBuffer, sizeof (paramsBuffer)); | ||
275 | 274 | | |||
276 | #if PW_CHECK_VERSION(0, 2, 90) | 275 | #if PW_CHECK_VERSION(0, 2, 90) | ||
277 | params[0] = (spa_pod*) spa_pod_builder_add_object(&pod_builder, | 276 | params[0] = (spa_pod*) spa_pod_builder_add_object(&pod_builder, | ||
278 | SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers, | 277 | SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers, | ||
279 | SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int(16, 2, 16), | 278 | SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int(16, 2, 16), | ||
▲ Show 20 Lines • Show All 233 Lines • ▼ Show 20 Line(s) | 503 | { | |||
513 | spa_buffer = buffer->buffer; | 512 | spa_buffer = buffer->buffer; | ||
514 | 513 | | |||
515 | if (!(data = (uint8_t *) spa_buffer->datas[0].data)) { | 514 | if (!(data = (uint8_t *) spa_buffer->datas[0].data)) { | ||
516 | return false; | 515 | return false; | ||
517 | } | 516 | } | ||
518 | 517 | | |||
519 | memcpy(data, screenData, BITS_PER_PIXEL * videoFormat.size.height * videoFormat.size.width * sizeof(uint8_t)); | 518 | memcpy(data, screenData, BITS_PER_PIXEL * videoFormat.size.height * videoFormat.size.width * sizeof(uint8_t)); | ||
520 | 519 | | |||
520 | spa_buffer->datas[0].chunk->offset = 0; | ||||
521 | spa_buffer->datas[0].chunk->size = spa_buffer->datas[0].maxsize; | 521 | spa_buffer->datas[0].chunk->size = spa_buffer->datas[0].maxsize; | ||
522 | spa_buffer->datas[0].chunk->stride = SPA_ROUND_UP_N (videoFormat.size.width * BITS_PER_PIXEL, 4); | ||||
522 | 523 | | |||
523 | pw_stream_queue_buffer(pwStream, buffer); | 524 | pw_stream_queue_buffer(pwStream, buffer); | ||
524 | return true; | 525 | return true; | ||
525 | } | 526 | } | ||
526 | 527 | | |||
527 | void ScreenCastStream::removeStream() | 528 | void ScreenCastStream::removeStream() | ||
528 | { | 529 | { | ||
529 | // FIXME destroying streams seems to be crashing, Mutter also doesn't remove them, maybe Pipewire does this automatically | 530 | // FIXME destroying streams seems to be crashing, Mutter also doesn't remove them, maybe Pipewire does this automatically | ||
Show All 19 Lines |