Ejemplo n.º 1
0
        private void WriteFilterchain(FFmpegCommand command, Filterchain filterchain)
        {
            if (filterchain == null)
            {
                throw new ArgumentNullException("filterchain");
            }

            var context = FilterBindingContext.Create(filterchain.InputCount, filterchain.OutputCount);

            WriteFilterchainIn(command, filterchain);

            var shouldIncludeDelimitor = false;

            filterchain.Filters.ToList().ForEach(filter =>
            {
                if (shouldIncludeDelimitor)
                {
                    BuilderBase.Append(",");
                }
                else
                {
                    BuilderBase.Append(" ");
                    shouldIncludeDelimitor = true;
                }

                WriteFilter(filter, context);
            });

            WriteFilterchainOut(filterchain);
        }
Ejemplo n.º 2
0
        public static string Serialize(IFilter filter, FilterBindingContext context)
        {
            var filterData       = GetFilterData(filter, context);
            var filterSerializer = new FilterSerializerWriter(filterData);

            return(filterSerializer.Write());
        }
Ejemplo n.º 3
0
        private void WriteFilter(IFilter filter, FilterBindingContext context)
        {
            if (filter == null)
            {
                throw new ArgumentNullException("filter");
            }

            BuilderBase.Append(FilterSerializer.Serialize(filter, context));
        }
Ejemplo n.º 4
0
        public static FilterSerializerData GetFilterSerializerData(IFilter filter, FilterBindingContext context)
        {
            var filterType           = filter.GetType();
            var filterSerializerData = new FilterSerializerData();

            FillFilterAttribute(filterSerializerData, filter, filterType);

            FillFilterParameterAttributes(filterSerializerData, filter, filterType, context);

            return(filterSerializerData);
        }
Ejemplo n.º 5
0
 public string GetValue(FilterBindingContext context)
 {
     return(context.NumberOfStreamsIn.ToString());
 }
Ejemplo n.º 6
0
 public static string Serialize(IFilter filter)
 {
     return(Serialize(filter, FilterBindingContext.Empty()));
 }
Ejemplo n.º 7
0
 private static FilterSerializerData GetFilterData(IFilter filter, FilterBindingContext context)
 {
     return(FilterSerializerAttributeParser.GetFilterSerializerData(filter, context));
 }
Ejemplo n.º 8
0
        private static object GetFilterSerializationBindingValue(FilterParameterAttribute filterParameterAttribute, PropertyInfo propertyInfo, FilterBindingContext context, IFilter filter)
        {
            if (filterParameterAttribute.Binding == null)
            {
                return(propertyInfo.GetValue(filter));
            }

            var bindingObject = (IFilterParameterBinding)Activator.CreateInstance(filterParameterAttribute.Binding);

            return(bindingObject.GetValue(context));
        }
Ejemplo n.º 9
0
        private static void FillFilterParameterAttributes(FilterSerializerData filterSerializerData, IFilter filter, Type filterType, FilterBindingContext context)
        {
            var propertyInfos = filterType.GetProperties().ToList();

            foreach (var propertyInfo in propertyInfos)
            {
                var filterParameterAttribute = AttributeRetrieval.GetAttribute <FilterParameterAttribute>(propertyInfo);
                if (filterParameterAttribute == null)
                {
                    continue;
                }

                //get the value set or bound to the parameter
                var value = GetFilterSerializationBindingValue(filterParameterAttribute, propertyInfo, context, filter);

                //run validation on the parameter to ensure that it meets all standards
                RunFilterSerializationValidation(filterType, propertyInfo, value);

                //run formatter on the validated value
                var filterPropertyFormattedValue = RunFilterSerializationFormat(filterParameterAttribute, filterType, propertyInfo, value);

                var filterPropertyIsDefault = filterParameterAttribute.Default != null &&
                                              value != null &&
                                              filterParameterAttribute.Default.Equals(value);

                filterSerializerData.Parameters.Add(new FilterSerializerDataParameter
                {
                    Name      = filterParameterAttribute.Name,
                    Value     = filterPropertyFormattedValue,
                    Parameter = filterParameterAttribute,
                    IsDefault = filterPropertyIsDefault
                });
            }
        }