/// <summary> /// Given a DIDL-Lite document in string form, this method /// creates a set of subtrees that represent the document. /// </summary> /// <param name="DidlLiteXml"></param> /// <returns> /// arraylist of /// <see cref="DvMediaItem"/> or /// <see cref="DvMediaContainer"/> objects. /// </returns> /// <exception cref="OpenSource.UPnP.AV.CdsMetadata.Error_BadMetadata"> /// Thrown when the DIDL-Lite is not well formed or not compliant /// with ContentDirectory specifications. /// </exception> public static ArrayList BuildMediaBranches(string DidlLiteXml) { ArrayList newBranches = MediaBuilder.BuildMediaBranches(DidlLiteXml, typeof(DvMediaItem), typeof(DvMediaContainer)); //recurse the branches and ensure all have tracking on foreach (IDvMedia dvm in newBranches) { EnableMetadataTracking(dvm); } return(newBranches); }
protected void URIMetaDataChangedSink(AVTransportLastChange sender) { if (sender.CurrentURIMetaData != "" && sender.CurrentURIMetaData != "NOT_IMPLEMENTED") { ArrayList a = MediaBuilder.BuildMediaBranches(sender.CurrentURIMetaData); if (a.Count > 0) { // Since new metadata was evented, we need to update the container, and then // update the current item _Container = (IMediaContainer)a[0]; UpdateCurrentItem(); } } }
/// <summary> /// Given a DIDL-Lite document in string form, this method /// creates a set of subtrees that represent the document. /// </summary> /// <param name="DidlLiteXml"></param> /// <returns> /// arraylist of /// <see cref="CpMediaItem"/> or /// <see cref="CpMediaContainer"/> objects. /// </returns> /// <exception cref="OpenSource.UPnP.AV.CdsMetadata.Error_BadMetadata"> /// Thrown when the DIDL-Lite is not well formed or not compliant /// with ContentDirectory specifications. /// </exception> public static ArrayList BuildMediaBranches(string DidlLiteXml) { return(MediaBuilder.BuildMediaBranches(DidlLiteXml, typeof(CpMediaItem), typeof(CpMediaContainer))); }
/// <summary> /// Performs a Browse invocation. /// </summary> /// <param name="input"></param> /// <param name="test"></param> /// <param name="arg"></param> /// <param name="cds"></param> /// <param name="stats"></param> /// <returns></returns> public static CdsBrowseSearchResults Browse(BrowseInput input, CdsSubTest test, CdsSubTestArgument arg, CpContentDirectory cds, CdsResult_BrowseStats stats) { CdsBrowseSearchResults results = new CdsBrowseSearchResults(); results.SetError(UPnPTestStates.Pass); results.ResultErrors = new ArrayList(); arg._TestGroup.AddEvent(LogImportance.Remark, test.Name, "\"" + test.Name + "\" about to do " + input.PrintBrowseParams() + "."); try { cds.Sync_Browse(input.ObjectID, input.BrowseFlag, input.Filter, input.StartingIndex, input.RequestedCount, input.SortCriteria, out results.Result, out results.NumberReturned, out results.TotalMatches, out results.UpdateID); } catch (UPnPInvokeException error) { results.InvokeError = error; } if (results.InvokeError == null) { arg._TestGroup.AddEvent(LogImportance.Remark, test.Name, "\"" + test.Name + "\" completed " + input.PrintBrowseParams() + " with no errors returned by the device."); } else { arg._TestGroup.AddEvent(LogImportance.Remark, test.Name, "\"" + test.Name + "\" completed " + input.PrintBrowseParams() + " with the device returning an error."); } stats.TotalBrowseRequests++; ArrayList branches = null; if (results.InvokeError == null) { try { if (results.Result != null) { if (results.Result != "") { bool schemaOK = CheckDidlLiteSchema(results.Result); if (schemaOK) { results.MediaObjects = branches = MediaBuilder.BuildMediaBranches(results.Result, typeof(MediaItem), typeof(MediaContainer), true); if (branches.Count != results.NumberReturned) { results.ResultErrors.Add(new CdsException(input.PrintBrowseParams() + " has the \"Result\" argument indicating the presence of " + branches.Count + " media objects but the request returned NumberReturned=" + results.NumberReturned + ".")); } if (input.BrowseFlag == CpContentDirectory.Enum_A_ARG_TYPE_BrowseFlag.BROWSEMETADATA) { if (branches.Count != 1) { results.ResultErrors.Add(new CdsException(input.PrintBrowseParams() + " has the \"Result\" argument indicating the presence of " + branches.Count + " media objects but the request should have only returned 1 media object.")); } } foreach (IUPnPMedia mobj in branches) { IMediaContainer imc = mobj as IMediaContainer; if (imc != null) { if (imc.CompleteList.Count > 0) { StringBuilder offendingList = new StringBuilder(); int offenses = 0; foreach (IUPnPMedia offending in imc.CompleteList) { if (offenses > 0) { offendingList.Append(","); } offendingList.AppendFormat("\"{0}\"", offending.ID); offenses++; } results.ResultErrors.Add(new CdsException(input.PrintBrowseParams() + " has the \"Result\" argument with a declared container (ID=\"" + imc.ID + "\") element that also includes its immediate children. Illegally declared media objects in the response are: " + offendingList.ToString())); } } } } } } } catch (Exception error2) { results.ResultErrors.Add(error2); if (results.MediaObjects == null) { results.MediaObjects = new ArrayList(); } } } // log any errors if ((results.InvokeError != null) || (results.ResultErrors.Count > 0)) { LogErrors(arg._TestGroup, test, input, "Browse", results.InvokeError, results.ResultErrors); results.SetError(UPnPTestStates.Failed); } return(results); }