Esempio n. 1
0
        public static IMediaConfiguration CreateMediaConfiguration(this IEnumerable <IMediaParserMediaStream> mediaParserMediaStreams, TimeSpan?duration)
        {
            MediaConfiguration mediaConfiguration = new MediaConfiguration()
            {
                Duration = duration
            };
            List <IMediaParserMediaStream> list = (List <IMediaParserMediaStream>)null;

            foreach (IMediaParserMediaStream parserMediaStream in mediaParserMediaStreams)
            {
                IConfigurationSource configurationSource = parserMediaStream.ConfigurationSource;
                if (configurationSource is IVideoConfigurationSource && null == mediaConfiguration.Video)
                {
                    mediaConfiguration.Video = parserMediaStream;
                }
                else if (configurationSource is IAudioConfigurationSource && null == mediaConfiguration.Audio)
                {
                    mediaConfiguration.Audio = parserMediaStream;
                }
                else
                {
                    if (null == list)
                    {
                        list = new List <IMediaParserMediaStream>();
                    }
                    list.Add(parserMediaStream);
                }
            }
            mediaConfiguration.AlternateStreams = (IReadOnlyCollection <IMediaParserMediaStream>)list;
            return((IMediaConfiguration)mediaConfiguration);
        }
        public static IMediaConfiguration CreateMediaConfiguration(this IEnumerable<IMediaParserMediaStream> mediaParserMediaStreams, TimeSpan? duration)
        {
            var configuration = new MediaConfiguration
            {
                Duration = duration
            };

            List<IMediaParserMediaStream> alternateStreams = null;

            foreach (var mediaStream in mediaParserMediaStreams)
            {
                var configurationSource = mediaStream.ConfigurationSource;

                var video = configurationSource as IVideoConfigurationSource;

                if (null != video && null == configuration.Video)
                {
                    configuration.Video = mediaStream;

                    continue;
                }

                var audio = configurationSource as IAudioConfigurationSource;

                if (null != audio && null == configuration.Audio)
                {
                    configuration.Audio = mediaStream;

                    continue;
                }

                if (null == alternateStreams)
                    alternateStreams = new List<IMediaParserMediaStream>();

                alternateStreams.Add(mediaStream);
            }

            configuration.AlternateStreams = alternateStreams;

            return configuration;
        }