Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offer 時は DataChannel を作る #243

Merged
merged 2 commits into from
Mar 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
- @voluntas
- [UPDATE] cmake を 3.22.2 に上げる
- @voluntas
- [ADD] DataChannel を使うことになっていて Offer を行う際には DataChannel を作るように変更
- @tnoho


## 2021.6.0
Expand Down
4 changes: 4 additions & 0 deletions src/rtc/peer_connection_observer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ PeerConnectionObserver::~PeerConnectionObserver() {
ClearAllRegisteredTracks();
}

RTCDataManager* PeerConnectionObserver::DataManager() {
return data_manager_;
}

void PeerConnectionObserver::OnDataChannel(
rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel) {
if (data_manager_ != nullptr) {
Expand Down
2 changes: 2 additions & 0 deletions src/rtc/peer_connection_observer.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class PeerConnectionObserver : public webrtc::PeerConnectionObserver {
: sender_(sender), receiver_(receiver), data_manager_(data_manager) {}
~PeerConnectionObserver();

RTCDataManager* DataManager();

private:
void OnSignalingChange(
webrtc::PeerConnectionInterface::SignalingState new_state) override {}
Expand Down
12 changes: 12 additions & 0 deletions src/rtc/rtc_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,18 @@ RTCConnection::~RTCConnection() {

void RTCConnection::CreateOffer(OnCreateSuccessFunc on_success,
OnCreateFailureFunc on_failure) {
// CreateOffer を行うのは Ayame だけのため、ここで Offer の場合には DataChannel を作ることとした
// Momo の性質上 ReOffer することは無いので問題ないと思われる
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

RTCDataManager* data_manager = observer_->DataManager();
if (data_manager != nullptr) {
webrtc::DataChannelInit config;
auto result = connection_->CreateDataChannelOrError("serial", &config);
if (!result.ok()) {
RTC_LOG(LS_ERROR) << "CreateDataChannel() failed: " << result.error().message();
}
data_manager->OnDataChannel(result.MoveValue());
}

using RTCOfferAnswerOptions =
webrtc::PeerConnectionInterface::RTCOfferAnswerOptions;
RTCOfferAnswerOptions options = RTCOfferAnswerOptions();
Expand Down