Save the content of the udp url to png file.

This commit is contained in:
Taeho Oh 2016-01-23 19:20:52 +09:00
parent 22de3de619
commit 94ed43a4ad

View File

@ -5,6 +5,8 @@
#include <gio/gio.h> #include <gio/gio.h>
#include <gst/gst.h> #include <gst/gst.h>
#include "omvs_gst.h"
#define _OMVS_IPPROTO_UDP 17 #define _OMVS_IPPROTO_UDP 17
static gint _omvs_net_dev_idx; static gint _omvs_net_dev_idx;
@ -74,6 +76,7 @@ typedef struct _OMVSUDPHdr {
typedef struct _OMVSIPAddr { typedef struct _OMVSIPAddr {
guint32 addr; guint32 addr;
OMVSGst *gsts;
guint16 *ports; guint16 *ports;
gint num_ports; gint num_ports;
} OMVSIPAddr; } OMVSIPAddr;
@ -284,16 +287,31 @@ static gpointer _omvs_start_scan_job(gpointer data) {
} }
if (!is_udp_port_found) { if (!is_udp_port_found) {
gchar *uri;
gchar *filename;
uri = g_strdup_printf("udp://%s:%d", addr_str, udp_port);
filename =
g_strdup_printf("%s/%s-%d.png", _omvs_outdir, addr_str, udp_port);
if (_omvs_verbose) {
g_print("[%p] trying to save %s to %s\n", (void *)g_thread_self(),
uri, filename);
}
o_ipaddr->gsts = g_realloc(o_ipaddr->gsts,
(o_ipaddr->num_ports + 1) * sizeof(OMVSGst));
o_ipaddr->gsts[o_ipaddr->num_ports] = omvs_gst_open(uri, filename);
g_free(filename);
g_free(uri);
o_ipaddr->ports = g_realloc(o_ipaddr->ports, o_ipaddr->ports = g_realloc(o_ipaddr->ports,
(o_ipaddr->num_ports + 1) * sizeof(guint16)); (o_ipaddr->num_ports + 1) * sizeof(guint16));
o_ipaddr->ports[o_ipaddr->num_ports] = udp_port; o_ipaddr->ports[o_ipaddr->num_ports] = udp_port;
o_ipaddr->num_ports++; o_ipaddr->num_ports++;
if (_omvs_verbose) {
g_print("[%p] found udp://%s:%d\n", (void *)g_thread_self(),
addr_str, udp_port);
} }
} }
for (j = 0; j < o_ipaddr->num_ports; j++) {
omvs_gst_close(o_ipaddr->gsts[j]);
} }
g_free(o_ipaddr->gsts);
if (_omvs_verbose) { if (_omvs_verbose) {
g_print("[%p] finish scanning %s\n", (void *)g_thread_self(), addr_str); g_print("[%p] finish scanning %s\n", (void *)g_thread_self(), addr_str);