mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
parent
34838b1b26
commit
426d76f05c
@ -82,6 +82,8 @@ API_EXPORT uint16_t API_CALL mk_media_info_get_port(const mk_media_info ctx);
|
|||||||
typedef void* mk_media_source;
|
typedef void* mk_media_source;
|
||||||
//查找MediaSource的回调函数
|
//查找MediaSource的回调函数
|
||||||
typedef void(API_CALL *on_mk_media_source_find_cb)(void *user_data, const mk_media_source ctx);
|
typedef void(API_CALL *on_mk_media_source_find_cb)(void *user_data, const mk_media_source ctx);
|
||||||
|
//生成AnswerSdp回调函数
|
||||||
|
typedef void(API_CALL *on_mk_media_source_answersdp_cb)(void *user_data, const mk_media_source ctx, const char *answer, const char *err);
|
||||||
|
|
||||||
//MediaSource::getSchema()
|
//MediaSource::getSchema()
|
||||||
API_EXPORT const char* API_CALL mk_media_source_get_schema(const mk_media_source ctx);
|
API_EXPORT const char* API_CALL mk_media_source_get_schema(const mk_media_source ctx);
|
||||||
@ -134,6 +136,9 @@ API_EXPORT void API_CALL mk_media_source_find(const char *schema,
|
|||||||
//MediaSource::for_each_media()
|
//MediaSource::for_each_media()
|
||||||
API_EXPORT void API_CALL mk_media_source_for_each(void *user_data, on_mk_media_source_find_cb cb, const char *schema,
|
API_EXPORT void API_CALL mk_media_source_for_each(void *user_data, on_mk_media_source_find_cb cb, const char *schema,
|
||||||
const char *vhost, const char *app, const char *stream);
|
const char *vhost, const char *app, const char *stream);
|
||||||
|
//MediaSource::find() + WebRtcPlayer::create + getOffer
|
||||||
|
API_EXPORT void API_CALL mk_media_source_answersdp(void *user_data, on_mk_media_source_answersdp_cb cb, const char *offer,
|
||||||
|
const char *schema, const char *vhost, const char *app, const char *stream, int from_mp4);
|
||||||
|
|
||||||
///////////////////////////////////////////HttpBody/////////////////////////////////////////////
|
///////////////////////////////////////////HttpBody/////////////////////////////////////////////
|
||||||
//HttpBody对象的C映射
|
//HttpBody对象的C映射
|
||||||
|
@ -257,6 +257,25 @@ API_EXPORT void API_CALL mk_media_source_for_each(void *user_data, on_mk_media_s
|
|||||||
}, schema ? schema : "", vhost ? vhost : "", app ? app : "", stream ? stream : "");
|
}, schema ? schema : "", vhost ? vhost : "", app ? app : "", stream ? stream : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
API_EXPORT void API_CALL mk_media_source_answersdp(void *user_data, on_mk_media_source_answersdp_cb cb, const char *offer,
|
||||||
|
const char *schema, const char *vhost, const char *app, const char *stream, int from_mp4) {
|
||||||
|
#ifdef ENABLE_WEBRTC
|
||||||
|
assert(offer && schema && vhost && app && stream && cb);
|
||||||
|
auto srcfound = MediaSource::find(schema, vhost, app, stream, from_mp4);
|
||||||
|
mediakit::MediaInfo info;
|
||||||
|
info._schema = RTC_SCHEMA;
|
||||||
|
info._host = vhost;
|
||||||
|
info._app = app;
|
||||||
|
info._streamid = stream;
|
||||||
|
try {
|
||||||
|
auto rtc = WebRtcPlayer::create(EventPollerPool::Instance().getPoller(), std::dynamic_pointer_cast<RtspMediaSource>(srcfound), info);
|
||||||
|
cb(user_data, srcfound.get(), rtc->getAnswerSdp(offer).c_str(), "");
|
||||||
|
} catch (std::exception &ex) {
|
||||||
|
cb(user_data, nullptr, nullptr, ex.what());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////HttpBody/////////////////////////////////////////////
|
///////////////////////////////////////////HttpBody/////////////////////////////////////////////
|
||||||
API_EXPORT mk_http_body API_CALL mk_http_body_from_string(const char *str, size_t len){
|
API_EXPORT mk_http_body API_CALL mk_http_body_from_string(const char *str, size_t len){
|
||||||
assert(str);
|
assert(str);
|
||||||
|
Loading…
Reference in New Issue
Block a user