diff --git a/fishjam/media_events/peer/peer.proto b/fishjam/media_events/peer/peer.proto new file mode 100644 index 0000000..e577f5d --- /dev/null +++ b/fishjam/media_events/peer/peer.proto @@ -0,0 +1,76 @@ +syntax = "proto3"; + +package fishjam.media_events.peer; + +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; + } + + // Sent when a peer disconnects from WebRTC Endpoint. + message Disconnect {} + + // Sent when a peer wants to update its metadata + message UpdateEndpointMetadata { + media_events.Metadata metadata = 1; + } + + // Sent when a peer wants to update its track's metadata + message UpdateTrackMetadata { + string track_id = 1; + media_events.Metadata metadata = 2; + } + + // Sent when peer wants to renegatiate connection due to adding a track or removing a track + message RenegotiateTracks {} + + // Sent as a response to `offerData` media event during renegotiation + // Maps contain only information about current peer's `sendonly` tracks. + // 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; + } + + // Sent when Peer wants to update its track's bitrate + message TrackBitrate { + string track_id = 1; + int32 bitrate = 2; + } + + oneof content { + Connect connect = 1; + Disconnect disconnect = 2; + UpdateEndpointMetadata update_endpoint_metadata = 3; + UpdateTrackMetadata update_track_metadata = 4; + RenegotiateTracks renegotiate_tracks = 5; + media_events.Candidate candidate = 6; + SdpOffer sdp_offer = 7; + TrackBitrate track_bitrate = 8; + } +} diff --git a/fishjam/media_events/server/server.proto b/fishjam/media_events/server/server.proto new file mode 100644 index 0000000..448d13c --- /dev/null +++ b/fishjam/media_events/server/server.proto @@ -0,0 +1,115 @@ +syntax = "proto3"; + +package fishjam.media_events.server; + +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; + } + + // MEDIA EVENTS + + // Sent when metadata of one of the endpoints was updated + message EndpointUpdated { + string endpoint_id = 1; + media_events.Metadata metadata = 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; + } + + // Sent to informs that one of the peers has added one or more tracks. + message TracksAdded { + string endpoint_id = 1; + repeated Track tracks = 2; + } + + // Sent to informs that one of the peers has removed one or more tracks. + message TracksRemoved { + string endpoint_id = 1; + repeated string track_ids = 2; + } + + // Sent to all peers in the room after a new endpoint was added. + message EndpointAdded { + string endpoint_id = 1; + media_events.Metadata metadata = 2; + } + + // Sent to the peer after connecting to the WebRTC Endpoint. + message Connected { + string endpoint_id = 1; + repeated Endpoint endpoints = 2; + } + + // Sent to all remaining peers in the room after some endpoint was removed. + message EndpointRemoved { + string endpoint_id = 1; + } + + // Sent to inform that an error occurred on the server providing a message to show + message Error { + string message = 1; + } + + // Sent to inform about the number of audio and video tracks that will be sent from the engine to the peer + message OfferData { + message TrackTypes { + int32 audio = 1; + int32 video = 2; + } + + TrackTypes tracks_types = 1; + } + + // Sent after receiving `SdpOffer` from Peer + message SdpAnswer { + string sdp_answer = 1; + repeated media_events.MidToTrackId mid_to_track_id = 2; + } + + // Sent to inform that the track denoted by `trackId` has changed their voice actiivty + // For this notification to work, the server must be configured to use VAD extension + // and the sender must support it. + message VadNotification { + enum Status { + STATUS_UNSPECIFIED = 0; + STATUS_SILENCE = 1; + STATUS_SPEECH = 2; + } + + string track_id = 1; + Status status = 2; + } + + oneof content { + EndpointUpdated endpoint_updated = 1; + TrackUpdated track_updated = 2; + TracksAdded tracks_added = 3; + TracksRemoved tracks_removed = 4; + EndpointAdded endpoint_added = 5; + EndpointRemoved endpoint_removed = 6; + Connected connected = 7; + Error error = 8; + OfferData offer_data = 9; + media_events.Candidate candidate = 10; + SdpAnswer sdp_answer = 11; + VadNotification vad_notification = 12; + } +} diff --git a/fishjam/media_events/shared.proto b/fishjam/media_events/shared.proto new file mode 100644 index 0000000..b66496f --- /dev/null +++ b/fishjam/media_events/shared.proto @@ -0,0 +1,27 @@ +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; + int32 sdp_m_line_index = 2; + string sdp_mid = 3; + string username_fragment = 4; +} diff --git a/fishjam/peer_notifications.proto b/fishjam/peer_notifications.proto index aff60c2..d75bc5e 100644 --- a/fishjam/peer_notifications.proto +++ b/fishjam/peer_notifications.proto @@ -2,6 +2,9 @@ syntax = "proto3"; package fishjam; +import "fishjam/media_events/peer/peer.proto"; +import "fishjam/media_events/server/server.proto"; + // Defines any type of message sent between FJ and a peer message PeerMessage { // Response sent by FJ, confirming successfull authentication @@ -10,11 +13,7 @@ message PeerMessage { // Request sent by peer, to authenticate to FJ server message AuthRequest { string token = 1; - } - - // Any type of WebRTC messages passed betweend FJ and peer - message MediaEvent { - string data = 1; + string sdk_version = 2; } // PeerConnection stats sent by peer @@ -26,7 +25,8 @@ message PeerMessage { oneof content { Authenticated authenticated = 1; AuthRequest auth_request = 2; - MediaEvent media_event = 3; - RTCStatsReport rtc_stats_report = 4; + media_events.peer.MediaEvent peer_media_event = 3; + media_events.server.MediaEvent server_media_event = 4; + RTCStatsReport rtc_stats_report = 5; } } diff --git a/fishjam/server_notifications.proto b/fishjam/server_notifications.proto index c3814c6..a137bce 100644 --- a/fishjam/server_notifications.proto +++ b/fishjam/server_notifications.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package fishjam; -// Defines any type of message passed between FJ and server client +// Defines any type of message passed between FJ and server peer message ServerMessage { // Notification sent when a room crashes message RoomCrashed { @@ -49,19 +49,19 @@ message ServerMessage { // Response sent by FJ, confirming successfull authentication message Authenticated {} - // Request sent by client, to authenticate to FJ server + // Request sent by peer, to authenticate to FJ server message AuthRequest { string token = 1; } - // Defines message groups for which client can subscribe + // Defines message groups for which peer can subscribe enum EventType { EVENT_TYPE_UNSPECIFIED = 0; EVENT_TYPE_SERVER_NOTIFICATION = 1; EVENT_TYPE_METRICS = 2; } - // Request sent by client to subsribe for certain message type + // Request sent by peer to subsribe for certain message type message SubscribeRequest { EventType event_type = 1; }