void Manager::receiveMessage(DecryptedMessage &&message) {
const auto data = &message.message.data;
if (const auto candidatesList = absl::get_if<CandidatesListMessage>(data)) {
_networkManager->perform(RTC_FROM_HERE, [message = std::move(message)](NetworkManager *networkManager) mutable {
networkManager->receiveSignalingMessage(std::move(message));
});
} else if (const auto videoFormats = absl::get_if<VideoFormatsMessage>(data)) {
_mediaManager->perform(RTC_FROM_HERE, [message = std::move(message)](MediaManager *mediaManager) mutable {
mediaManager->receiveMessage(std::move(message));
});
} else if (const auto remoteMediaState = absl::get_if<RemoteMediaStateMessage>(data)) {
if (_remoteMediaStateUpdated) {
_remoteMediaStateUpdated(
remoteMediaState->audio,
remoteMediaState->video);
}
_mediaManager->perform(RTC_FROM_HERE, [video = remoteMediaState->video](MediaManager *mediaManager) {
mediaManager->remoteVideoStateUpdated(video);
});
} else if (const auto remoteBatteryLevelIsLow = absl::get_if<RemoteBatteryLevelIsLowMessage>(data)) {
if (_remoteBatteryLevelIsLowUpdated) {
_remoteBatteryLevelIsLowUpdated(remoteBatteryLevelIsLow->batteryLow);
}
} else if (const auto remoteNetworkStatus = absl::get_if<RemoteNetworkStatusMessage>(data)) {
_remoteNetworkIsLowCost = remoteNetworkStatus->isLowCost;
_remoteIsLowDataRequested = remoteNetworkStatus->isLowDataRequested;
updateCurrentResolvedNetworkStatus();
} else {
if (const auto videoParameters = absl::get_if<VideoParametersMessage>(data)) {
float value = ((float)videoParameters->aspectRatio) / 1000.0;
if (_remotePrefferedAspectRatioUpdated) {
_remotePrefferedAspectRatioUpdated(value);
}
}
_mediaManager->perform(RTC_FROM_HERE, [=, message = std::move(message)](MediaManager *mediaManager) mutable {
mediaManager->receiveMessage(std::move(message));
});
}
}
candidatesList 给到networkManager
cpp复制代码
if (const auto candidatesList = absl::get_if<CandidatesListMessage>(data)) {
_networkManager->perform(RTC_FROM_HERE, [message = std::move(message)](NetworkManager *networkManager) mutable {
networkManager->receiveSignalingMessage(std::move(message));
});
}
VideoFormatsMessage 给到mediaManager
cpp复制代码
} else if (const auto videoFormats = absl::get_if<VideoFormatsMessage>(data)) {
_mediaManager->perform(RTC_FROM_HERE, [message = std::move(message)](MediaManager *mediaManager) mutable {
mediaManager->receiveMessage(std::move(message));
});
RemoteMediaStateMessage
cpp复制代码
} else if (const auto remoteMediaState = absl::get_if<RemoteMediaStateMessage>(data)) {
if (_remoteMediaStateUpdated) {
_remoteMediaStateUpdated(
remoteMediaState->audio,
remoteMediaState->video);
}
_mediaManager->perform(RTC_FROM_HERE, [video = remoteMediaState->video](MediaManager *mediaManager) {
mediaManager->remoteVideoStateUpdated(video);
});
}
RemoteBatteryLevelIsLowMessage 对端的电池
cpp复制代码
} else if (const auto remoteBatteryLevelIsLow = absl::get_if<RemoteBatteryLevelIsLowMessage>(data)) {
if (_remoteBatteryLevelIsLowUpdated) {
_remoteBatteryLevelIsLowUpdated(remoteBatteryLevelIsLow->batteryLow);
}
}
对端的网络
cpp复制代码
} else if (const auto remoteNetworkStatus = absl::get_if<RemoteNetworkStatusMessage>(data)) {
_remoteNetworkIsLowCost = remoteNetworkStatus->isLowCost;
_remoteIsLowDataRequested = remoteNetworkStatus->isLowDataRequested;
updateCurrentResolvedNetworkStatus();
}