From acac47830e3d7d9103c30729ad0cff50b0e8fcdc Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 1 Jul 2010 02:06:51 +0100 Subject: start storing incoming MediaEntry on a new Media field on PrimitiveBaseShape This allows the media texture to persist in memory - logging in and out will redisplay it (after a click) though navigation will be lost Next need to implement media uri on prim and delegate more incoming llsd parsing to libomv --- OpenSim/Framework/PrimitiveBaseShape.cs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'OpenSim/Framework/PrimitiveBaseShape.cs') diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs index 4d1de22..517dbf6 100644 --- a/OpenSim/Framework/PrimitiveBaseShape.cs +++ b/OpenSim/Framework/PrimitiveBaseShape.cs @@ -26,12 +26,14 @@ */ using System; +using System.Collections.Generic; using System.Drawing; using System.Drawing.Imaging; using System.Reflection; using System.Xml.Serialization; using log4net; using OpenMetaverse; +using OpenMetaverse.StructuredData; namespace OpenSim.Framework { @@ -170,6 +172,11 @@ namespace OpenSim.Framework } } } + + /// + /// Entries to store media textures on each face + /// + public List Media { get; set; } public PrimitiveBaseShape() { -- cgit v1.1 From a5ad792e6c90eb9412325e636c6e4eafc4a8a91d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 12 Jul 2010 19:46:23 +0100 Subject: implement llSetPrimMediaParams() Untested --- OpenSim/Framework/PrimitiveBaseShape.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Framework/PrimitiveBaseShape.cs') diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs index 517dbf6..85638ca 100644 --- a/OpenSim/Framework/PrimitiveBaseShape.cs +++ b/OpenSim/Framework/PrimitiveBaseShape.cs @@ -176,6 +176,7 @@ namespace OpenSim.Framework /// /// Entries to store media textures on each face /// + /// Do not change this value directly - always do it through an IMoapModule. public List Media { get; set; } public PrimitiveBaseShape() -- cgit v1.1 From 412fed975fc0b28c3af111be89a1bcb4aaa05a9b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 26 Jul 2010 21:09:54 +0100 Subject: relocate serialization code from SQLiteRegionData to MoapModule using load and save events. This is better modularity. It also allows MoapModule to be replaced with some other media module that may behave completely differently in the future. Remaining non-modularity: PrimitiveBaseShape needs explicit Media and MediaRaw fields. MediaRaw is required in order to shuttle the pre-serialization data back and forth from the database layer. The database also needs to know about MediaRaw though not about Media. IMO, it would be extremely nice to remove these hard codings but this is a bridge too far at the present time. --- OpenSim/Framework/PrimitiveBaseShape.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'OpenSim/Framework/PrimitiveBaseShape.cs') diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs index 85638ca..03ddb33 100644 --- a/OpenSim/Framework/PrimitiveBaseShape.cs +++ b/OpenSim/Framework/PrimitiveBaseShape.cs @@ -174,6 +174,12 @@ namespace OpenSim.Framework } /// + /// Raw media data suitable for serialization operations. This should only ever be used by an IMoapModule. + /// + [XmlIgnore] + public string MediaRaw { get; set; } + + /// /// Entries to store media textures on each face /// /// Do not change this value directly - always do it through an IMoapModule. -- cgit v1.1 From 60df76314f89d8a489a7f8a3182277cf1a52925c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 3 Aug 2010 15:45:49 +0100 Subject: serialize media textures to inventory with a largely osd representation rather than .net auto-serialization THIS WILL BREAK ANY EXISTING MEDIA TEXTURE SERIALIZATIONS. If you're testing this, please start with new databases. This makes media textures serialized in the same way, which is probably better in the long term. --- OpenSim/Framework/PrimitiveBaseShape.cs | 90 +++++++++++++++++++++++++++++++-- 1 file changed, 87 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/PrimitiveBaseShape.cs') diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs index 03ddb33..de7e42d 100644 --- a/OpenSim/Framework/PrimitiveBaseShape.cs +++ b/OpenSim/Framework/PrimitiveBaseShape.cs @@ -29,7 +29,10 @@ using System; using System.Collections.Generic; using System.Drawing; using System.Drawing.Imaging; +using System.IO; using System.Reflection; +using System.Xml; +using System.Xml.Schema; using System.Xml.Serialization; using log4net; using OpenMetaverse; @@ -183,7 +186,7 @@ namespace OpenSim.Framework /// Entries to store media textures on each face /// /// Do not change this value directly - always do it through an IMoapModule. - public List Media { get; set; } + public MediaList Media { get; set; } public PrimitiveBaseShape() { @@ -1221,5 +1224,86 @@ namespace OpenSim.Framework return prim; } - } -} + + public class MediaList : List, IXmlSerializable + { + public const string MEDIA_TEXTURE_TYPE = "sl"; + + public MediaList() : base() {} + public MediaList(IEnumerable collection) : base(collection) {} + public MediaList(int capacity) : base(capacity) {} + + public XmlSchema GetSchema() + { + return null; + } + + public void WriteXml(XmlWriter writer) + { + lock (this) + { + using (StringWriter sw = new StringWriter()) + { + using (XmlTextWriter xtw = new XmlTextWriter(sw)) + { + xtw.WriteStartElement("osmedia"); + xtw.WriteAttributeString("type", MEDIA_TEXTURE_TYPE); + xtw.WriteAttributeString("major_version", "0"); + xtw.WriteAttributeString("minor_version", "1"); + + OSDArray meArray = new OSDArray(); + foreach (MediaEntry me in this) + { + OSD osd = (null == me ? new OSD() : me.GetOSD()); + meArray.Add(osd); + } + + xtw.WriteStartElement("osdata"); + xtw.WriteRaw(OSDParser.SerializeLLSDXmlString(meArray)); + xtw.WriteEndElement(); + + xtw.WriteEndElement(); + + xtw.Flush(); + writer.WriteRaw(sw.ToString()); + } + } + } + } + + public void ReadXml(XmlReader reader) + { + if (reader.IsEmptyElement) + return; + + string rawXml = reader.ReadInnerXml(); + using (StringReader sr = new StringReader(rawXml)) + { + using (XmlTextReader xtr = new XmlTextReader(sr)) + { + xtr.MoveToContent(); + + string type = xtr.GetAttribute("type"); + //m_log.DebugFormat("[MOAP]: Loaded media texture entry with type {0}", type); + + if (type != MEDIA_TEXTURE_TYPE) + return; + + xtr.ReadStartElement("osmedia"); + + OSDArray osdMeArray = (OSDArray)OSDParser.DeserializeLLSDXml(xtr.ReadInnerXml()); + + List mediaEntries = new List(); + foreach (OSD osdMe in osdMeArray) + { + MediaEntry me = (osdMe is OSDMap ? MediaEntry.FromOSD(osdMe) : new MediaEntry()); + Add(me); + } + + xtr.ReadEndElement(); + } + } + } + } + } +} \ No newline at end of file -- cgit v1.1 From ac07d853b89d9b2bda2dd058f7f9ea94211a26f1 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 3 Aug 2010 15:58:17 +0100 Subject: remove duplicated serialization code --- OpenSim/Framework/PrimitiveBaseShape.cs | 38 ++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 12 deletions(-) (limited to 'OpenSim/Framework/PrimitiveBaseShape.cs') diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs index de7e42d..685599a 100644 --- a/OpenSim/Framework/PrimitiveBaseShape.cs +++ b/OpenSim/Framework/PrimitiveBaseShape.cs @@ -1238,7 +1238,7 @@ namespace OpenSim.Framework return null; } - public void WriteXml(XmlWriter writer) + public string ToXml() { lock (this) { @@ -1265,18 +1265,26 @@ namespace OpenSim.Framework xtw.WriteEndElement(); xtw.Flush(); - writer.WriteRaw(sw.ToString()); + return sw.ToString(); } } - } + } } - - public void ReadXml(XmlReader reader) + + public void WriteXml(XmlWriter writer) + { + writer.WriteRaw(ToXml()); + } + + public static MediaList FromXml(string rawXml) { - if (reader.IsEmptyElement) - return; - - string rawXml = reader.ReadInnerXml(); + MediaList ml = new MediaList(); + ml.ReadXml(rawXml); + return ml; + } + + public void ReadXml(string rawXml) + { using (StringReader sr = new StringReader(rawXml)) { using (XmlTextReader xtr = new XmlTextReader(sr)) @@ -1292,8 +1300,6 @@ namespace OpenSim.Framework xtr.ReadStartElement("osmedia"); OSDArray osdMeArray = (OSDArray)OSDParser.DeserializeLLSDXml(xtr.ReadInnerXml()); - - List mediaEntries = new List(); foreach (OSD osdMe in osdMeArray) { MediaEntry me = (osdMe is OSDMap ? MediaEntry.FromOSD(osdMe) : new MediaEntry()); @@ -1303,7 +1309,15 @@ namespace OpenSim.Framework xtr.ReadEndElement(); } } - } + } + + public void ReadXml(XmlReader reader) + { + if (reader.IsEmptyElement) + return; + + ReadXml(reader.ReadInnerXml()); + } } } } \ No newline at end of file -- cgit v1.1 From 9d8a67fe1348419c41374d1be77737bfa048106c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 3 Aug 2010 16:26:27 +0100 Subject: get rid of PrimitiveBaseShape.MediaRaw staging post using an OSD serialization rather than auto forces serialization code to be placed in OpenSim.Framework this makes the media texture raw data staging post in PrimitiveBaseShape redundant, now we just directly call the code in PrimitiveBaseShape.MediaList itself --- OpenSim/Framework/PrimitiveBaseShape.cs | 6 ------ 1 file changed, 6 deletions(-) (limited to 'OpenSim/Framework/PrimitiveBaseShape.cs') diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs index 685599a..9b52fe6 100644 --- a/OpenSim/Framework/PrimitiveBaseShape.cs +++ b/OpenSim/Framework/PrimitiveBaseShape.cs @@ -175,12 +175,6 @@ namespace OpenSim.Framework } } } - - /// - /// Raw media data suitable for serialization operations. This should only ever be used by an IMoapModule. - /// - [XmlIgnore] - public string MediaRaw { get; set; } /// /// Entries to store media textures on each face -- cgit v1.1 From 99c0f4c9c7820f6340155f7af30ab91745774c93 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 3 Aug 2010 17:09:20 +0100 Subject: Simplify serialized version string. Change element capitalization for consistency THIS CHANGE ALTERS THE SERIALIZATION FORMAT, HOPEFULLY FOR THE LAST TIME. If you're testing, please start with a new database. This commit also improves locking for manipulation of media entries. --- OpenSim/Framework/PrimitiveBaseShape.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'OpenSim/Framework/PrimitiveBaseShape.cs') diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs index 9b52fe6..70a61cc 100644 --- a/OpenSim/Framework/PrimitiveBaseShape.cs +++ b/OpenSim/Framework/PrimitiveBaseShape.cs @@ -180,6 +180,7 @@ namespace OpenSim.Framework /// Entries to store media textures on each face /// /// Do not change this value directly - always do it through an IMoapModule. + /// Lock before manipulating. public MediaList Media { get; set; } public PrimitiveBaseShape() @@ -1219,6 +1220,11 @@ namespace OpenSim.Framework return prim; } + /// + /// Encapsulates a list of media entries. + /// + /// This class is necessary because we want to replace auto-serialization of MediaEntry with something more + /// OSD like and less vulnerable to change. public class MediaList : List, IXmlSerializable { public const string MEDIA_TEXTURE_TYPE = "sl"; @@ -1240,10 +1246,9 @@ namespace OpenSim.Framework { using (XmlTextWriter xtw = new XmlTextWriter(sw)) { - xtw.WriteStartElement("osmedia"); + xtw.WriteStartElement("OSMedia"); xtw.WriteAttributeString("type", MEDIA_TEXTURE_TYPE); - xtw.WriteAttributeString("major_version", "0"); - xtw.WriteAttributeString("minor_version", "1"); + xtw.WriteAttributeString("version", "0.1"); OSDArray meArray = new OSDArray(); foreach (MediaEntry me in this) @@ -1252,7 +1257,7 @@ namespace OpenSim.Framework meArray.Add(osd); } - xtw.WriteStartElement("osdata"); + xtw.WriteStartElement("OSData"); xtw.WriteRaw(OSDParser.SerializeLLSDXmlString(meArray)); xtw.WriteEndElement(); @@ -1291,7 +1296,7 @@ namespace OpenSim.Framework if (type != MEDIA_TEXTURE_TYPE) return; - xtr.ReadStartElement("osmedia"); + xtr.ReadStartElement("OSMedia"); OSDArray osdMeArray = (OSDArray)OSDParser.DeserializeLLSDXml(xtr.ReadInnerXml()); foreach (OSD osdMe in osdMeArray) -- cgit v1.1