Пример #1
0
 public override OSDConfigurationOptions GetOSDOptions(string ConfigurationToken)
 {
     if (ONVIFMedia2Configuration.VideoSourceConfigurationList.Any(C => C.token == ConfigurationToken))
     {
         return((ONVIFMedia2Configuration.OSDOptionsList.Find(C => C.VideoSourceConfigurationToken1 == ConfigurationToken)).OSDConfigurationOptions);
     }
     else
     {
         throw ONVIFFault.GetMedia2Exception_InvalidArgVal_NoConfig(ConfigurationToken);
     }
 }
Пример #2
0
 public override void DeleteOSD(string OSDToken)
 {
     if (ONVIFMedia2Configuration.OSDConfigurationList.Any(C => C.token == OSDToken))
     {
         ONVIFMedia2Configuration.OSDConfigurationList.RemoveAll(C => C.token == OSDToken);
     }
     else
     {
         throw ONVIFFault.GetMedia2Exception_InvalidArgVal_NoConfig(OSDToken);
     }
 }
Пример #3
0
        public override OSDConfiguration[] GetOSDs(string OSDToken, string ConfigurationToken)
        {
            if ((OSDToken == null) && (ConfigurationToken == null))
            {
                return(ONVIFMedia2Configuration.OSDConfigurationList.ToArray());
            }

            if ((OSDToken != null) && (ConfigurationToken != null))
            {
                throw ONVIFFault.GetGeneralException_InvalidArgVal("Both OSDToken and ConfigurationToken are not allowed.");
            }

            if ((OSDToken != null) && (ConfigurationToken == null))
            {
                if (ONVIFMedia2Configuration.OSDConfigurationList.Any(C => C.token == OSDToken))
                {
                    return((ONVIFMedia2Configuration.OSDConfigurationList.FindAll(C => C.token == OSDToken)).ToArray());
                }
                else
                {
                    throw ONVIFFault.GetMedia2Exception_InvalidArgVal_NoConfig(OSDToken);
                }
            }

            if ((OSDToken == null) && (ConfigurationToken != null))
            {
                if (ONVIFMedia2Configuration.VideoSourceConfigurationList.Any(C => C.token == ConfigurationToken))
                {
                    return((ONVIFMedia2Configuration.OSDConfigurationList.FindAll(C => C.VideoSourceConfigurationToken.Value == ConfigurationToken)).ToArray());
                }
                else
                {
                    throw ONVIFFault.GetMedia2Exception_InvalidArgVal_NoConfig(ConfigurationToken);
                }
            }

            return(null);
        }
        public static void OSDColorCheck(Proxy.OSDColor oSDColor, Proxy.OSDColorOptions oSDColorOptions, string ParameterName)
        {
            if (oSDColor != null)
            {
                if (oSDColorOptions == null)
                {
                    throw ONVIFFault.GetGeneralException_InvalidArgVal(String.Format("OSD {0} is not supported.", ParameterName));
                }
                else
                {
                    if (oSDColor.Color != null)
                    {
                        if ((oSDColorOptions.Color == null) ||
                            (oSDColorOptions.Color.Items == null))
                        {
                            throw ONVIFFault.GetGeneralException_InvalidArgVal(String.Format("OSD {0}.Color is not supported.", ParameterName));
                        }
                        else
                        {
                            //TODO: OSD.TextString.FontColor.Color range check
                        }
                    }
                    else
                    {
                        if (oSDColorOptions.Color != null)
                        {
                            //TODOD: color
                        }
                    }

                    if (oSDColor.TransparentSpecified)
                    {
                        if ((oSDColorOptions.Transparent == null))
                        {
                            throw ONVIFFault.GetGeneralException_InvalidArgVal(String.Format("OSD {0}.Transparent is not supported.", ParameterName));
                        }
                        else
                        {
                            if ((oSDColor.Transparent > oSDColorOptions.Transparent.Max) ||
                                (oSDColor.Transparent < oSDColorOptions.Transparent.Min))
                            {
                                throw ONVIFFault.GetGeneralException_InvalidArgVal(String.Format("OSD {0}.Transparent is out of supported range.", ParameterName));
                            }
                        }
                    }
                    else
                    {
                        if (oSDColorOptions.Transparent != null)
                        {
                            oSDColor.TransparentSpecified = true;
                            oSDColor.Transparent          = oSDColorOptions.Transparent.Min;
                        }
                    }
                }
            }
            else
            {
                if (oSDColorOptions != null)
                {
                    oSDColor = new Proxy.OSDColor();
                    if (oSDColorOptions.Transparent != null)
                    {
                        oSDColor.TransparentSpecified = true;
                        oSDColor.Transparent          = oSDColorOptions.Transparent.Min;
                    }

                    if (oSDColorOptions.Color != null)
                    {
                        //TODOD: color
                    }
                }
            }
        }
        public static void OSDParametersCheck(Proxy.OSDConfiguration OSD, Proxy.OSDConfigurationOptions OSDOpt, List <Proxy.OSDConfiguration> OSDList)
        {
            #region CountChecks

            if (OSDList.Count >= OSDOpt.MaximumNumberOfOSDs.Total)
            {
                throw ONVIFFault.GetMedia2Exception_Action_MaxOSDs(OSD.VideoSourceConfigurationToken.Value);
            }

            if (OSDOpt.MaximumNumberOfOSDs.ImageSpecified &&
                OSDList.Count(C => C.Image != null) >= OSDOpt.MaximumNumberOfOSDs.Image)
            {
                throw ONVIFFault.GetMedia2Exception_Action_MaxOSDs(OSD.VideoSourceConfigurationToken.Value);
            }

            if (OSDOpt.MaximumNumberOfOSDs.PlainTextSpecified &&
                OSDList.Count(C => (C.TextString != null) && (C.TextString.PlainText != null)) >= OSDOpt.MaximumNumberOfOSDs.PlainText)
            {
                throw ONVIFFault.GetMedia2Exception_Action_MaxOSDs(OSD.VideoSourceConfigurationToken.Value);
            }

            if (OSDOpt.MaximumNumberOfOSDs.DateSpecified &&
                OSDList.Count(C => (C.TextString != null) && (C.TextString.Type == "Date")) >= OSDOpt.MaximumNumberOfOSDs.Date)
            {
                throw ONVIFFault.GetMedia2Exception_Action_MaxOSDs(OSD.VideoSourceConfigurationToken.Value);
            }

            if (OSDOpt.MaximumNumberOfOSDs.DateAndTimeSpecified &&
                OSDList.Count(C => (C.TextString != null) && (C.TextString.Type == "DateAndTime")) >= OSDOpt.MaximumNumberOfOSDs.DateAndTime)
            {
                throw ONVIFFault.GetMedia2Exception_Action_MaxOSDs(OSD.VideoSourceConfigurationToken.Value);
            }

            if (OSDOpt.MaximumNumberOfOSDs.PlainTextSpecified &&
                OSDList.Count(C => (C.TextString != null) && (C.TextString.Type == "Plain")) >= OSDOpt.MaximumNumberOfOSDs.PlainText)
            {
                throw ONVIFFault.GetMedia2Exception_Action_MaxOSDs(OSD.VideoSourceConfigurationToken.Value);
            }

            if (OSDOpt.MaximumNumberOfOSDs.TimeSpecified &&
                OSDList.Count(C => (C.TextString != null) && (C.TextString.Type == "Time")) >= OSDOpt.MaximumNumberOfOSDs.Time)
            {
                throw ONVIFFault.GetMedia2Exception_Action_MaxOSDs(OSD.VideoSourceConfigurationToken.Value);
            }

            #endregion //CountChecks

            //OSD.Type
            if (!OSDOpt.Type.Any(C => C == OSD.Type))
            {
                throw ONVIFFault.GetGeneralException_InvalidArgVal("OSD Type is not supported.");
            }

            //OSD.Position.Type
            if (!OSDOpt.PositionOption.Any(C => C == OSD.Position.Type))
            {
                throw ONVIFFault.GetGeneralException_InvalidArgVal("OSD Position Type is not supported.");
            }

            if (OSD.Image != null)
            {
                //TODO: validation for Image
            }

            if (OSD.TextString != null)
            {
                if (OSDOpt.TextOption == null)
                {
                    throw ONVIFFault.GetGeneralException_InvalidArgVal("OSD Text is not supported.");
                }

                //OSD.TextString.Type
                if (!OSDOpt.TextOption.Type.Any(C => C == OSD.TextString.Type))
                {
                    throw ONVIFFault.GetGeneralException_InvalidArgVal("OSD Text Type is not supported.");
                }

                //OSD.TextString.DateFormat
                if ((OSD.TextString.Type == "Date") || (OSD.TextString.Type == "DateAndTime"))
                {
                    if (OSD.TextString.DateFormat == null)
                    {
                        OSD.TextString.DateFormat = OSDOpt.TextOption.DateFormat[0];
                    }
                    else
                    {
                        if (!OSDOpt.TextOption.DateFormat.Any(C => C == OSD.TextString.DateFormat))
                        {
                            throw ONVIFFault.GetGeneralException_InvalidArgVal("OSD Date Format is not supported.");
                        }
                    }
                }

                //OSD.TextString.TimeFormat
                if ((OSD.TextString.Type == "Time") || (OSD.TextString.Type == "DateAndTime"))
                {
                    if (OSD.TextString.TimeFormat == null)
                    {
                        OSD.TextString.TimeFormat = OSDOpt.TextOption.TimeFormat[0];
                    }
                    else
                    {
                        if (!OSDOpt.TextOption.TimeFormat.Any(C => C == OSD.TextString.TimeFormat))
                        {
                            throw ONVIFFault.GetGeneralException_InvalidArgVal("OSD Time Format is not supported.");
                        }
                    }
                }

                //OSD.TextString.FontSize
                if (OSD.TextString.FontSizeSpecified)
                {
                    if (OSDOpt.TextOption.FontSizeRange == null)
                    {
                        throw ONVIFFault.GetGeneralException_InvalidArgVal("OSD FontSize is not supported.");
                    }
                    else
                    {
                        if ((OSD.TextString.FontSize > OSDOpt.TextOption.FontSizeRange.Max) ||
                            (OSD.TextString.FontSize < OSDOpt.TextOption.FontSizeRange.Min))
                        {
                            throw ONVIFFault.GetGeneralException_InvalidArgVal("OSD FontSize is out of supported range.");
                        }
                    }
                }
                else
                {
                    if (OSDOpt.TextOption.FontSizeRange != null)
                    {
                        OSD.TextString.FontSizeSpecified = true;
                        OSD.TextString.FontSize          = OSDOpt.TextOption.FontSizeRange.Min;
                    }
                }

                //OSD.TextString.FontColor
                OSDColorCheck(OSD.TextString.FontColor, OSDOpt.TextOption.FontColor, "FontColor");

                //OSD.TextString.BackgroundColor
                OSDColorCheck(OSD.TextString.BackgroundColor, OSDOpt.TextOption.BackgroundColor, "BackgroundColor");
            }
        }