Skip to content

Commit

Permalink
Remove udp/rtsp h264 (#235)
Browse files Browse the repository at this point in the history
Signed-off-by: Tomasz Szumski <[email protected]>
  • Loading branch information
tszumski authored Oct 23, 2024
1 parent 04ac9f1 commit cf23b20
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 1,059 deletions.
70 changes: 0 additions & 70 deletions docs/IPCamera-RTP-Memif.md

This file was deleted.

Binary file removed docs/_static/IPC-RTP-memif.png
Binary file not shown.
79 changes: 0 additions & 79 deletions media-proxy/include/mtl.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ extern "C" {
#include "app_platform.h"
#include "shm_memif.h" /* share memory */
#include "utils.h"
/*used by UDP H264*/
#include <mtl/mudp_api.h>
#include <mtl/mtl_sch_api.h>

#ifndef NS_PER_S
#define NS_PER_S (1000000000)
Expand All @@ -38,9 +35,6 @@ extern "C" {
#define NS_PER_MS (1000 * 1000)
#endif

#define SCH_CNT 3
#define TASKLETS 1000

typedef struct {
mtl_handle st;
int idx;
Expand Down Expand Up @@ -324,70 +318,6 @@ typedef struct {
double expect_fps;
} rx_st30_session_context_t;

enum sample_udp_mode {
SAMPLE_UDP_TRANSPORT_H264,
};

typedef struct {
mtl_handle st;
struct mtl_init_params param;
uint8_t rx_sip_addr[MTL_PORT_MAX][MTL_IP_ADDR_LEN]; /* rx source IP */
uint16_t framebuff_cnt;
uint16_t udp_port;
uint8_t payload_type;
// uint32_t sessions; /* number of sessions */
bool ext_frame;
bool hdr_split;
bool rx_dump;
uint32_t fb_count; /* Frame buffer count. */
enum sample_udp_mode udp_mode;
uint64_t udp_tx_bps;
int udp_len;
bool exit;
bool has_user_meta; /* if provide user meta data with the st2110-20 frame */
pthread_t thread;
pthread_cond_t wake_cond;
pthread_mutex_t wake_mutex;
mudp_handle socket;
struct sockaddr_in client_addr;
struct sockaddr_in bind_addr;
bool stop;

/* share memory arguments */
memif_socket_args_t memif_socket_args;
memif_conn_args_t memif_conn_args;

/* memif conenction handle */
memif_socket_handle_t memif_socket;
memif_conn_handle_t memif_conn;

memif_buffer_t* shm_bufs;
uint16_t shm_buf_num;
uint8_t shm_ready;

uint32_t memif_nalu_size;

char name[32];
pthread_t memif_event_thread;

/*udp poll*/
//mtl_sch_handle schs[SCH_CNT];
mtl_tasklet_handle udp_tasklet;
struct mtl_tasklet_ops udp_tasklet_ops;
struct mudp_pollfd udp_pollfd;
bool sch_start;
int new_NALU;
bool check_first_new_NALU;
bool fragments_bunch;
mcm_buffer* rtp_header;
uint16_t tx_buf_num;
char* dst;
char* dst_nalu_size_point;
//int sch_idx;
//int tasklet_idx;

} rx_udp_h264_session_context_t;

typedef struct {
mtl_handle st;
int idx;
Expand Down Expand Up @@ -517,21 +447,12 @@ void mtl_st22p_tx_session_stop(tx_st22p_session_context_t* tx_ctx);
/* RX: Stop ST22P session */
void mtl_st22p_rx_session_stop(rx_st22p_session_context_t* rx_ctx);

/* RX: Stop RTSP session */
void mtl_rtsp_rx_session_stop(rx_udp_h264_session_context_t* rx_ctx);

/* TX: Destroy ST22P session */
void mtl_st22p_tx_session_destroy(tx_st22p_session_context_t** p_tx_ctx);

/* RX: Destroy ST22P session */
void mtl_st22p_rx_session_destroy(rx_st22p_session_context_t** p_rx_ctx);

/* RX: Destroy RTSP session */
void mtl_rtsp_rx_session_destroy(rx_udp_h264_session_context_t** p_rx_ctx);

/* RX: Create UDP H264 session */
rx_udp_h264_session_context_t* mtl_udp_h264_rx_session_create(mtl_handle dev_handle, mcm_dp_addr* dp_addr, memif_ops_t* memif_ops, mtl_sch_handle schs[]);

/* TX: Stop ST30 session */
void mtl_st30_tx_session_stop(tx_st30_session_context_t* pctx);

Expand Down
3 changes: 0 additions & 3 deletions media-proxy/include/proxy_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ class ProxyContext {
mtl_handle mDevHandle = NULL;
libfabric_ctx *mDevHandle_rdma = NULL;

/*udp pool*/
mtl_sch_handle schs[SCH_CNT];
bool schs_ready;
bool imtl_init_preparing;
pthread_mutex_t mutex_lock;

Expand Down
1 change: 0 additions & 1 deletion media-proxy/include/sessions.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ typedef struct {
rx_st22p_session_context_t *rx_st22p_session;
tx_st30_session_context_t *tx_st30_session;
rx_st30_session_context_t *rx_st30_session;
rx_udp_h264_session_context_t *rx_udp_h264_session;
tx_st40_session_context_t *tx_st40_session;
rx_st40_session_context_t *rx_st40_session;
tx_rdma_session_context_t *tx_rdma_session;
Expand Down
1 change: 0 additions & 1 deletion media-proxy/include/shm_memif.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ int rx_st22p_on_connect(memif_conn_handle_t conn, void* priv_data);
int rx_st22p_on_disconnect(memif_conn_handle_t conn, void* priv_data);
int rx_st30_on_connect(memif_conn_handle_t conn, void* priv_data);
int rx_st40_on_connect(memif_conn_handle_t conn, void* priv_data);
int rx_udp_h264_on_connect(memif_conn_handle_t conn, void* priv_data);

int rx_rdma_on_connect(memif_conn_handle_t conn, void *priv_data);
int rx_rdma_on_disconnect(memif_conn_handle_t conn, void *priv_data);
Expand Down
6 changes: 0 additions & 6 deletions media-proxy/src/api_server_tcp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@ void* msg_loop(void* ptr)
memcpy(&param.socket_args, &it->tx_st40_session->memif_socket_args, sizeof(memif_socket_args_t));
memcpy(&param.conn_args, &it->tx_st40_session->memif_conn_args, sizeof(memif_conn_args_t));
break;
case PAYLOAD_TYPE_RTSP_VIDEO:
break;
case PAYLOAD_TYPE_ST20_VIDEO:
memcpy(&param.socket_args, &it->tx_session->memif_socket_args, sizeof(memif_socket_args_t));
memcpy(&param.conn_args, &it->tx_session->memif_conn_args, sizeof(memif_conn_args_t));
Expand Down Expand Up @@ -178,10 +176,6 @@ void* msg_loop(void* ptr)
memcpy(&param.socket_args, &it->rx_st40_session->memif_socket_args, sizeof(memif_socket_args_t));
memcpy(&param.conn_args, &it->rx_st40_session->memif_conn_args, sizeof(memif_conn_args_t));
break;
case PAYLOAD_TYPE_RTSP_VIDEO:
memcpy(&param.socket_args, &it->rx_udp_h264_session->memif_socket_args, sizeof(memif_socket_args_t));
memcpy(&param.conn_args, &it->rx_udp_h264_session->memif_conn_args, sizeof(memif_conn_args_t));
break;
case PAYLOAD_TYPE_ST20_VIDEO:
memcpy(&param.socket_args, &it->rx_session->memif_socket_args, sizeof(memif_socket_args_t));
memcpy(&param.conn_args, &it->rx_session->memif_conn_args, sizeof(memif_conn_args_t));
Expand Down
69 changes: 0 additions & 69 deletions media-proxy/src/mtl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2891,72 +2891,3 @@ void mtl_st40_rx_session_destroy(rx_st40_session_context_t** ppctx)
/* Free shared memory resource. */
free(pctx);
}

int rx_udp_h264_shm_deinit(rx_udp_h264_session_context_t* rx_ctx)
{
int err;

if (rx_ctx == NULL) {
ERROR("%s, Illegal parameter.", __func__);
return -1;
}

err = pthread_cancel(rx_ctx->memif_event_thread);
if (!err)
err = pthread_join(rx_ctx->memif_event_thread, NULL);
if (err && err != ESRCH)
ERROR("%s: Error joining thread: %s", __func__, strerror(err));

/* free-up resources */
memif_delete(&rx_ctx->memif_conn);
memif_delete_socket(&rx_ctx->memif_socket);

/* unlink socket file */
if (rx_ctx->memif_conn_args.is_master && rx_ctx->memif_socket_args.path[0] != '@') {
unlink(rx_ctx->memif_socket_args.path);
}

return 0;
}

/* Stop RX UDP H264 session */
void mtl_rtsp_rx_session_stop(rx_udp_h264_session_context_t* rx_ctx)
{
int ret;
if (rx_ctx == NULL) {
printf("%s: invalid parameter\n", __func__);
return;
}

rx_ctx->stop = true;

ret = mtl_sch_unregister_tasklet(rx_ctx->udp_tasklet);
if (ret != 0) {
INFO("%s, mtl_sch_unregister_tasklet fail %d\n", __func__, ret);
}

ret = mudp_close(rx_ctx->socket);
if (ret < 0) {
INFO("%s, udp close fail %d\n", __func__, ret);
// return NULL;
}
}

/* Destroy RX UDP h264 session */
void mtl_rtsp_rx_session_destroy(rx_udp_h264_session_context_t** p_rx_ctx)
{
int ret = 0;
rx_udp_h264_session_context_t* rx_ctx = NULL;

if (p_rx_ctx == NULL) {
printf("%s: invalid parameter\n", __func__);
return;
}

rx_ctx = *p_rx_ctx;

rx_udp_h264_shm_deinit(rx_ctx);

/* Free shared memory resource. */
free(rx_ctx);
}
51 changes: 2 additions & 49 deletions media-proxy/src/proxy_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,19 @@
#include <algorithm>

#include "proxy_context.h"
#include <mtl/mtl_sch_api.h>

ProxyContext::ProxyContext(void)
: mRpcCtrlAddr("0.0.0.0:8001")
, mTcpCtrlAddr("0.0.0.0:8002")
, schs_ready(false), imtl_init_preparing(false), mSessionCount(0)
, imtl_init_preparing(false), mSessionCount(0)
{
mTcpCtrlPort = 8002;
}

ProxyContext::ProxyContext(std::string_view rpc_addr, std::string_view tcp_addr)
: mRpcCtrlAddr(rpc_addr)
, mTcpCtrlAddr(tcp_addr)
, schs_ready(false), imtl_init_preparing(false), mSessionCount(0)
, imtl_init_preparing(false), mSessionCount(0)
{
auto colon = tcp_addr.find_first_of(":");
if (colon >= tcp_addr.size() ||
Expand Down Expand Up @@ -583,35 +582,6 @@ int ProxyContext::RxStart_mtl(const mcm_conn_param *request)
ERROR("%s, Failed to initialize MTL.", __func__);
return -1;
} else {
/*udp pool*/
if (schs_ready == false) {
struct mtl_sch_ops sch_ops;
memset(&sch_ops, 0x0, sizeof(sch_ops));

sch_ops.nb_tasklets = TASKLETS;

for (int i = 0; i < SCH_CNT; i++) {
char sch_name[32];

snprintf(sch_name, sizeof(sch_name), "sch_udp_%d", i);
sch_ops.name = sch_name;
mtl_sch_handle sch = mtl_sch_create(mDevHandle, &sch_ops);
if (sch == NULL) {
INFO("%s, error: schduler create fail.", __func__);
break;
}
ret = mtl_sch_start(sch);
INFO("%s, start schduler %d.", __func__, i);
if (ret < 0) {
INFO("%s, fail to start schduler %d.", __func__, i);
ret = mtl_sch_free(sch);
break;
}
schs[i] = sch;
}
schs_ready = true;
}

imtl_init_preparing = false;
}
}
Expand Down Expand Up @@ -670,19 +640,6 @@ int ProxyContext::RxStart_mtl(const mcm_conn_param *request)
st_ctx->rx_st40_session = rx_ctx;
break;
}
case PAYLOAD_TYPE_RTSP_VIDEO: {
rx_udp_h264_session_context_t* rx_ctx = NULL;
mcm_dp_addr local_addr = request->local_addr;
/*udp poll*/
rx_ctx = mtl_udp_h264_rx_session_create(mDevHandle, &local_addr, &memif_ops, schs);
if (rx_ctx == NULL) {
INFO("%s, Failed to create UDP H264 TX session.", __func__);
delete st_ctx;
return -1;
}
st_ctx->rx_udp_h264_session = rx_ctx;
break;
}
case PAYLOAD_TYPE_ST20_VIDEO:
case PAYLOAD_TYPE_NONE:
default: {
Expand Down Expand Up @@ -940,10 +897,6 @@ void ProxyContext::RxStop(const int32_t session_id)
mtl_st40_rx_session_stop((*it)->rx_st40_session);
mtl_st40_rx_session_destroy(&(*it)->rx_st40_session);
break;
case PAYLOAD_TYPE_RTSP_VIDEO:
mtl_rtsp_rx_session_stop((*it)->rx_udp_h264_session);
mtl_rtsp_rx_session_destroy(&(*it)->rx_udp_h264_session);
break;
case PAYLOAD_TYPE_RDMA_VIDEO:
rdma_rx_session_stop((*it)->rx_rdma_session);
rdma_rx_session_destroy(&(*it)->rx_rdma_session);
Expand Down
Loading

0 comments on commit cf23b20

Please sign in to comment.