2020-09-20 21:23:33 +08:00
|
|
|
|
/*
|
2023-12-09 16:23:51 +08:00
|
|
|
|
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
2020-09-20 21:23:33 +08:00
|
|
|
|
*
|
2023-12-09 16:23:51 +08:00
|
|
|
|
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
2020-09-20 21:23:33 +08:00
|
|
|
|
*
|
2023-12-09 16:23:51 +08:00
|
|
|
|
* Use of this source code is governed by MIT-like license that can be found in the
|
2020-09-20 21:23:33 +08:00
|
|
|
|
* LICENSE file in the root of the source tree. All contributing project authors
|
|
|
|
|
* may be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "mk_common.h"
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2023-02-26 21:45:14 +08:00
|
|
|
|
typedef struct mk_rtp_server_t *mk_rtp_server;
|
2020-09-20 21:23:33 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 创建GB28181 RTP 服务器
|
|
|
|
|
* @param port 监听端口,0则为随机
|
2022-09-09 10:56:28 +08:00
|
|
|
|
* @param tcp_mode tcp模式(0: 不监听端口 1: 监听端口 2: 主动连接到服务端)
|
2020-09-20 21:23:33 +08:00
|
|
|
|
* @param stream_id 该端口绑定的流id
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-09-09 10:56:28 +08:00
|
|
|
|
API_EXPORT mk_rtp_server API_CALL mk_rtp_server_create(uint16_t port, int tcp_mode, const char *stream_id);
|
2024-07-09 10:42:10 +08:00
|
|
|
|
API_EXPORT mk_rtp_server API_CALL mk_rtp_server_create2(uint16_t port, int tcp_mode, const char *vhost, const char *app, const char *stream_id);
|
2022-09-09 10:56:28 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* TCP 主动模式时连接到服务器是否成功的回调
|
|
|
|
|
*/
|
|
|
|
|
typedef void(API_CALL *on_mk_rtp_server_connected)(void *user_data, int err, const char *what, int sys_err);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* TCP 主动模式时连接到服务器
|
|
|
|
|
* @param @param ctx 服务器对象
|
|
|
|
|
* @param dst_url 服务端地址
|
|
|
|
|
* @param dst_port 服务端端口
|
|
|
|
|
* @param cb 连接到服务器是否成功的回调
|
|
|
|
|
* @param user_data 用户数据指针
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
API_EXPORT void API_CALL mk_rtp_server_connect(mk_rtp_server ctx, const char *dst_url, uint16_t dst_port, on_mk_rtp_server_connected cb, void *user_data);
|
2023-02-11 15:14:18 +08:00
|
|
|
|
API_EXPORT void API_CALL mk_rtp_server_connect2(mk_rtp_server ctx, const char *dst_url, uint16_t dst_port, on_mk_rtp_server_connected cb, void *user_data, on_user_data_free user_data_free);
|
2020-09-20 21:23:33 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 销毁GB28181 RTP 服务器
|
|
|
|
|
* @param ctx 服务器对象
|
|
|
|
|
*/
|
|
|
|
|
API_EXPORT void API_CALL mk_rtp_server_release(mk_rtp_server ctx);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取本地监听的端口号
|
|
|
|
|
* @param ctx 服务器对象
|
|
|
|
|
* @return 端口号
|
|
|
|
|
*/
|
|
|
|
|
API_EXPORT uint16_t API_CALL mk_rtp_server_port(mk_rtp_server ctx);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GB28181 RTP 服务器接收流超时时触发
|
|
|
|
|
* @param user_data 用户数据指针
|
|
|
|
|
*/
|
|
|
|
|
typedef void(API_CALL *on_mk_rtp_server_detach)(void *user_data);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 监听B28181 RTP 服务器接收流超时事件
|
|
|
|
|
* @param ctx 服务器对象
|
|
|
|
|
* @param cb 回调函数
|
|
|
|
|
* @param user_data 回调函数用户数据指针
|
|
|
|
|
*/
|
|
|
|
|
API_EXPORT void API_CALL mk_rtp_server_set_on_detach(mk_rtp_server ctx, on_mk_rtp_server_detach cb, void *user_data);
|
2023-02-11 15:14:18 +08:00
|
|
|
|
API_EXPORT void API_CALL mk_rtp_server_set_on_detach2(mk_rtp_server ctx, on_mk_rtp_server_detach cb, void *user_data, on_user_data_free user_data_free);
|
2020-09-20 21:23:33 +08:00
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|