Skip to content

Commit

Permalink
on_switched に対応する
Browse files Browse the repository at this point in the history
  • Loading branch information
enm10k committed Mar 15, 2024
1 parent 88f8403 commit bd523f4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/sora_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<webrtc::RtpTransceiverInterface> transceiver) {
if (on_track_) {
Expand Down
2 changes: 2 additions & 0 deletions src/sora_connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<webrtc::RtpTransceiverInterface> transceiver) override;
void OnRemoveTrack(
Expand All @@ -105,6 +106,7 @@ class SoraConnection : public sora::SoraSignalingObserver,
std::function<void(std::string)> on_notify_;
std::function<void(std::string)> on_push_;
std::function<void(std::string, nb::bytes)> on_message_;
std::function<void(std::string)> on_switched_;
std::function<void(std::shared_ptr<SoraMediaTrack>)> on_track_;
std::function<void(std::string)> on_data_channel_;

Expand Down
6 changes: 6 additions & 0 deletions src/sora_sdk_ext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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_);

Expand Down

0 comments on commit bd523f4

Please sign in to comment.