diff --git a/src/sora_connection.cpp b/src/sora_connection.cpp index 65c4b488..ae955c4d 100644 --- a/src/sora_connection.cpp +++ b/src/sora_connection.cpp @@ -157,6 +157,12 @@ void SoraConnection::OnMessage(std::string label, std::string data) { } } +void SoraConnection::OnSwitched(std::string text) { + if (on_switched_) { + on_switched_(text); + } +} + void SoraConnection::OnTrack( rtc::scoped_refptr transceiver) { if (on_track_) { diff --git a/src/sora_connection.h b/src/sora_connection.h index d99eb696..166db685 100644 --- a/src/sora_connection.h +++ b/src/sora_connection.h @@ -93,6 +93,7 @@ class SoraConnection : public sora::SoraSignalingObserver, void OnNotify(std::string text) override; void OnPush(std::string text) override; void OnMessage(std::string label, std::string data) override; + void OnSwitched(std::string text) override; void OnTrack( rtc::scoped_refptr transceiver) override; void OnRemoveTrack( @@ -105,6 +106,7 @@ class SoraConnection : public sora::SoraSignalingObserver, std::function on_notify_; std::function on_push_; std::function on_message_; + std::function on_switched_; std::function)> on_track_; std::function on_data_channel_; diff --git a/src/sora_sdk_ext.cpp b/src/sora_sdk_ext.cpp index 5af3d873..ea1094e3 100644 --- a/src/sora_sdk_ext.cpp +++ b/src/sora_sdk_ext.cpp @@ -118,6 +118,11 @@ int connection_tp_traverse(PyObject* self, visitproc visit, void* arg) { Py_VISIT(on_message.ptr()); } + if (conn->on_switched_) { + nb::object on_switched = nb::cast(conn->on_switched_, nb::rv_policy::none); + Py_VISIT(on_switched.ptr()); + } + if (conn->on_track_) { nb::object on_track = nb::cast(conn->on_track_, nb::rv_policy::none); Py_VISIT(on_track.ptr()); @@ -286,6 +291,7 @@ NB_MODULE(sora_sdk_ext, m) { .def_rw("on_notify", &SoraConnection::on_notify_) .def_rw("on_push", &SoraConnection::on_push_) .def_rw("on_message", &SoraConnection::on_message_) + .def_rw("on_switched", &SoraConnection::on_switched_) .def_rw("on_track", &SoraConnection::on_track_) .def_rw("on_data_channel", &SoraConnection::on_data_channel_);