Skip to content

Commit

Permalink
fixed track Id in transeivers description
Browse files Browse the repository at this point in the history
  • Loading branch information
RSATom committed May 15, 2022
1 parent 273735e commit fea2057
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/PluginMediaStreamTrack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class PluginMediaStreamTrack : NSObject {
}
}

func getJSON() -> NSDictionary {
func getJSON() -> [String: Any] {
return [
"id": self.id,
"kind": self.kind,
Expand Down
38 changes: 35 additions & 3 deletions src/PluginRTCPeerConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -815,17 +815,49 @@ class PluginRTCPeerConnection : NSObject, RTCPeerConnectionDelegate {
return currentMediaStreamTrack;
}

func getTransceiversJSON() -> [NSDictionary] {
func getTransceiversJSON() -> [[String: Any]] {
if (!IsUnifiedPlan()) {
NSLog("PluginRTCPeerConnection#getTransceiversJSON() | transceiers is not available when using plan-b")
return [];
}

return self.rtcPeerConnection.transceivers.map({ (transceiver: RTCRtpTransceiver) -> NSDictionary in
return self.rtcPeerConnection.transceivers.map({ (transceiver: RTCRtpTransceiver) -> [String: Any] in
// let receiverTrack = self.getPluginMediaStreamTrack(transceiver.receiver.track, trackId: nil);
// let senderTrack = self.getPluginMediaStreamTrack(transceiver.sender.track, trackId: nil);
let transceiverHolder = self.updateTransceivers(rtcRtpTransceiver: transceiver)
return transceiverHolder.getJSON()
var transceiverDesc = transceiverHolder.getJSON()

if var receiver = transceiverDesc["receiver"] as? [String: Any] {
if var track = receiver["track"] as? [String: Any] {
if let id = track["id"] as? String {
let pluginTrack = self.pluginMediaTracks.first { (key: String, value: PluginMediaStreamTrack) in
return value.originalId == id
}
if let pluginTrack = pluginTrack {
track["id"] = pluginTrack.value.id
}
}
receiver["track"] = track
}
transceiverDesc["receiver"] = receiver
}

if var sender = transceiverDesc["sender"] as? [String: Any] {
if var track = sender["track"] as? [String: Any] {
if let id = track["id"] as? String {
let pluginTrack = self.pluginMediaTracks.first { (key: String, value: PluginMediaStreamTrack) in
return value.originalId == id
}
if let pluginTrack = pluginTrack {
track["id"] = pluginTrack.value.id
}
}
sender["track"] = track
}
transceiverDesc["sender"] = sender
}

return transceiverDesc
})
}

Expand Down
2 changes: 1 addition & 1 deletion src/PluginRTCRtpReceiver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class PluginRTCRtpReceiver : NSObject {
self.id = id != 0 ? id : Int.random(in: 0...10000)
}

func getJSON() -> NSDictionary {
func getJSON() -> [String: Any] {
let track = self.rtpReceiver.track != nil ? [
"id": self.rtpReceiver.track!.trackId,
"kind": self.rtpReceiver.track!.kind,
Expand Down
2 changes: 1 addition & 1 deletion src/PluginRTCRtpSender.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class PluginRTCRtpSender : NSObject {
self.rtpSender.track = rtcMediaStreamTrack
}

func getJSON() -> NSDictionary {
func getJSON() -> [String: Any] {
let track = self.rtpSender.track != nil ? [
"id": self.rtpSender.track!.trackId,
"kind": self.rtpSender.track!.kind,
Expand Down
2 changes: 1 addition & 1 deletion src/PluginRTCRtpTransceiver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class PluginRTCRtpTransceiver : NSObject {
return rtcRtpTransceiverInit
}

func getJSON() -> NSDictionary {
func getJSON() -> [String: Any] {
var currentDirection = RTCRtpTransceiverDirection.inactive
self.rtcRtpTransceiver?.currentDirection(&currentDirection)

Expand Down

0 comments on commit fea2057

Please sign in to comment.