Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

# Xcode
build/
.build/
*.pbxuser
!default.pbxuser
*.mode1v3
Expand All @@ -18,6 +19,8 @@ profile
DerivedData
*.hmap
*.ipa
.swiftpm/
Package.resolved

# Bundler
.bundle
Expand Down
41 changes: 41 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// swift-tools-version: 5.9
import PackageDescription

let package = Package(
name: "WKWebViewRTC",
platforms: [
.iOS(.v13) // Bundle.module requires iOS 13+
],
products: [
.library(
name: "WKWebViewRTC",
targets: ["WKWebViewRTC"]
),
],
dependencies: [
.package(
url: "https://github.com/stasel/WebRTC.git",
.upToNextMajor(from: "125.0.0")
),
],
targets: [
.target(
name: "WKWebViewRTC",
dependencies: [
.product(name: "WebRTC", package: "WebRTC")
],
path: "WKWebViewRTC",
exclude: [
"Assets", // empty, .gitkeep only
"Js/src", // 25 JS source files not needed in binary
"Js/package.json" // Node.js build config, not needed
// Js/.gitignore is a hidden file; SPM ignores it automatically
// Classes/.gitkeep is a hidden file; SPM ignores it automatically
],
sources: ["Classes"],
resources: [
.process("Js/jsWKWebViewRTC.js") // 141 KB compiled JS bridge
]
),
]
)
2 changes: 1 addition & 1 deletion WKWebViewRTC/Classes/WKWebViewRTC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class WKWebViewRTC : NSObject {

setWebView(webview: wkwebview)

if let path = Bundle(for: type(of: self)).path(forResource: "jsWKWebViewRTC", ofType: "js") {
if let path = Bundle.module.path(forResource: "jsWKWebViewRTC", ofType: "js") {
if let bindingJS = try? String(contentsOfFile: path, encoding: .utf8) {
let script = WKUserScript(source: bindingJS, injectionTime: .atDocumentStart, forMainFrameOnly: false)
self.userContentController?.addUserScript(script)
Expand Down
6 changes: 3 additions & 3 deletions WKWebViewRTC/Classes/iMediaStreamRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class iMediaStreamRenderer : NSObject, RTCVideoViewDelegate {
var elementView: UIView
var pluginMediaStream: iMediaStream?

var videoView: RTCEAGLVideoView
var videoView: RTCMTLVideoView
var rtcAudioTrack: RTCAudioTrack?
var rtcVideoTrack: RTCVideoTrack?
var pluginVideoTrack: iMediaStreamTrack?
Expand All @@ -45,7 +45,7 @@ class iMediaStreamRenderer : NSObject, RTCVideoViewDelegate {

// The effective video view in which the the video stream is shown.
// It's placed over the elementView.
self.videoView = RTCEAGLVideoView()
self.videoView = RTCMTLVideoView()
self.videoView.isUserInteractionEnabled = false

self.elementView.isUserInteractionEnabled = false
Expand Down Expand Up @@ -308,7 +308,7 @@ class iMediaStreamRenderer : NSObject, RTCVideoViewDelegate {
}

/**
* Methods inherited from RTCEAGLVideoViewDelegate.
* Methods inherited from RTCVideoViewDelegate (RTCMTLVideoView).
*/

func videoView(_ videoView: RTCVideoRenderer, didChangeVideoSize size: CGSize) {
Expand Down
3 changes: 1 addition & 2 deletions WKWebViewRTC/Classes/iRTCPeerConnectionConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import WebRTC
class iRTCPeerConnectionConfig {

fileprivate let allowedSdpSemantics = [
"plan-b": RTCSdpSemantics.planB,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would still allow it to support old webrtc api usage. We kept it in iosrtc.

"unified-plan": RTCSdpSemantics.unifiedPlan
]

Expand Down Expand Up @@ -50,7 +49,7 @@ class iRTCPeerConnectionConfig {

let sdpSemanticsConfig = pcConfig?.object(forKey: "sdpSemantics") as? String;
let sdpSemantics = (sdpSemanticsConfig != nil && allowedSdpSemantics[sdpSemanticsConfig!] != nil) ?
allowedSdpSemantics[sdpSemanticsConfig!] : RTCSdpSemantics.planB
allowedSdpSemantics[sdpSemanticsConfig!] : RTCSdpSemantics.unifiedPlan
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


rtcConfiguration.sdpSemantics = sdpSemantics!;

Expand Down