Example #1
0
        public void TestClearMediaUrl()
        {
            TestHelpers.InMethod();           
//            log4net.Config.XmlConfigurator.Configure();
            
            SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene);
            MediaEntry me = new MediaEntry();            
            
            m_module.SetMediaEntry(part, 1, me);
            m_module.ClearMediaEntry(part, 1);
            
            Assert.That(part.Shape.Media[1], Is.EqualTo(null));
            
            // Although we've cleared one face, other faces may still be present.  So we need to check for an
            // update media url version
            Assert.That(part.MediaUrl, Is.EqualTo("x-mv:0000000001/" + UUID.Zero));
            
            // By changing media flag to false, the face texture once again becomes identical to the DefaultTexture.
            // Therefore, when libOMV reserializes it, it disappears and we are left with no face texture in this slot.
            // Not at all confusing, eh?
            Assert.That(part.Shape.Textures.FaceTextures[1], Is.Null);
        }
        /// <summary>
        /// Deserialize from OSD data
        /// </summary>
        /// <param name="osd">Serialized OSD data</param>
        /// <returns>Deserialized object</returns>
        public static MediaEntry FromOSD(OSD osd)
        {
            MediaEntry m   = new MediaEntry();
            OSDMap     map = (OSDMap)osd;

            m.EnableAlterntiveImage = map["alt_image_enable"].AsBoolean();
            m.AutoLoop             = map["auto_loop"].AsBoolean();
            m.AutoPlay             = map["auto_play"].AsBoolean();
            m.AutoScale            = map["auto_scale"].AsBoolean();
            m.AutoZoom             = map["auto_zoom"].AsBoolean();
            m.Controls             = (MediaControls)map["controls"].AsInteger();
            m.CurrentURL           = map["current_url"].AsString();
            m.InteractOnFirstClick = map["first_click_interact"].AsBoolean();
            m.Height              = map["height_pixels"].AsInteger();
            m.HomeURL             = map["home_url"].AsString();
            m.ControlPermissions  = (MediaPermission)map["perms_control"].AsInteger();
            m.InteractPermissions = (MediaPermission)map["perms_interact"].AsInteger();

            if (map["whitelist"].Type == OSDType.Array)
            {
                OSDArray wl = (OSDArray)map["whitelist"];
                if (wl.Count > 0)
                {
                    m.WhiteList = new string[wl.Count];
                    for (int i = 0; i < wl.Count; i++)
                    {
                        m.WhiteList[i] = wl[i].AsString();
                    }
                }
            }

            m.EnableWhiteList = map["whitelist_enable"].AsBoolean();
            m.Width           = map["width_pixels"].AsInteger();

            return(m);
        }
Example #3
0
 public ObjectMediaEventArgs(bool success, string version, MediaEntry[] faceMedia)
 {
     this.Success = success;
     this.Version = version;
     this.FaceMedia = faceMedia;
 }
Example #4
0
        /// <summary>
        /// Set object media
        /// </summary>
        /// <param name="primID">UUID of the prim</param>
        /// <param name="faceMedia">Array the length of prims number of faces. Null on face indexes where there is
        /// no media, <seealso cref="MediaEntry"/> on faces which contain the media</param>
        /// <param name="sim">Simulatior in which prim is located</param>
        public void UpdateObjectMedia(UUID primID, MediaEntry[] faceMedia, Simulator sim)
        {
            Uri url;
            if (sim.Caps != null && null != (url = sim.Caps.CapabilityURI("ObjectMedia")))
            {
                ObjectMediaUpdate req = new ObjectMediaUpdate();
                req.PrimID = primID;
                req.FaceMedia = faceMedia;
                req.Verb = "UPDATE";

                CapsClient request = new CapsClient(url);
                request.OnComplete += (CapsClient client, OSD result, Exception error) =>
                    {
                        if (error != null)
                        {
                            Logger.Log("ObjectMediaUpdate: " + error.Message, Helpers.LogLevel.Error, Client);
                        }
                    };
                request.BeginGetResponse(req.Serialize(), OSDFormat.Xml, Client.Settings.CAPS_TIMEOUT);
            }
            else
            {
                Logger.Log("ObjectMedia capability not available", Helpers.LogLevel.Error, Client);
            }
        }
Example #5
0
        public void SetMediaEntry (ISceneChildEntity part, int face, MediaEntry me)
        {
            CheckFaceParam(part, face);

            if (null == part.Shape.Media)
            {
                if (me == null)
                    return;
                else
                    part.Shape.Media = new PrimitiveBaseShape.MediaList(new MediaEntry[part.GetNumberOfSides()]);
            }

            lock (part.Shape.Media)
                part.Shape.Media[face] = me;

            UpdateMediaUrl(part, UUID.Zero);

            SetPartMediaFlags(part, face, me != null);

            part.ScheduleUpdate(PrimUpdateFlags.FullUpdate);
            part.TriggerScriptChangedEvent(Changed.MEDIA);
        }
Example #6
0
 public void SetMediaEntry(SceneObjectPart part, int face, MediaEntry me)
 {
     CheckFaceParam(part, face);
     
     if (null == part.Shape.Media)
         part.Shape.Media = new PrimitiveBaseShape.MediaList(new MediaEntry[part.GetNumberOfSides()]);
         
     lock (part.Shape.Media)
         part.Shape.Media[face] = me;
     
     UpdateMediaUrl(part, UUID.Zero);
     part.ScheduleFullUpdate(PrimUpdateFlags.FullUpdate);
     part.TriggerScriptChangedEvent(Changed.MEDIA);
 }
Example #7
0
        private LSL_Integer SetPrimMediaParams(SceneObjectPart part, LSL_Integer face, LSL_List rules)
        {
            // LSL Spec http://wiki.secondlife.com/wiki/LlSetPrimMediaParams says to fail silently if face is invalid
            // Assuming silently fail means sending back LSL_STATUS_OK.  Ideally, need to check this.
            // Don't perform the media check directly
            if (face < 0 || face > part.GetNumberOfSides() - 1)
                return ScriptBaseClass.LSL_STATUS_NOT_FOUND;

            IMoapModule module = m_ScriptEngine.World.RequestModuleInterface<IMoapModule>();
            if (null == module)
                return ScriptBaseClass.LSL_STATUS_NOT_SUPPORTED;

            MediaEntry me = module.GetMediaEntry(part, face);
            if (null == me)
                me = new MediaEntry();

            int i = 0;

            while (i < rules.Length - 1)
            {
                int code = rules.GetLSLIntegerItem(i++);

                switch (code)
                {
                    case ScriptBaseClass.PRIM_MEDIA_ALT_IMAGE_ENABLE:
                        me.EnableAlterntiveImage = (rules.GetLSLIntegerItem(i++) != 0 ? true : false);
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_CONTROLS:
                        int v = rules.GetLSLIntegerItem(i++);
                        if (ScriptBaseClass.PRIM_MEDIA_CONTROLS_STANDARD == v)
                            me.Controls = MediaControls.Standard;
                        else
                            me.Controls = MediaControls.Mini;
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_CURRENT_URL:
                        me.CurrentURL = rules.GetLSLStringItem(i++);
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_HOME_URL:
                        me.HomeURL = rules.GetLSLStringItem(i++);
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_AUTO_LOOP:
                        me.AutoLoop = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_AUTO_PLAY:
                        me.AutoPlay = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_AUTO_SCALE:
                        me.AutoScale = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_AUTO_ZOOM:
                        me.AutoZoom = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_FIRST_CLICK_INTERACT:
                        me.InteractOnFirstClick = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_WIDTH_PIXELS:
                        me.Width = (int)rules.GetLSLIntegerItem(i++);
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_HEIGHT_PIXELS:
                        me.Height = (int)rules.GetLSLIntegerItem(i++);
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_WHITELIST_ENABLE:
                        me.EnableWhiteList = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_WHITELIST:
                        string[] rawWhiteListUrls = rules.GetLSLStringItem(i++).ToString().Split(new char[] { ',' });
                        List<string> whiteListUrls = new List<string>();
                        Array.ForEach(
                            rawWhiteListUrls, delegate(string rawUrl) { whiteListUrls.Add(rawUrl.Trim()); });
                        me.WhiteList = whiteListUrls.ToArray();
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_PERMS_INTERACT:
                        me.InteractPermissions = (MediaPermission)(byte)(int)rules.GetLSLIntegerItem(i++);
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_PERMS_CONTROL:
                        me.ControlPermissions = (MediaPermission)(byte)(int)rules.GetLSLIntegerItem(i++);
                        break;

                    default: return ScriptBaseClass.LSL_STATUS_MALFORMED_PARAMS;
                }
            }

            module.SetMediaEntry(part, face, me);

            return ScriptBaseClass.LSL_STATUS_OK;
        }
Example #8
0
        /// <summary>
        /// Set the media entry on the face of the given part.
        /// </summary>
        /// <param name="part">/param>
        /// <param name="face"></param>
        /// <param name="me">If null, then the media entry is cleared.</param>
        public void SetMediaEntry(SceneObjectPart part, int face, MediaEntry me)
        {
            //            m_log.DebugFormat("[MOAP]: SetMediaEntry for {0}, face {1}", part.Name, face);
            int numFaces = part.GetNumberOfSides();
            if (part.Shape.Media == null)
                part.Shape.Media = new PrimitiveBaseShape.PrimMedia(numFaces);
            else
                part.Shape.Media.Resize(numFaces);

            if (!CheckFaceParam(part, face))
                return;

            // ClearMediaEntry passes null for me so it must not be ignored!
            lock (part.Shape.Media)
                part.Shape.Media[face] = me;

            UpdateMediaUrl(part, UUID.Zero);

            SetPartMediaFlags(part, face, me != null);

            part.ScheduleFullUpdate(PrimUpdateFlags.FindBest);
            part.TriggerScriptChangedEvent(Changed.MEDIA);
        }
Example #9
0
        public LSL_Integer SetPrimMediaParams(int face, LSL_List rules)
        {
            IMoapModule module = World.RequestModuleInterface<IMoapModule>();
            if (null == module)
                throw new Exception("Media on a prim functions not available");

            MediaEntry me = module.GetMediaEntry(m_host, face);
            if (null == me)
                me = new MediaEntry();

            int i = 0;

            while (i < rules.Length - 1)
            {
                int code = rules.GetLSLIntegerItem(i++);

                if (code == ScriptBaseClass.PRIM_MEDIA_ALT_IMAGE_ENABLE)
                {
                    me.EnableAlterntiveImage = (rules.GetLSLIntegerItem(i++) != 0 ? true : false);
                }
                else if (code == ScriptBaseClass.PRIM_MEDIA_CONTROLS)
                {
                    int v = rules.GetLSLIntegerItem(i++);
                    if (ScriptBaseClass.PRIM_MEDIA_CONTROLS_STANDARD == v)
                        me.Controls = MediaControls.Standard;
                    else
                        me.Controls = MediaControls.Mini;
                }
                else if (code == ScriptBaseClass.PRIM_MEDIA_CURRENT_URL)
                {
                    me.CurrentURL = rules.GetLSLStringItem(i++);
                }
                else if (code == ScriptBaseClass.PRIM_MEDIA_HOME_URL)
                {
                    me.HomeURL = rules.GetLSLStringItem(i++);
                }
                else if (code == ScriptBaseClass.PRIM_MEDIA_AUTO_LOOP)
                {
                    me.AutoLoop = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
                }
                else if (code == ScriptBaseClass.PRIM_MEDIA_AUTO_PLAY)
                {
                    me.AutoPlay = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
                }
                else if (code == ScriptBaseClass.PRIM_MEDIA_AUTO_SCALE)
                {
                    me.AutoScale = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
                }
                else if (code == ScriptBaseClass.PRIM_MEDIA_AUTO_ZOOM)
                {
                    me.AutoZoom = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
                }
                else if (code == ScriptBaseClass.PRIM_MEDIA_FIRST_CLICK_INTERACT)
                {
                    me.InteractOnFirstClick = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
                }
                else if (code == ScriptBaseClass.PRIM_MEDIA_WIDTH_PIXELS)
                {
                    me.Width = (int)rules.GetLSLIntegerItem(i++);
                }
                else if (code == ScriptBaseClass.PRIM_MEDIA_HEIGHT_PIXELS)
                {
                    me.Height = (int)rules.GetLSLIntegerItem(i++);
                }
                else if (code == ScriptBaseClass.PRIM_MEDIA_WHITELIST_ENABLE)
                {
                    me.EnableWhiteList = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
                }
                else if (code == ScriptBaseClass.PRIM_MEDIA_WHITELIST)
                {
                    string[] rawWhiteListUrls = rules.GetLSLStringItem(i++).ToString().Split(new char[] { ',' });
                    List<string> whiteListUrls = new List<string>();
                    Array.ForEach(
                        rawWhiteListUrls, delegate(string rawUrl) { whiteListUrls.Add(rawUrl.Trim()); });
                    me.WhiteList = whiteListUrls.ToArray();
                }
                else if (code == ScriptBaseClass.PRIM_MEDIA_PERMS_INTERACT)
                {
                    me.InteractPermissions = (MediaPermission)(byte)(int)rules.GetLSLIntegerItem(i++);
                }
                else if (code == ScriptBaseClass.PRIM_MEDIA_PERMS_CONTROL)
                {
                    me.ControlPermissions = (MediaPermission)(byte)(int)rules.GetLSLIntegerItem(i++);
                }
            }

            module.SetMediaEntry(m_host, face, me);

            return ScriptBaseClass.LSL_STATUS_OK;
        }
 public MediaEntry[] CopyArray()
 {
     lock (this)
     {
         int len = m_MediaFaces.Length;
         MediaEntry[] copyFaces = new MediaEntry[len];
         for (int x=0; x<len; x++)
         {
             copyFaces[x] = MediaEntryCopy(m_MediaFaces[x]);
         }
         return copyFaces;
     }
 }
            // This should be implemented in OpenMetaverse.MediaEntry but isn't.
            private MediaEntry MediaEntryCopy(MediaEntry entry)
            {
                if (entry == null) return null;

                MediaEntry newEntry = new MediaEntry();
                newEntry.AutoLoop = entry.AutoLoop;
                newEntry.AutoPlay = entry.AutoPlay;
                newEntry.AutoScale = entry.AutoScale;
                newEntry.AutoZoom = entry.AutoZoom;
                newEntry.ControlPermissions = entry.ControlPermissions;
                newEntry.Controls = entry.Controls;
                newEntry.CurrentURL = entry.CurrentURL;
                newEntry.EnableAlterntiveImage = entry.EnableAlterntiveImage;
                newEntry.EnableWhiteList = entry.EnableWhiteList;
                newEntry.Height = entry.Height;
                newEntry.HomeURL = entry.HomeURL;
                newEntry.InteractOnFirstClick = entry.InteractOnFirstClick;
                newEntry.InteractPermissions = entry.InteractPermissions;
                newEntry.Width = entry.Width;
                if (entry.WhiteList != null)
                    entry.WhiteList.CopyTo(newEntry.WhiteList, 0);
                else
                    entry.WhiteList = null;
                newEntry.Width = entry.Width;

                return newEntry;
            }
 public PrimMedia(MediaEntry[] entries) : base()
 {
     m_MediaFaces = entries.Clone() as MediaEntry[];
 }
Example #13
0
 public void TestSetMediaUrl()
 {
     TestHelpers.InMethod();
     
     string homeUrl = "opensimulator.org";            
     
     SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene);
     MediaEntry me = new MediaEntry() { HomeURL = homeUrl };            
     
     m_module.SetMediaEntry(part, 1, me);
     
     Assert.That(part.Shape.Media[1].HomeURL, Is.EqualTo(homeUrl));
     Assert.That(part.MediaUrl, Is.EqualTo("x-mv:0000000000/" + UUID.Zero));
     Assert.That(part.Shape.Textures.FaceTextures[1].MediaFlags, Is.True);
 }
Example #14
0
        /// <summary>
        /// Deserialize from OSD data
        /// </summary>
        /// <param name="osd">Serialized OSD data</param>
        /// <returns>Deserialized object</returns>
        public static MediaEntry FromOSD(OSD osd)
        {
            MediaEntry m = new MediaEntry();
            OSDMap map = (OSDMap)osd;

            m.EnableAlterntiveImage = map["alt_image_enable"].AsBoolean();
            m.AutoLoop = map["auto_loop"].AsBoolean();
            m.AutoPlay = map["auto_play"].AsBoolean();
            m.AutoScale = map["auto_scale"].AsBoolean();
            m.AutoZoom = map["auto_zoom"].AsBoolean();
            m.Controls = (MediaControls)map["controls"].AsInteger();
            m.CurrentURL = map["current_url"].AsString();
            m.InteractOnFirstClick = map["first_click_interact"].AsBoolean();
            m.Height = map["height_pixels"].AsInteger();
            m.HomeURL = map["home_url"].AsString();
            m.ControlPermissions = (MediaPermission)map["perms_control"].AsInteger();
            m.InteractPermissions = (MediaPermission)map["perms_interact"].AsInteger();

            if (map["whitelist"].Type == OSDType.Array)
            {
                OSDArray wl = (OSDArray)map["whitelist"];
                if (wl.Count > 0)
                {
                    m.WhiteList = new string[wl.Count];
                    for (int i = 0; i < wl.Count; i++)
                    {
                        m.WhiteList[i] = wl[i].AsString();
                    }
                }
            }

            m.EnableWhiteList = map["whitelist_enable"].AsBoolean();
            m.Width = map["width_pixels"].AsInteger();

            return m;
        }
Example #15
0
        public void SetMediaEntry(ISceneChildEntity part, int face, MediaEntry me)
        {
            CheckFaceParam(part, face);

            if (null == part.Shape.Media)
            {
                if (me == null)
                    return;
                else
                {
                    part.Shape.Media = new PrimitiveBaseShape.MediaList(new MediaEntry[part.GetNumberOfSides()]);
                }
            }

            if (part.Shape.Media[face] == null) //If it doesn't exist, set the default parameters for it
                me.InteractPermissions = MediaPermission.All;
            lock (part.Shape.Media)
                part.Shape.Media[face] = me;

            UpdateMediaUrl(part, UUID.Zero);

            SetPartMediaFlags(part, face, me != null);

            part.ScheduleUpdate(PrimUpdateFlags.FullUpdate);
            part.TriggerScriptChangedEvent(Changed.MEDIA);
        }
Example #16
0
        /// <summary>
        /// Set the media entry on the face of the given part.
        /// </summary>
        /// <param name="part">/param>
        /// <param name="face"></param>
        /// <param name="me">If null, then the media entry is cleared.</param>
        public void SetMediaEntry(SceneObjectPart part, int face, MediaEntry me)
        {
//            m_log.DebugFormat("[MOAP]: SetMediaEntry for {0}, face {1}", part.Name, face);
            
            CheckFaceParam(part, face);
            
            if (null == part.Shape.Media)
            {
                if (me == null)
                    return;
                else                            
                    part.Shape.Media = new PrimitiveBaseShape.MediaList(new MediaEntry[part.GetNumberOfSides()]);
            }

            lock (part.Shape.Media)
                part.Shape.Media[face] = me;                      
            
            UpdateMediaUrl(part, UUID.Zero);
            
            SetPartMediaFlags(part, face, me != null);
            
            part.ScheduleFullUpdate();
            part.TriggerScriptChangedEvent(Changed.MEDIA);
        }