mirror of
https://bitbucket.org/ohhara/ohmulticastvideoscanner.git
synced 2025-06-07 16:06:11 +00:00
Add udp scan option. The default is rtp scan.
This commit is contained in:
parent
7181e74c46
commit
20fcf95852
2
README
2
README
@ -30,6 +30,8 @@ With "-t" option, you can change the scan timeout. The default scan timeout is
|
|||||||
10000ms(10 seconds). It tries to get png image file while scanning. If it can't
|
10000ms(10 seconds). It tries to get png image file while scanning. If it can't
|
||||||
get the png image file for the timeout, it gives up and tries the next
|
get the png image file for the timeout, it gives up and tries the next
|
||||||
multicast ip address.
|
multicast ip address.
|
||||||
|
With "-u" option, you can scan with udp protocol instead of rtp protocol. The
|
||||||
|
default is scanning with rtp protocol.
|
||||||
With "-q" option, you can disable the log printing.
|
With "-q" option, you can disable the log printing.
|
||||||
With "-w" option, you can wait for the multicast packet without specifying the
|
With "-w" option, you can wait for the multicast packet without specifying the
|
||||||
scanning ip addresses. When it detects multicast packet from the specified
|
scanning ip addresses. When it detects multicast packet from the specified
|
||||||
|
15
omvs_main.c
15
omvs_main.c
@ -37,6 +37,7 @@ static gchar *_omvs_outdir = "omvs_out";
|
|||||||
static gint _omvs_jobs = 1;
|
static gint _omvs_jobs = 1;
|
||||||
static gint _omvs_sleep = 1000;
|
static gint _omvs_sleep = 1000;
|
||||||
static gint _omvs_timeout = 10000;
|
static gint _omvs_timeout = 10000;
|
||||||
|
static gboolean _omvs_udp_scan;
|
||||||
static gboolean _omvs_quiet;
|
static gboolean _omvs_quiet;
|
||||||
static gboolean _omvs_wait;
|
static gboolean _omvs_wait;
|
||||||
|
|
||||||
@ -61,6 +62,8 @@ static GOptionEntry _omvs_entries[] =
|
|||||||
"Sleep time(milliseconds) between scans", "ms" },
|
"Sleep time(milliseconds) between scans", "ms" },
|
||||||
{ "timeout", 't', 0, G_OPTION_ARG_INT, &_omvs_timeout,
|
{ "timeout", 't', 0, G_OPTION_ARG_INT, &_omvs_timeout,
|
||||||
"Timeout time(milliseconds) in each scan", "ms" },
|
"Timeout time(milliseconds) in each scan", "ms" },
|
||||||
|
{ "udp", 'u', 0, G_OPTION_ARG_NONE, &_omvs_udp_scan,
|
||||||
|
"Use udp protocol instead of rtp", NULL },
|
||||||
{ "quiet", 'q', 0, G_OPTION_ARG_NONE, &_omvs_quiet,
|
{ "quiet", 'q', 0, G_OPTION_ARG_NONE, &_omvs_quiet,
|
||||||
"Print no log except for errors", NULL },
|
"Print no log except for errors", NULL },
|
||||||
{ "wait", 'w', 0, G_OPTION_ARG_NONE, &_omvs_wait,
|
{ "wait", 'w', 0, G_OPTION_ARG_NONE, &_omvs_wait,
|
||||||
@ -312,7 +315,11 @@ static gpointer _omvs_start_scan_job(gpointer data) {
|
|||||||
if (!is_udp_port_found) {
|
if (!is_udp_port_found) {
|
||||||
gchar *uri;
|
gchar *uri;
|
||||||
gchar *filename;
|
gchar *filename;
|
||||||
|
if (_omvs_udp_scan) {
|
||||||
|
uri = g_strdup_printf("udp://%s:%d", addr_str, udp_port);
|
||||||
|
} else {
|
||||||
uri = g_strdup_printf("rtp://%s:%d", addr_str, udp_port);
|
uri = g_strdup_printf("rtp://%s:%d", addr_str, udp_port);
|
||||||
|
}
|
||||||
filename =
|
filename =
|
||||||
g_strdup_printf("%s/%s-%d.png", _omvs_outdir, addr_str, udp_port);
|
g_strdup_printf("%s/%s-%d.png", _omvs_outdir, addr_str, udp_port);
|
||||||
if (!_omvs_quiet) {
|
if (!_omvs_quiet) {
|
||||||
@ -369,7 +376,11 @@ static gpointer _omvs_start_scan_job(gpointer data) {
|
|||||||
_omvs_m3u_idx++;
|
_omvs_m3u_idx++;
|
||||||
g_mutex_lock(&_omvs_mutex);
|
g_mutex_lock(&_omvs_mutex);
|
||||||
fprintf(_omvs_m3u_fp, "#EXTINF:%u,%u\n", _omvs_m3u_idx, _omvs_m3u_idx);
|
fprintf(_omvs_m3u_fp, "#EXTINF:%u,%u\n", _omvs_m3u_idx, _omvs_m3u_idx);
|
||||||
|
if (_omvs_udp_scan) {
|
||||||
|
fprintf(_omvs_m3u_fp, "udp://%s:%u\n", addr_str, o_ipaddr->ports[j]);
|
||||||
|
} else {
|
||||||
fprintf(_omvs_m3u_fp, "rtp://%s:%u\n", addr_str, o_ipaddr->ports[j]);
|
fprintf(_omvs_m3u_fp, "rtp://%s:%u\n", addr_str, o_ipaddr->ports[j]);
|
||||||
|
}
|
||||||
fflush(_omvs_m3u_fp);
|
fflush(_omvs_m3u_fp);
|
||||||
g_mutex_unlock(&_omvs_mutex);
|
g_mutex_unlock(&_omvs_mutex);
|
||||||
}
|
}
|
||||||
@ -566,7 +577,11 @@ static gint _omvs_wait_for_multicast_packet(void) {
|
|||||||
(haddr >> 16) & 0xff,
|
(haddr >> 16) & 0xff,
|
||||||
(haddr >> 8) & 0xff,
|
(haddr >> 8) & 0xff,
|
||||||
(haddr >> 0) & 0xff);
|
(haddr >> 0) & 0xff);
|
||||||
|
if (_omvs_udp_scan) {
|
||||||
|
uri = g_strdup_printf("udp://%s:%u", addr_str, udp_port);
|
||||||
|
} else {
|
||||||
uri = g_strdup_printf("rtp://%s:%u", addr_str, udp_port);
|
uri = g_strdup_printf("rtp://%s:%u", addr_str, udp_port);
|
||||||
|
}
|
||||||
|
|
||||||
if (!g_hash_table_replace(urihashtable, uri, addr_str)) {
|
if (!g_hash_table_replace(urihashtable, uri, addr_str)) {
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user