Skip to content

Commit

Permalink
Merge pull request #56 from ant-media/detect_webrtc_track_and_stream_id
Browse files Browse the repository at this point in the history
Detect which webrtc track plays which stream Id
  • Loading branch information
mekya authored Jul 11, 2024
2 parents ea381f9 + c6fec93 commit d0c890a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
25 changes: 25 additions & 0 deletions WebRTC-Sample-App/ConferenceViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ extension ConferenceViewController: AntMediaClientDelegate
}

public func dataReceivedFromDataChannel(streamId: String, data: Data, binary: Bool) {


}

Expand Down Expand Up @@ -252,6 +253,30 @@ extension ConferenceViewController: AntMediaClientDelegate
if eventType == EVENT_TYPE_TRACK_LIST_UPDATED {
conferenceClient?.getBroadcastObject(forStreamId: streamId)
}
else if (eventType == EVENT_TYPE_VIDEO_TRACK_ASSIGNMENT_LIST) {

if let unwrappedPayload = payload?["payload"] as? [[String: Any]] {

//let array = unwrappedPayload as? [[String: Any]]
for (item) in unwrappedPayload
{
if let trackId = item["trackId"] as? String,
let videoLabel = item["videoLabel"] as? String
{

print("videoLabel:\(videoLabel) plays the trackId:\(trackId)")
//On the server side, we create WebRTC tracks with ARDAMSv{VIDEO_LABEL}
//It's useful in limiting/dynamic allocation of the streams and tracks in a conference call
//If you want to make sure, which webrtc track is playing which real streamId,
//you can learn from here

//i.e. you receive ARDAMSvvideoTrack0 in trackAdded method above, then you'll receive this event
//and it will tell you videoTrack0 is playing the specific streamId.
//If ARDAMSvvideoTrack0 starts to play another trackId, then you'll receive this event again.
}
}
}
}
}
}

3 changes: 2 additions & 1 deletion WebRTCiOSSDK/api/AntMediaClientProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@ let GET_STREAM_INFO_COMMAND = "getStreamInfo";
let STREAM_INFORMATION_COMMAND = "streamInformation";
let FORCE_STREAM_QUALITY_INFO = "forceStreamQuality";
let STREAM_HEIGHT_FIELD = "streamHeight";
let EVENT_TYPE = "eventType";
public let EVENT_TYPE = "eventType";
let EVENT_TYPE_MIC_MUTED = "MIC_MUTED"
let EVENT_TYPE_MIC_UNMUTED = "MIC_UNMUTED";
let EVENT_TYPE_CAM_TURNED_OFF = "CAM_TURNED_OFF";
let EVENT_TYPE_CAM_TURNED_ON = "CAM_TURNED_ON";
let GET_BROADCAST_OBJECT_COMMAND = "getBroadcastObject"
let BROADCAST_OBJECT_NOTIFICATION = "broadcastObject"
public let EVENT_TYPE_TRACK_LIST_UPDATED = "TRACK_LIST_UPDATED"
public let EVENT_TYPE_VIDEO_TRACK_ASSIGNMENT_LIST = "VIDEO_TRACK_ASSIGNMENT_LIST";

let ENABLE_TRACK_COMMAND = "enableTrack"
let ENABLE_VIDEO_TRACK_COMMAND = "toggleVideo"
Expand Down

0 comments on commit d0c890a

Please sign in to comment.