mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 10:40:05 +08:00
增加通过offer获取answer的接口,不依赖http模块
This commit is contained in:
parent
b77c19c969
commit
94d0505ea6
@ -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;
|
||||
//查找MediaSource的回调函数
|
||||
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()
|
||||
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()
|
||||
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);
|
||||
//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对象的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 : "");
|
||||
}
|
||||
|
||||
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/////////////////////////////////////////////
|
||||
API_EXPORT mk_http_body API_CALL mk_http_body_from_string(const char *str, size_t len){
|
||||
assert(str);
|
||||
|
Loading…
Reference in New Issue
Block a user