コード例 #1
0
        private LiveTvTunerInfo GetTunerInformation(Tuner i)
        {
            LiveTvTunerInfo tunerinfo = new LiveTvTunerInfo();

            tunerinfo.Name = i.tunerName;
            tunerinfo.Status = GetStatus(i);

            if (i.recordings.Count > 0)
            {
                tunerinfo.ChannelId = i.recordings.Single().Recording.channelOID.ToString();
            }

            return tunerinfo;
        }
コード例 #2
0
ファイル: LiveTvDtoService.cs プロジェクト: paul-777/Emby
        public LiveTvTunerInfoDto GetTunerInfoDto(string serviceName, LiveTvTunerInfo info, string channelName)
        {
            var dto = new LiveTvTunerInfoDto
            {
                Name = info.Name,
                Id = info.Id,
                Clients = info.Clients,
                ProgramName = info.ProgramName,
                SourceType = info.SourceType,
                Status = info.Status,
                ChannelName = channelName,
                Url = info.Url,
                CanReset = info.CanReset
            };

            if (!string.IsNullOrEmpty(info.ChannelId))
            {
                dto.ChannelId = GetInternalChannelId(serviceName, info.ChannelId).ToString("N");
            }

            if (!string.IsNullOrEmpty(info.RecordingId))
            {
                dto.RecordingId = GetInternalRecordingId(serviceName, info.RecordingId).ToString("N");
            }

            return dto;
        }
コード例 #3
0
        public Task<LiveTvServiceStatusInfo> GetStatusInfoAsync(CancellationToken cancellationToken)
        {
            LiveTvServiceStatusInfo result;

            var configurationValidationResult = Plugin.Instance.Configuration.Validate();
            var version = Assembly.GetExecutingAssembly().GetName().Version.ToString();

            // Validate configuration first
            if (!configurationValidationResult.IsValid)
            {
                result = new LiveTvServiceStatusInfo()
                {
                    HasUpdateAvailable = false,
                    Status = LiveTvServiceStatus.Unavailable,
                    StatusMessage = configurationValidationResult.Summary,
                    Tuners = new List<LiveTvTunerInfo>(),
                    Version = version
                };
            }
            else
            {
                try
                {

                    // Test connections to both the streaming and tv proxy
                    var response = Plugin.StreamingProxy.GetStatusInfo(cancellationToken);
                    response = Plugin.TvProxy.GetStatusInfo(cancellationToken);

                    var activeCards = Plugin.TvProxy.GetActiveCards(cancellationToken);
                    var cards = Plugin.TvProxy.GetTunerCards(cancellationToken).Where(c => c.Enabled).Select(c =>
                    {
                        var activeDetails = activeCards.SingleOrDefault(ac => ac.Id == c.Id);
                        var tunerInfo = new LiveTvTunerInfo()
                        {
                            Id = c.Id.ToString(CultureInfo.InvariantCulture),
                            Name = c.Name,
                        };

                        if (activeDetails != null)
                        {
                            tunerInfo.Clients = new List<string>() { activeDetails.User.Name };
                            tunerInfo.Status = 
                                activeDetails.IsRecording ? LiveTvTunerStatus.RecordingTv :
                                activeDetails.IsTunerLocked ? LiveTvTunerStatus.LiveTv : LiveTvTunerStatus.Available;
                        }
                        return tunerInfo;

                    }).ToList();

                    result = new LiveTvServiceStatusInfo()
                    {
                        HasUpdateAvailable = false,
                        Status = LiveTvServiceStatus.Ok,
                        StatusMessage = String.Format("MPExtended Service Version: {0} - API Version : {1}", response.ServiceVersion, response.ApiVersion),
                        Tuners = cards,
                        Version = version
                    };

                }
                catch (Exception ex)
                {
                    Plugin.Logger.Error(ex, "Exception occured getting the MP service status");

                    result = new LiveTvServiceStatusInfo()
                    {
                        HasUpdateAvailable = false,
                        Status = LiveTvServiceStatus.Unavailable,
                        StatusMessage = "Unable to establish a connection with MediaPortal API - check your settings",
                        Tuners = new List<LiveTvTunerInfo>(),
                        Version = version
                    };
                }
            }

            return Task.FromResult(result);
        }
コード例 #4
0
        /*
          <dump>
            channelId : 240
            channelNumber : 40
            channelName : zdf.kultur
            eventId : 11708150
            nextEventId : 11708152
            services :       name : CXD2837 DVB-C DVB-T/T2 (adapter 7)/KBW: 370,000 kHz/zdf.kultur
              type : SDTV
        ,       name : CXD2837 DVB-C DVB-T/T2  (adapter 6)/KBW: 370,000 kHz/zdf.kultur
              type : SDTV
        ,       name : STV0367 DVB-C DVB-T (adapter 5)/KBW: 370,000 kHz/zdf.kultur
              type : SDTV
        ,       name : STV0367 DVB-C DVB-T (adapter 4)/KBW: 370,000 kHz/zdf.kultur
              type : SDTV
        ,       name : CXD2837 DVB-C DVB-T/T2 (adapter 3)/KBW: 370,000 kHz/zdf.kultur
              type : SDTV
        ,       name : CXD2837 DVB-C DVB-T/T2 (adapter 2)/KBW: 370,000 kHz/zdf.kultur
              type : SDTV
        ,       name : STV0367 DVB-C DVB-T (adapter 1)/KBW: 370,000 kHz/zdf.kultur
              type : SDTV
        ,       name : STV0367 DVB-C DVB-T (adapter 0)/KBW: 370,000 kHz/zdf.kultur
              type : SDTV
        ,
            tags : 1, 2,
            method : channelAdd
          </dump>
        */
        public Task<List<LiveTvTunerInfo>> buildTunerInfos(CancellationToken cancellationToken)
        {
            return Task.Factory.StartNew<List<LiveTvTunerInfo>>(() =>
            {
                List<LiveTvTunerInfo> result = new List<LiveTvTunerInfo>();
                lock (_data)
                {
                    foreach (Message currMessage in _data.Values)
                    {
                        if (cancellationToken.IsCancellationRequested)
                        {
                            _logger.Info("[TVHclient] TunerDataHelper.buildTunerInfos: cancel requst received. Returning only partly results");
                            return result;
                        }

                        string channelId = "";
                        if (currMessage.containsField("channelId"))
                        {
                            channelId = "" + currMessage.getInt("channelId");
                        }

                        string programName = "";
                        if (currMessage.containsField("channelName"))
                        {
                            programName = currMessage.getString("channelName");
                        }

                        IList services = null;
                        if (currMessage.containsField("services"))
                        {
                            services = currMessage.getList("services");
                        }
                        if (services != null)
                        {
                            foreach (Message currService in services)
                            {
                                string name = "";
                                if (currService.containsField("name"))
                                {
                                    name = currService.getString("name");
                                }
                                else
                                {
                                    continue;
                                }
                                string type = "";
                                if (currService.containsField("type"))
                                {
                                    type = currService.getString("type");
                                }

                                LiveTvTunerInfo ltti = new LiveTvTunerInfo();
                                ltti.Id = name;
                                ltti.Name = name;
                                ltti.ProgramName = programName;
                                ltti.SourceType = type;
                                ltti.ChannelId = channelId;
                                ltti.Status = LiveTvTunerStatus.Available;

                                ltti.CanReset = false; // currently not possible

                                //ltti.Clients // not available from TVheadend
                                //ltti.RecordingId // not available from TVheadend

                                result.Add(ltti);
                            }
                        }
                    }
                }
                return result;
            });
        }
コード例 #5
0
ファイル: LiveTvService.cs プロジェクト: babgvant/Emby.MythTv
        public async Task<LiveTvServiceStatusInfo> GetStatusInfoAsync(CancellationToken cancellationToken)
        {
            EnsureSetup();
            
            bool upgradeAvailable = false;
            string serverVersion = string.Empty;

            var conInfoTask = _httpClient.Get(GetOptions(cancellationToken, "/Myth/GetConnectionInfo")).ConfigureAwait(false);

            var tunersTask = _httpClient.Get(GetOptions(cancellationToken, "/Dvr/GetEncoderList")).ConfigureAwait(false);
            var encodersTask = _httpClient.Get(GetOptions(cancellationToken, "/Capture/GetCaptureCardList")).ConfigureAwait(false); 

            EncoderList tuners = null;
            CaptureCardList encoders = null;

            using (var stream = await tunersTask)
            {
                tuners = DvrResponse.ParseEncoderList(stream, _jsonSerializer, _logger);
            }

            using (var stream = await encodersTask)
            {
                encoders = CaptureResponse.ParseCaptureCardList(stream, _jsonSerializer, _logger);
            }

            using (var stream = await conInfoTask)
            {
                var conInfo = UtilityResponse.GetConnectionInfo(stream, _jsonSerializer, _logger);
                serverVersion = conInfo.Version.Ver;
            }
            
            //Tuner information
            List<LiveTvTunerInfo> tvTunerInfos = new List<LiveTvTunerInfo>();
            foreach(var tuner in tuners.Encoders)
            {
                LiveTvTunerInfo info = new LiveTvTunerInfo()
                {
                    Id = tuner.Id.ToString(),
                    Status = (LiveTvTunerStatus)tuner.State
                };

                switch (tuner.State)
                {
                    case 0:
                        info.Status = LiveTvTunerStatus.Available;
                        break;
                    case 7:
                        info.Status = LiveTvTunerStatus.RecordingTv;
                        break;
                }

                if(!string.IsNullOrWhiteSpace(tuner.Recording.Title)){
                    info.RecordingId = tuner.Recording.ProgramId;
                    info.ProgramName = string.Format("{0} : {1}", tuner.Recording.Title, tuner.Recording.SubTitle);
                }

                foreach(var enc in encoders.CaptureCards)
                {
                    if(enc.CardId == tuner.Id)
                    {
                        info.Name = string.Format("{0} {1}", enc.CardType, enc.VideoDevice);
                        info.SourceType = enc.CardType;
                        break;
                    }
                }
                
                tvTunerInfos.Add(info);
            }

            return new LiveTvServiceStatusInfo
            {
                HasUpdateAvailable = upgradeAvailable,
                Version = serverVersion,
                Tuners = tvTunerInfos
            };
        }
コード例 #6
0
        /// <summary>
        /// Get server status info.
        /// </summary>
        /// <param name="cancellationToken">The CancellationToken</param>
        /// <returns>LiveTvServiceStatusInfo</returns>
        public async Task<LiveTvServiceStatusInfo> GetStatusInfoAsync(CancellationToken cancellationToken)
        {
            _logger.Info("[VuPlus] Start GetStatusInfoAsync Async, retrieve status details");
            await EnsureConnectionAsync(cancellationToken).ConfigureAwait(false);

            //TODO: Version check

            bool upgradeAvailable = false;
            string serverVersion = "Unknown";

            var protocol = "http";
            if (Plugin.Instance.Configuration.UseSecureHTTPS)
                protocol = "https";

            var baseUrl = protocol + "://" + Plugin.Instance.Configuration.HostName + ":" + Plugin.Instance.Configuration.WebInterfacePort;

            var url = string.Format("{0}/web/deviceinfo", baseUrl);
            UtilsHelper.DebugInformation(_logger, string.Format("[VuPlus] GetStatusInfoAsync url: {0}", url));

            var options = new HttpRequestOptions()
            {
                CancellationToken = cancellationToken,
                Url = url
            };

            if (!string.IsNullOrEmpty(Plugin.Instance.Configuration.WebInterfaceUsername))
            {
                string authInfo = Plugin.Instance.Configuration.WebInterfaceUsername + ":" + Plugin.Instance.Configuration.WebInterfacePassword;
                authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));
                options.RequestHeaders["Authorization"] = "Basic " + authInfo;
            }

            List<LiveTvTunerInfo> liveTvTunerInfos = new List<LiveTvTunerInfo>();

            using (var stream = await _httpClient.Get(options).ConfigureAwait(false))
            {
                using (StreamReader reader = new StreamReader(stream))
                {
                    string xmlResponse = reader.ReadToEnd();
                    UtilsHelper.DebugInformation(_logger, string.Format("[VuPlus] GetStatusInfoAsync response: {0}", xmlResponse));

                    try
                    {
                        var xml = new XmlDocument();
                        xml.LoadXml(xmlResponse);

                        XmlNodeList e2frontend = xml.GetElementsByTagName("e2frontend");
                        foreach (XmlNode xmlNode in e2frontend)
                        {
                            var liveTvTunerInfo = new LiveTvTunerInfo();

                            var e2name = "?";
                            var e2model = "?";

                            foreach (XmlNode node in xmlNode.ChildNodes)
                            {
                                if (node.Name == "e2name")
                                {
                                    e2name = node.InnerText;
                                }
                                else if (node.Name == "e2model")
                                {
                                    e2model = node.InnerText;
                                }
                            }

                            liveTvTunerInfo.Id = e2model;
                            liveTvTunerInfo.Name = e2name;
                            liveTvTunerInfo.SourceType = "";

                            liveTvTunerInfos.Add(liveTvTunerInfo);
                        }

                        return new LiveTvServiceStatusInfo
                        {
                            HasUpdateAvailable = upgradeAvailable,
                            Version = serverVersion,
                            Tuners = liveTvTunerInfos
                        };

                    }
                    catch (Exception e)
                    {
                        _logger.Error("[VuPlus] Failed to parse tuner information.");
                        _logger.Error(string.Format("[VuPlus] GetStatusInfoAsync error: {0}", e.Message));
                        throw new ApplicationException("Failed to parse tuner information.");
                    }

                }
            }
        }