in chime-sdk-signaling-cpp/src/utils/sdp_utils.h [52:74]
static std::vector<MediaSection> ParseSDP(const std::string& sdp) {
std::vector<std::string> sdp_vec = Split(sdp, "\r\n");
std::vector<MediaSection> media_sections;
const std::string mid_str = "a=mid:";
bool is_audio_section = false;
std::string mid;
for (const auto& line : sdp_vec) {
if (line.find("m=audio", 0) == 0) {
is_audio_section = true;
} else if (line.find("m=video", 0) == 0) {
is_audio_section = false;
} else if (line.find(mid_str, 0) == 0) {
mid = line.substr(mid_str.length(), std::string::npos);
} else if (line.find(rec_only, 0) == 0 || line.find(send_only, 0) == 0 || line.find(inactive, 0) == 0 ||
line.find(sendrecv, 0) == 0) {
MediaSection media_section{is_audio_section ? MediaType::kAudio : MediaType::kVideo, mid, GetDirection(line)};
media_sections.emplace_back(media_section);
}
}
return media_sections;
}