Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect which webrtc track plays which stream Id #56

Merged
merged 2 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading