[RTC-435] Add tracks and their metadata#141
Conversation
Codecov Report
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
Continue to review full report in Codecov by Sentry.
|
Karolk99
left a comment
There was a problem hiding this comment.
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.
| openapi.yaml: | ||
| no-empty-servers: | ||
| - '#/servers' | ||
| spec: |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
note: option removed in new WebRTC endpoint
| webhook_url, | ||
| Jason.encode!(%{notification: notification}), | ||
| [{"Content-Type", "application/json"}] | ||
| notification, |
There was a problem hiding this comment.
per this thread we must set encoding to binary
There was a problem hiding this comment.
Remember that it will require changes in SDKs.
There was a problem hiding this comment.
Btw the more recent thread informs that some companies use different content-type, e.g.: Cloudflare uses x-protobuf.
There was a problem hiding this comment.
So in the end you decided to use protobuf instead of x-protobuf or is it a typo?
3b1e180 to
356a0f5
Compare
356a0f5 to
74081f5
Compare
| 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 |
There was a problem hiding this comment.
Shouldn't we raise an error in a situation like this, as we don't support different types of tracks?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
|
|
||
| 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 |
| @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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
| nil -> | ||
| Logger.warning( | ||
| "Unable to update track's metadata - track #{inspect(track_info.track_id)} doesn't exist" | ||
| ) | ||
|
|
||
| {:noreply, state} |
There was a problem hiding this comment.
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.
| nil -> | ||
| Logger.warning( | ||
| "Unable to remove track - track #{inspect(track_info.track_id)} doesn't exist" | ||
| ) |
|
|
||
| @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)}") |
There was a problem hiding this comment.
As mentioned in TrackAdded.
| webhook_url, | ||
| Jason.encode!(%{notification: notification}), | ||
| [{"Content-Type", "application/json"}] | ||
| notification, |
There was a problem hiding this comment.
Remember that it will require changes in SDKs.
| webhook_url, | ||
| Jason.encode!(%{notification: notification}), | ||
| [{"Content-Type", "application/json"}] | ||
| notification, |
There was a problem hiding this comment.
Btw the more recent thread informs that some companies use different content-type, e.g.: Cloudflare uses x-protobuf.
de79057 to
abbddef
Compare
| 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) |
There was a problem hiding this comment.
How can we first receive TrackMetadataUpdated before TrackAdded?
| {nil, state} -> | ||
| Logger.warning( | ||
| "Unable to remove track - track #{inspect(track_info.track_id)} doesn't exist" | ||
| ) |
There was a problem hiding this comment.
How could we receive TrackRemoved before TrackAdded?
| webhook_url, | ||
| Jason.encode!(%{notification: notification}), | ||
| [{"Content-Type", "application/json"}] | ||
| notification, |
There was a problem hiding this comment.
So in the end you decided to use protobuf instead of x-protobuf or is it a typo?
2d988ac to
76ca6c1
Compare
| assert %{ | ||
| type: :TRACK_TYPE_AUDIO, | ||
| metadata: "null" | ||
| } = track |
There was a problem hiding this comment.
Couldn't we merge that with the previous assert?
| {:track_removed, state.id, {:component_id, component_id}, &1} | ||
| ) | ||
| ) | ||
|
|
There was a problem hiding this comment.
| track -> | |
| %Track{}=track -> |
Rados13
left a comment
There was a problem hiding this comment.
Only OpenAPI need fixes.
Check out PR in protos:
#141
Acknowledging the stipulations set forth: