internal override IMedia CreateMedia(IMediaProperties media)
        {
            var newFileName = media.FileName;

            if (IsRecursive && media is ServerMedia && !string.IsNullOrEmpty(media.Folder))
            {
                if (File.Exists(Path.Combine(Folder, media.Folder, newFileName)))
                {
                    Logger.Trace("{0}: File {1} already exists", nameof(CreateMedia), newFileName);
                    newFileName = FileUtils.GetUniqueFileName(Path.Combine(Folder, media.Folder), newFileName);
                }
            }
            else if (File.Exists(Path.Combine(Folder, newFileName)))
            {
                Logger.Trace("{0}: File {1} already exists", nameof(CreateMedia), newFileName);
                newFileName = FileUtils.GetUniqueFileName(Folder, newFileName);
            }
            var result = (new ServerMedia
            {
                MediaGuid = media.MediaGuid == Guid.Empty || FindMediaByMediaGuid(media.MediaGuid) != null ? Guid.NewGuid() : media.MediaGuid,
                LastUpdated = media.LastUpdated,
                MediaType = media.MediaType == TMediaType.Unknown ? TMediaType.Movie : media.MediaType,
                Folder = IsRecursive && media is IServerMedia && !string.IsNullOrEmpty(media.Folder) ? media.Folder : string.Empty,
                FileName = newFileName,
                MediaStatus = TMediaStatus.Required,
            });

            result.CloneMediaProperties(media);
            AddMedia(result);
            return(result);
        }
Esempio n. 2
0
 public static MediaProxy FromMedia(IMediaProperties media)
 {
     return(new MediaProxy
     {
         AudioChannelMapping = media.AudioChannelMapping,
         AudioLevelIntegrated = media.AudioLevelIntegrated,
         AudioLevelPeak = media.AudioLevelPeak,
         AudioVolume = media.AudioVolume,
         Duration = media.Duration,
         DurationPlay = media.DurationPlay,
         FileName = media.FileName,
         FileSize = media.FileSize,
         Folder = media.Folder,
         LastUpdated = media.LastUpdated,
         MediaCategory = media.MediaCategory,
         MediaName = media.MediaName,
         MediaStatus = media.MediaStatus,
         MediaType = media.MediaType,
         Parental = media.Parental,
         TcPlay = media.TcPlay,
         TcStart = media.TcStart,
         VideoFormat = media.VideoFormat,
         FieldOrderInverted = media.FieldOrderInverted,
         MediaGuid = media.MediaGuid,
     });
 }
Esempio n. 3
0
        /// <summary>
        /// <para>
        /// This method merges the standard metadata properties of a referring item
        /// and the metadat properties of an underlying item.
        /// </para>
        /// </summary>
        /// <param name="baseProps">metadata properties of this/referring item</param>
        /// <param name="refProps">metadata properties of the underlying/referred item</param>
        /// <returns></returns>
        private MediaProperties MergeProperties(IMediaProperties baseProps, IMediaProperties refProps)
        {
            MediaProperties mergedProps = new MediaProperties();

            ICollection basePropNames = baseProps.PropertyNames;
            ICollection refPropNames  = refProps.PropertyNames;

            // The referring item's metadata is always appended to the
            // underlying item's metadata.
            //
            foreach (string basePropName in basePropNames)
            {
                ArrayList al = this.GetMergedValues(basePropName, mergedProps, baseProps);
                mergedProps[basePropName] = al;
            }

            foreach (string refPropName in refPropNames)
            {
                ArrayList al = this.GetMergedValues(refPropName, mergedProps, refProps);
                mergedProps[refPropName] = al;
            }


            return(mergedProps);
        }
Esempio n. 4
0
 internal override IMedia CreateMedia(IMediaProperties media)
 {
     if (!DirectoryExists())
     {
         throw new DirectoryNotFoundException(Folder);
     }
     return(new TempMedia(this, media));
 }
Esempio n. 5
0
 public override void CloneMediaProperties(IMediaProperties fromMedia)
 {
     base.CloneMediaProperties(fromMedia);
     if (fromMedia is IServerMediaProperties)
     {
         DoNotArchive = (fromMedia as IServerMediaProperties).DoNotArchive;
     }
 }
Esempio n. 6
0
 public TempMedia(TempDirectory directory, IMediaProperties originalMedia)
 {
     OriginalMedia = originalMedia;
     Directory     = directory;
     MediaGuid     = originalMedia?.MediaGuid ?? Guid.NewGuid();
     FileName      = originalMedia == null
         ? $"{MediaGuid}.tmp"
         : $"{originalMedia.MediaGuid}{Path.GetExtension(originalMedia.FileName)}";
 }
Esempio n. 7
0
        public override void CloneMediaProperties(IMediaProperties fromMedia)
        {
            base.CloneMediaProperties(fromMedia);
            var a = (fromMedia as AnimatedMedia);

            if (a != null)
            {
                Fields = a.Fields;
            }
        }
 public override void CloneMediaProperties(IMediaProperties fromMedia)
 {
     base.CloneMediaProperties(fromMedia);
     if (fromMedia is IPersistentMediaProperties)
     {
         IdAux         = (fromMedia as IPersistentMediaProperties).IdAux;
         IdProgramme   = (fromMedia as IPersistentMediaProperties).IdProgramme;
         MediaEmphasis = (fromMedia as IPersistentMediaProperties).MediaEmphasis;
     }
 }
        public override IMedia CreateMedia(IMediaProperties mediaProperties)
        {
            string path   = Path.Combine(Folder, GetCurrentFolder());
            var    result = new ArchiveMedia(this, mediaProperties.MediaGuid, 0)
            {
                FullPath = Path.Combine(path, FileUtils.GetUniqueFileName(path, mediaProperties.FileName)),
            };

            result.CloneMediaProperties(mediaProperties);
            return(result);
        }
Esempio n. 10
0
        public override void CloneMediaProperties(IMediaProperties fromMedia)
        {
            base.CloneMediaProperties(fromMedia);
            var properties = fromMedia as IPersistentMediaProperties;

            if (properties != null)
            {
                IdAux         = properties.IdAux;
                IdProgramme   = properties.IdProgramme;
                MediaEmphasis = properties.MediaEmphasis;
            }
        }
Esempio n. 11
0
        internal IConvertOperation CreateConvertOperation(IMedia sourceMedia, IMediaProperties destMediaProperties, IMediaDirectory destDirectory, TVideoFormat outputFormat, decimal audioVolume, TFieldOrder sourceFieldOrderEnforceConversion, TAspectConversion aspectConversion, bool loudnessCheck)
        {
            IConvertOperation result = _fileManager.CreateConvertOperation();

            result.SourceMedia         = sourceMedia;
            result.DestMediaProperties = destMediaProperties;
            result.DestDirectory       = destDirectory;
            result.AudioVolume         = audioVolume;
            result.SourceFieldOrderEnforceConversion = sourceFieldOrderEnforceConversion;
            result.AspectConversion = aspectConversion;
            result.StartTC          = sourceMedia.TcPlay;
            result.Duration         = sourceMedia.DurationPlay;
            result.LoudnessCheck    = loudnessCheck;
            return(result);
        }
Esempio n. 12
0
        internal bool HasExtraLines; // VBI lines that shouldn't be displayed

        public virtual void CloneMediaProperties(IMediaProperties fromMedia)
        {
            MediaName            = fromMedia.MediaName;
            AudioChannelMapping  = fromMedia.AudioChannelMapping;
            AudioVolume          = fromMedia.AudioVolume;
            AudioLevelIntegrated = fromMedia.AudioLevelIntegrated;
            AudioLevelPeak       = fromMedia.AudioLevelPeak;
            Duration             = fromMedia.Duration;
            DurationPlay         = fromMedia.DurationPlay;
            TcStart       = fromMedia.TcStart;
            TcPlay        = fromMedia.TcPlay;
            MediaType     = fromMedia.MediaType;
            VideoFormat   = fromMedia.VideoFormat;
            MediaCategory = fromMedia.MediaCategory;
            Parental      = fromMedia.Parental;
        }
Esempio n. 13
0
        private string ValidateDestFileName()
        {
            IMediaProperties media = _convertOperation.DestMediaProperties;

            if (media != null)
            {
                IMediaDirectory dir = _convertOperation.DestDirectory;
                if (dir != null)
                {
                    if (_destFileName.StartsWith(" ") || _destFileName.EndsWith(" "))
                    {
                        return(resources._validate_FileNameCanNotStartOrEndWithSpace);
                    }
                    else
                    if (_destFileName.IndexOfAny(Path.GetInvalidFileNameChars()) > 0)
                    {
                        return(resources._validate_FileNameCanNotContainSpecialCharacters);
                    }
                    else
                    {
                        var newName = _destFileName.ToLowerInvariant();
                        if (dir.FileExists(newName, media.Folder))
                        {
                            return(resources._validate_FileAlreadyExists);
                        }
                        else
                        if (media is IPersistentMediaProperties)
                        {
                            if (media.MediaType == TMediaType.Movie &&
                                !FileUtils.VideoFileTypes.Contains(Path.GetExtension(newName).ToLower()))
                            {
                                return(string.Format(resources._validate_FileMustHaveExtension, string.Join(resources._or_, FileUtils.VideoFileTypes)));
                            }
                            if (media.MediaType == TMediaType.Still &&
                                !FileUtils.StillFileTypes.Contains(Path.GetExtension(newName).ToLower()))
                            {
                                return(string.Format(resources._validate_FileMustHaveExtension, string.Join(resources._or_, FileUtils.StillFileTypes)));
                            }
                        }
                    }
                }
            }
            return(null);
        }
        public override IMedia CreateMedia(IMediaProperties mediaProperties)
        {
            var newFileName = mediaProperties.FileName;

            if (File.Exists(Path.Combine(_folder, newFileName)))
            {
                Logger.Trace("{0}: File {1} already exists", nameof(CreateMedia), newFileName);
                newFileName = FileUtils.GetUniqueFileName(_folder, newFileName);
            }
            var newFileFullPath = Path.Combine(_folder, newFileName);
            var result          = (new ServerMedia(this, FindMediaByMediaGuid(mediaProperties.MediaGuid) == null ? mediaProperties.MediaGuid : Guid.NewGuid(), 0, MediaManager.ArchiveDirectory)
            {
                FullPath = newFileFullPath,
                MediaType = mediaProperties.MediaType == TMediaType.Unknown ? TMediaType.Movie : mediaProperties.MediaType,
                MediaStatus = TMediaStatus.Required,
            });

            result.CloneMediaProperties(mediaProperties);
            return(result);
        }
Esempio n. 15
0
        /// <summary>
        /// This method is used to take values of a specific metadata field from a MediaProperties object,
        /// and store the values in another MediaProperties object that is used for merging values
        /// from multiple MediaProperties objects.
        /// </summary>
        /// <param name="propName">Property name, usually acquired through Tags[CommonPropertyNames] enumeration.</param>
        /// <param name="mergedProps">The IMediaProperties object that will hold the merged values.</param>
        /// <param name="source">The IMediaProperties object that provides a set of values to copy from.</param>
        /// <returns></returns>
        private ArrayList GetMergedValues(string propName, IMediaProperties mergedProps, IMediaProperties source)
        {
            // contains a shallow copy of the results
            ArrayList results = new ArrayList();

            // get the values from the merged table
            IList list = (IList)mergedProps[propName];

            if (list != null)
            {
                if (list.Count > 0)
                {
                    results.AddRange(list);
                }
            }

            bool allowsMultiple;

            PropertyMappings.PropertyNameToType(propName, out allowsMultiple);

            // get the values that we will be merging with
            list = (IList)source[propName];

            if (list != null)
            {
                if (list.Count > 0)
                {
                    if (allowsMultiple == false)
                    {
                        results = new ArrayList();
                        results.Add(list[0]);
                    }
                    else
                    {
                        results.AddRange(list);
                    }
                }
            }

            return(results);
        }
Esempio n. 16
0
        internal override IMedia CreateMedia(IMediaProperties mediaProperties)
        {
            var newFileName = mediaProperties.FileName;

            if (File.Exists(Path.Combine(Folder, newFileName)))
            {
                Logger.Trace("{0}: File {1} already exists", nameof(CreateMedia), newFileName);
                newFileName = FileUtils.GetUniqueFileName(Folder, newFileName);
            }
            var result = (new ServerMedia
            {
                MediaName = mediaProperties.MediaName,
                MediaGuid = mediaProperties.MediaGuid == Guid.Empty || FindMediaByMediaGuid(mediaProperties.MediaGuid) != null ? Guid.NewGuid() : mediaProperties.MediaGuid,
                LastUpdated = mediaProperties.LastUpdated,
                MediaType = mediaProperties.MediaType == TMediaType.Unknown ? TMediaType.Movie : mediaProperties.MediaType,
                FileName = newFileName,
                MediaStatus = TMediaStatus.Required,
            });

            result.CloneMediaProperties(mediaProperties);
            AddMedia(result);
            return(result);
        }
Esempio n. 17
0
        internal override IMedia CreateMedia(IMediaProperties media)
        {
            var newFileName = media.FileName;

            if (File.Exists(Path.Combine(Folder, newFileName)))
            {
                Logger.Trace("{0}: File {1} already exists", nameof(CreateMedia), newFileName);
                newFileName = FileUtils.GetUniqueFileName(Folder, newFileName);
            }
            var result = new ArchiveMedia
            {
                MediaName   = media.MediaName,
                MediaGuid   = media.MediaGuid,
                LastUpdated = media.LastUpdated,
                MediaType   = media.MediaType,
                Folder      = GetCurrentFolder(),
                FileName    = newFileName,
                MediaStatus = TMediaStatus.Required,
            };

            result.CloneMediaProperties(media);
            AddMedia(result);
            return(result);
        }
Esempio n. 18
0
 public override IMedia CreateMedia(IMediaProperties mediaProperties)
 {
     throw new NotImplementedException();
 }
 public IArchiveMedia Find(IMediaProperties media)
 {
     return(EngineController.Database.DbMediaFind <ArchiveMedia>(this, media));
 }
Esempio n. 20
0
 public TempMedia(TempDirectory directory, IMediaProperties originalMedia) : base(directory, originalMedia?.MediaGuid ?? Guid.NewGuid())
 {
     OriginalMedia = originalMedia;
     MediaType     = originalMedia?.MediaType ?? TMediaType.Unknown;
     FileName      = $"{MediaGuid}{Path.GetExtension(originalMedia?.FileName ?? FileUtils.DefaultFileExtension(TMediaType.Unknown))}";
 }
Esempio n. 21
0
		/// <summary>
		/// <para>
		/// This method merges the standard metadata properties of a referring item 
		/// and the metadat properties of an underlying item.
		/// </para>
		/// </summary>
		/// <param name="baseProps">metadata properties of this/referring item</param>
		/// <param name="refProps">metadata properties of the underlying/referred item</param>
		/// <returns></returns>
		private MediaProperties MergeProperties(IMediaProperties baseProps, IMediaProperties refProps)
		{
			MediaProperties mergedProps = new MediaProperties();

			ICollection basePropNames = baseProps.PropertyNames;
			ICollection refPropNames = refProps.PropertyNames;

			// The referring item's metadata is always appended to the
			// underlying item's metadata.
			// 
			foreach (string basePropName in basePropNames)
			{
				ArrayList al = this.GetMergedValues(basePropName, mergedProps, baseProps);
				mergedProps[basePropName] = al;
			}

			foreach (string refPropName in refPropNames)
			{
				ArrayList al = this.GetMergedValues(refPropName, mergedProps, refProps);
				mergedProps[refPropName] = al;
			}


			return mergedProps;
		}
        /// <summary>
        /// Updates the value list with property data.
        /// </summary>
        private void UpdateValueListWithProperties(IMediaProperties properties)
        {
            valueListView.Items.Clear();
            foreach (string propertyName in properties.PropertyNames)
            {
                int rc = 0;
                IList propertyValues = m_Copy.MergedProperties[propertyName];

                foreach (ICdsElement propertyvalue in propertyValues)
                {
                    rc++;
                    if (rc == 1)
                    {
                        valueListView.Items.Add(new ListViewItem(new string[] { propertyName, propertyvalue.StringValue }));
                    }
                    else
                    {
                        valueListView.Items.Add(new ListViewItem(new string[] { propertyName + "(" + rc + ")", propertyvalue.StringValue }));
                    }
                }
            }

            valueListView.Items.Add(new ListViewItem(new string[] { "Restricted", m_Copy.IsRestricted.ToString() }));
            valueListView.Items.Add(new ListViewItem(new string[] { "Media Class", m_Copy.Class.ToString() }));
            valueListView.Items.Add(new ListViewItem(new string[] { "Object ID", m_Original.ID }));

            IMediaContainer originalC = this.m_Original as IMediaContainer;
            IMediaContainer mc = this.m_Copy as IMediaContainer;
            if (mc != null && originalC.IsRootContainer)
            {
                valueListView.Items.Add(new ListViewItem(new string[] { "Server UDN", ((CpRootContainer)m_Original).UDN }));
            }
            else
            {
                valueListView.Items.Add(new ListViewItem(new string[] { "Parent ID", m_Original.ParentID }));
            }

            if (mc != null) valueListView.Items.Add(new ListViewItem(new string[] { "Searchable", mc.IsSearchable.ToString() }));
        }
Esempio n. 23
0
 public TempMedia(TempDirectory directory, IMediaProperties originalMedia) : base(directory, originalMedia == null? Guid.NewGuid(): originalMedia.MediaGuid)
 {
     OriginalMedia = originalMedia;
     FileName      = string.Format("{0}{1}", _mediaGuid, originalMedia == null ? FileUtils.TempFileExtension : Path.GetExtension(originalMedia.FileName));
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="cds"></param>
        /// <param name="test"></param>
        /// <param name="arg"></param>
        /// <param name="details"></param>
        /// <param name="C"></param>
        /// <returns></returns>
        /// <exception cref="TerminateEarly">
        /// </exception>
        public static ArrayList GetContainerChildrenAndValidate(IMediaContainer parent, CpContentDirectory cds, CdsSubTest test, CdsSubTestArgument arg, CdsResult_BrowseAll details, Queue C)
        {
            uint totalExpected = uint.MaxValue;
            uint currentChild  = 0;

            ArrayList children = new ArrayList();

            while (currentChild < totalExpected)
            {
                BrowseInput input = new BrowseInput();
                input.ObjectID       = parent.ID;
                input.BrowseFlag     = CpContentDirectory.Enum_A_ARG_TYPE_BrowseFlag.BROWSEDIRECTCHILDREN;
                input.Filter         = "*";
                input.StartingIndex  = currentChild;
                input.RequestedCount = 1;
                input.SortCriteria   = "";

                string containerID = parent.ID;

                if (currentChild == 0)
                {
                    test.SetExpectedTestingTime((++details.ExpectedTotalBrowseRequests) * 30);
                    arg.ActiveTests.UpdateTimeAndProgress(details.TotalBrowseRequests * 30);
                }

                CdsBrowseSearchResults results = Browse(input, test, arg, cds, details);

                test.SetExpectedTestingTime((details.ExpectedTotalBrowseRequests) * 30);
                arg.ActiveTests.UpdateTimeAndProgress((details.TotalBrowseRequests) * 30);

                if (results.WorstError >= UPnPTestStates.Failed)
                {
                    throw new TerminateEarly("\"" + test.Name + "\" is terminating early because " + input.PrintBrowseParams() + " returned with an error or had problems with the DIDL-Lite.");
                }
                else
                {
                    if (results.NumberReturned != 1)
                    {
                        if (currentChild != 0)
                        {
                            results.SetError(UPnPTestStates.Failed);
                            arg._TestGroup.AddEvent(LogImportance.Low, test.Name, "\"" + test.Name + "\": " + input.PrintBrowseParams() + " returned NumberReturned=" + results.NumberReturned + " when it should logically be 1.");
                        }
                    }

                    if (results.TotalMatches != totalExpected)
                    {
                        if (currentChild != 0)
                        {
                            results.SetError(UPnPTestStates.Failed);
                            arg._TestGroup.AddEvent(LogImportance.Critical, test.Name, "\"" + test.Name + "\": " + input.PrintBrowseParams() + " returned TotalMatches=" + results.TotalMatches + " when it should logically be " + totalExpected + " as reported in an earlier Browse request. This portion of the test requires that a MediaServer device not be in a state where its content hierarchy will change.");
                        }
                        else
                        {
                            totalExpected = results.TotalMatches;
                            if (totalExpected > 0)
                            {
                                details.ExpectedTotalBrowseRequests += ((int)results.TotalMatches * 2) - 1;
                                test.SetExpectedTestingTime((details.ExpectedTotalBrowseRequests) * 30);
                                arg.ActiveTests.UpdateTimeAndProgress(details.TotalBrowseRequests * 30);
                            }
                        }
                    }

                    if (results.MediaObjects != null)
                    {
                        if (results.MediaObjects.Count == 1)
                        {
                            IUPnPMedia child = results.MediaObjects[0] as IUPnPMedia;

                            if (child == null)
                            {
                                throw new TestException("\"" + test.Name + "\"" + " has a TEST LOGIC ERROR. Browse returned without errors but the child object's metadata is not stored in an IUPnPMedia object. The offending type is " + results.MediaObjects[0].GetType().ToString(), results.MediaObjects[0]);
                            }

                            // ensure no duplicates in object ID
                            foreach (IUPnPMedia previousChild in details.AllObjects)
                            {
                                if (previousChild.ID == child.ID)
                                {
                                    string msg = "\"" + test.Name + "\": " + input.PrintBrowseParams() + " returned an object with ID=\"" + child.ID + "\" which conflicts with a previously seen media object in ParentContainerID=\"" + previousChild.ParentID + "\".";
                                    arg._TestGroup.AddEvent(LogImportance.Critical, test.Name, msg);
                                    throw new TerminateEarly(msg);
                                }
                            }

                            // ensure updateID is the same between BrowseDirectChildren and earlier BrowseMetadata.

                            try
                            {
                                uint previousUpdateID = (uint)parent.Tag;
                                if (results.UpdateID != previousUpdateID)
                                {
                                    string msg = "\"" + test.Name + "\": " + input.PrintBrowseParams() + " returned an UpdateID=" + results.UpdateID + " whilst an UpdateID=" + previousUpdateID + " was obtained in a previous call for ContainerID=\"" + parent.ID + "\" with BrowseMetadata.";
                                    arg._TestGroup.AddEvent(LogImportance.Critical, test.Name, msg);
                                    throw new TerminateEarly(msg);
                                }
                            }
                            catch (TerminateEarly te)
                            {
                                throw te;
                            }
                            catch (Exception e)
                            {
                                throw new TestException(test.Name + " has a TEST LOGIC ERROR. Error comparing UpdateID values", parent, e);
                            }

                            // add the child to lists: C, parent's child list, and Allobjects
                            try
                            {
                                parent.AddObject(child, false);
                            }
                            catch (Exception e)
                            {
                                AddObjectError aoe = new AddObjectError();
                                aoe.Parent = parent;
                                aoe.Child  = child;
                                throw new TestException(test.Name + " has a TEST LOGIC ERROR. Browse returned without errors but the child object could not be added to its parent.", aoe, e);
                            }

                            details.AllObjects.Add(child);
                            children.Add(child);
                            if (child.IsContainer)
                            {
                                C.Enqueue(child);
                                details.TotalContainers++;
                            }
                            else
                            {
                                details.TotalItems++;
                            }

                            //
                            // Do a BrowseMetadata and check to see if the XML values are the same.
                            //

                            CdsBrowseSearchResults compareResults = CheckMetadata(child, cds, test, arg, details);

                            if (compareResults.InvokeError != null)
                            {
                                arg._TestGroup.AddEvent(LogImportance.High, test.Name, test.Name + ": Browse(BrowseDirectChildren,StartingIndex=" + currentChild + ",RequestedCount=0) on ContainerID=[" + containerID + "] succeeded with warnings because a BrowseMetadata request was rejected by the CDS.");
                            }
                            else if (compareResults.ResultErrors.Count > 0)
                            {
                                string msg = "\"" + test.Name + "\": " + input.PrintBrowseParams() + " failed because a BrowseMetadata request succeeded but the DIDL-Lite could not be represented in object form. Invalid DIDL-Lite is most likely the cause.";
                                arg._TestGroup.AddEvent(LogImportance.Critical, test.Name, msg);
                                throw new TerminateEarly(msg);
                            }
                            else if (compareResults.WorstError >= UPnPTestStates.Failed)
                            {
                                string msg = "\"" + test.Name + "\": " + input.PrintBrowseParams() + " failed because one or more child object's failed a comparison of results between BrowseDirectChildren and BrowseMetadata or encountered some other critical error in that process.";
                                arg._TestGroup.AddEvent(LogImportance.Critical, test.Name, msg);
                                throw new TerminateEarly(msg);
                            }
                            else
                            {
                                //string msg = "\"" + test.Name + "\": " + input.PrintBrowseParams() + " succeeded.";
                                //arg._TestGroup.AddEvent(LogImportance.Remark, test.Name, msg);
                            }

                            //
                            // Track the metadata properties found so far
                            // as we may use them in Browse SortCriteria
                            //

                            // standard top-level attributes
                            Tags T = Tags.GetInstance();
                            AddTo(details.PropertyNames, "@" + T[_ATTRIB.id]);
                            AddTo(details.PropertyNames, "@" + T[_ATTRIB.parentID]);
                            AddTo(details.PropertyNames, "@" + T[_ATTRIB.restricted]);
                            if (child.IsContainer)
                            {
                                if (child.IsSearchable)
                                {
                                    AddTo(details.PropertyNames, "@" + T[_ATTRIB.searchable]);
                                    AddTo(details.PropertyNames, T[_DIDL.Container] + "@" + T[_ATTRIB.searchable]);
                                }

                                AddTo(details.PropertyNames, T[_DIDL.Container] + "@" + T[_ATTRIB.id]);
                                AddTo(details.PropertyNames, T[_DIDL.Container] + "@" + T[_ATTRIB.parentID]);
                                AddTo(details.PropertyNames, T[_DIDL.Container] + "@" + T[_ATTRIB.restricted]);
                            }
                            else if (child.IsItem)
                            {
                                if (child.IsReference)
                                {
                                    AddTo(details.PropertyNames, "@" + T[_ATTRIB.refID]);
                                    AddTo(details.PropertyNames, T[_DIDL.Item] + "@" + T[_ATTRIB.refID]);
                                }

                                AddTo(details.PropertyNames, T[_DIDL.Item] + "@" + T[_ATTRIB.id]);
                                AddTo(details.PropertyNames, T[_DIDL.Item] + "@" + T[_ATTRIB.parentID]);
                                AddTo(details.PropertyNames, T[_DIDL.Item] + "@" + T[_ATTRIB.restricted]);
                            }

                            // standard metadata
                            IMediaProperties properties    = child.MergedProperties;
                            IList            propertyNames = properties.PropertyNames;
                            foreach (string propertyName in propertyNames)
                            {
                                if (details.PropertyNames.Contains(propertyName) == false)
                                {
                                    details.PropertyNames.Add(propertyName);

                                    // add attributes if they are not added
                                    IList propertyValues = properties[propertyName];
                                    foreach (ICdsElement val in propertyValues)
                                    {
                                        ICollection attributes = val.ValidAttributes;
                                        foreach (string attribName in attributes)
                                        {
                                            StringBuilder sbpn = new StringBuilder();
                                            sbpn.AppendFormat("{0}@{1}", propertyName, attribName);
                                            string fullAttribName = sbpn.ToString();
                                            AddTo(details.PropertyNames, fullAttribName);
                                        }
                                    }
                                }

                                // resources
                                IList resources = child.MergedResources;
                                foreach (IMediaResource res in resources)
                                {
                                    ICollection attributes = res.ValidAttributes;
                                    foreach (string attribName in attributes)
                                    {
                                        string name1 = "res@" + attribName;
                                        string name2 = "@" + attribName;

                                        AddTo(details.PropertyNames, name1);
                                        AddTo(details.PropertyNames, name2);
                                    }
                                }

                                if (resources.Count > 0)
                                {
                                    AddTo(details.PropertyNames, T[_DIDL.Res]);
                                }
                            }
                        }
                        else
                        {
                            if (results.TotalMatches > 0)
                            {
                                results.SetError(UPnPTestStates.Failed);
                                string msg = "\"" + test.Name + "\": " + input.PrintBrowseParams() + " did not yield exactly one CDS-compliant media object in its result. Instantiated a total of " + results.MediaObjects.Count + " media objects.";
                                arg._TestGroup.AddEvent(LogImportance.Critical, test.Name, msg);
                                throw new TerminateEarly(msg);
                            }
                        }
                    }
                    else
                    {
                        throw new TestException(test.Name + " has a TEST LOGIC ERROR. Browse returned without errors but no media objects were instantiated.", null);
                    }
                }

                currentChild++;
            }

            return(children);
        }
 public override IMedia CreateMedia(IMediaProperties media)
 {
     return(new TempMedia(this, media));
 }
Esempio n. 26
0
 public override IMedia CreateMedia(IMediaProperties mediaProperties)
 {
     return(Query <IMedia>(parameters: new [] { mediaProperties }));
 }
Esempio n. 27
0
        public IArchiveMedia Find(IMediaProperties media)
        {
            var ret = Query <ArchiveMedia>(parameters: new object[] { media });

            return(ret);
        }
Esempio n. 28
0
 public IArchiveMedia Find(IMediaProperties media)
 {
     return(this.DbMediaFind <ArchiveMedia>(media));
 }
 public abstract IMedia CreateMedia(IMediaProperties mediaProperties);
Esempio n. 30
0
		/// <summary>
		/// This method is used to take values of a specific metadata field from a MediaProperties object,
		/// and store the values in another MediaProperties object that is used for merging values
		/// from multiple MediaProperties objects.
		/// </summary>
		/// <param name="propName">Property name, usually acquired through Tags[CommonPropertyNames] enumeration.</param>
		/// <param name="mergedProps">The IMediaProperties object that will hold the merged values.</param>
		/// <param name="source">The IMediaProperties object that provides a set of values to copy from.</param>
		/// <returns></returns>
		private ArrayList GetMergedValues (string propName, IMediaProperties mergedProps, IMediaProperties source)
		{
			// contains a shallow copy of the results
			ArrayList results = new ArrayList();
			
			// get the values from the merged table
			IList list = (IList) mergedProps[propName];

			if (list != null)
			{
				if (list.Count > 0)
				{
					results.AddRange(list);
				}
			}

			bool allowsMultiple;
			PropertyMappings.PropertyNameToType(propName, out allowsMultiple);

			// get the values that we will be merging with
			list = (IList) source[propName];

			if (list != null)
			{
				if (list.Count > 0)
				{
					if (allowsMultiple == false)
					{
						results = new ArrayList();
						results.Add(list[0]);
					}
					else
					{
						results.AddRange(list);
					}
				}
			}

			return results;
		}