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

FBS: WIP, scope notifications #1162

Draft
wants to merge 61 commits into
base: v3
Choose a base branch
from
Draft

FBS: WIP, scope notifications #1162

wants to merge 61 commits into from

Conversation

jmillan
Copy link
Member

@jmillan jmillan commented Sep 20, 2023

Scope notifications to the class to which they are being received.

This adds a level of indirection to the overall message but enhances the design of the flatbuffer types and allows exhausing the 'switch' statements in the processing blocks.

jmillan and others added 30 commits April 18, 2023 12:38
# Conflicts:
#	worker/Makefile
# Conflicts:
#	worker/src/RTC/RtpStream.cpp
# Conflicts:
#	.github/workflows/mediasoup-node.yaml
#	.gitignore
#	CHANGELOG.md
#	npm-scripts.js
#	worker/src/lib.cpp
# Conflicts:
#	CHANGELOG.md
#	npm-scripts.mjs
#	package.json
# Conflicts:
#	npm-scripts.mjs
Already thown by flatbuffers.
# Conflicts:
#	CHANGELOG.md
# Conflicts:
#	CHANGELOG.md
# Conflicts:
#	CHANGELOG.md
# Conflicts:
#	worker/src/RTC/RtpStreamRecv.cpp
And enable 'cargo test' workflow in GH actions.
ibc and others added 23 commits August 8, 2023 17:11
# Conflicts:
#	CHANGELOG.md
#	node/src/Router.ts
# Conflicts:
#	CHANGELOG.md
# Conflicts:
#	CHANGELOG.md
# Conflicts:
#	CHANGELOG.md
As Nazar said, for now the process is manual:

1. In `rust` directory run this: `planus rust -o src/fbs.rs ../worker/fbs/*`
2. Then revert some of the changes at the top of the file to make sure it re-exports things the same way and suppresses clippy warnings in there.
3. For ^ to work you might need to install it first with `cargo install planus-cli` (this will download, compile and install binary in Cargo's directory).
fbs: FBS WebRtcTransport

---------

Co-authored-by: Iñaki Baz Castillo <ibc@aliax.net>
Rust: port transport methods to FBS
Rust: port transport notifications to FBS
* FBS: normalize FBS types

* FBS: format schemas

* FBS: type for RtpHeaderExtensionUri (#1161)
Scope notifications to the class to which they are being received.

This adds a level of indirection to the overall message but enhances
the design of the flatbuffer types and allows exhausing the 'switch'
statements in the processing blocks.
Copy link
Member Author

@jmillan jmillan left a comment

Choose a reason for hiding this comment

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

@ibc, @nazar-pc, this is a WIP where we are scoping the notifications to each corresponding class. It adds a level of indirection to the overall message but IMHO it's worth it.

Similarly will be done with Request/Responses. Please Let me know your opinions.

let tuple_fbs = transport::Tuple::try_from(body.tuple().unwrap()).unwrap();
let tuple = TransportTuple::from_fbs(&tuple_fbs);
match notification {
plain_transport::Notification::Tuple(notification) => {
Copy link
Member Author

Choose a reason for hiding this comment

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

Switch cases only contain the specific PlainTransport Notification.

};

// Get the Notification instance.
let notification = notification_wrapper
Copy link
Member Author

Choose a reason for hiding this comment

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

Get the PlainTransport Notification out of the wrapper.

@@ -55,6 +55,7 @@ union Body {
DataProducer_SendNotification: FBS.DataProducer.SendNotification,

// Notifications from worker.
PlainTransport: FBS.PlainTransport.NotificationWrapper,
Copy link
Member Author

Choose a reason for hiding this comment

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

This type (Notification::Body) will only have the respective namespaces (PlainTransport, DirectTransport, Producer, Consumer, etc), not the specific notifications anymore.

@@ -46,6 +46,17 @@ table GetStatsResponse {

// Notifications from Worker.

union Notification {
Copy link
Member Author

Choose a reason for hiding this comment

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

PlainTransort Notification type.

Trace: FBS.Transport.TraceNotification,
}

table NotificationWrapper {
Copy link
Member Author

@jmillan jmillan Sep 20, 2023

Choose a reason for hiding this comment

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

This wrapper is needed since Notification, which is a union cannot be used by itself, it needs to be contained within a table.

@@ -1188,11 +1188,17 @@ namespace RTC
auto notification = FBS::PlainTransport::CreateTupleNotification(
this->shared->channelNotifier->GetBufferBuilder(), tuple);

auto notificationWrapper = FBS::PlainTransport::CreateNotificationWrapper(
Copy link
Member Author

Choose a reason for hiding this comment

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

Wrap Notification into NotificationWrapper.

@ibc
Copy link
Member

ibc commented Sep 20, 2023

I like it.

Copy link
Collaborator

@nazar-pc nazar-pc left a comment

Choose a reason for hiding this comment

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

Overall makes sense

Comment on lines +668 to +669
.try_into()
.unwrap();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is try_into needed here? Reading just on GitHub this looks a bit confusing.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is getting a Notification object out a NotificationRef. Otherwise each field in NotificationRef is accessed via a method with the field name, which returns a result with the value. IMHO it's too cluttered.

Copy link
Member Author

Choose a reason for hiding this comment

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

NOTE: We will finally use NotificationRef instead as noted here

@jmillan jmillan mentioned this pull request Oct 25, 2023
7 tasks
Base automatically changed from flatbuffers to v3 November 8, 2023 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants