ZLMediaKit icon indicating copy to clipboard operation
ZLMediaKit copied to clipboard

[功能请求]webrtc模块能否增加一个接口,传入offer,返回answer?

Open gongluck opened this issue 2 years ago • 2 comments

mk_webrtc_http_response_invoker_do过于依赖http模块了,我们这边有自己的信令服务,想使用zlm的webrtc但是不通过zlm的http做信令。 我测试过实现这样的接口可以满足

API_EXPORT void API_CALL mk_media_source_answersdp(
    const char *offer, const char *schema, const char *vhost, const char *app, const char *stream, int from_mp4,
   void *user_data, on_mk_media_source_answersdp_cb cb) {
#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(), rtc->getIdentifier().c_str(), "");
    } catch (std::exception &ex) {
        cb(user_data, nullptr, nullptr, nullptr, ex.what());
    }
#endif
}


gongluck avatar Sep 16 '22 15:09 gongluck

可以 要不提个pr上来? 感谢!

xia-chu avatar Sep 17 '22 04:09 xia-chu

可以 要不提个pr上来? 感谢!

好的👌🏻

gongluck avatar Sep 17 '22 12:09 gongluck

done

xia-chu avatar Oct 16 '22 08:10 xia-chu