private AventusChannel GetChannelInfoFromRest(IChannel channel) { AventusChannel channelInfo = BuildAventusChannel(channel, AccountConfig.AccountName); if (channelInfo != null) { switch (channelInfo.Status.ToLower()) { case "running": case "onair": case "ready": string telem = GetTelemetryInfo(channelInfo.BaseUrl); channelInfo.TelemetryResult = (!string.IsNullOrEmpty(telem) ? JsonConvert.DeserializeObject <AventusTelemetry>(telem) : null); channelInfo.RunId = ((channelInfo.TelemetryResult != null) ? channelInfo.TelemetryResult.RunId : Guid.NewGuid().ToString()); if (channelInfo.TelemetryResult != null) { channelInfo.TelemetryResult.ChannelName = channel.Name; } break; default: channelInfo.TelemetryResult = null; break; } string status = string.Format("{0} ({1})", channel.State.ToString(), channelInfo.Status); channelInfo.Status = status; } return(channelInfo); }
private AventusChannel BuildAventusChannel(IChannel channel, string mediaSvcAcctName) { string aventusApiBase = BuildAventusDNSBase(channel.Name, mediaSvcAcctName); string aventusChannelAddress = (string.Format(@"{0}/api/channels", aventusApiBase)); AventusChannel channelInfo = null; switch (channel.State) { case ChannelState.Running: //there is a separate Aventus GUID separate from AMS channel GUID. var result = GetHttpResponse(aventusChannelAddress); if (string.IsNullOrEmpty(result)) { break; } var channels = JsonConvert.DeserializeObject <AventusChannelList>(result); if (channels.ChannelList.Length == 0) { throw new WebException("Channel not in correct state!"); } channelInfo = channels.ChannelList[0]; channelInfo.AventusChannelId = GetAventusChannelId(channelInfo.BaseUrl); break; } return(channelInfo); }
public AventusChannel GetChannelInfo(IChannel channel) { if (TelemetryStorage != null) { var channelInfo = new AventusChannel(); channelInfo.TelemetryResult = GetTelemetryInfo(channel); channelInfo.Status = channelInfo.TelemetryResult == null?channel.State.ToString() : "OnAir"; return(channelInfo); } else { return(GetChannelInfoFromRest(channel)); } }
private AventusTelemetry GetTelemetryFromRest(IChannel channel) { AventusChannel channelInfo = BuildAventusChannel(channel, AccountConfig.AccountName); if (channelInfo != null) { string telemResult = GetTelemetryInfo(channelInfo.BaseUrl); if (!string.IsNullOrEmpty(telemResult)) { AventusTelemetry retVal = JsonConvert.DeserializeObject <AventusTelemetry>(telemResult); retVal.ChannelName = channel.Name; return(retVal); } } return(null); }