void SmoothStreamingSourceChanged(string url) { Uri currentStreamUri = new Uri(url, UriKind.Absolute); IsEdgeServerComplete = false; EdgeServer = EdgeServerDataClient.IpNA; // clear the current edge server ClientIP = EdgeServerDataClient.IpNA; if (Configuration.EdgeServerRuleCollection != null) { EdgeServerRules addressRules = Configuration.EdgeServerRuleCollection.FirstOrDefault(ai => ai.Domain != null && currentStreamUri.Host.EndsWith(ai.Domain, StringComparison.OrdinalIgnoreCase)); // fallback on the address rules without a domain if (addressRules == null) { addressRules = Configuration.EdgeServerRuleCollection.FirstOrDefault(ai => ai.Domain == null); } try { if (addressRules != null) { EdgeServerDataClient edgeServerDataClient = new EdgeServerDataClient(); edgeServerDataClient.GetEdgeServerCompleted += (s, e) => { // warning: this can come back after we've shut down, checking for the mediaelement is a good way to ensure we're still supposed to be tracking if (mediaElement != null) { if (e.Result != null) { EdgeServer = e.Result.EdgeServer; ClientIP = e.Result.ClientIP; } FinishSettingEdgeServer(); SmoothStreamingEvent entry = new SmoothStreamingEvent(); entry.EventType = EventType.AddressInfo; entry.Data1 = ClientIP.ToString(); entry.Data2 = EdgeServer; Enqueue(entry); } }; edgeServerDataClient.GetEdgeServerAsync(addressRules, currentStreamUri); } else { FinishSettingEdgeServer(); } } catch { FinishSettingEdgeServer(); } } else { FinishSettingEdgeServer(); } }
void SmoothStreamingSourceChanged(string url) { Uri currentStreamUri = new Uri(url, UriKind.Absolute); IsEdgeServerComplete = false; EdgeServer = EdgeServerDataClient.IpNA; // clear the current edge server ClientIP = EdgeServerDataClient.IpNA; if (Configuration.EdgeServerRuleCollection != null) { EdgeServerRules addressRules = Configuration.EdgeServerRuleCollection.FirstOrDefault(ai => ai.Domain != null && currentStreamUri.Host.EndsWith(ai.Domain, StringComparison.OrdinalIgnoreCase)); // fallback on the address rules without a domain if (addressRules == null) addressRules = Configuration.EdgeServerRuleCollection.FirstOrDefault(ai => ai.Domain == null); try { if (addressRules != null) { EdgeServerDataClient edgeServerDataClient = new EdgeServerDataClient(); edgeServerDataClient.GetEdgeServerCompleted += (s, e) => { // warning: this can come back after we've shut down, checking for the mediaelement is a good way to ensure we're still supposed to be tracking if (mediaElement != null) { if (e.Result != null) { EdgeServer = e.Result.EdgeServer; ClientIP = e.Result.ClientIP; } FinishSettingEdgeServer(); SmoothStreamingEvent entry = new SmoothStreamingEvent(); entry.EventType = EventType.AddressInfo; entry.Data1 = ClientIP.ToString(); entry.Data2 = EdgeServer; Enqueue(entry); } }; edgeServerDataClient.GetEdgeServerAsync(addressRules, currentStreamUri); } else FinishSettingEdgeServer(); } catch { FinishSettingEdgeServer(); } } else FinishSettingEdgeServer(); }