Skip to content

Commit

Permalink
Merge pull request #277 from ant-media/fix/credentials-cors
Browse files Browse the repository at this point in the history
Add support credentials header for CORS
  • Loading branch information
mekya authored Apr 11, 2022
2 parents 1ef52ba + 60d527f commit e4572cd
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 32 deletions.
18 changes: 18 additions & 0 deletions src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@
<param-name>cors.allowed.methods</param-name>
<param-value>GET,POST,HEAD,OPTIONS,PUT,DELETE</param-value>
</init-param>

<!-- cors.allowed.origins -> * and credentials are not supported at the same time.
If you set to cors.allowed.origins to specific domains and support credentials open the below lines
<init-param>
<param-name>cors.support.credentials</param-name>
<param-value>true</param-value>
</init-param>
-->
<init-param>
<param-name>cors.allowed.headers</param-name>
<param-value>Accept, Origin, X-Requested-With, Access-Control-Request-Headers, Content-Type, Access-Control-Request-Method, Authorization</param-value>
Expand Down Expand Up @@ -157,6 +165,16 @@
<url-pattern>/rest/*</url-pattern>
</filter-mapping>

<filter>
<filter-name>RestProxyFilter</filter-name>
<filter-class>io.antmedia.rest.RestProxyFilter</filter-class>
<async-supported>true</async-supported>
</filter>
<filter-mapping>
<filter-name>RestProxyFilter</filter-name>
<url-pattern>/rest/v2/broadcasts/*</url-pattern>
</filter-mapping>

<filter>
<filter-name>RestAuthenticationFiler</filter-name>
<filter-class>io.antmedia.filter.IPFilter</filter-class>
Expand Down
53 changes: 21 additions & 32 deletions src/main/webapp/js/webrtc_adaptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -1014,34 +1014,6 @@ export class WebRTCAdaptor
});
};

/**
* Called internally to get the video sender of the published stream.
* streamId: unique id for the stream
*/
getVideoSender(streamId)
{
var videoSender = null;
if ((adapter.browserDetails.browser === 'chrome' ||
(adapter.browserDetails.browser === 'firefox' ||
adapter.browserDetails.browser === 'safari' &&
adapter.browserDetails.version >= 64)) &&
'RTCRtpSender' in window &&
'setParameters' in window.RTCRtpSender.prototype)
{
if (this.remotePeerConnection[streamId] != null) {
const senders = this.remotePeerConnection[streamId].getSenders();

for (let i = 0; i < senders.length; i++) {
if (senders[i].track != null && senders[i].track.kind == "video") {
videoSender = senders[i];
break;
}
}
}

}
return videoSender;
}

/**
* Toggle video track on the server side.
Expand Down Expand Up @@ -1452,10 +1424,27 @@ export class WebRTCAdaptor
switchAudioInputSource(streamId, deviceId) {this.mediaManager.switchAudioInputSource(streamId, deviceId);}
setVolumeLevel(volumeLevel) {this.mediaManager.setVolumeLevel(volumeLevel);}
enableAudioLevelForLocalStream(levelCallback, period) {this.mediaManager.enableAudioLevelForLocalStream(levelCallback, period);}
changeBandwidth(bandwidth, streamId) {this.mediaManager.changeBandwidth(bandwidth, streamId);};
enableAudioLevelWhenMuted() {this.mediaManager.enableAudioLevelWhenMuted()};
disableAudioLevelWhenMuted() {this.mediaManager.disableAudioLevelWhenMuted()};
closeStream() {this.mediaManager.closeStream()};

changeBandwidth(bandwidth, streamId) {
this.mediaManager.changeBandwidth(bandwidth, streamId);
}

enableAudioLevelWhenMuted() {
this.mediaManager.enableAudioLevelWhenMuted();
}

disableAudioLevelWhenMuted() {
this.mediaManager.disableAudioLevelWhenMuted();
}

getVideoSender(streamId) {
return this.mediaManager.getVideoSender(streamId);
}

closeStream() {
this.mediaManager.closeStream();
};

}


Expand Down

0 comments on commit e4572cd

Please sign in to comment.