mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 10:40:05 +08:00
add exchangeSdp
This commit is contained in:
parent
5d33e4c9f9
commit
82bc416546
@ -308,7 +308,7 @@ API_EXPORT void API_CALL mk_webrtc_get_answer_sdp2(void *user_data, on_user_data
|
|||||||
WebRtcPluginManager::Instance().getAnswerSdp(*session, type, WebRtcArgsUrl(url),
|
WebRtcPluginManager::Instance().getAnswerSdp(*session, type, WebRtcArgsUrl(url),
|
||||||
[offer_str, session, ptr, cb](const WebRtcInterface &exchanger) mutable {
|
[offer_str, session, ptr, cb](const WebRtcInterface &exchanger) mutable {
|
||||||
try {
|
try {
|
||||||
auto sdp_answer = const_cast<WebRtcInterface &>(exchanger).getAnswerSdp(offer_str);
|
auto sdp_answer = exchangeSdp(exchanger, offer_str);
|
||||||
cb(ptr.get(), sdp_answer.data(), nullptr);
|
cb(ptr.get(), sdp_answer.data(), nullptr);
|
||||||
} catch (std::exception &ex) {
|
} catch (std::exception &ex) {
|
||||||
cb(ptr.get(), nullptr, ex.what());
|
cb(ptr.get(), nullptr, ex.what());
|
||||||
|
@ -1604,7 +1604,7 @@ void installWebApi() {
|
|||||||
headerOut["Access-Control-Allow-Origin"] = "*";
|
headerOut["Access-Control-Allow-Origin"] = "*";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
val["sdp"] = const_cast<WebRtcInterface &>(exchanger).getAnswerSdp(offer);
|
val["sdp"] = exchangeSdp(exchanger, offer);
|
||||||
val["id"] = exchanger.getIdentifier();
|
val["id"] = exchanger.getIdentifier();
|
||||||
val["type"] = "answer";
|
val["type"] = "answer";
|
||||||
invoker(200, headerOut, val.toStyledString());
|
invoker(200, headerOut, val.toStyledString());
|
||||||
@ -1628,7 +1628,7 @@ void installWebApi() {
|
|||||||
try {
|
try {
|
||||||
// 设置返回类型
|
// 设置返回类型
|
||||||
headerOut["Content-Type"] = "application/sdp";
|
headerOut["Content-Type"] = "application/sdp";
|
||||||
invoker(201, headerOut, const_cast<WebRtcInterface &>(exchanger).getAnswerSdp(offer));
|
invoker(201, headerOut, exchangeSdp(exchanger, offer));
|
||||||
} catch (std::exception &ex) {
|
} catch (std::exception &ex) {
|
||||||
headerOut["Content-Type"] = "text/plain";
|
headerOut["Content-Type"] = "text/plain";
|
||||||
invoker(406, headerOut, ex.what());
|
invoker(406, headerOut, ex.what());
|
||||||
|
@ -1131,6 +1131,10 @@ void WebRtcPluginManager::registerPlugin(const string &type, Plugin cb) {
|
|||||||
_map_creator[type] = std::move(cb);
|
_map_creator[type] = std::move(cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string exchangeSdp(const WebRtcInterface &exchanger, const std::string& offer) {
|
||||||
|
return const_cast<WebRtcInterface &>(exchanger).getAnswerSdp(offer);
|
||||||
|
}
|
||||||
|
|
||||||
void WebRtcPluginManager::getAnswerSdp(Session &sender, const string &type, const WebRtcArgs &args, const onCreateRtc &cb) {
|
void WebRtcPluginManager::getAnswerSdp(Session &sender, const string &type, const WebRtcArgs &args, const onCreateRtc &cb) {
|
||||||
lock_guard<mutex> lck(_mtx_creator);
|
lock_guard<mutex> lck(_mtx_creator);
|
||||||
auto it = _map_creator.find(type);
|
auto it = _map_creator.find(type);
|
||||||
|
@ -43,6 +43,8 @@ public:
|
|||||||
virtual const std::string &getIdentifier() const = 0;
|
virtual const std::string &getIdentifier() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
std::string exchangeSdp(const WebRtcInterface &exchanger, const std::string& offer);
|
||||||
|
|
||||||
class WebRtcException : public WebRtcInterface {
|
class WebRtcException : public WebRtcInterface {
|
||||||
public:
|
public:
|
||||||
WebRtcException(const SockException &ex) : _ex(ex) {};
|
WebRtcException(const SockException &ex) : _ex(ex) {};
|
||||||
|
Loading…
Reference in New Issue
Block a user