From 9c800ffefd4462743da7e096e83fb3440d9f15f7 Mon Sep 17 00:00:00 2001 From: Karol Konkol Date: Thu, 21 Nov 2024 18:29:16 +0100 Subject: [PATCH 1/2] Use map instead of repeated --- buf.yaml | 2 +- fishjam/media_events/peer/peer.proto | 29 ++------ fishjam/media_events/server/server.proto | 21 +++--- fishjam/media_events/shared.proto | 16 ----- .../lib/fishjam/media_events/peer/peer.pb.ex | 65 +++++++++-------- .../fishjam/media_events/server/server.pb.ex | 70 +++++++++++++++---- .../lib/fishjam/media_events/shared.pb.ex | 28 -------- 7 files changed, 103 insertions(+), 128 deletions(-) diff --git a/buf.yaml b/buf.yaml index 32841fe..e9779cd 100644 --- a/buf.yaml +++ b/buf.yaml @@ -7,7 +7,7 @@ build: - fishjam_protos lint: use: - - DEFAULT + - STANDARD ignore_only: PACKAGE_VERSION_SUFFIX: - fishjam diff --git a/fishjam/media_events/peer/peer.proto b/fishjam/media_events/peer/peer.proto index e577f5d..7a8f0d1 100644 --- a/fishjam/media_events/peer/peer.proto +++ b/fishjam/media_events/peer/peer.proto @@ -6,28 +6,11 @@ import "fishjam/media_events/shared.proto"; // Defines any type of message sent from Peer to Membrane RTC Engine message MediaEvent { - // SCHEMAS - message VariantBitrate { - media_events.Variant variant = 1; - int32 bitrate = 2; - } - - message TrackIdToMetadata { - string track_id = 1; - media_events.Metadata metadata = 2; - } - - message TrackIdToBitrates { - oneof tracks { - TrackBitrate track_bitrate = 1; - } - } - // MEDIA EVENTS // Sent when a peer wants to join WebRTC Endpoint. message Connect { - media_events.Metadata metadata = 1; + string metadata_json = 1; } // Sent when a peer disconnects from WebRTC Endpoint. @@ -35,13 +18,13 @@ message MediaEvent { // Sent when a peer wants to update its metadata message UpdateEndpointMetadata { - media_events.Metadata metadata = 1; + string metadata_json = 1; } // Sent when a peer wants to update its track's metadata message UpdateTrackMetadata { string track_id = 1; - media_events.Metadata metadata = 2; + string metadata_json = 2; } // Sent when peer wants to renegatiate connection due to adding a track or removing a track @@ -52,9 +35,9 @@ message MediaEvent { // The "mid" is an identifier used to associate an RTP packet with an MLine from the SDP offer/answer. message SdpOffer { string sdp_offer = 1; - repeated TrackIdToMetadata track_id_to_metadata = 2; - repeated TrackIdToBitrates track_id_to_bitrates = 3; - repeated media_events.MidToTrackId mid_to_track_id = 4; + map track_id_to_metadata_json = 2; + map track_id_to_bitrates = 3; + map mid_to_track_id = 4; } // Sent when Peer wants to update its track's bitrate diff --git a/fishjam/media_events/server/server.proto b/fishjam/media_events/server/server.proto index 5a666a7..a06e590 100644 --- a/fishjam/media_events/server/server.proto +++ b/fishjam/media_events/server/server.proto @@ -7,16 +7,11 @@ import "fishjam/media_events/shared.proto"; // Defines any type of message sent from Membrane RTC Engine to Peer message MediaEvent { // SCHEMAS - message Track { - string track_id = 1; - media_events.Metadata metadata = 2; - } message Endpoint { - string endpoint_id = 1; string endpoint_type = 2; - media_events.Metadata metadata = 3; - repeated Track tracks = 4; + string metadata_json = 3; + map track_id_to_metadata_json = 4; } message IceServer { @@ -30,20 +25,20 @@ message MediaEvent { // Sent when metadata of one of the endpoints was updated message EndpointUpdated { string endpoint_id = 1; - media_events.Metadata metadata = 2; + string metadata_json = 2; } // Sent when metadata of one of the tracks was updated message TrackUpdated { string endpoint_id = 1; string track_id = 2; - media_events.Metadata metadata = 3; + string metadata_json = 3; } // Sent to informs that one of the peers has added one or more tracks. message TracksAdded { string endpoint_id = 1; - repeated Track tracks = 2; + map track_id_to_metadata_json = 2; } // Sent to informs that one of the peers has removed one or more tracks. @@ -55,13 +50,13 @@ message MediaEvent { // Sent to all peers in the room after a new endpoint was added. message EndpointAdded { string endpoint_id = 1; - media_events.Metadata metadata = 2; + string metadata_json = 2; } // Sent to the peer after connecting to the WebRTC Endpoint. message Connected { string endpoint_id = 1; - repeated Endpoint endpoints = 2; + map endpoints_id_to_endpoint = 2; repeated IceServer ice_servers = 3; } @@ -88,7 +83,7 @@ message MediaEvent { // Sent after receiving `SdpOffer` from Peer message SdpAnswer { string sdp_answer = 1; - repeated media_events.MidToTrackId mid_to_track_id = 2; + map mid_to_track_id = 2; } // Sent to inform that the track denoted by `trackId` has changed their voice actiivty diff --git a/fishjam/media_events/shared.proto b/fishjam/media_events/shared.proto index b66496f..a56f12a 100644 --- a/fishjam/media_events/shared.proto +++ b/fishjam/media_events/shared.proto @@ -2,22 +2,6 @@ syntax = "proto3"; package fishjam.media_events; -enum Variant { - VARIANT_UNSPECIFIED = 0; - VARIANT_LOW = 1; - VARIANT_MEDIUM = 2; - VARIANT_HIGH = 3; -} - -message Metadata { - string json = 1; -} - -message MidToTrackId { - string mid = 1; - string track_id = 2; -} - // Contains information about an ICE candidate which will be sent to the peer/server message Candidate { string candidate = 1; diff --git a/fishjam_protos/lib/fishjam/media_events/peer/peer.pb.ex b/fishjam_protos/lib/fishjam/media_events/peer/peer.pb.ex index ce2b0d7..2c5328c 100644 --- a/fishjam_protos/lib/fishjam/media_events/peer/peer.pb.ex +++ b/fishjam_protos/lib/fishjam/media_events/peer/peer.pb.ex @@ -1,69 +1,65 @@ -defmodule Fishjam.MediaEvents.Peer.MediaEvent.VariantBitrate do +defmodule Fishjam.MediaEvents.Peer.MediaEvent.Connect do @moduledoc false use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" - field :variant, 1, type: Fishjam.MediaEvents.Variant, enum: true - field :bitrate, 2, type: :int32 + field :metadata_json, 1, type: :string, json_name: "metadataJson" end -defmodule Fishjam.MediaEvents.Peer.MediaEvent.TrackIdToMetadata do +defmodule Fishjam.MediaEvents.Peer.MediaEvent.Disconnect do @moduledoc false use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" - - field :track_id, 1, type: :string, json_name: "trackId" - field :metadata, 2, type: Fishjam.MediaEvents.Metadata end -defmodule Fishjam.MediaEvents.Peer.MediaEvent.TrackIdToBitrates do +defmodule Fishjam.MediaEvents.Peer.MediaEvent.UpdateEndpointMetadata do @moduledoc false use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" - oneof :tracks, 0 - - field :track_bitrate, 1, - type: Fishjam.MediaEvents.Peer.MediaEvent.TrackBitrate, - json_name: "trackBitrate", - oneof: 0 + field :metadata_json, 1, type: :string, json_name: "metadataJson" end -defmodule Fishjam.MediaEvents.Peer.MediaEvent.Connect do +defmodule Fishjam.MediaEvents.Peer.MediaEvent.UpdateTrackMetadata do @moduledoc false use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" - field :metadata, 1, type: Fishjam.MediaEvents.Metadata + field :track_id, 1, type: :string, json_name: "trackId" + field :metadata_json, 2, type: :string, json_name: "metadataJson" end -defmodule Fishjam.MediaEvents.Peer.MediaEvent.Disconnect do +defmodule Fishjam.MediaEvents.Peer.MediaEvent.RenegotiateTracks do @moduledoc false use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" end -defmodule Fishjam.MediaEvents.Peer.MediaEvent.UpdateEndpointMetadata do +defmodule Fishjam.MediaEvents.Peer.MediaEvent.SdpOffer.TrackIdToMetadataJsonEntry do @moduledoc false - use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + use Protobuf, map: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" - field :metadata, 1, type: Fishjam.MediaEvents.Metadata + field :key, 1, type: :string + field :value, 2, type: :string end -defmodule Fishjam.MediaEvents.Peer.MediaEvent.UpdateTrackMetadata do +defmodule Fishjam.MediaEvents.Peer.MediaEvent.SdpOffer.TrackIdToBitratesEntry do @moduledoc false - use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + use Protobuf, map: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" - field :track_id, 1, type: :string, json_name: "trackId" - field :metadata, 2, type: Fishjam.MediaEvents.Metadata + field :key, 1, type: :string + field :value, 2, type: Fishjam.MediaEvents.Peer.MediaEvent.TrackBitrate end -defmodule Fishjam.MediaEvents.Peer.MediaEvent.RenegotiateTracks do +defmodule Fishjam.MediaEvents.Peer.MediaEvent.SdpOffer.MidToTrackIdEntry do @moduledoc false - use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + use Protobuf, map: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field :key, 1, type: :string + field :value, 2, type: :string end defmodule Fishjam.MediaEvents.Peer.MediaEvent.SdpOffer do @@ -73,20 +69,23 @@ defmodule Fishjam.MediaEvents.Peer.MediaEvent.SdpOffer do field :sdp_offer, 1, type: :string, json_name: "sdpOffer" - field :track_id_to_metadata, 2, + field :track_id_to_metadata_json, 2, repeated: true, - type: Fishjam.MediaEvents.Peer.MediaEvent.TrackIdToMetadata, - json_name: "trackIdToMetadata" + type: Fishjam.MediaEvents.Peer.MediaEvent.SdpOffer.TrackIdToMetadataJsonEntry, + json_name: "trackIdToMetadataJson", + map: true field :track_id_to_bitrates, 3, repeated: true, - type: Fishjam.MediaEvents.Peer.MediaEvent.TrackIdToBitrates, - json_name: "trackIdToBitrates" + type: Fishjam.MediaEvents.Peer.MediaEvent.SdpOffer.TrackIdToBitratesEntry, + json_name: "trackIdToBitrates", + map: true field :mid_to_track_id, 4, repeated: true, - type: Fishjam.MediaEvents.MidToTrackId, - json_name: "midToTrackId" + type: Fishjam.MediaEvents.Peer.MediaEvent.SdpOffer.MidToTrackIdEntry, + json_name: "midToTrackId", + map: true end defmodule Fishjam.MediaEvents.Peer.MediaEvent.TrackBitrate do diff --git a/fishjam_protos/lib/fishjam/media_events/server/server.pb.ex b/fishjam_protos/lib/fishjam/media_events/server/server.pb.ex index 237006e..09ab256 100644 --- a/fishjam_protos/lib/fishjam/media_events/server/server.pb.ex +++ b/fishjam_protos/lib/fishjam/media_events/server/server.pb.ex @@ -8,13 +8,13 @@ defmodule Fishjam.MediaEvents.Server.MediaEvent.VadNotification.Status do field :STATUS_SPEECH, 2 end -defmodule Fishjam.MediaEvents.Server.MediaEvent.Track do +defmodule Fishjam.MediaEvents.Server.MediaEvent.Endpoint.TrackIdToMetadataJsonEntry do @moduledoc false - use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + use Protobuf, map: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" - field :track_id, 1, type: :string, json_name: "trackId" - field :metadata, 2, type: Fishjam.MediaEvents.Metadata + field :key, 1, type: :string + field :value, 2, type: :string end defmodule Fishjam.MediaEvents.Server.MediaEvent.Endpoint do @@ -22,10 +22,14 @@ defmodule Fishjam.MediaEvents.Server.MediaEvent.Endpoint do use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" - field :endpoint_id, 1, type: :string, json_name: "endpointId" field :endpoint_type, 2, type: :string, json_name: "endpointType" - field :metadata, 3, type: Fishjam.MediaEvents.Metadata - field :tracks, 4, repeated: true, type: Fishjam.MediaEvents.Server.MediaEvent.Track + field :metadata_json, 3, type: :string, json_name: "metadataJson" + + field :track_id_to_metadata_json, 4, + repeated: true, + type: Fishjam.MediaEvents.Server.MediaEvent.Endpoint.TrackIdToMetadataJsonEntry, + json_name: "trackIdToMetadataJson", + map: true end defmodule Fishjam.MediaEvents.Server.MediaEvent.IceServer do @@ -44,7 +48,7 @@ defmodule Fishjam.MediaEvents.Server.MediaEvent.EndpointUpdated do use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" field :endpoint_id, 1, type: :string, json_name: "endpointId" - field :metadata, 2, type: Fishjam.MediaEvents.Metadata + field :metadata_json, 2, type: :string, json_name: "metadataJson" end defmodule Fishjam.MediaEvents.Server.MediaEvent.TrackUpdated do @@ -54,7 +58,16 @@ defmodule Fishjam.MediaEvents.Server.MediaEvent.TrackUpdated do field :endpoint_id, 1, type: :string, json_name: "endpointId" field :track_id, 2, type: :string, json_name: "trackId" - field :metadata, 3, type: Fishjam.MediaEvents.Metadata + field :metadata_json, 3, type: :string, json_name: "metadataJson" +end + +defmodule Fishjam.MediaEvents.Server.MediaEvent.TracksAdded.TrackIdToMetadataJsonEntry do + @moduledoc false + + use Protobuf, map: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field :key, 1, type: :string + field :value, 2, type: :string end defmodule Fishjam.MediaEvents.Server.MediaEvent.TracksAdded do @@ -63,7 +76,12 @@ defmodule Fishjam.MediaEvents.Server.MediaEvent.TracksAdded do use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" field :endpoint_id, 1, type: :string, json_name: "endpointId" - field :tracks, 2, repeated: true, type: Fishjam.MediaEvents.Server.MediaEvent.Track + + field :track_id_to_metadata_json, 2, + repeated: true, + type: Fishjam.MediaEvents.Server.MediaEvent.TracksAdded.TrackIdToMetadataJsonEntry, + json_name: "trackIdToMetadataJson", + map: true end defmodule Fishjam.MediaEvents.Server.MediaEvent.TracksRemoved do @@ -81,7 +99,16 @@ defmodule Fishjam.MediaEvents.Server.MediaEvent.EndpointAdded do use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" field :endpoint_id, 1, type: :string, json_name: "endpointId" - field :metadata, 2, type: Fishjam.MediaEvents.Metadata + field :metadata_json, 2, type: :string, json_name: "metadataJson" +end + +defmodule Fishjam.MediaEvents.Server.MediaEvent.Connected.EndpointsIdToEndpointEntry do + @moduledoc false + + use Protobuf, map: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field :key, 1, type: :string + field :value, 2, type: Fishjam.MediaEvents.Server.MediaEvent.Endpoint end defmodule Fishjam.MediaEvents.Server.MediaEvent.Connected do @@ -90,7 +117,12 @@ defmodule Fishjam.MediaEvents.Server.MediaEvent.Connected do use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" field :endpoint_id, 1, type: :string, json_name: "endpointId" - field :endpoints, 2, repeated: true, type: Fishjam.MediaEvents.Server.MediaEvent.Endpoint + + field :endpoints_id_to_endpoint, 2, + repeated: true, + type: Fishjam.MediaEvents.Server.MediaEvent.Connected.EndpointsIdToEndpointEntry, + json_name: "endpointsIdToEndpoint", + map: true field :ice_servers, 3, repeated: true, @@ -133,6 +165,15 @@ defmodule Fishjam.MediaEvents.Server.MediaEvent.OfferData do json_name: "tracksTypes" end +defmodule Fishjam.MediaEvents.Server.MediaEvent.SdpAnswer.MidToTrackIdEntry do + @moduledoc false + + use Protobuf, map: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field :key, 1, type: :string + field :value, 2, type: :string +end + defmodule Fishjam.MediaEvents.Server.MediaEvent.SdpAnswer do @moduledoc false @@ -142,8 +183,9 @@ defmodule Fishjam.MediaEvents.Server.MediaEvent.SdpAnswer do field :mid_to_track_id, 2, repeated: true, - type: Fishjam.MediaEvents.MidToTrackId, - json_name: "midToTrackId" + type: Fishjam.MediaEvents.Server.MediaEvent.SdpAnswer.MidToTrackIdEntry, + json_name: "midToTrackId", + map: true end defmodule Fishjam.MediaEvents.Server.MediaEvent.VadNotification do diff --git a/fishjam_protos/lib/fishjam/media_events/shared.pb.ex b/fishjam_protos/lib/fishjam/media_events/shared.pb.ex index f0e222d..9323a17 100644 --- a/fishjam_protos/lib/fishjam/media_events/shared.pb.ex +++ b/fishjam_protos/lib/fishjam/media_events/shared.pb.ex @@ -1,31 +1,3 @@ -defmodule Fishjam.MediaEvents.Variant do - @moduledoc false - - use Protobuf, enum: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" - - field :VARIANT_UNSPECIFIED, 0 - field :VARIANT_LOW, 1 - field :VARIANT_MEDIUM, 2 - field :VARIANT_HIGH, 3 -end - -defmodule Fishjam.MediaEvents.Metadata do - @moduledoc false - - use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" - - field :json, 1, type: :string -end - -defmodule Fishjam.MediaEvents.MidToTrackId do - @moduledoc false - - use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" - - field :mid, 1, type: :string - field :track_id, 2, type: :string, json_name: "trackId" -end - defmodule Fishjam.MediaEvents.Candidate do @moduledoc false From f0352afeab2f15927b1a298dd890e26f58157812 Mon Sep 17 00:00:00 2001 From: Karol Konkol Date: Thu, 21 Nov 2024 18:30:39 +0100 Subject: [PATCH 2/2] Update bufbuild --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f4c3316..593d0e3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest name: Protobuf lint container: - image: bufbuild/buf:1.23.1 + image: bufbuild/buf:1.45.0 steps: - name: Checkout the code uses: actions/checkout@v3