Exemplo n.º 1
0
        private static VideoItem CreateVideoItem(bool isAdaptiveStreaming, IList <string> dataStreams, Uri sourceUri, string title, Uri thumbnailUri, double?duration, SmpteFrameRate smpteFrameRate, double width, double height, IList <AudioStreamInfo> audioStreamsInformation, IList <string> videoStreamInformation, string archiveURL, string cmsId, string vodUrl, string azureId)
        {
            VideoItem item;

            if (isAdaptiveStreaming)
            {
                SmoothStreamingVideoItem tempItem = new SmoothStreamingVideoItem();

                if (dataStreams != null && dataStreams.Count > 0)
                {
                    tempItem.DataStreams = (List <string>)dataStreams;
                }

                if (audioStreamsInformation != null && audioStreamsInformation.Count > 0)
                {
                    tempItem.AudioStreams = (List <AudioStreamInfo>)audioStreamsInformation;
                }

                if (videoStreamInformation != null && videoStreamInformation.Count > 0)
                {
                    tempItem.VideoStreams = (List <string>)videoStreamInformation;
                }

                tempItem.VodUrl = vodUrl;
                item            = tempItem;
            }
            else
            {
                item = new VideoItem();
            }

            item.Id        = CreateUri("Videos");
            item.Resources = new ResourceCollection();
            item.Resources.Add(new Resource
            {
                Id           = CreateUri("Resources"),
                Ref          = sourceUri.ToString(),
                ResourceType = isAdaptiveStreaming ? (UtilityHelper.IsLiveAdaptiveStreaming(sourceUri) ? "LiveSmoothStream" : "SmoothStream") : "Master",
            });

            item.Title           = title;
            item.ThumbnailSource = (thumbnailUri != null) ? thumbnailUri.ToString() : null;
            item.Duration        = duration;
            item.FrameRate       = smpteFrameRate;
            item.Width           = (int)width;
            item.Height          = (int)height;

            item.ArchiveURL = archiveURL;
            item.CMSId      = cmsId;
            item.AzureId    = azureId;

            return(item);
        }
        private static VideoItem CreateVideoItem(Uri id, bool isAdaptiveStreaming, IList <string> dataStreams, Uri thumbnailUri, double?duration, SmpteFrameRate smpteFrameRate, double width, double height, IList <AudioStreamInfo> audioStreamsInformation, IList <string> videoStreamInformation)
        {
            VideoItem item;

            if (isAdaptiveStreaming)
            {
                SmoothStreamingVideoItem tempItem = new SmoothStreamingVideoItem();

                if (dataStreams != null && dataStreams.Count > 0)
                {
                    tempItem.DataStreams = (List <string>)dataStreams;
                }

                if (audioStreamsInformation != null && audioStreamsInformation.Count > 0)
                {
                    tempItem.AudioStreams = (List <AudioStreamInfo>)audioStreamsInformation;
                }

                if (videoStreamInformation != null && videoStreamInformation.Count > 0)
                {
                    tempItem.VideoStreams = (List <string>)videoStreamInformation;
                }

                item = tempItem;
            }
            else
            {
                item = new VideoItem();
            }

            item.Id = id;
            item.ThumbnailSource = (thumbnailUri != null) ? thumbnailUri.AbsoluteUri : null;
            item.Duration        = duration;
            item.FrameRate       = smpteFrameRate;
            item.Width           = (int)width;
            item.Height          = (int)height;

            return(item);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates the video item.
        /// </summary>
        /// <param name="id">The <see cref="Uri"/> of the video.</param>
        /// <param name="title">The title of the video item.</param>
        /// <param name="duration">The duration of the video.</param>
        /// <param name="frameRate">The framerate of the video.</param>
        /// <param name="reference">The url of the audio item.</param>
        /// <param name="width">The width of the video.</param>
        /// <param name="height">The height of the video.</param>
        /// <param name="resourceType">The type of the resource.</param>
        /// <returns>The <see cref="VideoItem"/>.</returns>
        private static SmoothStreamingVideoItem CreateSmoothVideoItem(Uri id, string title, double?duration, SmpteFrameRate frameRate, string reference, int width, int height, string resourceType)
        {
            var result = new SmoothStreamingVideoItem
            {
                Id        = id,
                Title     = title,
                Duration  = duration,
                FrameRate = frameRate,
                Width     = width,
                Height    = height,
                Resources =
                {
                    new Resource
                    {
                        Id           = CreateUri(Resources),
                        Ref          = reference,
                        ResourceType = resourceType,
                    }
                },
                Telemetry = CreateRandomTelemetry(duration)
            };

            return(result);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Returns back given no. of items from the library.
        /// </summary>
        /// <param name="maxNumberOfItems">Maximum no. of records in the result.</param>
        /// <returns>A <see cref="Container"/> with the items.</returns>
        public Container LoadLibrary(int maxNumberOfItems)
        {
            Container libraryContainer = new Container();

            if (Directory.Exists(this.assetsPath))
            {
                string[] files = Directory.GetFiles(this.assetsPath, "*.*", SearchOption.AllDirectories);

                foreach (string file in files)
                {
                    Metadata metadata = this.metadataLocator.GetMetadata(file);

                    int    index        = file.IndexOf(this.assetsPath, StringComparison.OrdinalIgnoreCase) + this.assetsPath.Length;
                    string relativePath = file.Substring(index).Replace(@"\", "/");

                    if (this.IsVideoItem(file))
                    {
                        double             duration;
                        VideoItem          item;
                        ResourceCollection resources = new ResourceCollection();
                        Resource           resource;

                        if (UtilityHelper.IsProgressiveDownloadFile(file))
                        {
                            duration = 0;
                            item     = new VideoItem();
                            resource = new Resource
                            {
                                Ref          = String.Format(CultureInfo.InvariantCulture, this.assetsUriTemplate, relativePath),
                                ResourceType = "Master"
                            };
                        }
                        else
                        {
                            duration = 60;
                            item     = new SmoothStreamingVideoItem();
                            resource = new Resource
                            {
                                Ref          = String.Format(CultureInfo.InvariantCulture, this.assetsUriTemplate, relativePath) + (UtilityHelper.IsCompositeAdaptiveStreaming(file) ? string.Empty : "/manifest"),
                                ResourceType = UtilityHelper.IsLiveAdaptiveStreaming(file) ? "LiveSmoothStream" : "SmoothStream"
                            };
                        }

                        item.Id = new Uri("http://" + Guid.NewGuid());

                        resources.Add(resource);
                        item.Resources = resources;

                        if (metadata != null)
                        {
                            item.Duration  = metadata.Duration.TotalSeconds;
                            item.Title     = string.IsNullOrEmpty(metadata.Title) ? Path.GetFileName(file) : metadata.Title;
                            item.FrameRate = metadata.FrameRate == SmpteFrameRate.Unknown
                                                 ? SmpteFrameRate.Smpte2997NonDrop
                                                 : metadata.FrameRate;
                            item.Width    = metadata.Width ?? 1280;
                            item.Height   = metadata.Height ?? 720;
                            item.Metadata = new List <MetadataField>(metadata.MetadataFields);
                        }
                        else
                        {
                            item.Duration  = duration;
                            item.Title     = Path.GetFileName(file);
                            item.FrameRate = SmpteFrameRate.Smpte2997NonDrop;
                            item.Width     = 1280;
                            item.Height    = 720;
                        }

                        libraryContainer.Items.Add(item);
                    }
                    else if (this.IsAudioItem(file))
                    {
                        AudioItem item = new AudioItem
                        {
                            Id        = new Uri("http://" + Guid.NewGuid()),
                            Resources = new ResourceCollection()
                        };
                        Resource resource = new Resource
                        {
                            Ref          = String.Format(CultureInfo.InvariantCulture, this.assetsUriTemplate, relativePath),
                            ResourceType = "Master"
                        };

                        item.Resources.Add(resource);

                        if (metadata != null)
                        {
                            item.Duration = metadata.Duration.TotalSeconds;
                            item.Title    = string.IsNullOrEmpty(metadata.Title) ? Path.GetFileName(file) : metadata.Title;
                            item.Metadata = new List <MetadataField>(metadata.MetadataFields);
                        }
                        else
                        {
                            item.Duration = 0;
                            item.Title    = Path.GetFileName(file);
                        }

                        libraryContainer.Items.Add(item);
                    }
                    else if (this.IsImageItem(file))
                    {
                        ImageItem item = new ImageItem
                        {
                            Id        = new Uri("http://" + Guid.NewGuid()),
                            Resources = new ResourceCollection()
                        };

                        Resource resource = new Resource
                        {
                            Ref          = String.Format(CultureInfo.InvariantCulture, this.assetsUriTemplate, relativePath),
                            ResourceType = "Master"
                        };

                        item.Resources.Add(resource);

                        if (metadata != null)
                        {
                            item.Title    = string.IsNullOrEmpty(metadata.Title) ? Path.GetFileName(file) : metadata.Title;
                            item.Width    = metadata.Width ?? 1280;
                            item.Height   = metadata.Height ?? 720;
                            item.Metadata = new List <MetadataField>(metadata.MetadataFields);
                        }
                        else
                        {
                            item.Title  = Path.GetFileName(file);
                            item.Width  = 1280;
                            item.Height = 720;
                        }

                        libraryContainer.Items.Add(item);
                    }
                }
            }

            return(libraryContainer);
        }