xref: /OK3568_Linux_fs/external/rknpu2/examples/3rdparty/zlmediakit/include/mk_pusher.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
3  *
4  * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
5  *
6  * Use of this source code is governed by MIT license that can be found in the
7  * LICENSE file in the root of the source tree. All contributing project authors
8  * may be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #ifndef MK_PUSHER_H
12 #define MK_PUSHER_H
13 
14 #include "mk_common.h"
15 #include "mk_events_objects.h"
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 typedef void* mk_pusher;
22 
23 /**
24  * 推流结果或推流中断事件的回调
25  * @param user_data 用户数据指针
26  * @param err_code 错误代码,0为成功
27  * @param err_msg 错误提示
28  */
29 typedef void(API_CALL *on_mk_push_event)(void *user_data,int err_code,const char *err_msg);
30 
31 /**
32  * 绑定的MediaSource对象并创建rtmp[s]/rtsp[s]推流器
33  * MediaSource通过mk_media_create或mk_proxy_player_create或推流生成
34  * 该MediaSource对象必须已注册
35  *
36  * @param schema 绑定的MediaSource对象所属协议,支持rtsp/rtmp
37  * @param vhost 绑定的MediaSource对象的虚拟主机,一般为__defaultVhost__
38  * @param app 绑定的MediaSource对象的应用名,一般为live
39  * @param stream 绑定的MediaSource对象的流id
40  * @return 对象指针
41  */
42 API_EXPORT mk_pusher API_CALL mk_pusher_create(const char *schema,const char *vhost,const char *app, const char *stream);
43 
44 /**
45  * 绑定的MediaSource对象并创建rtmp[s]/rtsp[s]推流器
46  * MediaSource通过mk_media_create或mk_proxy_player_create或推流生成
47  * 该MediaSource对象必须已注册
48  *
49  * @param src MediaSource对象
50  * @return 对象指针
51  */
52 API_EXPORT mk_pusher API_CALL mk_pusher_create_src(mk_media_source src);
53 
54 /**
55  * 释放推流器
56  * @param ctx 推流器指针
57  */
58 API_EXPORT void API_CALL mk_pusher_release(mk_pusher ctx);
59 
60 /**
61  * 设置推流器配置选项
62  * @param ctx 推流器指针
63  * @param key 配置项键,支持 net_adapter/rtp_type/rtsp_user/rtsp_pwd/protocol_timeout_ms/media_timeout_ms/beat_interval_ms
64  * @param val 配置项值,如果是整形,需要转换成统一转换成string
65  */
66 API_EXPORT void API_CALL mk_pusher_set_option(mk_pusher ctx, const char *key, const char *val);
67 
68 /**
69  * 开始推流
70  * @param ctx 推流器指针
71  * @param url 推流地址,支持rtsp[s]/rtmp[s]
72  */
73 API_EXPORT void API_CALL mk_pusher_publish(mk_pusher ctx,const char *url);
74 
75 /**
76  * 设置推流器推流结果回调函数
77  * @param ctx 推流器指针
78  * @param cb 回调函数指针,不得为null
79  * @param user_data 用户数据指针
80  */
81 API_EXPORT void API_CALL mk_pusher_set_on_result(mk_pusher ctx, on_mk_push_event cb, void *user_data);
82 
83 /**
84  * 设置推流被异常中断的回调
85  * @param ctx 推流器指针
86  * @param cb 回调函数指针,不得为null
87  * @param user_data 用户数据指针
88  */
89 API_EXPORT void API_CALL mk_pusher_set_on_shutdown(mk_pusher ctx, on_mk_push_event cb, void *user_data);
90 
91 #ifdef __cplusplus
92 }
93 #endif
94 #endif //MK_PUSHER_H
95