コード例 #1
0
        public static TValue?AttributeValue <TValue>(this M3U8TagInstance tagInstance, M3U8ValueAttribute <TValue> attribute) where TValue : struct
        {
            M3U8AttributeValueInstance <TValue> attributeValueInstance = M3U8TagInstanceExtensions.Attribute <TValue>(tagInstance, attribute);

            if (null == attributeValueInstance)
            {
                return(new TValue?());
            }
            return(new TValue?(attributeValueInstance.Value));
        }
コード例 #2
0
        public static TValue AttributeObject <TValue>(this M3U8TagInstance tagInstance, M3U8ValueAttribute <TValue> attribute) where TValue : class
        {
            M3U8AttributeValueInstance <TValue> attributeValueInstance = M3U8TagInstanceExtensions.Attribute <TValue>(tagInstance, attribute);

            if (null == attributeValueInstance)
            {
                return(default(TValue));
            }
            return(attributeValueInstance.Value);
        }
コード例 #3
0
        public static IEnumerable <M3U8AttributeInstance> Attributes(this M3U8TagInstance tagInstance)
        {
            AttributesTagInstance attributesTagInstance = tagInstance as AttributesTagInstance;

            if (null == attributesTagInstance)
            {
                return(M3U8TagInstanceExtensions.NoAttributeInstances);
            }
            return(attributesTagInstance.Attributes);
        }
コード例 #4
0
        private void HandleExt(string line)
        {
            int    length  = line.IndexOf(':');
            string tagName = line;
            string str     = (string)null;

            if (length > 3)
            {
                tagName = line.Substring(0, length);
                if (length + 1 < line.Length)
                {
                    str = line.Substring(length + 1);
                }
            }
            M3U8TagInstance tagInstance = M3U8Tags.Default.Create(tagName, str);

            if (null == tagInstance)
            {
                return;
            }
            switch (tagInstance.Tag.Scope)
            {
            case M3U8TagScope.Global:
                if (1 == this._lineNumber && tagInstance.Tag == M3U8Tags.ExtM3UMarker)
                {
                    this._hasMarker = true;
                }
                this._globalTags.Add(tagInstance);
                break;

            case M3U8TagScope.Shared:
                this.ResolveShared(tagInstance);
                break;

            case M3U8TagScope.Segment:
                this._tags.Add(tagInstance);
                break;
            }
        }
コード例 #5
0
ファイル: M3U8Parser.cs プロジェクト: henricj/phonesm
 void ResolveShared(M3U8TagInstance tagInstance)
 {
     // TODO: Shared tags needs a conflict/update policy (e.g., a new key of the same type should remove the old one)
     _sharedTags.Add(tagInstance);
 }
コード例 #6
0
 private void ResolveShared(M3U8TagInstance tagInstance)
 {
     this._sharedTags.Add(tagInstance);
 }
コード例 #7
0
ファイル: HlsProgramManager.cs プロジェクト: henricj/phonesm
        static bool IsYesNo(M3U8TagInstance tag, M3U8ValueAttribute<string> attribute, bool defaultValue = false)
        {
            var attr = tag.Attribute(attribute);

            if (null == attr || string.IsNullOrWhiteSpace(attr.Value))
                return defaultValue;

            return 0 == string.CompareOrdinal("YES", attr.Value.ToUpperInvariant());
        }
コード例 #8
0
ファイル: HlsProgramManager.cs プロジェクト: henricj/phonesm
        static void AddMedia(Uri playlist, M3U8TagInstance gt, Dictionary<string, MediaGroup> audioStreams)
        {
            var groupId = gt.Attribute(ExtMediaSupport.AttrGroupId).Value;

            var urlAttribute = gt.AttributeObject(ExtMediaSupport.AttrUri);

            Uri playlistUrl = null;

            if (null != urlAttribute)
                playlistUrl = new Uri(playlist, new Uri(urlAttribute, UriKind.RelativeOrAbsolute));

            var language = gt.AttributeObject(ExtMediaSupport.AttrLanguage);

            var audioStream = new PlaylistSubStream
            {
                Type = gt.AttributeObject(ExtMediaSupport.AttrType),
                Name = groupId,
                Playlist = playlistUrl,
                IsAutoselect = IsYesNo(gt, ExtMediaSupport.AttrAutoselect),
                Language = null == language ? null : language.Trim().ToLower()
            };

            MediaGroup mediaGroup;
            if (!audioStreams.TryGetValue(groupId, out mediaGroup))
            {
                mediaGroup = new MediaGroup
                {
                    Default = audioStream
                };

                audioStreams[groupId] = mediaGroup;
            }

            var isDefault = IsYesNo(gt, ExtMediaSupport.AttrDefault);

            if (isDefault)
                mediaGroup.Default = audioStream;

            var name = gt.Attribute(ExtMediaSupport.AttrName).Value;

            mediaGroup.Streams[name] = audioStream;
        }
コード例 #9
0
 public static M3U8AttributeValueInstance <TValue> Attribute <TValue>(this M3U8TagInstance tagInstance, M3U8ValueAttribute <TValue> attribute, TValue value) where TValue : IEquatable <TValue>
 {
     return(Enumerable.FirstOrDefault <M3U8AttributeValueInstance <TValue> >(Enumerable.OfType <M3U8AttributeValueInstance <TValue> >((IEnumerable)M3U8TagInstanceExtensions.Attributes(tagInstance)), (Func <M3U8AttributeValueInstance <TValue>, bool>)(a => a.Attribute == (M3U8Attribute)attribute && a.Value.Equals(value))));
 }
コード例 #10
0
 public static IEnumerable <M3U8AttributeValueInstance <TValue> > Attributes <TValue>(this M3U8TagInstance tagInstance, M3U8ValueAttribute <TValue> attribute)
 {
     return(Enumerable.Where <M3U8AttributeValueInstance <TValue> >(Enumerable.OfType <M3U8AttributeValueInstance <TValue> >((IEnumerable)M3U8TagInstanceExtensions.Attributes(tagInstance)), (Func <M3U8AttributeValueInstance <TValue>, bool>)(a => a.Attribute == (M3U8Attribute)attribute)));
 }
コード例 #11
0
 public static TInstance AttributeInstance <TInstance>(this M3U8TagInstance tagInstance, M3U8Attribute attribute) where TInstance : M3U8AttributeInstance
 {
     return(Enumerable.FirstOrDefault <M3U8AttributeInstance>(M3U8TagInstanceExtensions.Attributes(tagInstance), (Func <M3U8AttributeInstance, bool>)(a => a.Attribute == attribute)) as TInstance);
 }
コード例 #12
0
 public static IEnumerable <M3U8AttributeInstance> Attributes(this M3U8TagInstance tagInstance, M3U8Attribute attribute)
 {
     return(Enumerable.Where <M3U8AttributeInstance>(M3U8TagInstanceExtensions.Attributes(tagInstance), (Func <M3U8AttributeInstance, bool>)(a => a.Attribute == attribute)));
 }