Skip to content

Commit

Permalink
Export workerBin absolute path (#1123)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibc committed Jul 20, 2023
1 parent dbc377c commit 1621b37
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

### Next

* Export `workerBin` absolute path ([PR #1123](https://github.com/versatica/mediasoup/pull/1123)).


### 3.12.7

* `SimulcastConsumer`: Fix lack of "layerschange" event when all streams in the producer die ([PR #1122](https://github.com/versatica/mediasoup/pull/1122)).
Expand Down
2 changes: 1 addition & 1 deletion doc/Building.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ In order to instruct the mediasoup Node.js module to use the `Debug` mediasoup-w
MEDIASOUP_BUILDTYPE=Debug node myapp.js
```

If the "MEDIASOUP_WORKER_BIN" environment variable is set, mediasoup will use the it as mediasoup-worker binary and **won't** compile the binary:
If the "MEDIASOUP_WORKER_BIN" environment variable is set (it must be an absolute file path), mediasoup will use the it as mediasoup-worker binary and **won't** compile the binary:

```bash
MEDIASOUP_WORKER_BIN="/home/xxx/src/foo/mediasoup-worker" node myapp.js
Expand Down
2 changes: 1 addition & 1 deletion node/src/Worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export type WorkerObserverEvents =
// If env MEDIASOUP_WORKER_BIN is given, use it as worker binary.
// Otherwise if env MEDIASOUP_BUILDTYPE is 'Debug' use the Debug binary.
// Otherwise use the Release binary.
const workerBin = process.env.MEDIASOUP_WORKER_BIN
export const workerBin = process.env.MEDIASOUP_WORKER_BIN
? process.env.MEDIASOUP_WORKER_BIN
: process.env.MEDIASOUP_BUILDTYPE === 'Debug'
? path.join(__dirname, '..', '..', 'worker', 'out', 'Debug', 'mediasoup-worker')
Expand Down
7 changes: 6 additions & 1 deletion node/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Logger } from './Logger';
import { EnhancedEventEmitter } from './EnhancedEventEmitter';
import { Worker, WorkerSettings } from './Worker';
import { workerBin, Worker, WorkerSettings } from './Worker';
import * as utils from './utils';
import { supportedRtpCapabilities } from './supportedRtpCapabilities';
import { RtpCapabilities } from './RtpParameters';
Expand Down Expand Up @@ -36,6 +36,11 @@ const observer = new EnhancedEventEmitter<ObserverEvents>();
*/
export { observer };

/**
* Full path of the mediasoup-worker binary.
*/
export { workerBin };

/**
* Create a Worker.
*/
Expand Down
11 changes: 11 additions & 0 deletions node/src/tests/test-Worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ let worker: mediasoup.types.Worker;
beforeEach(() => worker && !worker.closed && worker.close());
afterEach(() => worker && !worker.closed && worker.close());

test('Worker.workerBin matches mediasoup-worker absolute path', async () =>
{
const workerBin = process.env.MEDIASOUP_WORKER_BIN
? process.env.MEDIASOUP_WORKER_BIN
: process.env.MEDIASOUP_BUILDTYPE === 'Debug'
? path.join(__dirname, '..', '..', '..', 'worker', 'out', 'Debug', 'mediasoup-worker')
: path.join(__dirname, '..', '..', '..', 'worker', 'out', 'Release', 'mediasoup-worker');

expect(mediasoup.workerBin).toBe(workerBin);
});

test('createWorker() succeeds', async () =>
{
const onObserverNewWorker = jest.fn();
Expand Down

0 comments on commit 1621b37

Please sign in to comment.