-
Couldn't load subscription status.
- Fork 8.1k
UVC Video encoder (zephyr,videoenc) + H264 support + STM32 STM32N6 conf files #97425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
50abaa3
4b2a48f
c9c928f
8f1247e
c3ab4c9
0f2ff6e
38c8fc3
ba13133
ff25b78
89de557
431233f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -131,7 +131,10 @@ int configure_encoder(void) | |
| } | ||
|
|
||
| buffer->type = VIDEO_BUF_TYPE_OUTPUT; | ||
| video_enqueue(encoder_dev, buffer); | ||
| if (video_enqueue(encoder_dev, buffer)) { | ||
| LOG_ERR("Unable to enqueue encoder output buf"); | ||
| return -1; | ||
| } | ||
|
Comment on lines
+134
to
+137
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about contributing to samples transition to Zephyr-like coding style for new code, so that the original error code can be returned? ret = (video_enqueue(encoder_dev, buffer);
if (ret < 0) {
LOG_ERR("Unable to enqueue encoder output buf");
return ret;
} |
||
|
|
||
| /* Set input format */ | ||
| if (strcmp(CONFIG_VIDEO_PIXEL_FORMAT, "")) { | ||
|
|
@@ -165,12 +168,16 @@ int encode_frame(struct video_buffer *in, struct video_buffer **out) | |
| int ret; | ||
|
|
||
| in->type = VIDEO_BUF_TYPE_INPUT; | ||
| video_enqueue(encoder_dev, in); | ||
| ret = video_enqueue(encoder_dev, in); | ||
| if (ret) { | ||
| LOG_ERR("Unable to enqueue encoder input buf"); | ||
| return ret; | ||
| } | ||
|
|
||
| (*out)->type = VIDEO_BUF_TYPE_OUTPUT; | ||
| ret = video_dequeue(encoder_dev, out, K_FOREVER); | ||
| if (ret) { | ||
| LOG_ERR("Unable to dequeue encoder buf"); | ||
| LOG_ERR("Unable to dequeue encoder output buf"); | ||
| return ret; | ||
| } | ||
|
|
||
|
|
@@ -422,7 +429,11 @@ int main(void) | |
|
|
||
| /* Enqueue Buffers */ | ||
| for (i = 0; i < ARRAY_SIZE(buffers); i++) { | ||
| video_enqueue(video_dev, buffers[i]); | ||
| ret = video_enqueue(video_dev, buffers[i]); | ||
| if (ret) { | ||
| LOG_ERR("Unable to enqueue video buf"); | ||
| return 0; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Intentionally returning 0? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Overall in this sample the error code are either return 0 or -1 or ret depending on the function. I think this would be fixed by the rework of video related sample app ongoing in PR #96072 so here I return the same kind of error code as return by other calls "around". That's not good, but overall correction as to be done, which is not in the scope of this PR. |
||
| } | ||
| } | ||
|
|
||
| /* Start video capture */ | ||
|
|
@@ -452,7 +463,12 @@ int main(void) | |
| ret = sendall(client, vbuf_out->buffer, vbuf_out->bytesused); | ||
|
|
||
| vbuf_out->type = VIDEO_BUF_TYPE_OUTPUT; | ||
| video_enqueue(encoder_dev, vbuf_out); | ||
| ret = video_enqueue(encoder_dev, vbuf_out); | ||
| if (ret) { | ||
| LOG_ERR("Unable to enqueue encoder output buf"); | ||
| return 0; | ||
| } | ||
|
|
||
| #else | ||
| LOG_INF("Sending frame %d", i++); | ||
| /* Send video buffer to TCP client */ | ||
|
|
@@ -465,7 +481,11 @@ int main(void) | |
| } | ||
|
|
||
| vbuf->type = VIDEO_BUF_TYPE_INPUT; | ||
| (void)video_enqueue(video_dev, vbuf); | ||
| ret = video_enqueue(video_dev, vbuf); | ||
| if (ret) { | ||
| LOG_ERR("Unable to enqueue video buf"); | ||
| return 0; | ||
| } | ||
| } while (!ret); | ||
|
|
||
| /* stop capture */ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| /* | ||
| * Copyright (c) 2025 STMicroelectronics | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| #include "app.overlay" | ||
|
|
||
| / { | ||
| chosen { | ||
| zephyr,videoenc = &zephyr_h264enc; | ||
| }; | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| /* | ||
| * Copyright (c) 2025 STMicroelectronics | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| #include "app.overlay" | ||
|
|
||
| / { | ||
| chosen { | ||
| zephyr,videoenc = &zephyr_jpegenc; | ||
| }; | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like nothing but it saves a lot of variable definition in the samples 👍