Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
f478ac2
explicitly remove transport.@close listeners from closing consumers a…
mariat-atg Nov 8, 2018
46c7dc4
package json versioning and minor changes in code
mariat-atg Nov 9, 2018
5f66618
Merge pull request #1 from LivelyVideo/transportcallbackfix
mariat-atg Nov 13, 2018
750cd4c
cpu percentage
artushin Dec 13, 2018
f3df011
merge master
artushin Dec 13, 2018
b5d7f76
explicitly remove transport.@close listeners from closing consumers a…
mariat-atg Nov 8, 2018
6f22cb5
package json versioning and minor changes in code
mariat-atg Nov 9, 2018
3f62f0c
cpu percentage
artushin Dec 13, 2018
9f27ed1
cpu fixes
artushin Dec 14, 2018
54419d5
cpu fix
artushin Dec 14, 2018
41e628e
fix interval
artushin Dec 17, 2018
113c11c
clear intervals
artushin Jan 2, 2019
a3c3af4
worker cpu
artushin Jan 2, 2019
eaafef7
fix
artushin Jan 3, 2019
f0bcaec
merge upstream master
artushin Jan 7, 2019
1071865
berging
artushin Jan 7, 2019
e505251
package name
artushin Jan 7, 2019
bd88e52
merge
artushin Jan 7, 2019
40a2ad7
worker deps
artushin Jan 7, 2019
443243f
worker selection fix
artushin Jan 8, 2019
04b0ee1
workers fix
artushin Jan 9, 2019
07b7c35
merge 2.6.6
artushin Jan 15, 2019
2f36bb4
2.6.7
artushin Jan 16, 2019
f522036
merge 2.6.8
artushin Jan 25, 2019
62417d2
orientation; initial commit to try to pass orientation from rtp exten…
jseeley78 Mar 1, 2019
1c1949c
orientation; fix typo in ReadRid func
jseeley78 Mar 1, 2019
79fe374
orientation; udpate call to ReadVideoOrientatio
jseeley78 Mar 1, 2019
08d818e
orientation; fix build errors
jseeley78 Mar 1, 2019
44d839b
orientation; updates to try to get videoOrientation into stats object
jseeley78 Mar 4, 2019
ce61812
orientation; progress (or not much of) on parsing rotation from rtp h…
jseeley78 Mar 6, 2019
3e9a815
orientationv2.6.8; add a bool to stats to indicate if at least one cv…
jseeley78 Mar 6, 2019
8c03b2b
orientationv2.6.8; update ReadVideoOrientation func
jseeley78 Mar 6, 2019
42cd3d8
orientationv2.6.8; update ReadVideoOrientation to returnn clockwise v…
jseeley78 Mar 6, 2019
9e951cb
bump version in package.json
jseeley78 Mar 7, 2019
fb9fe5d
orientation; update readVideoOrientation to use uint16 and well as re…
jseeley78 Mar 8, 2019
8c0878a
orientationv2.6.8; add missing breaks in switch statement in ReadVide…
jseeley78 Mar 8, 2019
085851a
orientation; remove global var when setting orientation
jseeley78 Mar 8, 2019
3bc631b
remove throw which is causing uncaught rejections
artushin Mar 11, 2019
0ef770c
Merge remote-tracking branch 'origin/v2.6.8' into orientationv2.6.8
jseeley78 Mar 14, 2019
d2522e6
orientationv2.6.8; remove logger include from RtpPacket.hpp
jseeley78 Mar 15, 2019
865ad6d
Merge pull request #2 from LivelyVideo/orientationv2.6.8
artushin Mar 19, 2019
469a6c1
enable -gp compilation flag to run gprof
mariat-atg Mar 28, 2019
539c28d
package version to 2.6.8-lv3-gprof
mariat-atg Mar 28, 2019
4e3e867
correct compiler option
mariat-atg Mar 28, 2019
aebc379
Replace std::_Exit() with exit() to run gprof
mariat-atg Mar 31, 2019
bf2f542
version 2.6.8-lv3-gprof3
mariat-atg Mar 31, 2019
f93b201
try compiling with -no-pie option to enable gprof
mariat-atg Apr 1, 2019
a1ca742
tweaking compilation flags again
mariat-atg Apr 1, 2019
06d9f3b
another permutation of compiler and linker flags :)
mariat-atg Apr 3, 2019
7c1e2c8
bump up version
mariat-atg Apr 3, 2019
251d657
syntax
mariat-atg Apr 3, 2019
ddeece3
version
mariat-atg Apr 3, 2019
d7b632e
linker
mariat-atg Apr 3, 2019
08c2ccf
gprof works now but I want to measure with O2 optimization level
mariat-atg Apr 4, 2019
e432de8
Try O3 optimization
mariat-atg Apr 5, 2019
b8c123b
Try O3 and -fno-inline hoping to get more details gprof data
mariat-atg Apr 5, 2019
1ee8e1b
Compilable but not tested yet: replace std::list with circular array …
mariat-atg Apr 17, 2019
9d83a2d
Tested on my local dev machine
mariat-atg Apr 18, 2019
1634177
package version bump 2.6.8-lv3-gprof12
mariat-atg Apr 18, 2019
bdeda9d
small bugfix and version bump for ms worker
mariat-atg Apr 19, 2019
de6c3df
Disable grpof instrumentation; minor cleanup
mariat-atg Apr 22, 2019
5cc4d5b
Merge pull request #3 from LivelyVideo/v2.6.8gprof
mariat-atg Apr 23, 2019
d8ae3ea
version bump 2.6.8-lv4
mariat-atg Apr 23, 2019
214739a
possible memory leak fix
mariat-atg Apr 25, 2019
54d43cf
Port design change in RtpStreamSend from MS v.3
mariat-atg May 6, 2019
1c1c10a
port unit tests for NACK retransmission from v3
mariat-atg May 13, 2019
54f3474
rtx all
artushin May 24, 2019
06ba728
optionally allow sending old or out of order nacks to ffmpeg
mariat-atg May 30, 2019
bdf1c3c
minor fix
mariat-atg May 30, 2019
917dcbd
small logging change
mariat-atg May 31, 2019
339ca87
debug logging for nack option
mariat-atg May 31, 2019
96ad172
version bump
mariat-atg May 31, 2019
4199374
logging in producer
mariat-atg May 31, 2019
0b87c79
try Transport::SendOldNack() as pure virtual
mariat-atg Jun 1, 2019
3ce2058
version bump
mariat-atg Jun 20, 2019
ccffa62
only a bit more logging
mariat-atg Jun 20, 2019
aa1d63e
logging and versioning
mariat-atg Jun 20, 2019
57dbb6d
loging
mariat-atg Jun 20, 2019
9960f8c
version
mariat-atg Jun 21, 2019
de4cf30
try using rtcp-fb SDP
mariat-atg Jun 24, 2019
5a45b1d
keepdebugging
mariat-atg Jun 24, 2019
6dc0cac
check streams
mariat-atg Jun 24, 2019
420ac18
almost done
mariat-atg Jun 25, 2019
ba91415
make ffmpeg-proxy capability an option
mariat-atg Jun 25, 2019
715ce0b
optionally remove ffmpeg-proxy from consumer rtp capabilities
mariat-atg Jun 26, 2019
8f14a5e
same
mariat-atg Jun 27, 2019
c45a256
version
mariat-atg Jun 27, 2019
1bc4f1f
bugs
mariat-atg Jun 27, 2019
0171a22
fix
mariat-atg Jun 27, 2019
5bc1fdf
debug stuff, remove soon
mariat-atg Jun 27, 2019
eb3541b
final
mariat-atg Jun 27, 2019
3b6f174
cleanup ffmpeg property for other consumers
mariat-atg Jul 10, 2019
b633226
Merge branch 'port_from_v3-rtx' into oldnack
mariat-atg Jul 22, 2019
74d6151
Merge pull request #4 from LivelyVideo/oldnack
mariat-atg Jul 22, 2019
ed05f0d
merge
artushin Aug 5, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@

* Downgrade OpenSSL to version 1.1.0h (27 Mar 2018) until issue [#257](https://github.com/versatica/mediasoup/issues/257) is fixed.


### 2.6.2

* C++: Remove all `Destroy()` class methods and no longer do `delete this`.
Expand Down
14 changes: 11 additions & 3 deletions lib/Consumer.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class Consumer extends EnhancedEventEmitter
// - .kind
// - .peer (just if this Consumer belongs to a Peer)
// - .transport
// - .transportCallback
// - .rtpParameters
// - .source
this._data = data;
Expand Down Expand Up @@ -222,6 +223,14 @@ class Consumer extends EnhancedEventEmitter
// Remove notification subscriptions.
this._channel.removeAllListeners(this._internal.consumerId);

// Remove previously registered listener for transport's @close so that closed Consumer object can be picked up by GC
// while a Transport object it used to reffer to still stays alive
if (this._data.transport && this._data.transportCallback)
this._data.transport.removeListener('@close', this._data.transportCallback);

this._data.transportCallback = undefined;
this._data.transport = undefined;

if (notifyChannel)
{
this._channel.request('consumer.close', this._internal)
Expand Down Expand Up @@ -338,13 +347,13 @@ class Consumer extends EnhancedEventEmitter

this.safeEmit('handled');

transport.on('@close', () =>
this._data.transportCallback = () =>
{
this._internal.transportId = undefined;
this._data.transport = undefined;

this.safeEmit('unhandled');
});
};
})
.catch((error) =>
{
Expand Down Expand Up @@ -709,7 +718,6 @@ class Consumer extends EnhancedEventEmitter

if (typeof interval !== 'number')
{
logger.error('enableStats() | invalid interval provided');

return;
}
Expand Down
13 changes: 11 additions & 2 deletions lib/Peer.js
Original file line number Diff line number Diff line change
Expand Up @@ -753,10 +753,18 @@ class Peer extends EnhancedEventEmitter
transportId : undefined
};

const consumerRtpParameters =
let consumerRtpParameters =
ortc.getConsumerRtpParameters(
producer.consumableRtpParameters, this.rtpCapabilities);

consumerRtpParameters.codecs.forEach((codec) => {
if (codec.rtcpFeedback !== undefined && Array.isArray(codec.rtcpFeedback))
{
let rtcpFeedback = codec.rtcpFeedback.filter((val) => val.type !== 'ffmpeg-proxy');
codec.rtcpFeedback = rtcpFeedback;
}
});

const data =
{
kind : producer.kind,
Expand Down Expand Up @@ -790,7 +798,8 @@ class Peer extends EnhancedEventEmitter
{
logger.error('"router.createConsumer" request failed: %s', String(error));

throw error;
// remove throw as it's causing uncaught promise rejections
// throw error;
});

this.safeEmit('newconsumer', consumer);
Expand Down
18 changes: 16 additions & 2 deletions lib/Producer.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Producer extends EnhancedEventEmitter
// - .kind
// - .peer
// - .transport
// -.transportCallback
// - .rtpParameters
// - .consumableRtpParameters
this._data = data;
Expand Down Expand Up @@ -184,6 +185,13 @@ class Producer extends EnhancedEventEmitter
this.emit('@notify', 'producerClosed', data);
}

// Remove previously registered listener for transport's @close so that closed Producer object can be picked up by GC
// while a Transport object it used to reffer to still stays alive
if (this.transport && !this.transport.closed)
this.transport.removeListener('@close', this._data.transportCallback);
this._data.transportCallback = undefined;
this._data.transport = undefined;

this.emit('@close');
this.safeEmit('close', 'local', appData);

Expand Down Expand Up @@ -214,6 +222,11 @@ class Producer extends EnhancedEventEmitter
clearInterval(this._statsInterval);
}

if (this.transport && !this.transport.closed)
this.transport.removeListener('@close', this._data.transportCallback);
this._data.transportCallback = undefined;
this._data.transport = undefined;

this.emit('@close');
this.safeEmit('close', 'remote', appData);

Expand Down Expand Up @@ -589,11 +602,12 @@ class Producer extends EnhancedEventEmitter
{
// On closure, the worker Transport closes all its Producers and the client
// side gets producer.on('unhandled').
this.transport.on('@close', () =>
this._data.transportCallback = () =>
{
if (!this._closed)
this.close(undefined, false);
});
};
this.transport.on('@close', this._data.transportCallback);
}

_handleWorkerNotifications()
Expand Down
31 changes: 28 additions & 3 deletions lib/Room.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const logger = new Logger('Room');

class Room extends EnhancedEventEmitter
{
constructor(internal, data, channel)
constructor(internal, data, channel, getCpuPercentage)
{
super(logger);

Expand All @@ -22,9 +22,12 @@ class Room extends EnhancedEventEmitter
this._closed = false;

// Internal data.
// - .workerId
// - .routerId
this._internal = internal;

this._getCpuPercentage = getCpuPercentage;

// Room data.
// - .rtpCapabilities
this._data = data;
Expand All @@ -48,6 +51,16 @@ class Room extends EnhancedEventEmitter
return this._internal.routerId;
}

get workerId()
{
return this._internal.workerId;
}

get cpuPercentage()
{
return this._getCpuPercentage();
}

get closed()
{
return this._closed;
Expand Down Expand Up @@ -227,7 +240,7 @@ class Room extends EnhancedEventEmitter

createRtpStreamer(producer, options)
{
logger.debug('createRtpStreamer()');
logger.debug('"createRtpStreamer()" sendOldNack is %s producer.kind is %s', options.sendOldNack, producer.kind);

if (!this._producers.has(producer.id))
return Promise.reject(new Error('Producer not found'));
Expand Down Expand Up @@ -257,10 +270,22 @@ class Room extends EnhancedEventEmitter
};

// TODO: The app should provide his own RTP capabilities.
const consumerRtpParameters =
let consumerRtpParameters =
ortc.getConsumerRtpParameters(
producer.consumableRtpParameters, this.rtpCapabilities);

// Remove ffmpeg-proxy from capabilities if sendOldNack is not present
if (options.sendOldNack !== true)
{
consumerRtpParameters.codecs.forEach((codec) => {
if (codec.rtcpFeedback !== undefined && Array.isArray(codec.rtcpFeedback))
{
let rtcpFeedback = codec.rtcpFeedback.filter((val) => val.type !== 'ffmpeg-proxy');
codec.rtcpFeedback = rtcpFeedback;
}
});
}

const data =
{
kind : producer.kind,
Expand Down
63 changes: 49 additions & 14 deletions lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ class Server extends EnhancedEventEmitter
// Remove numWorkers.
delete options.numWorkers;

const workerOptions = options.worker;
delete options.worker;

// Normalize some options.

if (!check.array(options.logTags))
Expand Down Expand Up @@ -142,7 +145,7 @@ class Server extends EnhancedEventEmitter

// Create a Worker instance (do it in a separate method to avoid creating
// a callback function within a loop).
this._addWorker(new Worker(workerId, workerParameters));
this._addWorker(new Worker(workerId, workerParameters, workerOptions));
}
}

Expand All @@ -161,6 +164,11 @@ class Server extends EnhancedEventEmitter
return this._workers.size;
}

get workers()
{
return Array.from(this._workers);
}

/**
* Close the Server.
*/
Expand Down Expand Up @@ -257,22 +265,49 @@ class Server extends EnhancedEventEmitter
// This may throw.
const rtpCapabilities = ortc.generateRoomRtpCapabilities(mediaCodecs);

if (typeof workerIdx === 'number')
{
if (workerIdx < 0 || workerIdx >= this._workers.size)
throw new Error('requested worker idx out of range');

// Update latest worker idx.
this._latestWorkerIdx = workerIdx;
const array = Array.from(this._workers);

let lowestCpu;
let lowestCpuIndex;
const zeroCpus = [];
for (let i = array.length - 1; i >= 0; i--) {
const worker = array[i];
const wcpu = worker.cpuPercentage;
if (wcpu) {
if (!lowestCpu || wcpu < lowestCpu) {
lowestCpu = wcpu;
lowestCpuIndex = i;
}
} else {
zeroCpus.push(worker);
}
}
else
{
// Increase latest worker idx.
this._latestWorkerIdx++;

// Move to 0 if out of range.
if (this._latestWorkerIdx === this._workers.size)
this._latestWorkerIdx = 0;
if (zeroCpus.length) {
if (zeroCpus.length === array.length) {
if (typeof workerIdx === 'number')
{
if (workerIdx < 0 || workerIdx >= this._workers.size)
throw new Error('requested worker idx out of range');

// Update latest worker idx.
this._latestWorkerIdx = workerIdx;
}
else
{
// Increase latest worker idx.
this._latestWorkerIdx++;

// Move to 0 if out of range.
if (this._latestWorkerIdx === this._workers.size)
this._latestWorkerIdx = 0;
}
} else {
this._latestWorkerIdx = array.indexOf(zeroCpus[Math.floor(Math.random() * Math.floor(zeroCpus.length))]);
}
} else {
this._latestWorkerIdx = lowestCpuIndex
}

const worker = Array.from(this._workers)[this._latestWorkerIdx];
Expand Down
Loading