diff --git a/app/src/app_base.h b/app/src/app_base.h index 9782992c..dac784ce 100644 --- a/app/src/app_base.h +++ b/app/src/app_base.h @@ -551,6 +551,8 @@ struct st_app_rx_st20p_session { pthread_t st20p_app_thread; bool st20p_app_thread_stop; + char st20p_destination_url[ST_APP_URL_MAX_LEN]; + FILE* st20p_destination_file; struct st_display* display; uint32_t pcapng_max_pkts; @@ -717,6 +719,7 @@ struct st_app_context { struct st_app_rx_st22p_session* rx_st22p_sessions; int rx_st22p_session_cnt; + char rx_st20p_url[ST_APP_URL_MAX_LEN]; /* save st20p content url*/ struct st_app_rx_st20p_session* rx_st20p_sessions; int rx_st20p_session_cnt; diff --git a/app/src/parse_json.c b/app/src/parse_json.c index bc900aac..e4b2e4a5 100644 --- a/app/src/parse_json.c +++ b/app/src/parse_json.c @@ -2089,6 +2089,10 @@ static int st_json_parse_rx_st20p(int idx, json_object* st20p_obj, ret = parse_st20p_transport_format(st20p_obj, st20p); if (ret < 0) return ret; + /* parse st20p url */ + ret = parse_url(st20p_obj, "st20p_url", st20p->info.st20p_url); + if (ret < 0) return ret; + /* parse display option */ st20p->display = json_object_get_boolean(st_json_object_object_get(st20p_obj, "display")); diff --git a/app/src/rx_st20p_app.c b/app/src/rx_st20p_app.c index bdd0fce2..f206da03 100644 --- a/app/src/rx_st20p_app.c +++ b/app/src/rx_st20p_app.c @@ -9,6 +9,13 @@ static void app_rx_st20p_consume_frame(struct st_app_rx_st20p_session* s, struct st_display* d = s->display; int idx = s->idx; + if (s->st20p_destination_file) { + if (!fwrite(frame->addr[0], 1, s->st20p_frame_size, s->st20p_destination_file)) { + err("%s(%d), failed to write frame to file %s\n", __func__, idx, + s->st20p_destination_url); + } + } + if (s->num_port > 1) { dbg("%s(%d): pkts_total %u, pkts per port P %u R %u\n", __func__, idx, frame->pkts_total, frame->pkts_recv[MTL_SESSION_PORT_P], @@ -209,6 +216,18 @@ static int app_rx_st20p_init(struct st_app_context* ctx, st20p ? st20p->base.udp_port : (10000 + s->idx); } + if (st20p && st20p->info.st20p_url[0] != '\0') { + memcpy(s->st20p_destination_url, st20p->info.st20p_url, ST_APP_URL_MAX_LEN); + s->st20p_destination_file = fopen(s->st20p_destination_url, "wb"); + + if (!s->st20p_destination_file) { + err("%s(%d), failed to open destination file %s\n", __func__, idx, + s->st20p_destination_url); + app_rx_st20p_uinit(s); + return -EIO; + } + } + ops.width = st20p ? st20p->info.width : 1920; ops.height = st20p ? st20p->info.height : 1080; ops.fps = st20p ? st20p->info.fps : ST_FPS_P59_94;