Skip to content

Commit 7bf2051

Browse files
committed
samples: video: tcpserversink: N-buffering configuration
Allow to configure the number of allocated capture frames. This allows to make tradeof between framerate versus memory usage. 2 buffers allows to capture while sending data (optimal framerate). 1 buffer allows to reduce memory usage but capture framerate is lower. Signed-off-by: Hugues Fruchet <[email protected]>
1 parent 34f0587 commit 7bf2051

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

samples/drivers/video/tcpserversink/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Copyright (c) 2024 Espressif Systems (Shanghai) Co., Ltd.
2+
# Copyright (c) 2025 STMicroelectronics.
23
# SPDX-License-Identifier: Apache-2.0
34

45
mainmenu "TCP camera streaming sample application"
@@ -48,6 +49,15 @@ config VIDEO_PIXEL_FORMAT
4849
help
4950
Pixel format of the video frame. If not set, the default pixel format is used.
5051

52+
config VIDEO_NUM_FRAMES
53+
int "Capture N-buffering"
54+
default 2
55+
help
56+
Framerate versus memory usage tradeoff.
57+
"2" allows to capture while sending data (optimal framerate).
58+
"1" allows to reduce memory usage but capture framerate is lower.
59+
If not set defaults to "2".
60+
5161
config VIDEO_CTRL_HFLIP
5262
bool "Mirror the video frame horizontally"
5363
help

samples/drivers/video/tcpserversink/src/main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright (c) 2019 Linaro Limited
3+
* Copyright (c) 2025 STMicroelectronics.
34
*
45
* SPDX-License-Identifier: Apache-2.0
56
*/
@@ -141,7 +142,7 @@ int main(void)
141142
{
142143
struct sockaddr_in addr, client_addr;
143144
socklen_t client_addr_len = sizeof(client_addr);
144-
struct video_buffer *buffers[2];
145+
struct video_buffer *buffers[CONFIG_VIDEO_NUM_FRAMES];
145146
struct video_buffer *vbuf = &(struct video_buffer){};
146147
struct video_buffer *vbuf_out = &(struct video_buffer){};
147148
int ret, sock, client;

0 commit comments

Comments
 (0)