Skip to content

[RTC-435] Add tracks and their metadata#141

Merged
roznawsk merged 22 commits intomainfrom
RTC-435-rest-track-metadata
Feb 7, 2024
Merged

[RTC-435] Add tracks and their metadata#141
roznawsk merged 22 commits intomainfrom
RTC-435-rest-track-metadata

Conversation

@roznawsk
Copy link
Copy Markdown
Member

@roznawsk roznawsk commented Jan 16, 2024

Check out PR in protos:
#141

Acknowledging the stipulations set forth:

  • I hereby confirm that a Pull Request involving updates to the Software Development Kit (SDK) has been smoothly merged, currently awaits processing, or is otherwise deemed unnecessary in this context.
  • [ x ] I also affirm that another Pull Request, specifically addressing updates to the documentation body (commonly referred to as 'docs'), has either been successfully incorporated, is in the process of review, or is considered superfluous under the prevailing circumstances.

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 16, 2024

Codecov Report

Merging #141 (ff8556a) into main (8f6e1ca) will decrease coverage by 1.13%.
The diff coverage is 76.41%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #141      +/-   ##
==========================================
- Coverage   87.77%   86.65%   -1.13%     
==========================================
  Files          62       64       +2     
  Lines        1137     1221      +84     
==========================================
+ Hits          998     1058      +60     
- Misses        139      163      +24     
Files Coverage Δ
lib/jellyfish/component.ex 100.00% <ø> (ø)
lib/jellyfish/peer.ex 85.71% <ø> (ø)
lib/jellyfish/peer/webrtc.ex 48.27% <ø> (ø)
lib/jellyfish/room_service.ex 86.30% <ø> (-0.19%) ⬇️
lib/jellyfish/track.ex 100.00% <100.00%> (ø)
lib/jellyfish/webhook_notifier.ex 78.94% <ø> (ø)
lib/jellyfish_web/api_spec/component/file.ex 100.00% <ø> (ø)
lib/jellyfish_web/api_spec/component/hls.ex 100.00% <ø> (ø)
lib/jellyfish_web/api_spec/component/rtsp.ex 100.00% <ø> (ø)
lib/jellyfish_web/api_spec/peer.ex 100.00% <100.00%> (ø)
... and 8 more

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8f6e1ca...ff8556a. Read the comment docs.

@roznawsk roznawsk changed the title Add tracks to state [RTC-435] Add tracks and their metadata Jan 16, 2024
@roznawsk roznawsk marked this pull request as ready for review January 16, 2024 13:00
@roznawsk roznawsk requested review from Karolk99 and Rados13 January 16, 2024 13:00
Comment thread lib/jellyfish/room.ex Outdated
Comment thread lib/jellyfish/room.ex Outdated
Comment thread lib/jellyfish/room.ex
Comment thread lib/jellyfish/room.ex
Comment thread lib/jellyfish_web/api_spec/track.ex Outdated
Copy link
Copy Markdown
Contributor

@Karolk99 Karolk99 left a comment

Choose a reason for hiding this comment

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

I believe there is no necessity to inform the user about the internal state of the engine, as I can't identify any practical use or reason for it. However, when it comes to peers, the situation is different. Tracks represent the connection between the client and Jellyfish; understanding the quantity and types of tracks added by the client is useful.

Comment thread .redocly.lint-ignore.yaml
openapi.yaml:
no-empty-servers:
- '#/servers'
spec:
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Note: add lint rule, allowing for nullable field without type specified (metadata can have any type)

handshake_opts: handshake_options,
filter_codecs: filter_codecs,
log_metadata: [peer_id: options.peer_id],
trace_context: nil,
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

note: option removed in new WebRTC endpoint

webhook_url,
Jason.encode!(%{notification: notification}),
[{"Content-Type", "application/json"}]
notification,
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

per this thread we must set encoding to binary

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remember that it will require changes in SDKs.

Copy link
Copy Markdown
Contributor

@Rados13 Rados13 Feb 1, 2024

Choose a reason for hiding this comment

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

Btw the more recent thread informs that some companies use different content-type, e.g.: Cloudflare uses x-protobuf.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So in the end you decided to use protobuf instead of x-protobuf or is it a typo?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, typo

@roznawsk roznawsk force-pushed the RTC-435-rest-track-metadata branch from 3b1e180 to 356a0f5 Compare January 31, 2024 14:47
@roznawsk roznawsk force-pushed the RTC-435-rest-track-metadata branch from 356a0f5 to 74081f5 Compare January 31, 2024 14:50
Comment thread lib/jellyfish/event.ex Outdated
defp to_proto_encoding(:H264), do: :ENCODING_H264
defp to_proto_encoding(:VP8), do: :ENCODING_VP8
defp to_proto_encoding(:OPUS), do: :ENCODING_OPUS
defp to_proto_encoding(_encoding), do: :ENCODING_UNSPECIFIED
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't we raise an error in a situation like this, as we don't support different types of tracks?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is created from event sent from Rtc Engine, so I guess its better to have track with unknown encoding, than crashing Jellyfish.
Also, as you proposed I will remove the encoding from the Track anyway?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am not sure about that. I think that if a jellyfish doesn't expect something from the engine, it should raise an error. I think it would be more aligned with the BEAM approach, Let it crash.

Comment thread lib/jellyfish/event.ex

defp to_proto_track_type(:video), do: :TRACK_TYPE_VIDEO
defp to_proto_track_type(:audio), do: :TRACK_TYPE_AUDIO
defp to_proto_track_type(_type), do: :TRACK_TYPE_UNSPECIFIED
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As above.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

As above.

Comment thread lib/jellyfish/room.ex
Comment on lines +493 to +497
@impl true
def handle_info(%TrackAdded{endpoint_id: endpoint_id} = track_info, state) do
Logger.error("Unknown endpoint #{endpoint_id} added track #{inspect(track_info)}")
{:noreply, state}
end
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am not sure if the best way of handling the inconsistency of the state of the room is to log information about it and then simply ignore it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think this makes sense actually. I think we could expect this message if we delete Peer while it adds new track - we would receive TrackAdded and then EndpointRemoved messages.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If this is the case, then it shouldn't be an error because we expect that this can sometimes happen. I think we should modify the logic in room.ex, so we would remove endpoints from the state after we receive EndpointRemoved.

Comment thread lib/jellyfish/room.ex Outdated
Comment on lines +506 to +511
nil ->
Logger.warning(
"Unable to update track's metadata - track #{inspect(track_info.track_id)} doesn't exist"
)

{:noreply, state}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Doesn't a situation like that mean that we have some error? How could we receive a notification about a track that doesn't exist? I think we should raise an error here or use update_in instead of get_in.

Comment thread lib/jellyfish/room.ex Outdated
Comment on lines +542 to +545
nil ->
Logger.warning(
"Unable to remove track - track #{inspect(track_info.track_id)} doesn't exist"
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As above.

Comment thread lib/jellyfish/room.ex

@impl true
def handle_info(%TrackRemoved{endpoint_id: endpoint_id} = track_info, state) do
Logger.error("Unknown endpoint #{endpoint_id} removed track #{inspect(track_info)}")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As mentioned in TrackAdded.

webhook_url,
Jason.encode!(%{notification: notification}),
[{"Content-Type", "application/json"}]
notification,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remember that it will require changes in SDKs.

Comment thread test/jellyfish_web/controllers/component/file_component_test.exs Outdated
webhook_url,
Jason.encode!(%{notification: notification}),
[{"Content-Type", "application/json"}]
notification,
Copy link
Copy Markdown
Contributor

@Rados13 Rados13 Feb 1, 2024

Choose a reason for hiding this comment

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

Btw the more recent thread informs that some companies use different content-type, e.g.: Cloudflare uses x-protobuf.

Comment thread test/jellyfish_web/integration/server_notification_test.exs Outdated
Comment thread lib/jellyfish/room.ex Outdated
Comment on lines +506 to +511
nil ->
Logger.warning(
"Unable to update track's metadata - track #{inspect(track_info.track_id)} doesn't exist"
"Metadata updated of an unknown track #{inspect(track_info)}, new track added"
)

{:noreply, state}
Track.from_track_message(track_info)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How can we first receive TrackMetadataUpdated before TrackAdded?

Comment thread lib/jellyfish/room.ex Outdated
Comment on lines 543 to 546
{nil, state} ->
Logger.warning(
"Unable to remove track - track #{inspect(track_info.track_id)} doesn't exist"
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How could we receive TrackRemoved before TrackAdded?

webhook_url,
Jason.encode!(%{notification: notification}),
[{"Content-Type", "application/json"}]
notification,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So in the end you decided to use protobuf instead of x-protobuf or is it a typo?

@roznawsk roznawsk requested a review from Rados13 February 6, 2024 10:47
@roznawsk roznawsk force-pushed the RTC-435-rest-track-metadata branch from 2d988ac to 76ca6c1 Compare February 6, 2024 14:34
Comment on lines +104 to +107
assert %{
type: :TRACK_TYPE_AUDIO,
metadata: "null"
} = track
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Couldn't we merge that with the previous assert?

Comment thread lib/jellyfish/room.ex
{:track_removed, state.id, {:component_id, component_id}, &1}
)
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
track ->
%Track{}=track ->

Copy link
Copy Markdown
Contributor

@Rados13 Rados13 left a comment

Choose a reason for hiding this comment

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

Only OpenAPI need fixes.

@roznawsk roznawsk merged commit 36e1d00 into main Feb 7, 2024
@roznawsk roznawsk deleted the RTC-435-rest-track-metadata branch February 7, 2024 15:20
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.

3 participants