当前位置: 首页>>代码示例>>C#>>正文


C# LiveTv.TunerHostInfo类代码示例

本文整理汇总了C#中MediaBrowser.Model.LiveTv.TunerHostInfo的典型用法代码示例。如果您正苦于以下问题:C# TunerHostInfo类的具体用法?C# TunerHostInfo怎么用?C# TunerHostInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TunerHostInfo类属于MediaBrowser.Model.LiveTv命名空间,在下文中一共展示了TunerHostInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetChannelStreamMediaSources

        protected override async Task<List<MediaSourceInfo>> GetChannelStreamMediaSources(TunerHostInfo info, string channelId, CancellationToken cancellationToken)
        {
            var urlHash = info.Url.GetMD5().ToString("N");
            var prefix = ChannelIdPrefix + urlHash;
            if (!channelId.StartsWith(prefix, StringComparison.OrdinalIgnoreCase))
            {
                return null;
            }

            var channels = await GetChannels(info, true, cancellationToken).ConfigureAwait(false);
            var m3uchannels = channels.Cast<M3UChannel>();
            var channel = m3uchannels.FirstOrDefault(c => string.Equals(c.Id, channelId, StringComparison.OrdinalIgnoreCase));
            if (channel != null)
            {
                var path = channel.Path;
                MediaProtocol protocol = MediaProtocol.File;
                if (path.StartsWith("http", StringComparison.OrdinalIgnoreCase))
                {
                    protocol = MediaProtocol.Http;
                }
                else if (path.StartsWith("rtmp", StringComparison.OrdinalIgnoreCase))
                {
                    protocol = MediaProtocol.Rtmp;
                }
                else if (path.StartsWith("rtsp", StringComparison.OrdinalIgnoreCase))
                {
                    protocol = MediaProtocol.Rtsp;
                }

                var mediaSource = new MediaSourceInfo
                {
                    Path = channel.Path,
                    Protocol = protocol,
                    MediaStreams = new List<MediaStream>
                    {
                        new MediaStream
                        {
                            Type = MediaStreamType.Video,
                            // Set the index to -1 because we don't know the exact index of the video stream within the container
                            Index = -1,
                            IsInterlaced = true
                        },
                        new MediaStream
                        {
                            Type = MediaStreamType.Audio,
                            // Set the index to -1 because we don't know the exact index of the audio stream within the container
                            Index = -1

                        }
                    },
                    RequiresOpening = false,
                    RequiresClosing = false,

                    ReadAtNativeFramerate = true
                };

                return new List<MediaSourceInfo> { mediaSource };
            }
            return new List<MediaSourceInfo>();
        }
开发者ID:softworkz,项目名称:Emby,代码行数:60,代码来源:M3UTunerHost.cs

示例2: GetChannelStream

        protected override async Task<LiveStream> GetChannelStream(TunerHostInfo info, string channelId, string streamId, CancellationToken cancellationToken)
        {
            var sources = await GetChannelStreamMediaSources(info, channelId, cancellationToken).ConfigureAwait(false);

            var liveStream = new LiveStream(sources.First());
            return liveStream;
        }
开发者ID:t-andre,项目名称:Emby,代码行数:7,代码来源:M3UTunerHost.cs

示例3: GetChannelsInternal

        protected override async Task<IEnumerable<ChannelInfo>> GetChannelsInternal(TunerHostInfo info, CancellationToken cancellationToken)
        {
            var options = new HttpRequestOptions
            {
                Url = string.Format("{0}/lineup.json", GetApiUrl(info, false)),
                CancellationToken = cancellationToken
            };
            using (var stream = await _httpClient.Get(options))
            {
                var root = JsonSerializer.DeserializeFromStream<List<Channels>>(stream);

                if (root != null)
                {
                    var result = root.Select(i => new ChannelInfo
                    {
                        Name = i.GuideName,
                        Number = i.GuideNumber.ToString(CultureInfo.InvariantCulture),
                        Id = ChannelIdPrefix + i.GuideNumber.ToString(CultureInfo.InvariantCulture),
                        IsFavorite = i.Favorite

                    });

                    if (info.ImportFavoritesOnly)
                    {
                        result = result.Where(i => (i.IsFavorite ?? true)).ToList();
                    }

                    return result;
                }
                return new List<ChannelInfo>();
            }
        }
开发者ID:rezafouladian,项目名称:Emby,代码行数:32,代码来源:HdHomerunHost.cs

示例4: GetModelInfo

        private async Task<string> GetModelInfo(TunerHostInfo info, CancellationToken cancellationToken)
        {
            string model = null;

            using (var stream = await _httpClient.Get(new HttpRequestOptions()
            {
                Url = string.Format("{0}/", GetApiUrl(info, false)),
                CancellationToken = cancellationToken,
                CacheLength = TimeSpan.FromDays(1),
                CacheMode = CacheMode.Unconditional,
                TimeoutMs = Convert.ToInt32(TimeSpan.FromSeconds(5).TotalMilliseconds)
            }))
            {
                using (var sr = new StreamReader(stream, System.Text.Encoding.UTF8))
                {
                    while (!sr.EndOfStream)
                    {
                        string line = StripXML(sr.ReadLine());
                        if (line.StartsWith("Model:")) { model = line.Replace("Model: ", ""); }
                        //if (line.StartsWith("Device ID:")) { deviceID = line.Replace("Device ID: ", ""); }
                        //if (line.StartsWith("Firmware:")) { firmware = line.Replace("Firmware: ", ""); }
                    }
                }
            }

            return model;
        }
开发者ID:rezafouladian,项目名称:Emby,代码行数:27,代码来源:HdHomerunHost.cs

示例5: Validate

        public async Task Validate(TunerHostInfo info)
        {
            using (var stream = await new M3uParser(Logger, _fileSystem, _httpClient).GetListingsStream(info.Url, CancellationToken.None).ConfigureAwait(false))
            {

            }
        }
开发者ID:softworkz,项目名称:Emby,代码行数:7,代码来源:M3UTunerHost.cs

示例6: GetChannels

        public async Task<IEnumerable<ChannelInfo>> GetChannels(TunerHostInfo tuner, bool enableCache, CancellationToken cancellationToken)
        {
            ChannelCache cache = null;
            var key = tuner.Id;

            if (enableCache && !string.IsNullOrWhiteSpace(key) && _channelCache.TryGetValue(key, out cache))
            {
                if ((DateTime.UtcNow - cache.Date) < TimeSpan.FromMinutes(60))
                {
                    return cache.Channels.ToList();
                }
            }

            var result = await GetChannelsInternal(tuner, cancellationToken).ConfigureAwait(false);
            var list = result.ToList();
            Logger.Debug("Channels from {0}: {1}", tuner.Url, JsonSerializer.SerializeToString(list));

            if (!string.IsNullOrWhiteSpace(key) && list.Count > 0)
            {
                cache = cache ?? new ChannelCache();
                cache.Date = DateTime.UtcNow;
                cache.Channels = list;
                _channelCache.AddOrUpdate(key, cache, (k, v) => cache);
            }

            return list;
        }
开发者ID:NickBolles,项目名称:Emby,代码行数:27,代码来源:BaseTunerHost.cs

示例7: GetChannelsInternal

        protected override async Task<IEnumerable<ChannelInfo>> GetChannelsInternal(TunerHostInfo info, CancellationToken cancellationToken)
        {
            var urlHash = info.Url.GetMD5().ToString("N");

            // Read the file and display it line by line.
            using (var reader = new StreamReader(await GetListingsStream(info, cancellationToken).ConfigureAwait(false)))
            {
                return GetChannels(reader, urlHash);
            }
        }
开发者ID:ratanparai,项目名称:Emby,代码行数:10,代码来源:M3UTunerHost.cs

示例8: GetChannelsInternal

        protected override async Task<IEnumerable<ChannelInfo>> GetChannelsInternal(TunerHostInfo tuner, CancellationToken cancellationToken)
        {
            if (!string.IsNullOrWhiteSpace(tuner.M3UUrl))
            {
                return await new M3uParser(Logger, _fileSystem, _httpClient).Parse(tuner.M3UUrl, ChannelIdPrefix, tuner.Id, cancellationToken).ConfigureAwait(false);
            }

            var channels = await new ChannelScan(Logger).Scan(tuner, cancellationToken).ConfigureAwait(false);
            return channels;
        }
开发者ID:paul-777,项目名称:Emby,代码行数:10,代码来源:SatIpHost.cs

示例9: GetChannelId

        private string GetChannelId(TunerHostInfo info, Channels i)
        {
            var id = ChannelIdPrefix + i.GuideNumber.ToString(CultureInfo.InvariantCulture);

            if (info.DataVersion >= 1)
            {
                id += '_' + (i.GuideName ?? string.Empty).GetMD5().ToString("N");
            }

            return id;
        }
开发者ID:paul-777,项目名称:Emby,代码行数:11,代码来源:HdHomerunHost.cs

示例10: GetChannelsInternal

        protected override async Task<IEnumerable<ChannelInfo>> GetChannelsInternal(TunerHostInfo info, CancellationToken cancellationToken)
        {
            var url = info.Url;
            var urlHash = url.GetMD5().ToString("N");

            string line;
            // Read the file and display it line by line.
            using (var file = new StreamReader(await GetListingsStream(info, cancellationToken).ConfigureAwait(false)))
            {
                var channels = new List<M3UChannel>();

                string channnelName = null;
                string channelNumber = null;

                while ((line = file.ReadLine()) != null)
                {
                    line = line.Trim();
                    if (string.IsNullOrWhiteSpace(line))
                    {
                        continue;
                    }

                    if (line.StartsWith("#EXTM3U", StringComparison.OrdinalIgnoreCase))
                    {
                        continue;
                    }

                    if (line.StartsWith("#EXTINF:", StringComparison.OrdinalIgnoreCase))
                    {
                        var parts = line.Split(new[] { ':' }, 2).Last().Split(new[] { ',' }, 2);
                        channelNumber = parts[0];
                        channnelName = parts[1];
                    }
                    else if (!string.IsNullOrWhiteSpace(channelNumber))
                    {
                        channels.Add(new M3UChannel
                        {
                            Name = channnelName,
                            Number = channelNumber,
                            Id = ChannelIdPrefix + urlHash + channelNumber,
                            Path = line
                        });

                        channelNumber = null;
                        channnelName = null;
                    }
                }
                return channels;
            }
        }
开发者ID:rezafouladian,项目名称:Emby,代码行数:50,代码来源:M3UTunerHost.cs

示例11: GetLineup

        private async Task<IEnumerable<Channels>> GetLineup(TunerHostInfo info, CancellationToken cancellationToken)
        {
            var options = new HttpRequestOptions
            {
                Url = string.Format("{0}/lineup.json", GetApiUrl(info, false)),
                CancellationToken = cancellationToken
            };
            using (var stream = await _httpClient.Get(options))
            {
                var lineup = JsonSerializer.DeserializeFromStream<List<Channels>>(stream) ?? new List<Channels>();

                if (info.ImportFavoritesOnly)
                {
                    lineup = lineup.Where(i => i.Favorite).ToList();
                }

                return lineup.Where(i => !i.DRM).ToList();
            }
        }
开发者ID:paul-777,项目名称:Emby,代码行数:19,代码来源:HdHomerunHost.cs

示例12: IsAvailableInternal

        protected override async Task<bool> IsAvailableInternal(TunerHostInfo tuner, string channelId, CancellationToken cancellationToken)
        {
            var info = await GetTunerInfos(tuner, cancellationToken).ConfigureAwait(false);

            return info.Any(i => i.Status == LiveTvTunerStatus.Available);
        }
开发者ID:rezafouladian,项目名称:Emby,代码行数:6,代码来源:HdHomerunHost.cs

示例13: Validate

 public async Task Validate(TunerHostInfo info)
 {
     if (info.IsEnabled)
     {
         await GetChannels(info, false, CancellationToken.None).ConfigureAwait(false);
     }
 }
开发者ID:rezafouladian,项目名称:Emby,代码行数:7,代码来源:HdHomerunHost.cs

示例14: GetChannelStream

        protected override async Task<MediaSourceInfo> GetChannelStream(TunerHostInfo info, string channelId, string streamId, CancellationToken cancellationToken)
        {
            Logger.Info("GetChannelStream: channel id: {0}. stream id: {1}", channelId, streamId ?? string.Empty);

            if (!channelId.StartsWith(ChannelIdPrefix, StringComparison.OrdinalIgnoreCase))
            {
                throw new ArgumentException("Channel not found");
            }
            channelId = channelId.Substring(ChannelIdPrefix.Length);

            return GetMediaSource(info, channelId, streamId);
        }
开发者ID:rezafouladian,项目名称:Emby,代码行数:12,代码来源:HdHomerunHost.cs

示例15: GetChannelStreamMediaSources

        protected override async Task<List<MediaSourceInfo>> GetChannelStreamMediaSources(TunerHostInfo info, string channelId, CancellationToken cancellationToken)
        {
            var list = new List<MediaSourceInfo>();

            if (!channelId.StartsWith(ChannelIdPrefix, StringComparison.OrdinalIgnoreCase))
            {
                return list;
            }
            channelId = channelId.Substring(ChannelIdPrefix.Length);

            list.Add(GetMediaSource(info, channelId, "native"));

            try
            {
                string model = await GetModelInfo(info, cancellationToken).ConfigureAwait(false);
                model = model ?? string.Empty;

                if (model.IndexOf("hdtc", StringComparison.OrdinalIgnoreCase) != -1)
                {
                    list.Insert(0, GetMediaSource(info, channelId, "heavy"));

                    list.Add(GetMediaSource(info, channelId, "internet480"));
                    list.Add(GetMediaSource(info, channelId, "internet360"));
                    list.Add(GetMediaSource(info, channelId, "internet240"));
                    list.Add(GetMediaSource(info, channelId, "mobile"));
                }
            }
            catch (Exception ex)
            {

            }

            return list;
        }
开发者ID:rezafouladian,项目名称:Emby,代码行数:34,代码来源:HdHomerunHost.cs


注:本文中的MediaBrowser.Model.LiveTv.TunerHostInfo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。