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

マルチ転送フィルターの追加 #108

Open
wants to merge 14 commits into
base: develop
Choose a base branch
from

Conversation

torikizi
Copy link
Contributor

@torikizi torikizi commented Dec 19, 2024

  • 既存の転送フィルターに name / priority を追加
  • マルチ転送フィルターを追加

This pull request introduces several enhancements to the Sora class and related protobuf definitions, primarily focusing on the forwarding filter functionality. The changes add new fields to the ForwardingFilter class and introduce a new ForwardingFilters class to handle multiple filters.

Enhancements to forwarding filter functionality:

  • Sora/Sora.cs: Added Name and Priority fields to the ForwardingFilter class and created a new ForwardingFilters class to manage a list of ForwardingFilter objects. Updated the Config class to include an optional ForwardingFilters property. Enhanced the Connect method to handle the new fields and iterate through multiple filters if provided. [1] [2] [3] [4] [5]

Protobuf updates:

  • proto/sora_conf_internal.proto: Added name and priority fields to the ForwardingFilter message. Introduced a new ForwardingFilters message to encapsulate multiple ForwardingFilter objects. Updated the ConnectConfig message to include the new ForwardingFilters field. [1] [2] [3]

C++ implementation updates:

  • src/sora.cpp: Updated the DoConnect method to handle the new name and priority fields in ForwardingFilter. Added logic to process the new ForwardingFilters message, iterating over multiple filters and setting their respective fields. [1] [2]

@torikizi torikizi changed the title [WIP [WIP] マルチ転送フィルターの追加 Dec 19, 2024
@torikizi torikizi changed the title [WIP] マルチ転送フィルターの追加 マルチ転送フィルターの追加 Dec 19, 2024
@torikizi torikizi requested review from melpon and miosakuma December 19, 2024 07:58
Sora/Sora.cs Outdated
public ForwardingFilter ForwardingFilter;
public ForwardingFilters? ForwardingFilters;
Copy link
Contributor

Choose a reason for hiding this comment

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

public List<ForwardingFilter> ForwardingFilters で良さそう

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/Sora.cs Outdated
var ffs = new SoraConf.Internal.ForwardingFilters();
foreach (var filter in config.ForwardingFilters.Filters)
{
var ff = new SoraConf.Internal.ForwardingFilter();
Copy link
Contributor

Choose a reason for hiding this comment

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

このあたりのロジックは ForwardingFilter に対する処理と共通化できるはず

Copy link
Contributor Author

Choose a reason for hiding this comment

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

c55e160 で共通化しました。

@@ -80,6 +86,7 @@ message ConnectConfig {
string audio_streaming_language_code = 48;
string signaling_notify_metadata = 49;
optional ForwardingFilter forwarding_filter = 51;
optional ForwardingFilters forwarding_filters = 52;
Copy link
Contributor

Choose a reason for hiding this comment

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

optional repeated ForwardingFilter forwarding_filters とは書けないんでしたっけ。できないならそのままで良いです。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

書けないようです。ビルドエラーとなりました。

src/sora.cpp Outdated
if (cc.has_forwarding_filters()) {
std::vector<sora::SoraSignalingConfig::ForwardingFilter> filters;
for (const auto& filter : cc.forwarding_filters.filters) {
sora::SoraSignalingConfig::ForwardingFilter ff;
Copy link
Contributor

Choose a reason for hiding this comment

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

このあたりのロジックは forwarding_filter に対する処理と共通化できるはず

Copy link
Contributor Author

@torikizi torikizi Dec 20, 2024

Choose a reason for hiding this comment

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

c55e160 にて共通化しました。

Sora/Sora.cs Outdated
@@ -85,7 +86,10 @@ public class Rule
public string? Version;
public string? Metadata;
}

public class ForwardingFilters
Copy link
Contributor

Choose a reason for hiding this comment

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

これはもう不要なはず

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/Sora.cs Outdated
@@ -522,6 +507,48 @@ public void Disconnect()
sora_disconnect(p);
}

private SoraConf.Internal.ForwardingFilter ConvertToInternalFilter(ForwardingFilter filter)
Copy link
Contributor

Choose a reason for hiding this comment

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

forwarding filter で1個の機能なので、ConvertToInternalForwardingFilter の方が良さそう

Copy link
Contributor

Choose a reason for hiding this comment

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

あとこの関数は static で良いはず

Copy link
Contributor Author

Choose a reason for hiding this comment

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

名前の変更と static へ変更しました

Sora/Sora.cs Outdated
cc.SetForwardingFilter(ConvertToInternalFilter(config.ForwardingFilter));
}

if (config.ForwardingFilters != null && config.ForwardingFilters.Count > 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

config.ForwardingFilters.Count == 0 の時に空の SoraConf.Internal.ForwardingFilters を設定しないといけないので、config.ForwardingFilters.Count > 0 の条件は外した方が良いです。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ご指摘の通りに修正しました。

src/sora.cpp Outdated
@@ -761,6 +740,48 @@ bool Sora::InitADM(rtc::scoped_refptr<webrtc::AudioDeviceModule> adm,
return true;
}

sora::SoraSignalingConfig::ForwardingFilter Sora::convertForwardingFilter(
Copy link
Contributor

Choose a reason for hiding this comment

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

  • convertForwardingFilter だと、sora::SoraSignalingConfig::ForwardingFiltersora_conf::internal::ForwardingFilter に変換する関数に読めるので、convertToForwardingFilter の方が良さそう
  • 全体的に関数名は UpperCamelCase で書いてるので ConvertToForwardingFilter にした方が良さそう

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ConvertToForwardingFilter に修正しました

src/sora.h Outdated
@@ -80,6 +80,10 @@ class Sora : public std::enable_shared_from_this<Sora>,
void* GetAndroidApplicationContext(void* env);
static sora_conf::ErrorCode ToErrorCode(sora::SoraSignalingErrorCode ec);

private:
sora::SoraSignalingConfig::ForwardingFilter convertForwardingFilter(
Copy link
Contributor

Choose a reason for hiding this comment

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

この関数は static にできるはず

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cpp の修正と合わせて static に変更しました。

Sora/Sora.cs Outdated
@@ -85,7 +86,7 @@ public class Rule
public string? Version;
public string? Metadata;
}

public List<ForwardingFilter> Filters = new List<ForwardingFilter>();
Copy link
Contributor

Choose a reason for hiding this comment

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

これ要らないですよね…?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

失礼しました。ご指摘の通り不要でした。

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.

よさそう

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants