{"id":18352749,"url":"https://github.com/membraneframework/ex_libnice","last_synced_at":"2025-04-06T11:33:04.081Z","repository":{"id":39996004,"uuid":"298241358","full_name":"membraneframework/ex_libnice","owner":"membraneframework","description":"Libnice-based Interactive Connectivity Establishment (ICE) protocol support for Elixir","archived":false,"fork":false,"pushed_at":"2023-11-17T14:49:34.000Z","size":79,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-21T22:33:42.808Z","etag":null,"topics":["elixir","ice","libnice","stun","turn"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/membraneframework.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-24T10:13:14.000Z","updated_at":"2024-12-30T18:30:46.000Z","dependencies_parsed_at":"2022-08-30T20:10:18.008Z","dependency_job_id":"2afaf204-f3c6-4e61-a43c-30aa10829264","html_url":"https://github.com/membraneframework/ex_libnice","commit_stats":{"total_commits":55,"total_committers":5,"mean_commits":11.0,"dds":0.5454545454545454,"last_synced_commit":"ebef6fdc6d85a8469405159e9fa7c57a38120241"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/membraneframework%2Fex_libnice","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/membraneframework%2Fex_libnice/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/membraneframework%2Fex_libnice/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/membraneframework%2Fex_libnice/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/membraneframework","download_url":"https://codeload.github.com/membraneframework/ex_libnice/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247478152,"owners_count":20945258,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elixir","ice","libnice","stun","turn"],"created_at":"2024-11-05T21:37:10.000Z","updated_at":"2025-04-06T11:33:03.531Z","avatar_url":"https://github.com/membraneframework.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ExLibnice\n\n[![Hex.pm](https://img.shields.io/hexpm/v/ex_libnice.svg)](https://hex.pm/packages/ex_libnice)\n[![API Docs](https://img.shields.io/badge/api-docs-yellow.svg?style=flat)](https://hexdocs.pm/ex_libnice/)\n[![CircleCI](https://circleci.com/gh/membraneframework/ex_libnice.svg?style=svg)](https://circleci.com/gh/membraneframework/ex_libnice)\n\nLibnice-based Interactive Connectivity Establishment (ICE) protocol support for Elixir.\n\nIt is a part of [Membrane Multimedia Framework](https://membraneframework.org).\n\n## Installation\n\nFirst, install [libnice] on your system:\n\n### macOS\n\n```bash\nbrew install libnice\n```\n\n### Ubuntu\n\n```bash\nsudo apt-get install libnice-dev\n```\n\nThe package can be installed by adding `ex_libnice` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:ex_libnice, \"~\u003e 0.8.0\"}\n  ]\nend\n```\n\n## Usage\n\nBasically this library works similarly to [libnice].\n\n`ExLibnice` can work both as CNode and as NIF.\nBy default `CNode` implementation is used however, user can change it by passing proper option while starting `ExLibnice` (see below) or by `config.exs`:\n\n```elixir\nconfig :ex_libnice, impl: :NIF\n```\n\nUser can also choose whether to resolve mDNS addresses or not:\n\n```elixir\nconfig :ex_libnice, mdns: false\n```\n\nExample flow can look in the following way (this is not complete i.e. runnable example).\n\nListed functions must be invoked on both peers.\n\n```elixir\n# Init ExLibnice\n{:ok, pid} =\n  ExLibnice.start_link(\n    impl: NIF,\n    parent: self(),\n    stun_servers: [\n      %{server_addr: {64, 233, 161, 127}, server_port: 19_302},\n      %{server_addr: \"stun1.l.google.com\", server_port: 19_302}\n    ],\n    controlling_mode: true,\n    port_range: 0..0\n  )\n\n# Add stream, get local credentials\n{:ok, stream_id} = ExLibnice.add_stream(ice, 1, \"audio\")\n{:ok, credentials} = ExLibnice.get_local_credentials(ice, stream_id)\n\n# Send local credentials to the remote peer\n:socket.send(peer_socket, credentials)\n```\n\n```elixir\n# Receive remote credentials and set them on ExLibnice\n{:ok, credentials} = :socket.recv(peer_socket)\n:ok = ExLibnice.set_remote_credentials(ice, peer_credentials, stream_id)\n\n# Start gathering candidates\n:ok = ExLibnice.gather_candidates(ice, stream_id)\n```\n\n```elixir\n# Now we should prepare for receiving messages in form of `{:new_candidate_full, candidate}`\n# and send them to the remote peer. If module that runs ExLibnice is a GenServer we can use\n# handle_info/2 callback\n@impl true\ndef handle_info({:new_candidate_full, candidate}, {peer_socket: peer_socket} = state) do\n  :socket.send(peer_socket, {:peer_new_candidate_full, candidate})\nend\n```\n\n```elixir\n# Set received peer candidates.\n:ok = ExLibnice.set_remote_candidate(ice, peer_candidate, stream_id, 1)\n```\n\nThis will start connectivity checks. Receiving message\n`{:component_state_ready, stream_id, component_id}` indicates that the given component in the given\nstream is ready to send and receive messages.\n\nFor more complete examples please refer to\n[membrane_ice_plugin](https://github.com/membraneframework/membrane_ice_plugin) where we use\n`ex_libnice` or our integration test.\n\n## Copyright and License\n\nCopyright 2020, [Software Mansion](https://swmansion.com/?utm_source=git\u0026utm_medium=readme\u0026utm_campaign=membrane_ice)\n\n[![Software Mansion](https://logo.swmansion.com/logo?color=white\u0026variant=desktop\u0026width=200\u0026tag=membrane-github)](https://swmansion.com/?utm_source=git\u0026utm_medium=readme\u0026utm_campaign=membrane_ice)\n\nLicensed under the [Apache License, Version 2.0](LICENSE)\n\n[libnice]: https://libnice.freedesktop.org/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmembraneframework%2Fex_libnice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmembraneframework%2Fex_libnice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmembraneframework%2Fex_libnice/lists"}