Skip to content

Commit 7b69077

Browse files
committed
improved blank diagnostics
1 parent 7a1d481 commit 7b69077

File tree

7 files changed

+58
-14
lines changed

7 files changed

+58
-14
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
|----------|---------------|-------------------|
1212
| Multithreaded JPEG encoding |||
1313
| Hardware image encoding<br>on Raspberry Pi |||
14-
| Behavior when the device<br>is disconnected while streaming | ✔ Shows a black screen<br>with ```NO SIGNAL``` on it<br>until reconnected | ✘ Stops the streaming <sup>1</sup> |
14+
| Behavior when the device<br>is disconnected while streaming | ✔ Shows a black screen<br>with ```NO LIVE VIDEO``` on it<br>until reconnected | ✘ Stops the streaming <sup>1</sup> |
1515
| [DV-timings](https://linuxtv.org/downloads/v4l-dvb-apis-new/userspace-api/v4l/dv-timings.html) support -<br>the ability to change resolution<br>on the fly by source signal || ☹ Partially yes <sup>1</sup> |
1616
| Option to skip frames when streaming<br>static images by HTTP to save the traffic | ✔ <sup>2</sup> ||
1717
| Streaming via UNIX domain socket |||

src/libs/capture.c

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,11 @@ int us_capture_open(us_capture_s *cap) {
200200
}
201201
}
202202
_LOG_DEBUG("Probing DV-timings or QuerySTD ...");
203-
if (_capture_open_dv_timings(cap, false) < 0) {
204-
US_ONCE_FOR(run->open_error_once, __LINE__, {
205-
_LOG_ERROR("No signal from source");
206-
});
207-
goto error_no_signal;
203+
switch (_capture_open_dv_timings(cap, false)) {
204+
case 0: break;
205+
case US_ERROR_NO_SIGNAL: goto error_no_signal;
206+
case US_ERROR_NO_SYNC: goto error_no_sync;
207+
default: goto error_no_data;
208208
}
209209
}
210210

@@ -259,6 +259,17 @@ int us_capture_open(us_capture_s *cap) {
259259
return US_ERROR_NO_CABLE;
260260

261261
error_no_signal:
262+
US_ONCE_FOR(run->open_error_once, __LINE__, { _LOG_ERROR("No signal from source"); });
263+
us_capture_close(cap);
264+
return US_ERROR_NO_SIGNAL;
265+
266+
error_no_sync:
267+
US_ONCE_FOR(run->open_error_once, __LINE__, { _LOG_ERROR("No sync on signal"); });
268+
us_capture_close(cap);
269+
return US_ERROR_NO_SYNC;
270+
271+
error_no_data:
272+
US_ONCE_FOR(run->open_error_once, __LINE__, { _LOG_ERROR("Unknown signal"); });
262273
us_capture_close(cap);
263274
return US_ERROR_NO_DATA;
264275

@@ -630,6 +641,10 @@ static int _capture_open_dv_timings(us_capture_s *cap, bool apply) {
630641
// TC358743 errors here (see in the kernel: drivers/media/i2c/tc358743.c):
631642
// - ENOLINK: No valid signal (SYS_STATUS & MASK_S_TMDS)
632643
// - ENOLCK: No sync on signal (SYS_STATUS & MASK_S_SYNC)
644+
switch (errno) {
645+
case ENOLINK: return US_ERROR_NO_SIGNAL;
646+
case ENOLCK: return US_ERROR_NO_SYNC;
647+
}
633648
dv_errno = errno;
634649
goto querystd;
635650
} else if (!apply) {

src/libs/drm/drm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ int us_drm_expose_stub(us_drm_s *drm, us_drm_stub_e stub, const us_capture_s *ca
378378
DRAW_MSG("=== PiKVM ===\n \n< UNSUPPORTED CAPTURE FORMAT >");
379379
break;
380380
case US_DRM_STUB_NO_SIGNAL:
381-
DRAW_MSG("=== PiKVM ===\n \n< NO SIGNAL >");
381+
DRAW_MSG("=== PiKVM ===\n \n< NO LIVE VIDEO >");
382382
break;
383383
case US_DRM_STUB_BUSY:
384384
DRAW_MSG("=== PiKVM ===\n \n< ONLINE IS ACTIVE >");

src/libs/errors.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,6 @@
2525
#define US_ERROR_COMMON -1
2626
#define US_ERROR_NO_DEVICE -2
2727
#define US_ERROR_NO_CABLE -3
28-
#define US_ERROR_NO_DATA -4
28+
#define US_ERROR_NO_SIGNAL -4
29+
#define US_ERROR_NO_SYNC -5
30+
#define US_ERROR_NO_DATA -6

src/ustreamer/blank.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ us_blank_s *us_blank_init(void) {
3636
blank->ft = us_frametext_init();
3737
blank->raw = blank->ft->frame;
3838
blank->jpeg = us_frame_init();
39-
us_blank_draw(blank, "< NO SIGNAL >", 640, 480);
39+
us_blank_draw(blank, "< NO LIVE VIDEO >", 640, 480);
4040
return blank;
4141
}
4242

src/ustreamer/http/server.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ static void _http_send_snapshot(us_server_s *server) {
880880
if (!captured_meta.online) {
881881
if (blank == NULL) {
882882
blank = us_blank_init();
883-
us_blank_draw(blank, "< NO SIGNAL >", captured_meta.width, captured_meta.height);
883+
us_blank_draw(blank, "< NO LIVE VIDEO >", captured_meta.width, captured_meta.height);
884884
}
885885
frame = blank->jpeg;
886886
}

src/ustreamer/stream.c

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ us_stream_s *us_stream_init(us_capture_s *cap, us_encoder_s *enc) {
129129

130130
void us_stream_update_blank(us_stream_s *stream, const us_capture_s *cap) {
131131
us_stream_runtime_s *const run = stream->run;
132-
us_blank_draw(run->blank, "< NO SIGNAL >", cap->width, cap->height);
132+
us_blank_draw(run->blank, "< NO LIVE VIDEO >", cap->width, cap->height);
133133
us_fpsi_frame_to_meta(run->blank->raw, &run->notify_meta); // Initial "unchanged" meta
134134
_stream_update_captured_fpsi(stream, run->blank->raw, false);
135135
}
@@ -529,7 +529,7 @@ static int _stream_init_loop(us_stream_s *stream) {
529529

530530
int once = 0;
531531
while (!atomic_load(&stream->run->stop)) {
532-
char *blank_reason = "< NO SIGNAL >";
532+
char *blank_reason = "< NO LIVE VIDEO >";
533533

534534
# ifdef WITH_GPIO
535535
us_gpio_set_stream_online(false);
@@ -556,10 +556,37 @@ static int _stream_init_loop(us_stream_s *stream) {
556556
switch (us_capture_open(stream->cap)) {
557557
case 0: break;
558558
case US_ERROR_NO_DEVICE:
559-
blank_reason = "< NO CAPTURE DEVICE >";
559+
blank_reason = (
560+
"< NO CAPTURE DEVICE >\n \n"
561+
" Possible reasons: \n \n"
562+
" - Device unplugged \n \n"
563+
" - Bad config \n \n"
564+
" - Malfunction "
565+
);
560566
goto known_error;
561567
case US_ERROR_NO_CABLE:
562-
blank_reason = "< NO VIDEO SOURCE >";
568+
blank_reason = (
569+
"< NO VIDEO SOURCE >\n \n"
570+
" Possible reasons: \n \n"
571+
" - Source is off \n \b"
572+
" - Cable problems "
573+
);
574+
goto known_error;
575+
case US_ERROR_NO_SIGNAL:
576+
blank_reason = (
577+
"< NO SIGNAL DETECTED >\n \n"
578+
" Possible reasons: \n \n"
579+
" - Video suspended \n \n"
580+
" - Cable problems "
581+
);
582+
goto known_error;
583+
case US_ERROR_NO_SYNC:
584+
blank_reason = (
585+
"< NO SYNC WITH SIGNAL >\n \n"
586+
" Possible reasons: \n \n"
587+
" - Source is crazy \n \n"
588+
" - Cable problems "
589+
);
563590
goto known_error;
564591
case US_ERROR_NO_DATA:
565592
goto known_error;

0 commit comments

Comments
 (0)