Skip to content

Commit

Permalink
Merge branch 'feature/2022.7.0' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
melpon committed Jul 10, 2022
2 parents 372938f + 041d938 commit fdde222
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 49 deletions.
9 changes: 9 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@

## develop

## 2022.7.0 (2022-07-11)

- [ADD] run.py に --relwithdebinfo フラグを追加
- @melpon
- [UPDATE] libwebrtc を m103.5060.5.0 に上げる
- @voluntas @melpon
- [FIX] boost::asio::post に strand を渡してなかったのを修正
- @melpon

## 2022.6.2 (2022-07-03)

- [FIX] DataChannel が有効だと切断時にエラーが起きていたのを修正
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SORA_CPP_SDK_VERSION=2022.6.2
WEBRTC_BUILD_VERSION=m102.5005.7.5
WEBRTC_BUILD_VERSION=m103.5060.5.0
BOOST_VERSION=1.79.0
CMAKE_VERSION=3.23.1
CUDA_VERSION=10.2.89-1
Expand Down
7 changes: 6 additions & 1 deletion run.py
Original file line number Diff line number Diff line change
Expand Up @@ -1217,6 +1217,7 @@ def main():
parser = argparse.ArgumentParser()
parser.add_argument("target", choices=AVAILABLE_TARGETS)
parser.add_argument("--debug", action='store_true')
parser.add_argument("--relwithdebinfo", action='store_true')
parser.add_argument("--webrtcbuild", action='store_true')
parser.add_argument("--webrtcbuild-fetch", action='store_true')
parser.add_argument("--webrtcbuild-fetch-force", action='store_true')
Expand Down Expand Up @@ -1266,7 +1267,11 @@ def main():
install_deps(platform, source_dir, build_dir, install_dir, args.debug,
webrtcbuild=args.webrtcbuild, webrtc_config=args)

configuration = 'Debug' if args.debug else 'Release'
configuration = 'Release'
if args.debug:
configuration = 'Debug'
if args.relwithdebinfo:
configuration = 'RelWithDebInfo'

sora_build_dir = os.path.join(build_dir, 'sora')
mkdir_p(sora_build_dir)
Expand Down
11 changes: 6 additions & 5 deletions src/hwenc_jetson/jetson_video_encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,14 @@ int32_t JetsonVideoEncoder::InitEncode(const webrtc::VideoCodec* codec_settings,
RTC_LOG(LS_INFO) << "interLayerPred: "
<< codec_settings->VP9().interLayerPred;
} else if (codec_settings->codecType == webrtc::kVideoCodecAV1) {
absl::string_view scalability_mode = codec_settings->ScalabilityMode();
if (scalability_mode.empty()) {
auto scalability_mode = codec_settings->GetScalabilityMode();
if (!scalability_mode) {
RTC_LOG(LS_WARNING) << "Scalability mode is not set, using 'L1T1'.";
scalability_mode = "L1T1";
scalability_mode = webrtc::ScalabilityMode::kL1T1;
}
RTC_LOG(LS_INFO) << "InitEncode scalability_mode:" << scalability_mode;
svc_controller_ = webrtc::CreateScalabilityStructure(scalability_mode);
RTC_LOG(LS_INFO) << "InitEncode scalability_mode:"
<< (int)*scalability_mode;
svc_controller_ = webrtc::CreateScalabilityStructure(*scalability_mode);
}
framerate_ = codec_settings->maxFramerate;

Expand Down
11 changes: 7 additions & 4 deletions src/session_description.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ void SessionDescription::SetOffer(webrtc::PeerConnectionInterface* pc,
return;
}
pc->SetRemoteDescription(SetSessionDescriptionThunk::Create(
std::move(on_success), std::move(on_failure)),
std::move(on_success), std::move(on_failure))
.get(),
session_description.release());
}

Expand All @@ -86,13 +87,14 @@ void SessionDescription::CreateAnswer(webrtc::PeerConnectionInterface* pc,
desc->ToString(&sdp);
RTC_LOG(LS_INFO) << "Created session description : " << sdp;
rpc->SetLocalDescription(
SetSessionDescriptionThunk::Create(nullptr, nullptr), desc);
SetSessionDescriptionThunk::Create(nullptr, nullptr).get(), desc);
if (on_success) {
on_success(desc);
}
};
rpc->CreateAnswer(CreateSessionDescriptionThunk::Create(
std::move(with_set_local_desc), std::move(on_failure)),
std::move(with_set_local_desc), std::move(on_failure))
.get(),
webrtc::PeerConnectionInterface::RTCOfferAnswerOptions());
}

Expand All @@ -113,7 +115,8 @@ void SessionDescription::SetAnswer(webrtc::PeerConnectionInterface* pc,
return;
}
pc->SetRemoteDescription(SetSessionDescriptionThunk::Create(
std::move(on_success), std::move(on_failure)),
std::move(on_success), std::move(on_failure))
.get(),
session_description.release());
}

Expand Down
76 changes: 42 additions & 34 deletions src/sora_signaling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ void SoraSignaling::OnRead(boost::system::error_code ec,
const std::string sdp = m.at("sdp").as_string().c_str();

SessionDescription::SetOffer(
pc_, sdp,
pc_.get(), sdp,
[self = shared_from_this(), m]() {
boost::asio::post(*self->config_.io_context, [self, m]() {
if (self->state_ != State::Connected) {
Expand Down Expand Up @@ -861,7 +861,7 @@ void SoraSignaling::OnRead(boost::system::error_code ec,
}

SessionDescription::CreateAnswer(
self->pc_,
self->pc_.get(),
[self](webrtc::SessionDescriptionInterface* desc) {
std::string sdp;
desc->ToString(&sdp);
Expand Down Expand Up @@ -889,7 +889,7 @@ void SoraSignaling::OnRead(boost::system::error_code ec,
std::string answer_type = type == "update" ? "update" : "re-answer";
const std::string sdp = m.at("sdp").as_string().c_str();
SessionDescription::SetOffer(
pc_, sdp,
pc_.get(), sdp,
[self = shared_from_this(), type, answer_type]() {
boost::asio::post(*self->config_.io_context, [self, type,
answer_type]() {
Expand All @@ -903,7 +903,7 @@ void SoraSignaling::OnRead(boost::system::error_code ec,
}

SessionDescription::CreateAnswer(
self->pc_,
self->pc_.get(),
[self, answer_type](webrtc::SessionDescriptionInterface* desc) {
std::string sdp;
desc->ToString(&sdp);
Expand Down Expand Up @@ -936,15 +936,18 @@ void SoraSignaling::OnRead(boost::system::error_code ec,
} else if (type == "ping") {
auto it = m.as_object().find("stats");
if (it != m.as_object().end() && it->value().as_bool()) {
pc_->GetStats(RTCStatsCallback::Create(
[self = shared_from_this()](
const rtc::scoped_refptr<const webrtc::RTCStatsReport>& report) {
if (self->state_ != State::Connected) {
return;
}
pc_->GetStats(
RTCStatsCallback::Create(
[self = shared_from_this()](
const rtc::scoped_refptr<const webrtc::RTCStatsReport>&
report) {
if (self->state_ != State::Connected) {
return;
}

self->DoSendPong(report);
}));
self->DoSendPong(report);
})
.get());
} else {
DoSendPong();
}
Expand Down Expand Up @@ -1287,22 +1290,24 @@ void SoraSignaling::OnIceCandidateError(const std::string& address,

void SoraSignaling::OnTrack(
rtc::scoped_refptr<webrtc::RtpTransceiverInterface> transceiver) {
boost::asio::post([self = shared_from_this(), transceiver]() {
auto ob = self->config_.observer.lock();
if (ob != nullptr) {
ob->OnTrack(transceiver);
}
});
boost::asio::post(*config_.io_context,
[self = shared_from_this(), transceiver]() {
auto ob = self->config_.observer.lock();
if (ob != nullptr) {
ob->OnTrack(transceiver);
}
});
}

void SoraSignaling::OnRemoveTrack(
rtc::scoped_refptr<webrtc::RtpReceiverInterface> receiver) {
boost::asio::post([self = shared_from_this(), receiver]() {
auto ob = self->config_.observer.lock();
if (ob != nullptr) {
ob->OnRemoveTrack(receiver);
}
});
boost::asio::post(*config_.io_context,
[self = shared_from_this(), receiver]() {
auto ob = self->config_.observer.lock();
if (ob != nullptr) {
ob->OnRemoveTrack(receiver);
}
});
}

// -----------------------------
Expand Down Expand Up @@ -1356,7 +1361,7 @@ void SoraSignaling::OnMessage(
if (type == "re-offer") {
const std::string sdp = json.at("sdp").as_string().c_str();
SessionDescription::SetOffer(
pc_, sdp,
pc_.get(), sdp,
[self = shared_from_this()]() {
boost::asio::post(*self->config_.io_context, [self]() {
if (self->state_ != State::Connected) {
Expand All @@ -1369,7 +1374,7 @@ void SoraSignaling::OnMessage(
}

SessionDescription::CreateAnswer(
self->pc_,
self->pc_.get(),
[self](webrtc::SessionDescriptionInterface* desc) {
std::string sdp;
desc->ToString(&sdp);
Expand All @@ -1391,14 +1396,17 @@ void SoraSignaling::OnMessage(
}

if (label == "stats") {
pc_->GetStats(RTCStatsCallback::Create(
[self = shared_from_this()](
const rtc::scoped_refptr<const webrtc::RTCStatsReport>& report) {
if (self->state_ != State::Connected) {
return;
}
self->DoSendPong(report);
}));
pc_->GetStats(
RTCStatsCallback::Create(
[self = shared_from_this()](
const rtc::scoped_refptr<const webrtc::RTCStatsReport>&
report) {
if (self->state_ != State::Connected) {
return;
}
self->DoSendPong(report);
})
.get());
return;
}

Expand Down
6 changes: 4 additions & 2 deletions test/connect_disconnect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ class SoraClient : public std::enable_shared_from_this<SoraClient>,
std::string audio_track_id = rtc::CreateRandomString(16);
std::string video_track_id = rtc::CreateRandomString(16);
audio_track_ = factory()->CreateAudioTrack(
audio_track_id, factory()->CreateAudioSource(cricket::AudioOptions()));
video_track_ = factory()->CreateVideoTrack(video_track_id, video_source_);
audio_track_id,
factory()->CreateAudioSource(cricket::AudioOptions()).get());
video_track_ =
factory()->CreateVideoTrack(video_track_id, video_source_.get());

ioc_.reset(new boost::asio::io_context(1));

Expand Down
6 changes: 4 additions & 2 deletions test/hello.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ void HelloSora::Run() {
std::string audio_track_id = rtc::CreateRandomString(16);
std::string video_track_id = rtc::CreateRandomString(16);
audio_track_ = factory()->CreateAudioTrack(
audio_track_id, factory()->CreateAudioSource(cricket::AudioOptions()));
video_track_ = factory()->CreateVideoTrack(video_track_id, video_source_);
audio_track_id,
factory()->CreateAudioSource(cricket::AudioOptions()).get());
video_track_ =
factory()->CreateVideoTrack(video_track_id, video_source_.get());

ioc_.reset(new boost::asio::io_context(1));

Expand Down

0 comments on commit fdde222

Please sign in to comment.