Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge master and fix missing RTCEAGLVideoViewDelegate via src/cordova-plugin-iosrtc-Bridging-Header.h #1

Merged
merged 33 commits into from
Feb 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
c8fe819
Remove `Remove the iOS platform and add it again` to avoid confusion
hthetiot Dec 9, 2019
8dfa05b
Update Building.md
hthetiot Dec 9, 2019
da9d234
Update Building.md
hthetiot Dec 9, 2019
3907830
Update ios_arch.js script link
onerinas Jan 2, 2020
8646fca
Update cordova plugin path
onerinas Jan 2, 2020
f5a5026
Merge pull request #457 from onerinas/patch-1
hthetiot Jan 8, 2020
74fee80
disable sudo gem install cocoapods that cause travis build to fail
hthetiot Jan 13, 2020
d26a61e
Update README.md
hthetiot Jan 16, 2020
e972a65
Update renderer-and-libwebrtc-tests.js
hthetiot Jan 16, 2020
5657a75
suffix PluginMediaStream.id with real RTCMediaStream.streamId
hthetiot Jan 27, 2020
04c11fa
suffix PluginMediaStreamTrack.id with real PluginMediaStreamTrack.str…
hthetiot Jan 27, 2020
0aa1c5c
fix PeerConnection removestream to use PluginMediaStream.id instead o…
hthetiot Jan 27, 2020
4b9ea40
Merge pull request #460 from cordova-rtc/bugs/removeStreamId
hthetiot Jan 28, 2020
70818ca
prepare 6.0.6
hthetiot Feb 8, 2020
ac6ddb8
fix readOnly dispatchEvent event.target issue
hthetiot Feb 17, 2020
b6f12f8
update extra/renderer-and-libwebrtc-tests.js to work on existing page
hthetiot Feb 17, 2020
49266ab
Merge pull request #463 from cordova-rtc/bugs/EventTarget
hthetiot Feb 18, 2020
d3ab0f2
update dist/cordova-plugin-iosrtc.js with dispatchEvent fix
hthetiot Feb 18, 2020
d626ec1
Merge pull request #464 from cordova-rtc/bugs/EventTarget
hthetiot Feb 18, 2020
eb7c7ac
prepare 6.0.7
hthetiot Feb 18, 2020
b90228e
add MediaStream_init debug
hthetiot Feb 25, 2020
999d94d
use UUID().uuidString preffix for PluginMediaStream and PluginMediaSt…
hthetiot Feb 25, 2020
38b1eb4
use UUID().uuidString preffix for PluginMediaStream and PluginMediaSt…
hthetiot Feb 25, 2020
0f76d59
prevent webrtc-adapter to override RTCPeerConnection.prototype.addStr…
hthetiot Feb 25, 2020
8047440
implement candidateToJson SDP candidate parser into RTCIceCandidate t…
hthetiot Feb 25, 2020
bdc335c
build dist/cordova-plugin-iosrtc.js
hthetiot Feb 25, 2020
0070e49
Merge pull request #467 from cordova-rtc/bugs/addStream
hthetiot Feb 25, 2020
6942814
Add Known Issues > iOS >= 13.3.1 Device support to README.md
hthetiot Feb 25, 2020
44de34c
Merge pull request #468 from cordova-rtc/task/parseCandidate
hthetiot Feb 25, 2020
5cb5b33
prepare 6.0.8
hthetiot Feb 25, 2020
4eda87f
build dist/cordova-plugin-iosrtc.js for 6.0.8
hthetiot Feb 25, 2020
61526bc
Merge branch 'master' into m75
hthetiot Feb 25, 2020
639873c
add missing RTCEAGLVideoViewDelegate to src/cordova-plugin-iosrtc-Bri…
hthetiot Feb 25, 2020
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ matrix:
#- sudo gem install bundler
#- sudo gem install xcpretty --no-rdoc --no-ri --no-document --quiet
#- sudo gem install xcpretty-travis-formatter --no-rdoc --no-ri --no-document --quiet
- sudo gem install cocoapods --pre # Since Travis is not always on latest version
#- sudo gem install cocoapods --pre # Since Travis is not always on latest version
cache:
directories:
- node_modules
Expand Down
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
#### Version 6.0.8
* Add Known Issues > iOS >= 13.3.1 Device support to README.md
* implement candidateToJson SDP candidate parser into RTCIceCandidate to populate foundation, component, priority, type, address, ip, protocol, port, relatedAddress and relatedPort RTCIceCandidate values #468
* Fix PeerConnection.addStream|addTrack by using UUID().uuidString preffix for PluginMediaStream and PluginMediaStreamTrack only for Janus #467

#### Version 6.0.7
* Missing Event.target value on iosRTC Events to fix Datachannel for Janus.js #447
* Update extras/renderer-and-libwebrtc-tests.js

#### Version 6.0.6
* Update ios_arch.js script link ([PR #457](https://github.com/cordova-rtc/cordova-plugin-iosrtc/pull/457) by @onerinas)
* Fix removeStream and add real Ids with UUID suffix to PluginMediaStream and PluginMediaStreamTrack ([PR #460](https://github.com/cordova-rtc/cordova-plugin-iosrtc/pull/460))
* handle webrtc-adapter multiple video.optional constraints values add support for maxHeight and maxWidth
* Update README with sdpSemantics, bundlePolicy, rtcpMuxPolicy sample

#### Version 6.0.5
* Fix missing typeof on constraints.video.facingMode.ideal

Expand Down
29 changes: 20 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,6 @@ $ cordova plugin add cordova-plugin-iosrtc

(or add it into a `<plugin>` entry in the `config.xml` of your app).


* Remove the iOS platform and add it again (this apply "hook" file):
```bash
$ cordova platform remove ios
$ cordova platform add ios
```

## Building

* Last [Tested WebRTC.framework](./lib/WebRTC.framework/) version: M69 on cordova-plugin-iosrtc version 6.0.0
Expand Down Expand Up @@ -140,11 +133,26 @@ function TestGetUserMedia() {

var pc1, pc2;

var peerConnectionConfig = {
offerToReceiveVideo: true,
offerToReceiveAudio: true,
//iceTransportPolicy: 'relay',
sdpSemantics: 'unified-plan',
//sdpSemantics: 'plan-b',
bundlePolicy: 'max-compat',
rtcpMuxPolicy: 'negotiate',
iceServers: [
{
url: "stun:stun.stunprotocol.org"
}
]
};

var peerVideoEl, peerStream;
function TestRTCPeerConnection(localStream) {

pc1 = new RTCPeerConnection();
pc2 = new RTCPeerConnection();
pc1 = new RTCPeerConnection(peerConnectionConfig);
pc2 = new RTCPeerConnection(peerConnectionConfig);

// Note: Deprecated but supported
//pc1.addStream(localStream);
Expand Down Expand Up @@ -335,6 +343,9 @@ There is no real media source attached to the `<video>` element so some [HTML5 v

Methods such as `play()`, `pause()` are not implemented. In order to pause a video just set `enabled = false` on the associated `MediaStreamTrack`.

#### iOS >= 13.3.1 Device support

To run on Devices with iOS >= 13.3.1, you need a valid Apple Developer account to sign the WebRTC dynamic frameworks for more info see https://stackoverflow.com/questions/60015309/running-ios-apps-causes-runtime-error-for-frameworks-code-signature-invalid

## Changelog

Expand Down
216 changes: 199 additions & 17 deletions dist/cordova-plugin-iosrtc.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
* cordova-plugin-iosrtc v6.0.5
* cordova-plugin-iosrtc v6.0.8
* Cordova iOS plugin exposing the full WebRTC W3C JavaScript APIs
* Copyright 2015-2017 eFace2Face, Inc. (https://eface2face.com)
* Copyright 2015-2019 BasqueVoIPMafia (https://github.com/BasqueVoIPMafia)
* Copyright 2017-2019 Cordova-RTC (https://github.com/cordova-rtc)
* Copyright 2017-2020 Cordova-RTC (https://github.com/cordova-rtc)
* License MIT
*/

Expand Down Expand Up @@ -75,6 +75,16 @@ var EventTarget = function () {
EventTarget.prototype = Object.create(YaetiEventTarget.prototype);
EventTarget.prototype.constructor = EventTarget;

EventTarget.prototype.dispatchEvent = function (event) {

Object.defineProperty(event, 'target', {
value: this,
writable: false
});

YaetiEventTarget.prototype.dispatchEvent.call(this, event);
};

/**
* Expose the EventTarget class.
*/
Expand Down Expand Up @@ -1478,15 +1488,186 @@ function onEvent(data) {
module.exports = RTCIceCandidate;



/**
* RFC-5245: http://tools.ietf.org/html/rfc5245#section-15.1
*
* candidate-attribute = "candidate" ":" foundation SP component-id SP
transport SP
priority SP
connection-address SP ;from RFC 4566
port ;port from RFC 4566
SP cand-type
[SP rel-addr]
[SP rel-port]
*(SP extension-att-name SP
extension-att-value)
*
* foundation = 1*32ice-char
* component-id = 1*5DIGIT
* transport = "UDP" / transport-extension
* transport-extension = token ; from RFC 3261
* priority = 1*10DIGIT
* cand-type = "typ" SP candidate-types
* candidate-types = "host" / "srflx" / "prflx" / "relay" / token
* rel-addr = "raddr" SP connection-address
* rel-port = "rport" SP port
* extension-att-name = byte-string ;from RFC 4566
* extension-att-value = byte-string
* ice-char = ALPHA / DIGIT / "+" / "/"
*/

/**
* RFC-3261: https://tools.ietf.org/html/rfc3261#section-25.1
*
* token = 1*(alphanum / "-" / "." / "!" / "%" / "*"
/ "_" / "+" / "`" / "'" / "~" )
*/

/*
* RFC-4566: https://tools.ietf.org/html/rfc4566#section-9
*
* port = 1*DIGIT
* IP4-address = b1 3("." decimal-uchar)
* b1 = decimal-uchar
; less than "224"
* ; The following is consistent with RFC 2373 [30], Appendix B.
* IP6-address = hexpart [ ":" IP4-address ]
* hexpart = hexseq / hexseq "::" [ hexseq ] /
"::" [ hexseq ]
* hexseq = hex4 *( ":" hex4)
* hex4 = 1*4HEXDIG
* decimal-uchar = DIGIT
/ POS-DIGIT DIGIT
/ ("1" 2*(DIGIT))
/ ("2" ("0"/"1"/"2"/"3"/"4") DIGIT)
/ ("2" "5" ("0"/"1"/"2"/"3"/"4"/"5"))
*/

var candidateToJson = (function () {
var candidateFieldName = {
FOUNDATION: 'foundation',
COMPONENT_ID: 'componentId',
TRANSPORT: 'transport',
PRIORITY: 'priority',
CONNECTION_ADDRESS: 'connectionAddress',
PORT: 'port',
CANDIDATE_TYPE: 'candidateType',
REMOTE_CANDIDATE_ADDRESS: 'remoteConnectionAddress',
REMOTE_CANDIDATE_PORT: 'remotePort'
};

var candidateType = {
HOST: 'host',
SRFLX: 'srflx',
PRFLX: 'prflx',
RELAY: 'relay'
};

var transport = {
TCP: 'TCP',
UDP: 'UDP'
};

var IPV4SEG = '(?:25[0-5]|(?:2[0-4]|1{0,1}[0-9]){0,1}[0-9])';
var IPV4ADDR = '(?:' + IPV4SEG + '\\.){3}' + IPV4SEG + '';
var IPV6SEG = '[0-9a-fA-F]{1,4}';
var IPV6ADDR =
'(?:' + IPV6SEG + ':){7,7}' + IPV6SEG + '|' + // 1:2:3:4:5:6:7:8
'(?:' + IPV6SEG + ':){1,7}:|' + // 1:: 1:2:3:4:5:6:7::
'(?:' + IPV6SEG + ':){1,6}:' + IPV6SEG + '|' + // 1::8 1:2:3:4:5:6::8 1:2:3:4:5:6::8
'(?:' + IPV6SEG + ':){1,5}(?::' + IPV6SEG + '){1,2}|' + // 1::7:8 1:2:3:4:5::7:8 1:2:3:4:5::8
'(?:' + IPV6SEG + ':){1,4}(?::' + IPV6SEG + '){1,3}|' + // 1::6:7:8 1:2:3:4::6:7:8 1:2:3:4::8
'(?:' + IPV6SEG + ':){1,3}(?::' + IPV6SEG + '){1,4}|' + // 1::5:6:7:8 1:2:3::5:6:7:8 1:2:3::8
'(?:' + IPV6SEG + ':){1,2}(?::' + IPV6SEG + '){1,5}|' + // 1::4:5:6:7:8 1:2::4:5:6:7:8 1:2::8
'' + IPV6SEG + ':(?:(?::' + IPV6SEG + '){1,6})|' + // 1::3:4:5:6:7:8 1::3:4:5:6:7:8 1::8
':(?:(?::' + IPV6SEG + '){1,7}|:)|' + // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::
'fe80:(?::' + IPV6SEG + '){0,4}%[0-9a-zA-Z]{1,}|' + // fe80::7:8%eth0 fe80::7:8%1 (link-local IPv6 addresses with zone index)
'::(?:ffff(?::0{1,4}){0,1}:){0,1}' + IPV4ADDR + '|' + // ::255.255.255.255 ::ffff:255.255.255.255 ::ffff:0:255.255.255.255 (IPv4-mapped IPv6 addresses and IPv4-translated addresses)
'(?:' + IPV6SEG + ':){1,4}:' + IPV4ADDR + ''; // 2001:db8:3:4::192.0.2.33 64:ff9b::192.0.2.33 (IPv4-Embedded IPv6 Address)

var TOKEN = '[0-9a-zA-Z\\-\\.!\\%\\*_\\+\\`\\\'\\~]+';

var CANDIDATE_TYPE = '';
Object.keys(candidateType).forEach(function (key) {
CANDIDATE_TYPE += candidateType[key] + '|';
});
CANDIDATE_TYPE += TOKEN;

var pattern = {
COMPONENT_ID: '[0-9]{1,5}',
FOUNDATION: '[a-zA-Z0-9\\+\\/\\-]+',
PRIORITY: '[0-9]{1,10}',
TRANSPORT: transport.UPD + '|' + TOKEN,
CONNECTION_ADDRESS: IPV4ADDR + '|' + IPV6ADDR,
PORT: '[0-9]{1,5}',
CANDIDATE_TYPE: CANDIDATE_TYPE
};

return function candidateToJson(iceCandidate) {
var iceCandidateJson = null;

if (iceCandidate && typeof iceCandidate === 'string') {
var ICE_CANDIDATE_PATTERN = new RegExp(
'candidate:(' + pattern.FOUNDATION + ')' + // 10
'\\s(' + pattern.COMPONENT_ID + ')' + // 1
'\\s(' + pattern.TRANSPORT + ')' + // UDP
'\\s(' + pattern.PRIORITY + ')' + // 1845494271
'\\s(' + pattern.CONNECTION_ADDRESS + ')' + // 13.93.107.159
'\\s(' + pattern.PORT + ')' + // 53705
'\\s' +
'typ' +
'\\s(' + pattern.CANDIDATE_TYPE + ')' + // typ prflx
'(?:\\s' +
'raddr' +
'\\s(' + pattern.CONNECTION_ADDRESS + ')' + // raddr 10.1.221.7
'\\s' +
'rport' +
'\\s(' + pattern.PORT + '))?' // rport 54805
);

var iceCandidateFields = iceCandidate.match(ICE_CANDIDATE_PATTERN);
if (iceCandidateFields) {
iceCandidateJson = {};
Object.keys(candidateFieldName).forEach(function (key, i) {
// i+1 because match returns the entire match result
// and the parentheses-captured matched results.
if (iceCandidateFields.length > (i + 1) && iceCandidateFields[i + 1]) {
iceCandidateJson[candidateFieldName[key]] = iceCandidateFields[i + 1];
}
});
}
}

return iceCandidateJson;
};
}());

// See https://developer.mozilla.org/en-US/docs/Web/API/RTCIceCandidate/RTCIceCandidate
function RTCIceCandidate(data) {
data = data || {};

// Public atributes.
this.sdpMid = data.sdpMid;
this.sdpMLineIndex = data.sdpMLineIndex;
this.candidate = data.candidate;
}

// Parse candidate SDP:
// Example: candidate:1829696681 1 udp 2122262783 2a01:cb05:8d3e:a300:e1ad:79c1:7096:8ba0 49778 typ host generation 0 ufrag c9L6 network-id 2 network-cost 10
var iceCandidateFields = candidateToJson(this.candidate);
this.foundation = iceCandidateFields.foundation;
this.component = iceCandidateFields.componentId;
this.priority = iceCandidateFields.priority;
this.type = iceCandidateFields.candidateType;

this.address = iceCandidateFields.connectionAddress;
this.ip = iceCandidateFields.connectionAddress;
this.protocol = iceCandidateFields.transport;
this.port = iceCandidateFields.port;

this.relatedAddress = iceCandidateFields.remoteConnectionAddress || null;
this.relatedPort = iceCandidateFields.remotePort || null;
}
},{}],10:[function(_dereq_,module,exports){
(function (global){
/**
Expand All @@ -1498,7 +1679,7 @@ module.exports = RTCPeerConnection;
/**
* Dependencies.
*/
var
var
debug = _dereq_('debug')('iosrtc:RTCPeerConnection'),
debugerror = _dereq_('debug')('iosrtc:ERROR:RTCPeerConnection'),
exec = _dereq_('cordova/exec'),
Expand All @@ -1520,7 +1701,7 @@ function deprecateWarning(method, newMethod) {
if (!newMethod) {
console.warn(method + ' is deprecated.');
} else {
console.warn(method + ' method is deprecated, use ' + newMethod + ' instead.');
console.warn(method + ' method is deprecated, use ' + newMethod + ' instead.');
}
}

Expand All @@ -1537,10 +1718,11 @@ function RTCPeerConnection(pcConfig, pcConstraints) {
// Object.defineProperties(this, RTCPeerConnection.prototype_descriptor);

// Fix webrtc-adapter bad SHIM on addTrack causing error when original does support multiple streams.
// NotSupportedError: The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.
// NotSupportedError: The adapter.js addTrack, addStream polyfill only supports a single stream which is associated with the specified track.
Object.defineProperty(this, 'addTrack', RTCPeerConnection.prototype_descriptor.addTrack);
Object.defineProperty(this, 'addStream', RTCPeerConnection.prototype_descriptor.addStream);
Object.defineProperty(this, 'getLocalStreams', RTCPeerConnection.prototype_descriptor.getLocalStreams);

// Public atributes.
this._localDescription = null;
this.remoteDescription = null;
Expand All @@ -1565,17 +1747,17 @@ RTCPeerConnection.prototype = Object.create(EventTarget.prototype);
RTCPeerConnection.prototype.constructor = RTCPeerConnection;

Object.defineProperties(RTCPeerConnection.prototype, {
'localDescription': {
'localDescription': {
// Fix webrtc-adapter TypeError: Attempting to change the getter of an unconfigurable property.
configurable: true,
get: function() {
get: function() {
return this._localDescription;
}
},
'connectionState': {
get: function() {
'connectionState': {
get: function() {
return this.iceConnectionState;
}
}
},
'onicecandidate': {
// Fix webrtc-adapter TypeError: Attempting to change the getter of an unconfigurable property.
Expand Down Expand Up @@ -1700,8 +1882,8 @@ RTCPeerConnection.prototype.setLocalDescription = function (desc) {
});
}

// "This is no longer necessary, however; RTCPeerConnection.setLocalDescription() and other
// methods which take SDP as input now directly accept an object conforming to the RTCSessionDescriptionInit dictionary,
// "This is no longer necessary, however; RTCPeerConnection.setLocalDescription() and other
// methods which take SDP as input now directly accept an object conforming to the RTCSessionDescriptionInit dictionary,
// so you don't have to instantiate an RTCSessionDescription yourself.""
// Source: https://developer.mozilla.org/en-US/docs/Web/API/RTCSessionDescription/RTCSessionDescription#Example
// Still we do instnanciate RTCSessionDescription, so internal object is used properly.
Expand Down Expand Up @@ -1751,8 +1933,8 @@ RTCPeerConnection.prototype.setRemoteDescription = function (desc) {

debug('setRemoteDescription() [desc:%o]', desc);

// "This is no longer necessary, however; RTCPeerConnection.setLocalDescription() and other
// methods which take SDP as input now directly accept an object conforming to the RTCSessionDescriptionInit dictionary,
// "This is no longer necessary, however; RTCPeerConnection.setLocalDescription() and other
// methods which take SDP as input now directly accept an object conforming to the RTCSessionDescriptionInit dictionary,
// so you don't have to instantiate an RTCSessionDescription yourself.""
// Source: https://developer.mozilla.org/en-US/docs/Web/API/RTCSessionDescription/RTCSessionDescription#Example
// Still we do instnanciate RTCSessionDescription so internal object is used properly.
Expand Down Expand Up @@ -1930,7 +2112,7 @@ RTCPeerConnection.prototype.addTrack = function (track, stream) {
for (id in this.localStreams) {
if (this.localStreams.hasOwnProperty(id)) {
// Target provided stream argument or first added stream to group track
if (!stream || (stream && stream.id === id)) {
if (!stream || (stream && stream.id === id)) {
stream = this.localStreams[id];
stream.addTrack(track);
exec(null, null, 'iosrtcPlugin', 'RTCPeerConnection_addTrack', [this.pcId, track.id, id]);
Expand Down
Loading