Skip to content

Commit

Permalink
disable MediaStreamRenderer 500ms Intervals, add refreshVideos on win…
Browse files Browse the repository at this point in the history
…dow resize event to resize peer MediaStreamRenderer while local MediaStreamRenderer will resize due device video size change in most of the cases
  • Loading branch information
hthetiot committed Oct 24, 2019
1 parent 7814fee commit 07d00dc
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 22 deletions.
30 changes: 19 additions & 11 deletions dist/cordova-plugin-iosrtc.js
Original file line number Diff line number Diff line change
Expand Up @@ -620,10 +620,12 @@ function MediaStreamRenderer(element) {

exec(onResultOK, null, 'iosrtcPlugin', 'new_MediaStreamRenderer', [this.id]);

this.refresh(this);
this.refreshInterval = setInterval(function () {
self.refresh(self);
}, 500);
this.refresh();

// TODO cause video resizing jiggling add semaphore
//this.refreshInterval = setInterval(function () {
// self.refresh(self);
//}, 500);

element.render = this;
}
Expand Down Expand Up @@ -892,12 +894,12 @@ MediaStreamRenderer.prototype.refresh = function () {

function nativeRefresh() {
var data = {
elementLeft: elementLeft,
elementTop: elementTop,
elementWidth: elementWidth,
elementHeight: elementHeight,
videoViewWidth: parseInt(videoViewWidth , 10),
videoViewHeight: parseInt(videoViewHeight , 10),
elementLeft: Math.round(elementLeft),
elementTop: Math.round(elementTop),
elementWidth: Math.round(elementWidth),
elementHeight: Math.round(elementHeight),
videoViewWidth: Math.round(videoViewWidth),
videoViewHeight: Math.round(videoViewHeight),
visible: visible,
opacity: opacity,
zIndex: zIndex,
Expand Down Expand Up @@ -952,7 +954,7 @@ function onEvent(data) {
case 'videoresize':
this.videoWidth = data.size.width;
this.videoHeight = data.size.height;
this.refresh(this);
this.refresh();

event = new Event(type);
event.videoWidth = data.size.width;
Expand Down Expand Up @@ -2808,6 +2810,12 @@ function refreshVideos() {
}
}

// refreshVideos on device orientation change to resize peers video
// while local video will resize du orientation change
window.addEventListener('resize', function () {
refreshVideos();
});

function selectAudioOutput(output) {
debug('selectAudioOutput() | [output:"%s"]', output);

Expand Down
24 changes: 13 additions & 11 deletions js/MediaStreamRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ function MediaStreamRenderer(element) {

exec(onResultOK, null, 'iosrtcPlugin', 'new_MediaStreamRenderer', [this.id]);

this.refresh(this);
this.refreshInterval = setInterval(function () {
self.refresh(self);
}, 500);
this.refresh();

// TODO cause video resizing jiggling add semaphore
//this.refreshInterval = setInterval(function () {
// self.refresh(self);
//}, 500);

element.render = this;
}
Expand Down Expand Up @@ -314,12 +316,12 @@ MediaStreamRenderer.prototype.refresh = function () {

function nativeRefresh() {
var data = {
elementLeft: elementLeft,
elementTop: elementTop,
elementWidth: elementWidth,
elementHeight: elementHeight,
videoViewWidth: parseInt(videoViewWidth , 10),
videoViewHeight: parseInt(videoViewHeight , 10),
elementLeft: Math.round(elementLeft),
elementTop: Math.round(elementTop),
elementWidth: Math.round(elementWidth),
elementHeight: Math.round(elementHeight),
videoViewWidth: Math.round(videoViewWidth),
videoViewHeight: Math.round(videoViewHeight),
visible: visible,
opacity: opacity,
zIndex: zIndex,
Expand Down Expand Up @@ -374,7 +376,7 @@ function onEvent(data) {
case 'videoresize':
this.videoWidth = data.size.width;
this.videoHeight = data.size.height;
this.refresh(this);
this.refresh();

event = new Event(type);
event.videoWidth = data.size.width;
Expand Down
6 changes: 6 additions & 0 deletions js/iosrtc.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ function refreshVideos() {
}
}

// refreshVideos on device orientation change to resize peers video
// while local video will resize du orientation change
window.addEventListener('resize', function () {
refreshVideos();
});

function selectAudioOutput(output) {
debug('selectAudioOutput() | [output:"%s"]', output);

Expand Down

0 comments on commit 07d00dc

Please sign in to comment.