Skip to content

Commit aea2e0f

Browse files
required resolution and explicit demo characteristics
1 parent 592ab3b commit aea2e0f

3 files changed

Lines changed: 23 additions & 7 deletions

File tree

‎include/livekit/capture_source.h‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,13 @@ struct GstreamerVideoSourceConfig {
104104
};
105105

106106
/// Configuration for the built-in test source producing solid-color frames.
107-
struct DemoVideoSourceConfig {};
107+
struct DemoVideoSourceConfig {
108+
/// Output resolution; both components must be non-zero.
109+
CaptureResolution resolution;
110+
111+
/// Output frame rate in frames per second; must be non-zero.
112+
std::uint32_t framerate_fps = 0;
113+
};
108114

109115
/// Why a capture ended without error.
110116
enum class CaptureExit {

‎src/capture_source.cpp‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,12 @@ std::future<std::shared_ptr<CaptureSource>> CaptureSource::create(GstreamerVideo
7373
return createFromRequest(std::move(request));
7474
}
7575

76-
std::future<std::shared_ptr<CaptureSource>> CaptureSource::create(DemoVideoSourceConfig /*config*/) {
76+
std::future<std::shared_ptr<CaptureSource>> CaptureSource::create(DemoVideoSourceConfig config) {
7777
proto::NewCaptureSourceRequest request;
78-
request.mutable_demo();
78+
auto* demo = request.mutable_demo();
79+
demo->mutable_resolution()->set_width(config.resolution.width);
80+
demo->mutable_resolution()->set_height(config.resolution.height);
81+
demo->set_framerate_fps(config.framerate_fps);
7982
return createFromRequest(std::move(request));
8083
}
8184

‎src/tests/integration/test_capture_source.cpp‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#include <chrono>
2727
#include <condition_variable>
28+
#include <cstdint>
2829
#include <mutex>
2930
#include <optional>
3031
#include <string>
@@ -39,12 +40,18 @@ using namespace std::chrono_literals;
3940
namespace {
4041

4142
constexpr int kMinFramesReceived = 5;
43+
constexpr int kCaptureWidth = 1280;
44+
constexpr int kCaptureHeight = 720;
45+
constexpr std::uint32_t kCaptureFramerateFps = 30;
4246

4347
/// Creates the capture source, or skips the test when the FFI library was
4448
/// built without the capture feature.
4549
std::shared_ptr<CaptureSource> createDemoCaptureOrSkip() {
50+
DemoVideoSourceConfig config;
51+
config.resolution = {kCaptureWidth, kCaptureHeight};
52+
config.framerate_fps = kCaptureFramerateFps;
4653
try {
47-
return CaptureSource::create(DemoVideoSourceConfig{}).get();
54+
return CaptureSource::create(config).get();
4855
} catch (const std::exception& e) {
4956
if (std::string(e.what()).find("without the 'capture' feature") != std::string::npos) {
5057
return nullptr;
@@ -66,10 +73,10 @@ TEST_F(CaptureSourceServerTest, DemoCaptureSourcePublishesFramesEndToEnd) {
6673
"configure with -DLIVEKIT_ENABLE_CAPTURE=ON";
6774
}
6875

69-
// The demo source produces 1280x720 pixel frames.
76+
// The demo source reports back the resolution it was configured with.
7077
ASSERT_EQ(capture->kind(), CaptureSourceKind::Pixel);
71-
ASSERT_EQ(capture->width(), 1280);
72-
ASSERT_EQ(capture->height(), 720);
78+
ASSERT_EQ(capture->width(), kCaptureWidth);
79+
ASSERT_EQ(capture->height(), kCaptureHeight);
7380
ASSERT_FALSE(capture->codec().has_value());
7481
ASSERT_NE(capture->videoSource(), nullptr);
7582

0 commit comments

Comments
 (0)