Skip to content

Commit d0c890a

Browse files
authored
Merge pull request #56 from ant-media/detect_webrtc_track_and_stream_id
Detect which webrtc track plays which stream Id
2 parents ea381f9 + c6fec93 commit d0c890a

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

WebRTC-Sample-App/ConferenceViewController.swift

+25
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ extension ConferenceViewController: AntMediaClientDelegate
126126
}
127127

128128
public func dataReceivedFromDataChannel(streamId: String, data: Data, binary: Bool) {
129+
129130

130131
}
131132

@@ -252,6 +253,30 @@ extension ConferenceViewController: AntMediaClientDelegate
252253
if eventType == EVENT_TYPE_TRACK_LIST_UPDATED {
253254
conferenceClient?.getBroadcastObject(forStreamId: streamId)
254255
}
256+
else if (eventType == EVENT_TYPE_VIDEO_TRACK_ASSIGNMENT_LIST) {
257+
258+
if let unwrappedPayload = payload?["payload"] as? [[String: Any]] {
259+
260+
//let array = unwrappedPayload as? [[String: Any]]
261+
for (item) in unwrappedPayload
262+
{
263+
if let trackId = item["trackId"] as? String,
264+
let videoLabel = item["videoLabel"] as? String
265+
{
266+
267+
print("videoLabel:\(videoLabel) plays the trackId:\(trackId)")
268+
//On the server side, we create WebRTC tracks with ARDAMSv{VIDEO_LABEL}
269+
//It's useful in limiting/dynamic allocation of the streams and tracks in a conference call
270+
//If you want to make sure, which webrtc track is playing which real streamId,
271+
//you can learn from here
272+
273+
//i.e. you receive ARDAMSvvideoTrack0 in trackAdded method above, then you'll receive this event
274+
//and it will tell you videoTrack0 is playing the specific streamId.
275+
//If ARDAMSvvideoTrack0 starts to play another trackId, then you'll receive this event again.
276+
}
277+
}
278+
}
279+
}
255280
}
256281
}
257282

WebRTCiOSSDK/api/AntMediaClientProtocol.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,15 @@ let GET_STREAM_INFO_COMMAND = "getStreamInfo";
2929
let STREAM_INFORMATION_COMMAND = "streamInformation";
3030
let FORCE_STREAM_QUALITY_INFO = "forceStreamQuality";
3131
let STREAM_HEIGHT_FIELD = "streamHeight";
32-
let EVENT_TYPE = "eventType";
32+
public let EVENT_TYPE = "eventType";
3333
let EVENT_TYPE_MIC_MUTED = "MIC_MUTED"
3434
let EVENT_TYPE_MIC_UNMUTED = "MIC_UNMUTED";
3535
let EVENT_TYPE_CAM_TURNED_OFF = "CAM_TURNED_OFF";
3636
let EVENT_TYPE_CAM_TURNED_ON = "CAM_TURNED_ON";
3737
let GET_BROADCAST_OBJECT_COMMAND = "getBroadcastObject"
3838
let BROADCAST_OBJECT_NOTIFICATION = "broadcastObject"
3939
public let EVENT_TYPE_TRACK_LIST_UPDATED = "TRACK_LIST_UPDATED"
40+
public let EVENT_TYPE_VIDEO_TRACK_ASSIGNMENT_LIST = "VIDEO_TRACK_ASSIGNMENT_LIST";
4041

4142
let ENABLE_TRACK_COMMAND = "enableTrack"
4243
let ENABLE_VIDEO_TRACK_COMMAND = "toggleVideo"

0 commit comments

Comments
 (0)