Skip to content

Commit

Permalink
Be strit with var&let (a bit more ready for Swifth 2.0).
Browse files Browse the repository at this point in the history
  • Loading branch information
ibc committed Aug 6, 2015
1 parent 6a9afa8 commit caff432
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-iosrtc",
"version": "1.4.3",
"version": "1.4.4-pre",
"description": "Cordova iOS plugin exposing the full WebRTC W3C JavaScript APIs",
"author": "Iñaki Baz Castillo at eFace2Face, inc. (https://eface2face.com)",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion src/PluginGetMediaDevices.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class PluginGetMediaDevices {

let devices = AVCaptureDevice.devices() as! Array<AVCaptureDevice>

var json: NSMutableDictionary = [
let json: NSMutableDictionary = [
"devices": NSMutableDictionary()
]

Expand Down
10 changes: 5 additions & 5 deletions src/PluginMediaStream.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ class PluginMediaStream : NSObject, RTCMediaStreamDelegate {
self.id = rtcMediaStream.label // Old API uses "label" instead of "id".

for track: RTCMediaStreamTrack in (self.rtcMediaStream.audioTracks as! Array<RTCMediaStreamTrack>) {
var pluginMediaStreamTrack = PluginMediaStreamTrack(rtcMediaStreamTrack: track)
let pluginMediaStreamTrack = PluginMediaStreamTrack(rtcMediaStreamTrack: track)

pluginMediaStreamTrack.run()
self.audioTracks[pluginMediaStreamTrack.id] = pluginMediaStreamTrack
}

for track: RTCMediaStreamTrack in (self.rtcMediaStream.videoTracks as! Array<RTCMediaStreamTrack>) {
var pluginMediaStreamTrack = PluginMediaStreamTrack(rtcMediaStreamTrack: track)
let pluginMediaStreamTrack = PluginMediaStreamTrack(rtcMediaStreamTrack: track)

pluginMediaStreamTrack.run()
self.videoTracks[pluginMediaStreamTrack.id] = pluginMediaStreamTrack
Expand All @@ -44,7 +44,7 @@ class PluginMediaStream : NSObject, RTCMediaStreamDelegate {


func getJSON() -> NSDictionary {
var json: NSMutableDictionary = [
let json: NSMutableDictionary = [
"id": self.id,
"audioTracks": NSMutableDictionary(),
"videoTracks": NSMutableDictionary()
Expand Down Expand Up @@ -140,7 +140,7 @@ class PluginMediaStream : NSObject, RTCMediaStreamDelegate {
func OnAddAudioTrack(rtcMediaStream: RTCMediaStream!, track: RTCMediaStreamTrack!) {
NSLog("PluginMediaStream | OnAddAudioTrack [label:\(track.label)]")

var pluginMediaStreamTrack = PluginMediaStreamTrack(rtcMediaStreamTrack: track)
let pluginMediaStreamTrack = PluginMediaStreamTrack(rtcMediaStreamTrack: track)

pluginMediaStreamTrack.run()
self.audioTracks[pluginMediaStreamTrack.id] = pluginMediaStreamTrack
Expand All @@ -159,7 +159,7 @@ class PluginMediaStream : NSObject, RTCMediaStreamDelegate {
func OnAddVideoTrack(rtcMediaStream: RTCMediaStream!, track: RTCMediaStreamTrack!) {
NSLog("PluginMediaStream | OnAddVideoTrack [label:\(track.label)]")

var pluginMediaStreamTrack = PluginMediaStreamTrack(rtcMediaStreamTrack: track)
let pluginMediaStreamTrack = PluginMediaStreamTrack(rtcMediaStreamTrack: track)

pluginMediaStreamTrack.run()
self.videoTracks[pluginMediaStreamTrack.id] = pluginMediaStreamTrack
Expand Down
12 changes: 6 additions & 6 deletions src/PluginMediaStreamRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class PluginMediaStreamRenderer : RTCEAGLVideoViewDelegate {

self.webView = webView
self.eventListener = eventListener
self.elementView = RTCEAGLVideoView()
self.elementView = UIView()
self.videoView = RTCEAGLVideoView()

self.webView.addSubview(self.elementView)
Expand Down Expand Up @@ -78,7 +78,7 @@ class PluginMediaStreamRenderer : RTCEAGLVideoViewDelegate {
return
}

var oldRtcVideoTrack: RTCVideoTrack? = self.rtcVideoTrack
let oldRtcVideoTrack: RTCVideoTrack? = self.rtcVideoTrack

self.rtcAudioTrack = nil
self.rtcVideoTrack = nil
Expand Down Expand Up @@ -141,8 +141,8 @@ class PluginMediaStreamRenderer : RTCEAGLVideoViewDelegate {

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

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

self.elementView.frame = CGRectMake(
CGFloat(elementLeft),
Expand All @@ -152,7 +152,7 @@ class PluginMediaStreamRenderer : RTCEAGLVideoViewDelegate {
)

// NOTE: Avoid a zero-size UIView for the video (the library complains).
if (videoViewWidth == 0 || videoViewHeight == 0) {
if videoViewWidth == 0 || videoViewHeight == 0 {
videoViewWidth = 1
videoViewHeight = 1
self.videoView.hidden = true
Expand Down Expand Up @@ -182,7 +182,7 @@ class PluginMediaStreamRenderer : RTCEAGLVideoViewDelegate {
self.elementView.transform = CGAffineTransformMakeScale(-1.0, 1.0)
}

if (clip) {
if clip {
self.elementView.clipsToBounds = true
} else {
self.elementView.clipsToBounds = false
Expand Down
8 changes: 4 additions & 4 deletions src/PluginRTCDataChannel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,12 @@ class PluginRTCDataChannel : NSObject, RTCDataChannelDelegate {
) {
NSLog("PluginRTCDataChannel#sendString()")

var buffer = RTCDataBuffer(
let buffer = RTCDataBuffer(
data: (data.dataUsingEncoding(NSUTF8StringEncoding))!,
isBinary: false
)

var result = self.rtcDataChannel!.sendData(buffer)
let result = self.rtcDataChannel!.sendData(buffer)
if result == true {
callback(data: [
"bufferedAmount": self.rtcDataChannel!.bufferedAmount
Expand All @@ -151,12 +151,12 @@ class PluginRTCDataChannel : NSObject, RTCDataChannelDelegate {
) {
NSLog("PluginRTCDataChannel#sendBinary()")

var buffer = RTCDataBuffer(
let buffer = RTCDataBuffer(
data: data,
isBinary: true
)

var result = self.rtcDataChannel!.sendData(buffer)
let result = self.rtcDataChannel!.sendData(buffer)
if result == true {
callback(data: [
"bufferedAmount": self.rtcDataChannel!.bufferedAmount
Expand Down
2 changes: 1 addition & 1 deletion src/PluginRTCPeerConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class PluginRTCPeerConnection : NSObject, RTCPeerConnectionDelegate, RTCSessionD
let sdpMLineIndex = candidate.objectForKey("sdpMLineIndex") as? Int ?? 0
let candidate = candidate.objectForKey("candidate") as? String ?? ""

var result: Bool = self.rtcPeerConnection.addICECandidate(RTCICECandidate(
let result: Bool = self.rtcPeerConnection.addICECandidate(RTCICECandidate(
mid: sdpMid,
index: sdpMLineIndex,
sdp: candidate
Expand Down
8 changes: 4 additions & 4 deletions src/PluginRTCPeerConnectionConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ class PluginRTCPeerConnectionConfig {
init(pcConfig: NSDictionary?) {
NSLog("PluginRTCPeerConnectionConfig#init()")

var iceServers = pcConfig?.objectForKey("iceServers") as? [NSDictionary]
let iceServers = pcConfig?.objectForKey("iceServers") as? [NSDictionary]

if iceServers == nil {
return
}

for iceServer: NSDictionary in iceServers! {
var url = iceServer.objectForKey("url") as? String
var username = iceServer.objectForKey("username") as? String ?? ""
var password = iceServer.objectForKey("credential") as? String ?? ""
let url = iceServer.objectForKey("url") as? String
let username = iceServer.objectForKey("username") as? String ?? ""
let password = iceServer.objectForKey("credential") as? String ?? ""

if (url != nil) {
NSLog("PluginRTCPeerConnectionConfig#init() | adding ICE server [url:\(url!), username:\(username), password:\(password)]")
Expand Down
16 changes: 8 additions & 8 deletions src/iosrtcPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class iosrtcPlugin : CDVPlugin {
pcConfig: pcConfig,
pcConstraints: pcConstraints,
eventListener: { (data: NSDictionary) -> Void in
var result = CDVPluginResult(status: CDVCommandStatus_OK, messageAsDictionary: data as [NSObject : AnyObject])
let result = CDVPluginResult(status: CDVCommandStatus_OK, messageAsDictionary: data as [NSObject : AnyObject])

// Allow more callbacks.
result.setKeepCallbackAsBool(true);
Expand Down Expand Up @@ -316,14 +316,14 @@ class iosrtcPlugin : CDVPlugin {
label: label,
options: options,
eventListener: { (data: NSDictionary) -> Void in
var result = CDVPluginResult(status: CDVCommandStatus_OK, messageAsDictionary: data as [NSObject : AnyObject])
let result = CDVPluginResult(status: CDVCommandStatus_OK, messageAsDictionary: data as [NSObject : AnyObject])

// Allow more callbacks.
result.setKeepCallbackAsBool(true);
self.emit(command.callbackId, result: result)
},
eventListenerForBinaryMessage: { (data: NSData) -> Void in
var result = CDVPluginResult(status: CDVCommandStatus_OK, messageAsArrayBuffer: data)
let result = CDVPluginResult(status: CDVCommandStatus_OK, messageAsArrayBuffer: data)

// Allow more callbacks.
result.setKeepCallbackAsBool(true);
Expand Down Expand Up @@ -369,14 +369,14 @@ class iosrtcPlugin : CDVPlugin {
dispatch_async(self.queue) {
pluginRTCPeerConnection!.RTCDataChannel_setListener(dcId,
eventListener: { (data: NSDictionary) -> Void in
var result = CDVPluginResult(status: CDVCommandStatus_OK, messageAsDictionary: data as [NSObject : AnyObject])
let result = CDVPluginResult(status: CDVCommandStatus_OK, messageAsDictionary: data as [NSObject : AnyObject])

// Allow more callbacks.
result.setKeepCallbackAsBool(true);
self.emit(command.callbackId, result: result)
},
eventListenerForBinaryMessage: { (data: NSData) -> Void in
var result = CDVPluginResult(status: CDVCommandStatus_OK, messageAsArrayBuffer: data)
let result = CDVPluginResult(status: CDVCommandStatus_OK, messageAsArrayBuffer: data)

// Allow more callbacks.
result.setKeepCallbackAsBool(true);
Expand Down Expand Up @@ -472,7 +472,7 @@ class iosrtcPlugin : CDVPlugin {
// Set the eventListener.
pluginMediaStream!.setListener(
{ (data: NSDictionary) -> Void in
var result = CDVPluginResult(status: CDVCommandStatus_OK, messageAsDictionary: data as [NSObject : AnyObject])
let result = CDVPluginResult(status: CDVCommandStatus_OK, messageAsDictionary: data as [NSObject : AnyObject])

// Allow more callbacks.
result.setKeepCallbackAsBool(true);
Expand Down Expand Up @@ -563,7 +563,7 @@ class iosrtcPlugin : CDVPlugin {
// Set the eventListener.
pluginMediaStreamTrack!.setListener(
{ (data: NSDictionary) -> Void in
var result = CDVPluginResult(status: CDVCommandStatus_OK, messageAsDictionary: data as [NSObject : AnyObject])
let result = CDVPluginResult(status: CDVCommandStatus_OK, messageAsDictionary: data as [NSObject : AnyObject])

// Allow more callbacks.
result.setKeepCallbackAsBool(true);
Expand Down Expand Up @@ -619,7 +619,7 @@ class iosrtcPlugin : CDVPlugin {
let id = command.argumentAtIndex(0) as! Int

let pluginMediaStreamRenderer = PluginMediaStreamRenderer(
webView: self.webView,
webView: self.webView!,
eventListener: { (data: NSDictionary) -> Void in
var result = CDVPluginResult(status: CDVCommandStatus_OK, messageAsDictionary: data as [NSObject : AnyObject])

Expand Down

0 comments on commit caff432

Please sign in to comment.