mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-21 21:40:20 +00:00
vcap/dshow: GetSubtypeName - handle non-printable characters
added resolve_fourcc to utils/string - fixed wrong signal.h include guard (it should be definitely included in mac, it was perhaps meant to be MSW, but it is needed there too) - removed config*h
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
* @author Martin Pulec <pulec@cesnet.cz>
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 2014-2023 CESNET, z. s. p. o.
|
||||
* Copyright (c) 2014-2024 CESNET, z. s. p. o.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -35,17 +35,18 @@
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#include "config_unix.h"
|
||||
#include "config_win32.h"
|
||||
#endif
|
||||
|
||||
#ifndef __APPLE__
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <stdint.h>
|
||||
#include <signal.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <io.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "debug.h"
|
||||
#include "utils/string.h"
|
||||
|
||||
@@ -185,3 +186,36 @@ append_sig_desc(char **ptr, const char *ptr_end, int signum)
|
||||
#endif
|
||||
strappend(ptr, ptr_end, ")");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns string representation of input FourCC in a fashion FFmpeg does -
|
||||
* non-printable character value is printed as a number in '[]'.
|
||||
*
|
||||
* @returns NUL-terminated FourCC, which will be longer than 4B + '\0' if
|
||||
* non-printable characters are present
|
||||
*/
|
||||
|
||||
const char *
|
||||
pretty_print_fourcc(const void *fcc)
|
||||
{
|
||||
enum {
|
||||
CHAR_LEN = 5, // at worst [XXX]
|
||||
CHARS = sizeof(uint32_t),
|
||||
MAX_LEN = CHARS * CHAR_LEN + 1 /* '\0' */,
|
||||
};
|
||||
_Thread_local static char out[MAX_LEN];
|
||||
char *out_ptr = out;
|
||||
const unsigned char *fourcc = fcc;
|
||||
|
||||
for (int i = 0; i < CHARS; ++i) {
|
||||
if (isprint(fourcc[i])) {
|
||||
*out_ptr++ = (char) fourcc[i];
|
||||
} else {
|
||||
const int written =
|
||||
snprintf(out_ptr, CHAR_LEN + 1, "[%hhu]", fourcc[i]);
|
||||
out_ptr+= written;
|
||||
}
|
||||
}
|
||||
*out_ptr = '\0';
|
||||
return out;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user