Skip to content

Commit a465a81

Browse files
committed
linux-pipewire: Support MJPEG and H264 devices
1 parent 31574b4 commit a465a81

5 files changed

Lines changed: 394 additions & 61 deletions

File tree

plugins/linux-pipewire/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ if(NOT ENABLE_PIPEWIRE)
77
endif()
88

99
find_package(PipeWire 0.3.33 REQUIRED)
10+
find_package(FFmpeg REQUIRED COMPONENTS avcodec avutil avformat)
1011
find_package(Gio 2.76 REQUIRED)
1112
find_package(Libdrm REQUIRED)
1213
get_target_property(libdrm_include_directories Libdrm::Libdrm INTERFACE_INCLUDE_DIRECTORIES)
@@ -26,6 +27,8 @@ target_sources(
2627
PRIVATE
2728
$<$<BOOL:${_HAS_PIPEWIRE_CAMERA}>:camera-portal.c>
2829
$<$<BOOL:${_HAS_PIPEWIRE_CAMERA}>:camera-portal.h>
30+
$<$<BOOL:${_HAS_PIPEWIRE_CAMERA}>:video-decoder.c>
31+
$<$<BOOL:${_HAS_PIPEWIRE_CAMERA}>:video-decoder.h>
2932
formats.c
3033
formats.h
3134
linux-pipewire.c

plugins/linux-pipewire/camera-portal.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,18 @@ static void camera_format_list(struct camera_device *dev, obs_property_t *prop)
366366
obs_data_set_int(data, "video_format", format);
367367

368368
format_name = obs_pw_video_format.pretty_name;
369-
} else {
370-
continue;
369+
} else if (media_subtype == SPA_MEDIA_SUBTYPE_mjpg || media_subtype == SPA_MEDIA_SUBTYPE_h264) {
370+
obs_data_set_bool(data, "encoded", true);
371+
obs_data_set_int(data, "video_format", SPA_VIDEO_FORMAT_ENCODED);
372+
373+
switch (media_subtype) {
374+
case SPA_MEDIA_SUBTYPE_mjpg:
375+
format_name = "MJPG";
376+
break;
377+
case SPA_MEDIA_SUBTYPE_h264:
378+
format_name = "H264";
379+
break;
380+
}
371381
}
372382

373383
if (spa_pod_parse_object(p->param, SPA_TYPE_OBJECT_Format, format ? &format : NULL,
@@ -647,7 +657,6 @@ static void framerate_list(struct camera_device *dev, uint32_t pixelformat, cons
647657
spa_list_for_each(p, &dev->param_list, link)
648658
{
649659
const struct spa_fraction *framerate_values;
650-
struct obs_pw_video_format obs_pw_video_format;
651660
enum spa_choice_type choice;
652661
const struct spa_pod_prop *prop;
653662
struct spa_rectangle this_resolution;
@@ -672,10 +681,7 @@ static void framerate_list(struct camera_device *dev, uint32_t pixelformat, cons
672681
format = SPA_VIDEO_FORMAT_ENCODED;
673682
}
674683

675-
if (!obs_pw_video_format_from_spa_format(format, &obs_pw_video_format))
676-
continue;
677-
678-
if (obs_pw_video_format.video_format != pixelformat)
684+
if (format != pixelformat)
679685
continue;
680686

681687
if (spa_pod_parse_object(p->param, SPA_TYPE_OBJECT_Format, NULL, SPA_FORMAT_VIDEO_size,

0 commit comments

Comments
 (0)