ZLMediaKit/api/include/mk_proxyplayer.h

218 lines
8.0 KiB
C++
Raw Permalink Normal View History

2019-12-18 11:47:49 +08:00
/*
2023-12-09 16:23:51 +08:00
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
2019-12-17 18:45:31 +08:00
*
2023-12-09 16:23:51 +08:00
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
2019-12-17 18:45:31 +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-04-04 20:30:09 +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.
2019-12-17 18:45:31 +08:00
*/
#ifndef MK_PROXY_PLAYER_H_
#define MK_PROXY_PLAYER_H_
#include "mk_common.h"
#include "mk_util.h"
2019-12-17 18:45:31 +08:00
#ifdef __cplusplus
extern "C" {
#endif
typedef struct mk_proxy_player_t *mk_proxy_player;
2019-12-17 18:45:31 +08:00
/**
*
2019-12-18 14:43:32 +08:00
* @param vhost __defaultVhost__
2019-12-17 18:45:31 +08:00
* @param app
* @param stream
* @param rtp_type rtsp播放方式:RTP_TCP = 0, RTP_UDP = 1, RTP_MULTICAST = 2
* @param hls_enabled hls
* @param mp4_enabled mp4
* @return
* Create a proxy player
* @param vhost Virtual host name, generally __defaultVhost__
* @param app Application name
* @param stream Stream name
* @param rtp_type rtsp playback method: RTP_TCP = 0, RTP_UDP = 1, RTP_MULTICAST = 2
* @param hls_enabled Whether to generate hls
* @param mp4_enabled Whether to generate mp4
* @return Object pointer
* [AUTO-TRANSLATED:1d4f13f4]
2019-12-17 18:45:31 +08:00
*/
2019-12-18 14:43:32 +08:00
API_EXPORT mk_proxy_player API_CALL mk_proxy_player_create(const char *vhost, const char *app, const char *stream, int hls_enabled, int mp4_enabled);
2019-12-17 18:45:31 +08:00
/**
*
* @param vhost __defaultVhost__
* @param app
* @param stream
* @param option ProtocolOption相关配置
* @return
* Create a proxy player
* @param vhost Virtual host name, generally __defaultVhost__
* @param app Application name
* @param stream Stream name
* @param option ProtocolOption related configuration
* @return Object pointer
* [AUTO-TRANSLATED:4c6208df]
*/
API_EXPORT mk_proxy_player API_CALL mk_proxy_player_create2(const char *vhost, const char *app, const char *stream, mk_ini option);
/**
*
* @param vhost __defaultVhost__
* @param app
* @param stream
* @param rtp_type rtsp播放方式:RTP_TCP = 0, RTP_UDP = 1, RTP_MULTICAST = 2
* @param hls_enabled hls
* @param mp4_enabled mp4
* @param retry_count <0
* @return
* Create a proxy player
* @param vhost Virtual host name, generally __defaultVhost__
* @param app Application name
* @param stream Stream name
* @param rtp_type rtsp playback method: RTP_TCP = 0, RTP_UDP = 1, RTP_MULTICAST = 2
* @param hls_enabled Whether to generate hls
* @param mp4_enabled Whether to generate mp4
* @param retry_count Retry count, when <0 retry infinitely
* @return Object pointer
* [AUTO-TRANSLATED:e25286c3]
*/
API_EXPORT mk_proxy_player API_CALL mk_proxy_player_create3(const char *vhost, const char *app, const char *stream, int hls_enabled, int mp4_enabled, int retry_count);
/**
*
* @param vhost __defaultVhost__
* @param app
* @param stream
* @param option ProtocolOption相关配置
* @param retry_count <0
* @return
* Create a proxy player
* @param vhost Virtual host name, generally __defaultVhost__
* @param app Application name
* @param stream Stream name
* @param option ProtocolOption related configuration
* @param retry_count Retry count, when <0 retry infinitely
* @return Object pointer
* [AUTO-TRANSLATED:2cb296d1]
*/
API_EXPORT mk_proxy_player API_CALL mk_proxy_player_create4(const char *vhost, const char *app, const char *stream, mk_ini option, int retry_count);
2019-12-17 18:45:31 +08:00
/**
*
* @param ctx
* Destroy the proxy player
* @param ctx Object pointer
* [AUTO-TRANSLATED:fe451691]
2019-12-17 18:45:31 +08:00
*/
API_EXPORT void API_CALL mk_proxy_player_release(mk_proxy_player ctx);
2019-12-18 14:43:32 +08:00
/**
*
* @param ctx
* @param key , net_adapter/rtp_type/rtsp_user/rtsp_pwd/protocol_timeout_ms/media_timeout_ms/beat_interval_ms/rtsp_speed
2019-12-18 14:43:32 +08:00
* @param val ,string
* Set proxy player configuration options
* @param ctx Proxy player pointer
* @param key Configuration item key, supports net_adapter/rtp_type/rtsp_user/rtsp_pwd/protocol_timeout_ms/media_timeout_ms/beat_interval_ms/rtsp_speed
* @param val Configuration item value, if it is an integer, it needs to be converted to a unified string
* [AUTO-TRANSLATED:78938fba]
2019-12-18 14:43:32 +08:00
*/
API_EXPORT void API_CALL mk_proxy_player_set_option(mk_proxy_player ctx, const char *key, const char *val);
2019-12-17 18:45:31 +08:00
/**
*
* @param ctx
* @param url url,rtsp/rtmp
* Start playback
* @param ctx Object pointer
* @param url Playback url, supports rtsp/rtmp
* [AUTO-TRANSLATED:9597bafb]
2019-12-17 18:45:31 +08:00
*/
API_EXPORT void API_CALL mk_proxy_player_play(mk_proxy_player ctx, const char *url);
2020-03-10 22:55:19 +08:00
/**
* MediaSource.close()
* MediaSource时
* mk_proxy_player_release函数并且释放其他资源
* mk_proxy_player_release函数MediaSource.close()
* @param user_data mk_proxy_player_set_on_close函数设置
* MediaSource.close() callback event
* When you choose to close an associated MediaSource, it will eventually trigger this callback
* You should call mk_proxy_player_release function through this event and release other resources
* If you do not call mk_proxy_player_release function, then MediaSource.close() operation will be invalid
* @param user_data User data pointer, set by mk_proxy_player_set_on_close function
* [AUTO-TRANSLATED:c99b6bfd]
2020-03-10 22:55:19 +08:00
*/
typedef void(API_CALL *on_mk_proxy_player_cb)(void *user_data, int err, const char *what, int sys_err);
// 保持兼容 [AUTO-TRANSLATED:94139ca7]
// Keep compatible
#define on_mk_proxy_player_close on_mk_proxy_player_cb
2020-03-10 22:55:19 +08:00
/**
* MediaSource.close()
* MediaSource时
* mk_proxy_player_release函数并且释放其他资源
* @param ctx
* @param cb
* @param user_data
* Listen for MediaSource.close() event
* When you choose to close an associated MediaSource, it will eventually trigger this callback
* You should call mk_proxy_player_release function through this event and release other resources
* @param ctx Object pointer
* @param cb Callback pointer
* @param user_data User data pointer
* [AUTO-TRANSLATED:174060d4]
2020-03-10 22:55:19 +08:00
*/
API_EXPORT void API_CALL mk_proxy_player_set_on_close(mk_proxy_player ctx, on_mk_proxy_player_cb cb, void *user_data);
API_EXPORT void API_CALL mk_proxy_player_set_on_close2(mk_proxy_player ctx, on_mk_proxy_player_cb cb, void *user_data, on_user_data_free user_data_free);
/**
*
* @param ctx
* @param cb
* @param user_data
* @param user_data_free
* Set the proxy's first playback result callback. If the first playback fails, it can be considered a startup failure.
* @param ctx Object pointer
* @param cb Callback pointer
* @param user_data User data pointer
* @param user_data_free User data release callback
* [AUTO-TRANSLATED:1f34852a]
*/
API_EXPORT void API_CALL mk_proxy_player_set_on_play_result(mk_proxy_player ctx, on_mk_proxy_player_cb cb, void *user_data, on_user_data_free user_data_free);
2020-03-10 22:55:19 +08:00
/**
*
* @param ctx
* @return
* Get the total number of viewers
* @param ctx Object pointer
* @return Number of viewers
* [AUTO-TRANSLATED:56635caf]
2020-03-10 22:55:19 +08:00
*/
API_EXPORT int API_CALL mk_proxy_player_total_reader_count(mk_proxy_player ctx);
2019-12-17 18:45:31 +08:00
#ifdef __cplusplus
}
#endif
#endif /* MK_PROXY_PLAYER_H_ */