mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-25 20:27:34 +08:00
添加pusher接口
整理代码
This commit is contained in:
parent
ee4659a185
commit
ef7e937808
@ -37,6 +37,7 @@ typedef void *mk_media;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建一个媒体源
|
* 创建一个媒体源
|
||||||
|
* @param vhost 虚拟主机名,一般为__defaultVhost__
|
||||||
* @param app 应用名,推荐为live
|
* @param app 应用名,推荐为live
|
||||||
* @param stream 流id,例如camera
|
* @param stream 流id,例如camera
|
||||||
* @param duration 时长(单位秒),直播则为0
|
* @param duration 时长(单位秒),直播则为0
|
||||||
@ -44,7 +45,7 @@ typedef void *mk_media;
|
|||||||
* @param mp4_enabled 是否生成mp4
|
* @param mp4_enabled 是否生成mp4
|
||||||
* @return 对象指针
|
* @return 对象指针
|
||||||
*/
|
*/
|
||||||
API_EXPORT mk_media API_CALL mk_media_create(const char *app, const char *stream, float duration, int hls_enabled, int mp4_enabled);
|
API_EXPORT mk_media API_CALL mk_media_create(const char *vhost, const char *app, const char *stream, float duration, int hls_enabled, int mp4_enabled);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 销毁媒体源
|
* 销毁媒体源
|
||||||
|
@ -33,5 +33,6 @@
|
|||||||
#include "proxyplayer.h"
|
#include "proxyplayer.h"
|
||||||
#include "flvrecorder.h"
|
#include "flvrecorder.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
|
#include "pusher.h"
|
||||||
|
|
||||||
#endif /* MK_API_H_ */
|
#endif /* MK_API_H_ */
|
||||||
|
@ -56,7 +56,7 @@ typedef void(API_CALL *on_mk_play_event)(void *user_data,int err_code,const char
|
|||||||
typedef void(API_CALL *on_mk_play_data)(void *user_data,int track_type,int codec_id,void *data,int len,uint32_t dts,uint32_t pts);
|
typedef void(API_CALL *on_mk_play_data)(void *user_data,int track_type,int codec_id,void *data,int len,uint32_t dts,uint32_t pts);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建一个播放器,支持rtmp/rtsp
|
* 创建一个播放器,支持rtmp[s]/rtsp[s]
|
||||||
* @return 播放器指针
|
* @return 播放器指针
|
||||||
*/
|
*/
|
||||||
API_EXPORT mk_player API_CALL mk_player_create();
|
API_EXPORT mk_player API_CALL mk_player_create();
|
||||||
@ -78,7 +78,7 @@ API_EXPORT void API_CALL mk_player_set_option(mk_player ctx, const char *key, co
|
|||||||
/**
|
/**
|
||||||
* 开始播放url
|
* 开始播放url
|
||||||
* @param ctx 播放器指针
|
* @param ctx 播放器指针
|
||||||
* @param url rtsp/rtmp url
|
* @param url rtsp[s]/rtmp[s] url
|
||||||
*/
|
*/
|
||||||
API_EXPORT void API_CALL mk_player_play(mk_player ctx, const char *url);
|
API_EXPORT void API_CALL mk_player_play(mk_player ctx, const char *url);
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ API_EXPORT void API_CALL mk_player_seekto(mk_player ctx, float progress);
|
|||||||
/**
|
/**
|
||||||
* 设置播放器开启播放结果回调函数
|
* 设置播放器开启播放结果回调函数
|
||||||
* @param ctx 播放器指针
|
* @param ctx 播放器指针
|
||||||
* @param cb 回调函数指针
|
* @param cb 回调函数指针,不得为null
|
||||||
* @param user_data 用户数据指针
|
* @param user_data 用户数据指针
|
||||||
*/
|
*/
|
||||||
API_EXPORT void API_CALL mk_player_set_on_result(mk_player ctx, on_mk_play_event cb, void *user_data);
|
API_EXPORT void API_CALL mk_player_set_on_result(mk_player ctx, on_mk_play_event cb, void *user_data);
|
||||||
|
@ -37,6 +37,7 @@ typedef void *mk_proxy_player;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建一个代理播放器
|
* 创建一个代理播放器
|
||||||
|
* @param vhost 虚拟主机名,一般为__defaultVhost__
|
||||||
* @param app 应用名
|
* @param app 应用名
|
||||||
* @param stream 流名
|
* @param stream 流名
|
||||||
* @param rtp_type rtsp播放方式:RTP_TCP = 0, RTP_UDP = 1, RTP_MULTICAST = 2
|
* @param rtp_type rtsp播放方式:RTP_TCP = 0, RTP_UDP = 1, RTP_MULTICAST = 2
|
||||||
@ -44,7 +45,7 @@ typedef void *mk_proxy_player;
|
|||||||
* @param mp4_enabled 是否生成mp4
|
* @param mp4_enabled 是否生成mp4
|
||||||
* @return 对象指针
|
* @return 对象指针
|
||||||
*/
|
*/
|
||||||
API_EXPORT mk_proxy_player API_CALL mk_proxy_player_create(const char *app, const char *stream, int rtp_type, int hls_enabled, int mp4_enabled);
|
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);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 销毁代理播放器
|
* 销毁代理播放器
|
||||||
@ -52,6 +53,15 @@ API_EXPORT mk_proxy_player API_CALL mk_proxy_player_create(const char *app, cons
|
|||||||
*/
|
*/
|
||||||
API_EXPORT void API_CALL mk_proxy_player_release(mk_proxy_player ctx);
|
API_EXPORT void API_CALL mk_proxy_player_release(mk_proxy_player ctx);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置代理播放器配置选项
|
||||||
|
* @param ctx 代理播放器指针
|
||||||
|
* @param key 配置项键,支持 net_adapter/rtp_type/rtsp_user/rtsp_pwd/protocol_timeout_ms/media_timeout_ms/beat_interval_ms/max_analysis_ms
|
||||||
|
* @param val 配置项值,如果是整形,需要转换成统一转换成string
|
||||||
|
*/
|
||||||
|
API_EXPORT void API_CALL mk_proxy_player_set_option(mk_proxy_player ctx, const char *key, const char *val);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 开始播放
|
* 开始播放
|
||||||
* @param ctx 对象指针
|
* @param ctx 对象指针
|
||||||
|
@ -45,7 +45,7 @@ static TcpServer::Ptr http_server[2];
|
|||||||
|
|
||||||
//////////////////////////environment init///////////////////////////
|
//////////////////////////environment init///////////////////////////
|
||||||
API_EXPORT void API_CALL mk_env_init(const config *cfg) {
|
API_EXPORT void API_CALL mk_env_init(const config *cfg) {
|
||||||
assert(cfg != nullptr);
|
assert(cfg);
|
||||||
static onceToken token([&]() {
|
static onceToken token([&]() {
|
||||||
Logger::Instance().add(std::make_shared<ConsoleChannel>("console", (LogLevel) cfg->log_level));
|
Logger::Instance().add(std::make_shared<ConsoleChannel>("console", (LogLevel) cfg->log_level));
|
||||||
Logger::Instance().setWriter(std::make_shared<AsyncLogWriter>());
|
Logger::Instance().setWriter(std::make_shared<AsyncLogWriter>());
|
||||||
@ -70,6 +70,7 @@ API_EXPORT void API_CALL mk_env_init(const config *cfg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
API_EXPORT void API_CALL mk_set_option(const char *key, const char *val) {
|
API_EXPORT void API_CALL mk_set_option(const char *key, const char *val) {
|
||||||
|
assert(key && val);
|
||||||
if (mINI::Instance().find(key) == mINI::Instance().end()) {
|
if (mINI::Instance().find(key) == mINI::Instance().end()) {
|
||||||
WarnL << "key:" << key << " not existed!";
|
WarnL << "key:" << key << " not existed!";
|
||||||
return;
|
return;
|
||||||
@ -129,6 +130,7 @@ API_EXPORT uint16_t API_CALL mk_rtmp_server_start(uint16_t port, int ssl) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
API_EXPORT void API_CALL mk_log_printf(int level, const char *file, const char *function, int line, const char *fmt, ...) {
|
API_EXPORT void API_CALL mk_log_printf(int level, const char *file, const char *function, int line, const char *fmt, ...) {
|
||||||
|
assert(file && function && fmt);
|
||||||
LogContextCapturer info(Logger::Instance(), (LogLevel) level, file, function, line);
|
LogContextCapturer info(Logger::Instance(), (LogLevel) level, file, function, line);
|
||||||
va_list pArg;
|
va_list pArg;
|
||||||
va_start(pArg, fmt);
|
va_start(pArg, fmt);
|
||||||
|
@ -34,13 +34,14 @@ API_EXPORT mk_flv_recorder API_CALL mk_flv_recorder_create(){
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
API_EXPORT void API_CALL mk_flv_recorder_release(mk_flv_recorder ctx){
|
API_EXPORT void API_CALL mk_flv_recorder_release(mk_flv_recorder ctx){
|
||||||
|
assert(ctx);
|
||||||
FlvRecorder::Ptr *record = (FlvRecorder::Ptr *)(ctx);
|
FlvRecorder::Ptr *record = (FlvRecorder::Ptr *)(ctx);
|
||||||
delete record;
|
delete record;
|
||||||
}
|
}
|
||||||
API_EXPORT int API_CALL mk_flv_recorder_start(mk_flv_recorder ctx, const char *app, const char *stream, const char *file_path){
|
API_EXPORT int API_CALL mk_flv_recorder_start(mk_flv_recorder ctx, const char *app, const char *stream, const char *file_path){
|
||||||
DebugL << app << " " << stream << " " << file_path;
|
assert(ctx && app && stream && file_path);
|
||||||
FlvRecorder::Ptr *record = (FlvRecorder::Ptr *)(ctx);
|
|
||||||
try {
|
try {
|
||||||
|
FlvRecorder::Ptr *record = (FlvRecorder::Ptr *)(ctx);
|
||||||
(*record)->startRecord(EventPollerPool::Instance().getPoller(), DEFAULT_VHOST,app,stream,file_path);
|
(*record)->startRecord(EventPollerPool::Instance().getPoller(), DEFAULT_VHOST,app,stream,file_path);
|
||||||
return 0;
|
return 0;
|
||||||
}catch (std::exception &ex){
|
}catch (std::exception &ex){
|
||||||
|
@ -37,11 +37,13 @@ API_EXPORT mk_http_downloader API_CALL mk_http_downloader_create() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
API_EXPORT void API_CALL mk_http_downloader_release(mk_http_downloader ctx) {
|
API_EXPORT void API_CALL mk_http_downloader_release(mk_http_downloader ctx) {
|
||||||
|
assert(ctx);
|
||||||
HttpDownloader::Ptr *obj = (HttpDownloader::Ptr *) ctx;
|
HttpDownloader::Ptr *obj = (HttpDownloader::Ptr *) ctx;
|
||||||
delete obj;
|
delete obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
API_EXPORT void API_CALL mk_http_downloader_start(mk_http_downloader ctx, const char *url, const char *file, on_mk_download_complete cb, void *user_data) {
|
API_EXPORT void API_CALL mk_http_downloader_start(mk_http_downloader ctx, const char *url, const char *file, on_mk_download_complete cb, void *user_data) {
|
||||||
|
assert(ctx && url && file);
|
||||||
HttpDownloader::Ptr *obj = (HttpDownloader::Ptr *) ctx;
|
HttpDownloader::Ptr *obj = (HttpDownloader::Ptr *) ctx;
|
||||||
(*obj)->setOnResult([cb, user_data](ErrCode code, const string &errMsg, const string &filePath) {
|
(*obj)->setOnResult([cb, user_data](ErrCode code, const string &errMsg, const string &filePath) {
|
||||||
if (cb) {
|
if (cb) {
|
||||||
|
@ -32,17 +32,20 @@ using namespace std;
|
|||||||
using namespace toolkit;
|
using namespace toolkit;
|
||||||
using namespace mediakit;
|
using namespace mediakit;
|
||||||
|
|
||||||
API_EXPORT mk_media API_CALL mk_media_create(const char *app, const char *stream, float duration, int hls_enabled, int mp4_enabled) {
|
API_EXPORT mk_media API_CALL mk_media_create(const char *vhost, const char *app, const char *stream, float duration, int hls_enabled, int mp4_enabled) {
|
||||||
DevChannel::Ptr *obj(new DevChannel::Ptr(new DevChannel(DEFAULT_VHOST, app, stream, duration, true, true, hls_enabled, mp4_enabled)));
|
assert(vhost && app && stream);
|
||||||
|
DevChannel::Ptr *obj(new DevChannel::Ptr(new DevChannel(vhost, app, stream, duration, true, true, hls_enabled, mp4_enabled)));
|
||||||
return (mk_media) obj;
|
return (mk_media) obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
API_EXPORT void API_CALL mk_media_release(mk_media ctx) {
|
API_EXPORT void API_CALL mk_media_release(mk_media ctx) {
|
||||||
|
assert(ctx);
|
||||||
DevChannel::Ptr *obj = (DevChannel::Ptr *) ctx;
|
DevChannel::Ptr *obj = (DevChannel::Ptr *) ctx;
|
||||||
delete obj;
|
delete obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
API_EXPORT void API_CALL mk_media_init_h264(mk_media ctx, int width, int height, int frameRate) {
|
API_EXPORT void API_CALL mk_media_init_h264(mk_media ctx, int width, int height, int frameRate) {
|
||||||
|
assert(ctx);
|
||||||
DevChannel::Ptr *obj = (DevChannel::Ptr *) ctx;
|
DevChannel::Ptr *obj = (DevChannel::Ptr *) ctx;
|
||||||
VideoInfo info;
|
VideoInfo info;
|
||||||
info.iFrameRate = frameRate;
|
info.iFrameRate = frameRate;
|
||||||
@ -52,6 +55,7 @@ API_EXPORT void API_CALL mk_media_init_h264(mk_media ctx, int width, int height,
|
|||||||
}
|
}
|
||||||
|
|
||||||
API_EXPORT void API_CALL mk_media_init_h265(mk_media ctx, int width, int height, int frameRate) {
|
API_EXPORT void API_CALL mk_media_init_h265(mk_media ctx, int width, int height, int frameRate) {
|
||||||
|
assert(ctx);
|
||||||
DevChannel::Ptr *obj = (DevChannel::Ptr *) ctx;
|
DevChannel::Ptr *obj = (DevChannel::Ptr *) ctx;
|
||||||
VideoInfo info;
|
VideoInfo info;
|
||||||
info.iFrameRate = frameRate;
|
info.iFrameRate = frameRate;
|
||||||
@ -61,6 +65,7 @@ API_EXPORT void API_CALL mk_media_init_h265(mk_media ctx, int width, int height,
|
|||||||
}
|
}
|
||||||
|
|
||||||
API_EXPORT void API_CALL mk_media_init_aac(mk_media ctx, int channel, int sample_bit, int sample_rate, int profile) {
|
API_EXPORT void API_CALL mk_media_init_aac(mk_media ctx, int channel, int sample_bit, int sample_rate, int profile) {
|
||||||
|
assert(ctx);
|
||||||
DevChannel::Ptr *obj = (DevChannel::Ptr *) ctx;
|
DevChannel::Ptr *obj = (DevChannel::Ptr *) ctx;
|
||||||
AudioInfo info;
|
AudioInfo info;
|
||||||
info.iSampleRate = sample_rate;
|
info.iSampleRate = sample_rate;
|
||||||
@ -71,21 +76,25 @@ API_EXPORT void API_CALL mk_media_init_aac(mk_media ctx, int channel, int sample
|
|||||||
}
|
}
|
||||||
|
|
||||||
API_EXPORT void API_CALL mk_media_input_h264(mk_media ctx, void *data, int len, uint32_t dts, uint32_t pts) {
|
API_EXPORT void API_CALL mk_media_input_h264(mk_media ctx, void *data, int len, uint32_t dts, uint32_t pts) {
|
||||||
|
assert(ctx && data && len > 0);
|
||||||
DevChannel::Ptr *obj = (DevChannel::Ptr *) ctx;
|
DevChannel::Ptr *obj = (DevChannel::Ptr *) ctx;
|
||||||
(*obj)->inputH264((char *) data, len, dts, pts);
|
(*obj)->inputH264((char *) data, len, dts, pts);
|
||||||
}
|
}
|
||||||
|
|
||||||
API_EXPORT void API_CALL mk_media_input_h265(mk_media ctx, void *data, int len, uint32_t dts, uint32_t pts) {
|
API_EXPORT void API_CALL mk_media_input_h265(mk_media ctx, void *data, int len, uint32_t dts, uint32_t pts) {
|
||||||
|
assert(ctx && data && len > 0);
|
||||||
DevChannel::Ptr *obj = (DevChannel::Ptr *) ctx;
|
DevChannel::Ptr *obj = (DevChannel::Ptr *) ctx;
|
||||||
(*obj)->inputH265((char *) data, len, dts, pts);
|
(*obj)->inputH265((char *) data, len, dts, pts);
|
||||||
}
|
}
|
||||||
|
|
||||||
API_EXPORT void API_CALL mk_media_input_aac(mk_media ctx, void *data, int len, uint32_t dts, int with_adts_header) {
|
API_EXPORT void API_CALL mk_media_input_aac(mk_media ctx, void *data, int len, uint32_t dts, int with_adts_header) {
|
||||||
|
assert(ctx && data && len > 0);
|
||||||
DevChannel::Ptr *obj = (DevChannel::Ptr *) ctx;
|
DevChannel::Ptr *obj = (DevChannel::Ptr *) ctx;
|
||||||
(*obj)->inputAAC((char *) data, len, dts, with_adts_header);
|
(*obj)->inputAAC((char *) data, len, dts, with_adts_header);
|
||||||
}
|
}
|
||||||
|
|
||||||
API_EXPORT void API_CALL mk_media_input_aac1(mk_media ctx, void *data, int len, uint32_t dts, void *adts) {
|
API_EXPORT void API_CALL mk_media_input_aac1(mk_media ctx, void *data, int len, uint32_t dts, void *adts) {
|
||||||
|
assert(ctx && data && len > 0 && adts);
|
||||||
DevChannel::Ptr *obj = (DevChannel::Ptr *) ctx;
|
DevChannel::Ptr *obj = (DevChannel::Ptr *) ctx;
|
||||||
(*obj)->inputAAC((char *) data, len, dts, (char *) adts);
|
(*obj)->inputAAC((char *) data, len, dts, (char *) adts);
|
||||||
}
|
}
|
||||||
|
@ -42,9 +42,7 @@ API_EXPORT void API_CALL mk_player_release(mk_player ctx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
API_EXPORT void API_CALL mk_player_set_option(mk_player ctx,const char* key,const char *val){
|
API_EXPORT void API_CALL mk_player_set_option(mk_player ctx,const char* key,const char *val){
|
||||||
assert(ctx);
|
assert(ctx && key && val);
|
||||||
assert(key);
|
|
||||||
assert(val);
|
|
||||||
MediaPlayer::Ptr &player = *((MediaPlayer::Ptr *)ctx);
|
MediaPlayer::Ptr &player = *((MediaPlayer::Ptr *)ctx);
|
||||||
string key_str(key), val_str(val);
|
string key_str(key), val_str(val);
|
||||||
player->getPoller()->async([key_str,val_str,player](){
|
player->getPoller()->async([key_str,val_str,player](){
|
||||||
@ -53,8 +51,7 @@ API_EXPORT void API_CALL mk_player_set_option(mk_player ctx,const char* key,cons
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
API_EXPORT void API_CALL mk_player_play(mk_player ctx, const char *url) {
|
API_EXPORT void API_CALL mk_player_play(mk_player ctx, const char *url) {
|
||||||
assert(ctx);
|
assert(ctx && url);
|
||||||
assert(url);
|
|
||||||
MediaPlayer::Ptr &player = *((MediaPlayer::Ptr *)ctx);
|
MediaPlayer::Ptr &player = *((MediaPlayer::Ptr *)ctx);
|
||||||
string url_str(url);
|
string url_str(url);
|
||||||
player->getPoller()->async([url_str,player](){
|
player->getPoller()->async([url_str,player](){
|
||||||
@ -82,8 +79,7 @@ API_EXPORT void API_CALL mk_player_seekto(mk_player ctx, float progress) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void mk_player_set_on_event(mk_player ctx, on_mk_play_event cb, void *user_data, int type) {
|
static void mk_player_set_on_event(mk_player ctx, on_mk_play_event cb, void *user_data, int type) {
|
||||||
assert(ctx);
|
assert(ctx && cb);
|
||||||
assert(cb);
|
|
||||||
MediaPlayer::Ptr &player = *((MediaPlayer::Ptr *)ctx);
|
MediaPlayer::Ptr &player = *((MediaPlayer::Ptr *)ctx);
|
||||||
player->getPoller()->async([cb,user_data,type,player](){
|
player->getPoller()->async([cb,user_data,type,player](){
|
||||||
//切换线程后再操作
|
//切换线程后再操作
|
||||||
@ -108,8 +104,7 @@ API_EXPORT void API_CALL mk_player_set_on_shutdown(mk_player ctx, on_mk_play_eve
|
|||||||
}
|
}
|
||||||
|
|
||||||
API_EXPORT void API_CALL mk_player_set_on_data(mk_player ctx, on_mk_play_data cb, void *user_data) {
|
API_EXPORT void API_CALL mk_player_set_on_data(mk_player ctx, on_mk_play_data cb, void *user_data) {
|
||||||
assert(ctx);
|
assert(ctx && cb);
|
||||||
assert(cb);
|
|
||||||
MediaPlayer::Ptr &player = *((MediaPlayer::Ptr *)ctx);
|
MediaPlayer::Ptr &player = *((MediaPlayer::Ptr *)ctx);
|
||||||
player->getPoller()->async([player,cb,user_data](){
|
player->getPoller()->async([player,cb,user_data](){
|
||||||
//切换线程后再操作
|
//切换线程后再操作
|
||||||
|
@ -30,18 +30,34 @@
|
|||||||
using namespace toolkit;
|
using namespace toolkit;
|
||||||
using namespace mediakit;
|
using namespace mediakit;
|
||||||
|
|
||||||
API_EXPORT mk_proxy_player API_CALL mk_proxy_player_create(const char *app, const char *stream, int rtp_type, int hls_enabled, int mp4_enabled) {
|
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) {
|
||||||
PlayerProxy::Ptr *obj(new PlayerProxy::Ptr(new PlayerProxy(DEFAULT_VHOST, app, stream, true, true, hls_enabled, mp4_enabled)));
|
assert(vhost && app && stream);
|
||||||
(**obj)[Client::kRtpType] = rtp_type;
|
PlayerProxy::Ptr *obj(new PlayerProxy::Ptr(new PlayerProxy(vhost, app, stream, true, true, hls_enabled, mp4_enabled)));
|
||||||
return (mk_proxy_player) obj;
|
return (mk_proxy_player) obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
API_EXPORT void API_CALL mk_proxy_player_release(mk_proxy_player ctx) {
|
API_EXPORT void API_CALL mk_proxy_player_release(mk_proxy_player ctx) {
|
||||||
|
assert(ctx);
|
||||||
PlayerProxy::Ptr *obj = (PlayerProxy::Ptr *) ctx;
|
PlayerProxy::Ptr *obj = (PlayerProxy::Ptr *) ctx;
|
||||||
delete obj;
|
delete obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
API_EXPORT void API_CALL mk_proxy_player_play(mk_proxy_player ctx, const char *url) {
|
API_EXPORT void API_CALL mk_proxy_player_set_option(mk_proxy_player ctx, const char *key, const char *val){
|
||||||
PlayerProxy::Ptr *obj = (PlayerProxy::Ptr *) ctx;
|
assert(ctx && key && val);
|
||||||
(*obj)->play(url);
|
PlayerProxy::Ptr &obj = *((PlayerProxy::Ptr *) ctx);
|
||||||
|
string key_str(key),val_str(val);
|
||||||
|
obj->getPoller()->async([obj,key_str,val_str](){
|
||||||
|
//切换线程再操作
|
||||||
|
(*obj)[key_str] = val_str;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
API_EXPORT void API_CALL mk_proxy_player_play(mk_proxy_player ctx, const char *url) {
|
||||||
|
assert(ctx && url);
|
||||||
|
PlayerProxy::Ptr &obj = *((PlayerProxy::Ptr *) ctx);
|
||||||
|
string url_str(url);
|
||||||
|
obj->getPoller()->async([obj,url_str](){
|
||||||
|
//切换线程再操作
|
||||||
|
obj->play(url_str);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user