Skip to content

Commit

Permalink
Fishjam protos lib (#8)
Browse files Browse the repository at this point in the history
* Add fishjam_protos library

* Fix CI rewrite fishjam_protos README

* Fix CI

* Add end line in compile_proto.sh
  • Loading branch information
Karolk99 authored Nov 7, 2024
1 parent 6a23a98 commit 6938d98
Show file tree
Hide file tree
Showing 12 changed files with 921 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,30 @@ jobs:
run: buf lint
- name: format
run: buf format --exit-code

fishjam_protos_lint:
runs-on: ubuntu-latest
name: CI elixir lint
strategy:
matrix:
otp: ['27']
elixir: ['1.17']
steps:
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
otp-version: ${{matrix.otp}}
elixir-version: ${{matrix.elixir}}
- name: Checkout the code
uses: actions/checkout@v3
- name: Install dependencies
working-directory: fishjam_protos
run: mix deps.get
- name: Compile without warnings
working-directory: fishjam_protos
id: compile
run: mix compile --warnings-as-errors
- name: Check formatting
working-directory: fishjam_protos
if: ${{ !cancelled() && steps.compile.outcome == 'success' }}
run: mix format --check-formatted
4 changes: 4 additions & 0 deletions fishjam_protos/.formatter.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Used by "mix format"
[
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
]
26 changes: 26 additions & 0 deletions fishjam_protos/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# The directory Mix will write compiled artifacts to.
/_build/

# If you run "mix test --cover", coverage assets end up here.
/cover/

# The directory Mix downloads your dependencies sources to.
/deps/

# Where third-party dependencies like ExDoc output generated docs.
/doc/

# Ignore .fetch files in case you like to edit your project deps locally.
/.fetch

# If the VM crashes, it generates a dump, let's ignore it too.
erl_crash.dump

# Also ignore archive artifacts (built via "mix archive.build").
*.ez

# Ignore package tarball (built via "mix hex.build").
fishjam_protos-*.tar

# Temporary files, for example, from tests.
/tmp/
16 changes: 16 additions & 0 deletions fishjam_protos/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# FishjamProtos

Elixir protobuf modules for Fishjam and [MembraneRTCEngine](https://github.com/fishjam-cloud/membrane_rtc_engine)

## Installation

The package can be installed by adding `fishjam_protos` to your list of dependencies in `mix.exs`:

```elixir
def deps do
[
{:fishjam_protos, "~> 0.1.0"}
]
end
```

19 changes: 19 additions & 0 deletions fishjam_protos/compile_proto.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

# Terminate on errors
set -e

cd ..

files=$(find fishjam -name "*.proto")

printf "Compiling:\n"
count=1
total=${#files[@]}

for file in $files; do
printf "Compile file %s %s ... " $count $file
protoc --elixir_out=./fishjam_protos/lib $file
printf "DONE\n"
count=$(($count + 1))
done
146 changes: 146 additions & 0 deletions fishjam_protos/lib/fishjam/media_events/peer/peer.pb.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
defmodule Fishjam.MediaEvents.Peer.MediaEvent.VariantBitrate do
@moduledoc false

use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0"

field(:variant, 1, type: Fishjam.MediaEvents.Variant, enum: true)
field(:bitrate, 2, type: :int32)
end

defmodule Fishjam.MediaEvents.Peer.MediaEvent.TrackIdToMetadata do
@moduledoc false

use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.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
@moduledoc false

use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0"

oneof(:tracks, 0)

field(:track_bitrate, 1,
type: Fishjam.MediaEvents.Peer.MediaEvent.TrackBitrate,
json_name: "trackBitrate",
oneof: 0
)
end

defmodule Fishjam.MediaEvents.Peer.MediaEvent.Connect do
@moduledoc false

use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0"

field(:metadata, 1, type: Fishjam.MediaEvents.Metadata)
end

defmodule Fishjam.MediaEvents.Peer.MediaEvent.Disconnect do
@moduledoc false

use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0"
end

defmodule Fishjam.MediaEvents.Peer.MediaEvent.UpdateEndpointMetadata do
@moduledoc false

use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0"

field(:metadata, 1, type: Fishjam.MediaEvents.Metadata)
end

defmodule Fishjam.MediaEvents.Peer.MediaEvent.UpdateTrackMetadata do
@moduledoc false

use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0"

field(:track_id, 1, type: :string, json_name: "trackId")
field(:metadata, 2, type: Fishjam.MediaEvents.Metadata)
end

defmodule Fishjam.MediaEvents.Peer.MediaEvent.RenegotiateTracks do
@moduledoc false

use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0"
end

defmodule Fishjam.MediaEvents.Peer.MediaEvent.SdpOffer do
@moduledoc false

use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0"

field(:sdp_offer, 1, type: :string, json_name: "sdpOffer")

field(:track_id_to_metadata, 2,
repeated: true,
type: Fishjam.MediaEvents.Peer.MediaEvent.TrackIdToMetadata,
json_name: "trackIdToMetadata"
)

field(:track_id_to_bitrates, 3,
repeated: true,
type: Fishjam.MediaEvents.Peer.MediaEvent.TrackIdToBitrates,
json_name: "trackIdToBitrates"
)

field(:mid_to_track_id, 4,
repeated: true,
type: Fishjam.MediaEvents.MidToTrackId,
json_name: "midToTrackId"
)
end

defmodule Fishjam.MediaEvents.Peer.MediaEvent.TrackBitrate do
@moduledoc false

use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0"

field(:track_id, 1, type: :string, json_name: "trackId")
field(:bitrate, 2, type: :int32)
end

defmodule Fishjam.MediaEvents.Peer.MediaEvent do
@moduledoc false

use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0"

oneof(:content, 0)

field(:connect, 1, type: Fishjam.MediaEvents.Peer.MediaEvent.Connect, oneof: 0)
field(:disconnect, 2, type: Fishjam.MediaEvents.Peer.MediaEvent.Disconnect, oneof: 0)

field(:update_endpoint_metadata, 3,
type: Fishjam.MediaEvents.Peer.MediaEvent.UpdateEndpointMetadata,
json_name: "updateEndpointMetadata",
oneof: 0
)

field(:update_track_metadata, 4,
type: Fishjam.MediaEvents.Peer.MediaEvent.UpdateTrackMetadata,
json_name: "updateTrackMetadata",
oneof: 0
)

field(:renegotiate_tracks, 5,
type: Fishjam.MediaEvents.Peer.MediaEvent.RenegotiateTracks,
json_name: "renegotiateTracks",
oneof: 0
)

field(:candidate, 6, type: Fishjam.MediaEvents.Candidate, oneof: 0)

field(:sdp_offer, 7,
type: Fishjam.MediaEvents.Peer.MediaEvent.SdpOffer,
json_name: "sdpOffer",
oneof: 0
)

field(:track_bitrate, 8,
type: Fishjam.MediaEvents.Peer.MediaEvent.TrackBitrate,
json_name: "trackBitrate",
oneof: 0
)
end
Loading

0 comments on commit 6938d98

Please sign in to comment.