Skip to content

Commit

Permalink
fix: use Double over Float to fix native video rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
dunnky committed Dec 3, 2018
1 parent d46ca8f commit 2031bfa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/PluginGetUserMedia.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class PluginGetUserMedia {
let videoMaxWidth = constraints.object(forKey: "videoMaxWidth") as? Int ?? 0
let videoMinHeight = constraints.object(forKey: "videoMinHeight") as? Int ?? 0
let videoMaxHeight = constraints.object(forKey: "videoMaxHeight") as? Int ?? 0
let videoMinFrameRate = constraints.object(forKey: "videoMinFrameRate") as? Float ?? 0.0
let videoMaxFrameRate = constraints.object(forKey: "videoMaxFrameRate") as? Float ?? 0.0
let videoMinFrameRate = constraints.object(forKey: "videoMinFrameRate") as? Double ?? 0.0
let videoMaxFrameRate = constraints.object(forKey: "videoMaxFrameRate") as? Double ?? 0.0

var rtcMediaStream: RTCMediaStream
var pluginMediaStream: PluginMediaStream?
Expand Down
22 changes: 11 additions & 11 deletions src/PluginMediaStreamRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,26 +135,26 @@ class PluginMediaStreamRenderer : NSObject, RTCEAGLVideoViewDelegate {


func refresh(_ data: NSDictionary) {
let elementLeft = data.object(forKey: "elementLeft") as? Float ?? 0
let elementTop = data.object(forKey: "elementTop") as? Float ?? 0
let elementWidth = data.object(forKey: "elementWidth") as? Float ?? 0
let elementHeight = data.object(forKey: "elementHeight") as? Float ?? 0
var videoViewWidth = data.object(forKey: "videoViewWidth") as? Float ?? 0
var videoViewHeight = data.object(forKey: "videoViewHeight") as? Float ?? 0
let elementLeft = data.object(forKey: "elementLeft") as? Double ?? 0
let elementTop = data.object(forKey: "elementTop") as? Double ?? 0
let elementWidth = data.object(forKey: "elementWidth") as? Double ?? 0
let elementHeight = data.object(forKey: "elementHeight") as? Double ?? 0
var videoViewWidth = data.object(forKey: "videoViewWidth") as? Double ?? 0
var videoViewHeight = data.object(forKey: "videoViewHeight") as? Double ?? 0
let visible = data.object(forKey: "visible") as? Bool ?? true
let opacity = data.object(forKey: "opacity") as? Float ?? 1
let zIndex = data.object(forKey: "zIndex") as? Float ?? 0
let opacity = data.object(forKey: "opacity") as? Double ?? 1
let zIndex = data.object(forKey: "zIndex") as? Double ?? 0
let mirrored = data.object(forKey: "mirrored") as? Bool ?? false
let clip = data.object(forKey: "clip") as? Bool ?? true
let borderRadius = data.object(forKey: "borderRadius") as? Float ?? 0
let borderRadius = data.object(forKey: "borderRadius") as? Double ?? 0

NSLog("PluginMediaStreamRenderer#refresh() [elementLeft:%@, elementTop:%@, elementWidth:%@, elementHeight:%@, videoViewWidth:%@, videoViewHeight:%@, visible:%@, opacity:%@, zIndex:%@, mirrored:%@, clip:%@, borderRadius:%@]",
String(elementLeft), String(elementTop), String(elementWidth), String(elementHeight),
String(videoViewWidth), String(videoViewHeight), String(visible), String(opacity), String(zIndex),
String(mirrored), String(clip), String(borderRadius))

let videoViewLeft: Float = (elementWidth - videoViewWidth) / 2
let videoViewTop: Float = (elementHeight - videoViewHeight) / 2
let videoViewLeft: Double = (elementWidth - videoViewWidth) / 2
let videoViewTop: Double = (elementHeight - videoViewHeight) / 2

self.elementView.frame = CGRect(
x: CGFloat(elementLeft),
Expand Down

4 comments on commit 2031bfa

@ibc
Copy link
Collaborator

@ibc ibc commented on 2031bfa Jan 24, 2019

Choose a reason for hiding this comment

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

@onerinas
Copy link
Contributor

Choose a reason for hiding this comment

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

@kklindic I've added a forked version in npm for my use. Feel free to use if needed.
https://www.npmjs.com/package/cordova-plugin-iosrtc-fork
https://github.com/onerinas/cordova-plugin-iosrtc-fork

@ibc I might not be able to cover all items mentioned in #338 hence the forked version.

I've kept the same name and mentioned as fork to give credit to this repository. Hope that's not an issue.

@dunnky
Copy link
Contributor Author

@dunnky dunnky commented on 2031bfa Jul 31, 2019

Choose a reason for hiding this comment

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

You can always do npm install git+https://github.com/BasqueVoIPMafia/cordova-plugin-iosrtc.git#master as well.

@onerinas
Copy link
Contributor

Choose a reason for hiding this comment

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

@uunp Hey, I ended up using https://github.com/simplyrtc/cordova-plugin-iosrtc-simplyrtc for Swift 4.2 support.
It would be really helpful if you can make the fix in https://github.com/simplyrtc/cordova-plugin-iosrtc-simplyrtc.

If you are busy, let me know if I can cherrypick your commit and create a pull request there.

Thanks

Please # to comment.