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

libwebrtc を m124.6367.3.1 にあげる #98

Merged
merged 17 commits into from May 13, 2024

Conversation

enm10k
Copy link
Contributor

@enm10k enm10k commented May 7, 2024

変更内容

libwebrtc を m124 に更新しました

残作業

  • README.md を書く

@enm10k enm10k force-pushed the feature/update-libwebrtc-to-m124 branch from b927602 to 4861e13 Compare May 7, 2024 09:46
@enm10k enm10k force-pushed the feature/update-libwebrtc-to-m124 branch from 1e78ecf to 01ad4ff Compare May 7, 2024 11:03
@enm10k enm10k force-pushed the feature/update-libwebrtc-to-m124 branch from 477ae4c to 7061b78 Compare May 7, 2024 12:20
@enm10k enm10k force-pushed the feature/update-libwebrtc-to-m124 branch from 7061b78 to cac00ea Compare May 8, 2024 01:48
@enm10k enm10k marked this pull request as ready for review May 8, 2024 05:21
@enm10k enm10k requested a review from melpon May 8, 2024 05:21
Comment on lines 17 to 18
// TODO(enm10k): environment を外部から設定できるようにする
webrtc::ConnectionContext::Create(webrtc::CreateEnvironment(),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@melpon
既存の API を維持しつつ、新しい API を追加して webrtc::Environment を外部から渡せるようにしたかったのですが、上手くいきませんでした
良い対応方法があればアドバイスをいただきたいです

Copy link
Contributor

Choose a reason for hiding this comment

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

これってそもそも複数作ったらいけないんですかね?いろんな場所で webrtc::CreateEnvironment() して動くならそれで良さそうな気も

Copy link
Contributor Author

Choose a reason for hiding this comment

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

これってそもそも複数作ったらいけないんですかね?

自信が無いですが、クラスによっては? 複数作っても問題なさそうです

いろんな場所で webrtc::CreateEnvironment() して動くならそれで良さそうな気も

Sora C++ SDK の内部でで webrtc::CreateEnvironment() するのでも動くはずです
最近 libwebrtc の色んなクラスが webrtc::Environment を引数にとるようになってきているので、将来的には外部から渡せた方が良いのかなと思っていますが、本当にそうなってからの対応で良いのかもしれませんね

Copy link
Contributor Author

Choose a reason for hiding this comment

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

... 将来的には外部から渡せた方が良いのかなと思っています

上記の部分について補足をすると、現在の webrtc::Environment のメンバーを見る限り、 field trials を Sora C++ SDK のユーザーが設定したい場合を除いて、 webrtc::Environment を外部から受け取る必要はなさそうです
参照: https://source.chromium.org/chromium/chromium/src/+/main:third_party/webrtc/api/environment/environment.h;l=118-123;drc=db329edf40185945b3ead6fccaf0c2ce780c72b9

@@ -84,6 +89,7 @@ class SoraClientContext {
std::unique_ptr<rtc::Thread> signaling_thread_;
rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> factory_;
rtc::scoped_refptr<webrtc::ConnectionContext> connection_context_;
std::shared_ptr<webrtc::Environment> env_;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@melpon
(webrtc::Environement を引数にとらない) 既存の API を維持しようとしたところ、ライフタイムの問題が発生したため、 webrtc::Environment をこのクラスで保持しています
実装方針として問題ないか相談したいです

Copy link
Contributor

Choose a reason for hiding this comment

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

shared_ptr にする必要は無さそう

@@ -84,6 +89,7 @@ class SoraClientContext {
std::unique_ptr<rtc::Thread> signaling_thread_;
rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> factory_;
rtc::scoped_refptr<webrtc::ConnectionContext> connection_context_;
std::shared_ptr<webrtc::Environment> env_;
Copy link
Contributor

Choose a reason for hiding this comment

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

shared_ptr にする必要は無さそう

static std::shared_ptr<SoraClientContext> Create(
const SoraClientContextConfig& config,
webrtc::Environment& env);

Copy link
Contributor

Choose a reason for hiding this comment

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

Create に引数追加しなくても、SoraClientContextConfig に webrtc::Environment 入れてしまえば良さそうに見えます。

ただ、そもそも外から指定可能にする意味も無さそうに見えるので、SoraClientContext のメンバに env_ 持たせて内部で webrtc::CreateEnvironment すれば良さそう。

Comment on lines 17 to 18
// TODO(enm10k): environment を外部から設定できるようにする
webrtc::ConnectionContext::Create(webrtc::CreateEnvironment(),
Copy link
Contributor

Choose a reason for hiding this comment

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

これってそもそも複数作ったらいけないんですかね?いろんな場所で webrtc::CreateEnvironment() して動くならそれで良さそうな気も

std::shared_ptr<CudaContext> cuda_context = nullptr,
void* env = nullptr);
void* jni_env = nullptr);
Copy link
Contributor

Choose a reason for hiding this comment

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

1番目に引数を追加すると破壊的変更になるので、ここらは内部で webrtc::CreateEnvironment を呼んで生成するか、一番うしろに引数を追加してデフォルトを webrtc::CreateEnvironment にしないといけないですね

@enm10k enm10k force-pushed the feature/update-libwebrtc-to-m124 branch from 95bd6d4 to 9d5eb9b Compare May 10, 2024 06:28
@enm10k enm10k force-pushed the feature/update-libwebrtc-to-m124 branch from f263614 to ecec7db Compare May 10, 2024 07:24
@enm10k
Copy link
Contributor Author

enm10k commented May 10, 2024

@melpon
修正したので再度ご確認いただきたいです

以下の理由で webrtc::Environment を引き回すのを止めました

  • 最終的に webrtc::CreateEnvironment を実行する回数が (ほとんど) 変わらない
  • webrtc::Environment を引き回そうとすると変更箇所が多くなるので、本当に必要になるまで保留したい

SoraVideoDecoderFactoryConfig config;
config.decoders.push_back(VideoDecoderConfig(
webrtc::kVideoCodecVP8,
[](auto format) { return webrtc::VP8Decoder::Create(); }));
[&env](auto format) { return webrtc::CreateVp8Decoder(env); }));
Copy link
Contributor

Choose a reason for hiding this comment

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

参照を渡すのは未定義動作なので env を渡して下さい。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

2ae98b7 で修正しました

return factory->CreateVideoDecoder(format);
};
create_video_decoder = [factory = enc.factory.get(),
&env](const webrtc::SdpVideoFormat& format) {
Copy link
Contributor

Choose a reason for hiding this comment

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

参照でも動作するとは思いますけど、参照にする理由もないので env にして下さい。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

2ae98b7 で修正しました

CHANGES.md Outdated
@@ -11,14 +11,15 @@

## develop

- [CHANGE] libwebrtc を m124.6367.3.1 にあげる
- 継承元のクラスの変更に追従するため、 SoraVideoDecoderFactory の初期化に利用する関数を CreateVideoDecoder から Create に変更
Copy link
Contributor

Choose a reason for hiding this comment

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

CHANGE なのはこの部分だけで、他の部分は違うと思うので、分けたほうが良いです

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fdb7947 で対応しました

WEBRTC_BUILD_VERSION=m123.6312.3.5
BOOST_VERSION=1.85.0
WEBRTC_BUILD_VERSION=m124.6367.3.1
BOOST_VERSION=1.84.0
Copy link
Contributor

Choose a reason for hiding this comment

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

Boost のバージョンが下がってる…?

Copy link
Contributor Author

@enm10k enm10k May 10, 2024

Choose a reason for hiding this comment

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

こちらですが、現在 Sora C++ SDK でリリースされている最新の Boost のバージョンが 1.84.0 なため、 --sora-dir . を指定しない場合ビルドが落ちるようです (= develop のsサンプル BOOST_VERSION を誤ってあげてしまっている)

この PR のマージにもう少し時間がかかるようであれば、 develop ブランチを直接修正します

Copy link
Member

Choose a reason for hiding this comment

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

1fa19e0

あやまってあげてしまってるってのがよくわからんのだが。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

サンプルのビルド時は Sora C++ SDK のリリースに含まれる Boost のバイナリを取得してビルドする挙動がデフォルトとなっています。
そのため、 SDK とサンプルの Boost のバージョンを同時に上げられないようです。
(SDK の Boost のバージョンを上げてリリースした後、サンプルの Boost のバージョンをあげる必要がある)

0997648 でサンプルの BOOST_VERSION を 1.84.0 に戻しました

@enm10k
Copy link
Contributor Author

enm10k commented May 10, 2024

@melpon 指摘いただいた箇所を修正しました

@miosakuma miosakuma requested a review from melpon May 13, 2024 06:56
Copy link
Contributor

@melpon melpon left a comment

Choose a reason for hiding this comment

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

よさそう

@enm10k
Copy link
Contributor Author

enm10k commented May 13, 2024

ありがとうございます。
マージします。

@enm10k enm10k merged commit ac936f5 into develop May 13, 2024
9 checks passed
@enm10k enm10k deleted the feature/update-libwebrtc-to-m124 branch May 13, 2024 07:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants