コード例 #1
0
ファイル: WebMetadataFactory.cs プロジェクト: henricj/phonesm
        public ISegmentMetadata CreateSegmentMetadata(WebResponse webResponse, ContentType contentType)
        {
            var shoutcast = new ShoutcastHeaders(webResponse.RequestUri, webResponse.Headers);

            if (shoutcast.MetaInterval > 0 || shoutcast.SupportsIcyMetadata)
            {
                var segmentMetadata = new ShoutcastSegmentMetadata
                {
                    Url = webResponse.RequestUri,
                    ContentType = contentType ?? webResponse.ContentType,
                    Length = webResponse.ContentLength,
                    IcyMetaInt = shoutcast.MetaInterval,
                    SupportsIcyMetadata = shoutcast.SupportsIcyMetadata
                };

                return segmentMetadata;
            }

            var streamMetadata = new SegmentMetadata
            {
                Url = webResponse.RequestUri,
                ContentType = contentType ?? webResponse.ContentType,
                Length = webResponse.ContentLength
            };

            return streamMetadata;
        }
コード例 #2
0
        public ISegmentMetadata CreateSegmentMetadata(WebResponse webResponse, ContentType contentType)
        {
            ShoutcastHeaders shoutcastHeaders = new ShoutcastHeaders(webResponse.RequestUri, webResponse.Headers);
            int?metaInterval = shoutcastHeaders.MetaInterval;

            if ((metaInterval.GetValueOrDefault() <= 0 ? 0 : (metaInterval.HasValue ? 1 : 0)) != 0 || shoutcastHeaders.SupportsIcyMetadata)
            {
                ShoutcastSegmentMetadata shoutcastSegmentMetadata = new ShoutcastSegmentMetadata();
                shoutcastSegmentMetadata.Url                 = webResponse.RequestUri;
                shoutcastSegmentMetadata.ContentType         = contentType ?? webResponse.ContentType;
                shoutcastSegmentMetadata.Length              = webResponse.ContentLength;
                shoutcastSegmentMetadata.IcyMetaInt          = shoutcastHeaders.MetaInterval;
                shoutcastSegmentMetadata.SupportsIcyMetadata = shoutcastHeaders.SupportsIcyMetadata;
                return((ISegmentMetadata)shoutcastSegmentMetadata);
            }
            return((ISegmentMetadata) new SegmentMetadata()
            {
                Url = webResponse.RequestUri,
                ContentType = (contentType ?? webResponse.ContentType),
                Length = webResponse.ContentLength
            });
        }