{"id":16526689,"url":"https://github.com/rtippin/janus-client","last_synced_at":"2025-03-21T09:31:07.905Z","repository":{"id":42195525,"uuid":"387571926","full_name":"RTippin/janus-client","owner":"RTippin","description":"Laravel API wrapper to interact fluently with your Janus Media Server. Core server interactions, as well as the video room plugin included.","archived":false,"fork":false,"pushed_at":"2023-02-19T00:16:35.000Z","size":66,"stargazers_count":14,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-05-02T03:11:17.533Z","etag":null,"topics":["client","janus","janus-client","janus-gateway","laravel","media-server","meetecho","plugin","video-call","video-room","webrtc","websocket","wrapper"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RTippin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","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},"funding":{"github":"RTippin"}},"created_at":"2021-07-19T19:22:53.000Z","updated_at":"2024-04-27T12:55:46.000Z","dependencies_parsed_at":"2024-10-11T17:29:35.600Z","dependency_job_id":"6b44aa84-1350-4beb-9115-136813b5663d","html_url":"https://github.com/RTippin/janus-client","commit_stats":{"total_commits":58,"total_committers":3,"mean_commits":"19.333333333333332","dds":"0.051724137931034475","last_synced_commit":"c23295f73e47195f54e2ef085be3434405a1d02e"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RTippin%2Fjanus-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RTippin%2Fjanus-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RTippin%2Fjanus-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RTippin%2Fjanus-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RTippin","download_url":"https://codeload.github.com/RTippin/janus-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244771596,"owners_count":20507834,"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":["client","janus","janus-client","janus-gateway","laravel","media-server","meetecho","plugin","video-call","video-room","webrtc","websocket","wrapper"],"created_at":"2024-10-11T17:29:32.937Z","updated_at":"2025-03-21T09:31:07.898Z","avatar_url":"https://github.com/RTippin.png","language":"PHP","funding_links":["https://github.com/sponsors/RTippin"],"categories":[],"sub_categories":[],"readme":"# Laravel Janus Gateway Client\n\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Total Downloads][ico-downloads]][link-downloads]\n[![Tests][ico-test]][link-test]\n[![StyleCI][ico-styleci]][link-styleci]\n[![License][ico-license]][link-license]\n\n---\n\n### This package provides a client to fluently interact with your [Janus Gateway Server][link-janus]\n\n### Prerequisites\n\n| Laravel |         PHP          | janus-client |\n|---------|:--------------------:|-------------:|\n| `8.x`   | `^7.4` `^8.0` `^8.1` |   `\u003c= 1.0.0` |\n| `9.x`   |   `^8.0.2` `^8.1`    |   `\u003e= 1.1.0` |\n| `10.x`  |    `^8.1` `^8.2`     |   `\u003e= 1.2.0` |\n| `11.x`  |    `^8.2` `^8.3`     |   `\u003e= 1.3.0` |\n| `12.x`  | `^8.2` `^8.3` `^8.4` |   `\u003e= 1.4.0` |\n\n## Included\n- Core REST API wrapper to interact with janus.\n- VideoRoom plugin wrapper.\n\n---\n**Fluent, convenient, clean.**\n```php\nuse RTippin\\Janus\\Facades\\Janus;\n\n$ping = Janus::ping(); \n\n---------------------------------------\n\n['pong' =\u003e true]\n\n---------------------------------------\n\n$room = Janus::videoRoom()-\u003ecreate([\n    'description' =\u003e 'My first room!',\n    'publishers' =\u003e 4,\n]);\n\n---------------------------------------\n\n[\n  'videoroom' =\u003e 'created',\n  'room' =\u003e 6663183870503329,\n  'permanent' =\u003e false,\n  'pin' =\u003e 'TFQuls',\n  'secret' =\u003e 'y2WaVehf7cOM',\n]\n```\n\n---\n\n# Installation\n\n### Via Composer\n\n``` bash\ncomposer require rtippin/janus-client\n```\n\n### Publish the config file\n\n``` bash\nphp artisan vendor:publish --tag=janus\n```\n\n---\n\n# Config\n\n```php\n'server_endpoint' =\u003e env('JANUS_SERVER_ENDPOINT'),\n'admin_server_endpoint' =\u003e env('JANUS_ADMIN_SERVER_ENDPOINT'),\n'verify_ssl' =\u003e env('JANUS_VERIFY_SSL', true),\n'debug' =\u003e env('JANUS_DEBUG', false),\n'admin_secret' =\u003e env('JANUS_ADMIN_SECRET'),\n'api_secret' =\u003e env('JANUS_API_SECRET'),\n'video_room_secret' =\u003e env('JANUS_VIDEO_ROOM_SECRET'),\n```\n\n- `server_endpoint` is the main HTTP endpoint for your janus server.\n- `admin_server_endpoint` is the admin HTTP endpoint for your janus server.\n- `verify_ssl` enables or disables our `Guzzle HTTP` calls from verifying the SSL.\n- `debug` When enabled, each request in a cycle will dump the payload and responses.\n- `admin_secret` API secret to access the admin endpoint.\n- `api_secret` The general API secret.\n- `video_room_secret` Optional video room secret to protect creates.\n\n----\n\n# General Usage\n\n- You may choose to use our provided facade, or dependency injection to access our core `Janus` class.\n\n### Notice, `Janus` is registered as a singleton. Once you instantiate our class, it will be kept in memory with its current state  for that request cycle.\n\n## Obtaining the `Janus` client\n\n**Using Facade**\n```php\nuse RTippin\\Janus\\Facades\\Janus;\n\n$info = Janus::info() || Janus::getInstance()-\u003einfo();\n```\n**Using Dependency Injection**\n```php\n\u003c?php\n\nnamespace App\\Http\\Controllers;\n\nuse RTippin\\Janus\\Janus;\n\nclass JanusController\n{\n    private Janus $janus;\n\n    public function __construct(Janus $janus)\n    {\n       $this-\u003ejanus = $janus;\n    }\n}\n```\n### `info()`\n- Returns the janus server info array.\n```php\nJanus::info();\n```\n### `ping()`\n- Ping will always return an array (even if an exception is thrown), containing `pong` as true|false, along with server latency.\n```php\nJanus::ping();\n```\n### `debug(bool $debug = true)`\n- Enable debugging/dumps on the fly by calling to the `debug` method on `Janus`. This will dump each HTTP call's payload, response, and latency.\n```php\nuse RTippin\\Janus\\Facades\\Janus;\n\nRoute::get('test', function(){\n    Janus::debug()-\u003eping();\n    dump('It dumps inline for each http call!');\n});\n\n//OUTPUT\n\n\"PAYLOAD\"\n\narray:3 [▼\n  \"transaction\" =\u003e \"q52xpYrZJ6e6\"\n  \"apisecret\" =\u003e \"secret\"\n  \"janus\" =\u003e \"ping\"\n]\n\n\"RESPONSE\"\n\narray:2 [▼\n  \"janus\" =\u003e \"pong\"\n  \"transaction\" =\u003e \"q52xpYrZJ6e6\"\n]\n\n\"LATENCY\"\n\n16.0\n\n\"It dumps inline for each http call!\"\n```\n### `connect()`\n- Connect will initiate a handshake with janus to set our session ID for any following request. This is a fluent method and can be chained.\n```php\nJanus::connect();\n```\n### `attach(string $plugin)`\n- Attach to a janus plugin to set our handle ID. All following API calls in this request cycles will go to this plugin unless you call detach or disconnect. This is a fluent method and can be chained.\n```php\nJanus::attach('janus.plugin.name');\n```\n### `detach()`\n- Detach from the current plugin/handle. This is a fluent method and can be chained.\n```php\nJanus::detach();\n```\n### `disconnect()`\n- Disconnect from janus, destroying our session and handle/plugin. This is a fluent method and can be chained.\n```php\nJanus::disconnect();\n```\n### `message(array $message, $jsep = null)`\n- Send janus our message. This is usually called once attached to a plugin, and sends commands to janus. This is a fluent method and can be chained.\n```php\nJanus::message(['request' =\u003e 'list']);\n```\n### `trickle($candidate)`\n- Send a trickle candidate to janus. This is a fluent method and can be chained.\n```php\nJanus::trickle('candidate information');\n```\n### `server()`\n- Returns the underlying janus server class, allowing you to set configs, or access current payloads/responses in the cycle.\n```php\nuse RTippin\\Janus\\Facades\\Janus;\n\n$server = Janus::server()\n    -\u003esetServerEndpoint('http://test.com')\n    -\u003esetAdminServerEndpoint('http://test.com/admin')\n    -\u003esetApiSecret('secret');\n    \nJanus::connect();\n\n$response = $server-\u003egetApiResponse();\n$payload = $server-\u003egetApiPayload();\n$latency = $server-\u003egetEndLatency();\n```\n## Example Cycle\n- Say we want to obtain a list of video rooms, 4 calls must be made.\n    - First we connect which sets our session id.\n    - Then we want to attach to the video room plugin to set our handle id.\n    - Once attached, we send janus our command message to list rooms.\n    - If no further calls need to be made, we then disconnect which will reset our session and handle ID's. This also ensures state sessions are not kept in your janus servers memory.\n\n```php\nuse RTippin\\Janus\\Facades\\Janus;\n\n//Send our command for the results we want.    \nJanus::connect()\n    -\u003eattach('janus.plugin.videoroom')\n    -\u003emessage(['request' =\u003e 'list']);\n\n//Set the results from the last command sent.\n$rooms = Janus::getApiResponse();\n\n//Disconnect and reset all janus values.\nJanus::disconnect();\n```\n\n----\n\n# Shared Plugin Methods\n\n### All Plugin methods will return the plugin response array from janus directly. \n- `['plugindata']['data']` contents returned.\n\n**Examples using `VideoRoom` plugin**\n\n### `{JanusPlugin}-\u003ewithoutDisconnect()` | `{JanusPlugin}-\u003edisconnect(bool $force = false)`\n- If you plan to use many commands in one cycle while attached to the same plugin, calling this method will only create one `connect` and `attach` call to reuse our session and handle ID's.\n- When you have completed all individual calls, you must manually call to the parent `Janus` to disconnect, or force it within the current plugin instance, using `disconnect(true)`.\n- These are fluent methods and can be chained.\n\n**Example video room call to remove all rooms**\n```php\nuse RTippin\\Janus\\Facades\\Janus;\n\n//Disable disconnects for plugin calls.\nJanus::videoRoom()-\u003ewithoutDisconnect();\n\n//Grab list of rooms.\n$rooms = Janus::videoRoom()-\u003elist()['list'];\n\n//Destroy each room.\nforeach ($rooms as $room) {\n    Janus::videoRoom()-\u003edestroy($room['room']);\n}\n\n//Now disconnect to remove our session/handle.\nJanus::videoRoom()-\u003edisconnect(true); //Forced on current plugin instance.\n---------------------------------------------------------------------------\nJanus::disconnect(); //Main disconnect will always be run if called.\n```\n### `{JanusPlugin}-\u003egetPluginResponse(?string $key = null)`\n- Get the API response from the last plugin method called.\n    - `['plugindata']['data']` contents will be returned.\n```php\n//Make plugin call. \nJanus::videoRoom()-\u003elist();\n\n//Get response.\n$list = Janus::videoRoom()-\u003egetPluginResponse('list');\n```\n### `{JanusPlugin}-\u003egetPluginPayload(?string $key = null)`\n- Get the API payload for the last plugin method called.\n```php\n//Make plugin call. \nJanus::videoRoom()-\u003elist();\n\n//Get payload.\n$payload = Janus::videoRoom()-\u003egetPluginPayload();\n```\n\n----\n\n# Video Room\n\n### For full docs relating to the video room plugin and its responses, please check the [Official Docs][link-videoroom]\n\n- You may access the video room plugin through the core `Janus` class/facade, or dependency injection of the core `VideoRoom` class.\n- Each main janus method completes a full cycle (connect, attach, message, disconnect) unless you specify `withoutDisconnect()`.\n\n**Using Facade**\n```php\nuse RTippin\\Janus\\Facades\\Janus;\n\n$videoRoom = Janus::videoRoom();\n```\n**Using Dependency Injection**\n```php\n\u003c?php\n\nnamespace App\\Http\\Controllers;\n\nuse RTippin\\Janus\\Plugins\\VideoRoom;\n\nclass VideoRoomController\n{\n    private VideoRoom $videoRoom;\n\n    public function __construct(VideoRoom $videoRoom)\n    {\n       $this-\u003evideoRoom = $videoRoom;\n    }\n}\n```\n### `list()`\n- Returns a list of the available rooms (excluded those configured or created as private rooms).\n```php\n$list = Janus::videoRoom()-\u003elist();\n```\n### `exists(int $room)`\n- Check whether a room exists.\n```php\n$exists = Janus::videoRoom()-\u003eexists(12345678);\n```\n### `create(array $params = [], bool $usePin = true, bool $useSecret = true)`\n- Create a new video room. By default, we will create a `PIN` and `SECRET` for you, as well as set certain properties. Any `params` you set will override any of our defaults.\n    - We will merge the PIN/SECRET with the returned array from the janus plugin response, so that you may save it if needed.\n```php\n$room = Janus::videoRoom()-\u003ecreate([\n    'description' =\u003e 'My first room!',\n    'publishers' =\u003e 10,\n    'bitrate' =\u003e 1024000,\n    'is_private' =\u003e true,\n]);\n```\n### `edit(int $room, array $params, ?string $secret = null)`\n- Edit the allowed properties of an existing room.\n```php\n$newProperties = [\n    'new_description' =\u003e 'First room!',\n    'new_bitrate' =\u003e 600000,\n];\n\n$edit = Janus::videoRoom()-\u003eedit(12345678, $newProperties, 'SECRET');\n```\n### `allowed(int $room, string $action, ?array $allowed = null, ?string $secret = null)`\n- You can configure whether to check tokens or add/remove people who can join a room.\n```php\n$allowed = Janus::videoRoom()-\u003eallowed(12345678, 'remove', ['token'], 'SECRET');\n```\n### `kick(int $room, int $participantID, ?string $secret = null)`\n- Kick a participant from the room.\n```php\n$kick = Janus::videoRoom()-\u003ekick(12345678, 987654321, 'SECRET');\n```\n### `listParticipants(int $room)`\n- Get a list of the participants in a specific room.\n```php\n$participants = Janus::videoRoom()-\u003elistParticipants(12345678);\n```\n### `listForwarders(int $room, ?string $secret = null)`\n- Get a list of all the forwarders in a specific room.\n```php\n$forwarders = Janus::videoRoom()-\u003elistForwarders(12345678, 'SECRET');\n```\n### `destroy(int $room, ?string $secret = null)`\n- Destroy an existing video room.\n```php\n$destroy = Janus::videoRoom()-\u003edestroy(12345678, 'SECRET');\n```\n### `moderate(int $room, int $participantID, bool $mute, ?string $mid = null, ?string $secret = null)`\n- Forcibly mute/unmute any of the media streams sent by participants.\n```php\n$moderate = Janus::videoRoom()-\u003emoderate(12345678, 987654321, true, 'm-line' 'SECRET');\n```\n### `enableRecording(int $room, bool $record, ?string $secret = null)`\n- Enable or disable recording on all participants while the conference is in progress.\n```php\n$record = Janus::videoRoom()-\u003eenableRecording(12345678, true, 'SECRET');\n```\n## Example Cycle using many methods without disconnecting between them.\n```php\nuse RTippin\\Janus\\Facades\\Janus;\n\n//Disable disconnect between each method call.\nJanus::videoRoom()-\u003ewithoutDisconnect();\n\n//Run methods as needed. Connect and attach will only be called once.\nif (Janus::videoRoom()-\u003eexists(12345678)['exists']) {\n    Janus::videoRoom()-\u003edestroy(12345678);\n}\n\n//Disconnect and reset all janus values.\nJanus::disconnect();\n```\n\n---\n\n## Credits - Richard Tippin\n\n## License - MIT\n\n### Please see the [license file](LICENSE.md) for more information.\n\n[link-author]: https://github.com/rtippin\n[ico-version]: https://img.shields.io/packagist/v/rtippin/janus-client.svg?style=plastic\u0026cacheSeconds=3600\n[ico-downloads]: https://img.shields.io/packagist/dt/rtippin/janus-client.svg?style=plastic\u0026cacheSeconds=3600\n[link-test]: https://github.com/RTippin/janus-client/actions\n[ico-test]: https://img.shields.io/github/actions/workflow/status/rtippin/janus-client/test.yml?branch=master\u0026style=plastic\n[ico-styleci]: https://styleci.io/repos/387571926/shield?style=plastic\u0026cacheSeconds=3600\n[ico-license]: https://img.shields.io/github/license/RTippin/janus-client?style=plastic\n[link-packagist]: https://packagist.org/packages/rtippin/janus-client\n[link-downloads]: https://packagist.org/packages/rtippin/janus-client\n[link-license]: https://packagist.org/packages/rtippin/janus-client\n[link-styleci]: https://styleci.io/repos/387571926\n[link-janus]: https://janus.conf.meetecho.com/docs/index.html\n[link-videoroom]: https://janus.conf.meetecho.com/docs/videoroom.html","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frtippin%2Fjanus-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frtippin%2Fjanus-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frtippin%2Fjanus-client/lists"}