Ejemplo n.º 1
0
 public override void Activation(MHEngine engine)
 {
     if (m_fRunning)
     {
         return;
     }
     base.Activation(engine);
     // We're supposed to apply Activation to each of the "items" but it isn't clear
     // exactly what that means.  Assume it means each of the visibles.
     for (int i = 0; i < m_TokenGrpItems.Size; i++)
     {
         MHObjectRef pObject = m_TokenGrpItems.GetAt(i).Object;
         // The object reference may be the null reference.
         // Worse: it seems that sometimes in BBC's MHEG the reference simply doesn't exist.
         if (pObject.IsSet())
         {
             try
             {
                 engine.FindObject(m_TokenGrpItems.GetAt(i).Object).Activation(engine);
             } catch (MHEGException) {}
         }
     }
     engine.EventTriggered(this, EventTokenMovedTo, new MHUnion(m_nTokenPosition));
     m_fRunning = true;
     engine.EventTriggered(this, EventIsRunning);
 }
Ejemplo n.º 2
0
 protected void TransferToken(int newPos, MHEngine engine)
 {
     if (newPos != m_nTokenPosition)
     {
         engine.EventTriggered(this, EventTokenMovedFrom, new MHUnion(m_nTokenPosition));
         m_nTokenPosition = newPos;
         engine.EventTriggered(this, EventTokenMovedTo, new MHUnion(m_nTokenPosition));
     }
 }
Ejemplo n.º 3
0
        public override void ContentArrived(byte[] data, MHEngine engine)
        {
            Region updateArea = GetVisibleArea(); // If there's any content already we have to redraw it.

            if (m_pContent == null)
            {
                return;                     // Shouldn't happen.
            }
            int nCHook = m_nContentHook;

            if (nCHook == 0)
            {
                nCHook = engine.GetDefaultBitmapCHook();
            }

            // TODO: What if we can't convert it?
            if (nCHook == 4)
            { // PNG.
                m_pContent.CreateFromPNG(data);
            }
            else if (nCHook == 2)
            { // MPEG I-frame.
                m_pContent.CreateFromMPEG(data);
            }
            else
            {
                throw new MHEGException("Unknown bitmap content hook " + nCHook);
            }

            updateArea.Union(GetVisibleArea()); // Redraw this bitmap.
            engine.Redraw(updateArea);          // Mark for redrawing

            // Now signal that the content is available.
            engine.EventTriggered(this, EventContentAvailable);
        }
Ejemplo n.º 4
0
 public override void ContentArrived(byte[] data, MHEngine engine)
 {
     CreateContent(data, engine);
     // Now signal that the content is available.
     engine.EventTriggered(this, EventContentAvailable);
     m_NeedsRedraw = true;
 }
Ejemplo n.º 5
0
        // Actions implemented
        public override void TestVariable(int nOp, MHUnion parm, MHEngine engine)
        {
            parm.CheckType(MHUnion.U_String);
            int  nRes = m_Value.Compare(parm.String);
            bool fRes = false;

            switch (nOp)
            {
            case TC_Equal: fRes = (nRes == 0); break;

            case TC_NotEqual: fRes = (nRes != 0); break;

/*              case TC_Less: fRes = (m_nValue < parm.Int); break;
 *              case TC_LessOrEqual: fRes = (m_nValue <= parm.Int); break;
 *              case TC_Greater: fRes = (m_nValue > parm.Int); break;
 *              case TC_GreaterOrEqual: fRes = (m_nValue >= parm.Int); break;*/
            default: throw new MHEGException("Invalid comparison for string");     // Shouldn't ever happen
            }
            MHOctetString sample1 = new MHOctetString(m_Value, 0, 10);
            MHOctetString sample2 = new MHOctetString(parm.String, 0, 10);

            Logging.Log(Logging.MHLogDetail, "Comparison " + TestToString(nOp) + " between " + sample1.Printable()
                        + " and " + sample2.Printable() + " => " + (fRes ? "true" : "false"));
            engine.EventTriggered(this, EventTestEvent, new MHUnion(fRes));
        }
Ejemplo n.º 6
0
        // Actions implemented
        public override void TestVariable(int nOp, MHUnion parm, MHEngine engine)
        {
            parm.CheckType(MHUnion.U_Int);
            bool fRes = false;

            switch (nOp)
            {
            case TC_Equal: fRes = (m_nValue == parm.Int); break;

            case TC_NotEqual: fRes = (m_nValue != parm.Int); break;

            case TC_Less: fRes = (m_nValue < parm.Int); break;

            case TC_LessOrEqual: fRes = (m_nValue <= parm.Int); break;

            case TC_Greater: fRes = (m_nValue > parm.Int); break;

            case TC_GreaterOrEqual: fRes = (m_nValue >= parm.Int); break;

            default: throw new MHEGException("Invalid comparison for int");     // Shouldn't ever happen
            }
            Logging.Log(Logging.MHLogDetail, "Comparison " + TestToString(nOp) + " between " + m_nValue
                        + " and " + parm.Int + " => " + (fRes ? "true" : "false"));
            engine.EventTriggered(this, EventTestEvent, new MHUnion(fRes));
        }
Ejemplo n.º 7
0
 // The MHEG corrigendum allows SetData to be targeted to a stream so
 // the content ref could change while the stream is playing.
 // Not currently handled.
 public override void ContentPreparation(MHEngine engine)
 {
     engine.EventTriggered(this, EventContentAvailable); // Perhaps test for the streams being available?
     for (int i = 0; i < m_Multiplex.Size; i++)
     {
         m_Multiplex.GetAt(i).SetStreamRef(m_ContentRef);
     }
 }
Ejemplo n.º 8
0
 public override void Activation(MHEngine engine)
 {
     if (RunningStatus)
     {
         return;
     }
     base.Activation(engine);
     engine.EventTriggered(this, EventIsRunning);
 }
Ejemplo n.º 9
0
        public override void Activation(MHEngine engine)
        {
            if (RunningStatus) return;
            base.Activation(engine);
            m_fRunning = true;
            engine.Redraw(GetVisibleArea()); // Display the visible.
            engine.EventTriggered(this, EventIsRunning);

        }
Ejemplo n.º 10
0
 public override void Deactivation(MHEngine engine)
 {
     if (!RunningStatus)
     {
         return;
     }
     engine.EventTriggered(this, EventTokenMovedFrom, new MHUnion(m_nTokenPosition));
     base.Deactivation(engine);
 }
Ejemplo n.º 11
0
 public override void Activation(MHEngine engine)
 {
     if (m_fRunning)
     {
         return;
     }
     base.Activation(engine);
     m_fRunning = true;
     engine.EventTriggered(this, EventIsRunning);
 }
Ejemplo n.º 12
0
        public void Deselect(int nIndex, MHEngine engine)
        {
            MHListItem pListItem = m_ItemList[nIndex - 1];

            if (pListItem == null || !pListItem.Selected)
            {
                return;                                           // Ignore if not selected.
            }
            pListItem.Selected = false;
            engine.EventTriggered(this, EventItemDeselected, new MHUnion(nIndex));
        }
Ejemplo n.º 13
0
        public override void Perform(MHEngine engine)
        {
            // The target is always the current scene so we ignore it here.
            MHObjectRef target = new MHObjectRef();
            MHObjectRef source = new MHObjectRef();

            m_Target.GetValue(target, engine); // TODO: Check this is the scene?
            m_EventSource.GetValue(source, engine);
            // Generate the event.
            if (m_EventData.Type == MHParameter.P_Null)
            {
                engine.EventTriggered(engine.FindObject(source), m_EventType);
            }
            else
            {
                MHUnion data = new MHUnion();
                data.GetValueFrom(m_EventData, engine);
                engine.EventTriggered(engine.FindObject(source), m_EventType, data);
            }
        }
Ejemplo n.º 14
0
 public override void ContentPreparation(MHEngine engine)
 {
     if (m_ContentType == IN_IncludedContent)
     {
         // Included content is there - generate ContentAvailable.
         engine.EventTriggered(this, EventContentAvailable);
     }
     else if (m_ContentType == IN_ReferencedContent)
     {
         // We are requesting external content
         engine.CancelExternalContentRequest(this);
         engine.RequestExternalContent(this);
     }
 }
Ejemplo n.º 15
0
 public override void Activation(MHEngine engine)
 {
     if (RunningStatus)
     {
         return;
     }
     base.Activation(engine);
     if (m_fRestarting)   // Set by Quit
     {
         engine.AddActions(m_OnRestart);
         engine.RunActions();
     }
     engine.EventTriggered(this, EventIsRunning);
 }
Ejemplo n.º 16
0
        // Actions implemented
        public override void TestVariable(int nOp, MHUnion parm, MHEngine engine)
        {
            parm.CheckType(MHUnion.U_ContentRef);
            bool fRes = false;

            switch (nOp)
            {
            case TC_Equal: fRes = m_Value.Equal(parm.ContentRef, engine); break;

            case TC_NotEqual: fRes = !m_Value.Equal(parm.ContentRef, engine); break;

            default: throw new MHEGException("Invalid comparison for Content ref");
            }
            engine.EventTriggered(this, EventTestEvent, new MHUnion(fRes));
        }
Ejemplo n.º 17
0
 public override void Activation(MHEngine engine)
 {
     if (m_fRunning)
     {
         return;
     }
     base.Activation(engine);
     // Start playing all active stream components.
     for (int i = 0; i < m_Multiplex.Size; i++)
     {
         m_Multiplex.GetAt(i).BeginPlaying(engine);
     }
     m_fRunning = true;
     engine.EventTriggered(this, EventIsRunning);
 }
Ejemplo n.º 18
0
        public override void TestVariable(int nOp, MHUnion parm, MHEngine engine)
        {
            parm.CheckType(MHUnion.U_Bool);
            bool fRes = false;

            switch (nOp)
            {
            case TC_Equal: fRes = m_fValue == parm.Bool; break;

            case TC_NotEqual: fRes = m_fValue != parm.Bool; break;

            default: throw new MHEGException("Invalid comparison for bool");
            }
            Logging.Log(Logging.MHLogDetail, "Comparison " + TestToString(nOp) + " between " + (m_fValue ? "true" : "false")
                        + " and " + (parm.Bool ? "true" : "false") + " => " + (fRes ? "true" : "false"));
            engine.EventTriggered(this, EventTestEvent, new MHUnion(fRes));
        }
Ejemplo n.º 19
0
        public void Select(int nIndex, MHEngine engine)
        {
            MHListItem pListItem = m_ItemList[nIndex - 1];

            if (pListItem == null || pListItem.Selected)
            {
                return;                                          // Ignore if already selected.
            }
            if (!m_fMultipleSelection)
            {
                // Deselect any existing selections.
                for (int i = 0; i < (int)m_ItemList.Count; i++)
                {
                    if (m_ItemList[i].Selected)
                    {
                        Deselect(i + 1, engine);
                    }
                }
            }
            pListItem.Selected = true;
            engine.EventTriggered(this, EventItemSelected, new MHUnion(nIndex));
        }
Ejemplo n.º 20
0
        // Activation for Audio is defined in the corrigendum
        public override void Activation(MHEngine engine)
        {
            if (m_fRunning)
            {
                return;
            }
            base.Activation(engine);
            // Beginning presentation is started by the Stream object.
            m_fRunning = true;
            engine.EventTriggered(this, EventIsRunning);

            if (m_fStreamPlaying && m_streamContentRef.IsSet())
            {
                string        stream = "";
                MHOctetString str    = m_streamContentRef.ContentRef;
                if (str.Size != 0)
                {
                    stream = str.ToString();
                }
                engine.GetContext().BeginAudio(stream, m_nComponentTag);
            }
        }
Ejemplo n.º 21
0
        // Checks the timers and fires any relevant events.  Returns the millisecs to the
        // next event or zero if there aren't any.
        public int CheckTimers(MHEngine engine)
        {
            TimeSpan currentTime = MHTimer.getCurrentTimeSpan(); // Get current time
            int      nMSecs      = 0;

            List <MHTimer> executedTimers = new List <MHTimer>();

            for (int i = 0; i < m_Timers.Count; i++)
            {
                MHTimer timer = m_Timers[i];

                // Use <= rather than < here so we fire timers with zero time immediately.
                if (timer.PositionTimeSpan <= currentTime)
                {
                    // If the time has passed trigger the event and remove the timer from the queue.
                    engine.EventTriggered(this, EventTimerFired, new MHUnion(timer.Identifier));
                    executedTimers.Add(timer); // Add to list of executed timers which are removed later
                }
                else
                {
                    // This has not yet expired.  Set "nMSecs" to the earliest time we have.
                    int nMSecsToGo = timer.PositionTimeSpan.Subtract(currentTime).Milliseconds;
                    if (nMSecs == 0 || nMSecsToGo < nMSecs)
                    {
                        nMSecs = nMSecsToGo;
                    }
                }
            }

            // Remove all executed timers
            for (int i = 0; i < executedTimers.Count; i++)
            {
                MHTimer timer = executedTimers[i];
                m_Timers.Remove(timer);
            }

            return(nMSecs);
        }
Ejemplo n.º 22
0
 public void Update(MHEngine engine)
 {
     if (m_ItemList.Count == 0)
     { // Special cases when the list becomes empty
         if (m_fFirstItemDisplayed)
         {
             m_fFirstItemDisplayed = false;
             engine.EventTriggered(this, EventFirstItemPresented, new MHUnion(false));
         }
         if (m_fLastItemDisplayed)
         {
             m_fLastItemDisplayed = false;
             engine.EventTriggered(this, EventLastItemPresented, new MHUnion(false));
         }
     }
     else
     { // Usual case.
         int i = -1;
         foreach (MHListItem p in m_ItemList)
         {
             i++;
             MHRoot pVis  = p.Visible;
             int    nCell = i + 1 - m_nFirstItem; // Which cell does this item map onto?
             if (nCell >= 0 && nCell < m_Positions.Size)
             {
                 if (i == 0 && !m_fFirstItemDisplayed)
                 {
                     m_fFirstItemDisplayed = true;
                     engine.EventTriggered(this, EventFirstItemPresented, new MHUnion(true));
                 }
                 if (i == (int)m_ItemList.Count - 1 && !m_fLastItemDisplayed)
                 {
                     m_fLastItemDisplayed = true;
                     engine.EventTriggered(this, EventLastItemPresented, new MHUnion(true));
                 }
                 pVis.SetPosition(m_Positions.GetAt(i - m_nFirstItem + 1).X, m_Positions.GetAt(i - m_nFirstItem + 1).Y, engine);
                 if (!pVis.RunningStatus)
                 {
                     pVis.Activation(engine);
                 }
             }
             else
             {
                 if (i == 0 && m_fFirstItemDisplayed)
                 {
                     m_fFirstItemDisplayed = false;
                     engine.EventTriggered(this, EventFirstItemPresented, new MHUnion(false));
                 }
                 if (i == (int)m_ItemList.Count - 1 && m_fLastItemDisplayed)
                 {
                     m_fLastItemDisplayed = false;
                     engine.EventTriggered(this, EventLastItemPresented, new MHUnion(false));
                 }
                 if (pVis.RunningStatus)
                 {
                     pVis.Deactivation(engine); pVis.ResetPosition();
                 }
             }
         }
     }
     // Generate the HeadItems and TailItems events.  Even in the MHEG corrigendum this is unclear.
     // I'm not at all sure this is right.
     if (m_nLastFirstItem != m_nFirstItem)
     {
         engine.EventTriggered(this, EventHeadItems, new MHUnion(m_nFirstItem));
     }
     if (m_nLastCount - m_nLastFirstItem != (int)m_ItemList.Count - m_nFirstItem)
     {
         engine.EventTriggered(this, EventTailItems, new MHUnion(m_ItemList.Count - m_nFirstItem));
     }
     m_nLastCount     = m_ItemList.Count;
     m_nLastFirstItem = m_nFirstItem;
 }
Ejemplo n.º 23
0
        public override void CallProgram(bool fIsFork, MHObjectRef success, MHSequence <MHParameter> args, MHEngine engine)
        {
            if (!m_fAvailable)
            {
                Preparation(engine);
            }
            if (m_fRunning)
            {
                return;             // Strictly speaking there should be only one instance of a program running at a time.
            }
            Activation(engine);
            Logging.Log(Logging.MHLogDetail, "Calling program " + m_Name.Printable());
            try
            {
                // Run the code.
                if (m_Name.ToString().Equals("GCD"))
                {
                    // GetCurrentDate - returns local time.
                    GetCurrentDate(success, args, engine);
                }
                else if (m_Name.ToString().Equals("FDa"))
                {
                    // FormatDate
                    FormatDate(success, args, engine);
                }
                else if (m_Name.ToString().Equals("GDW"))
                {
                    // GetDayOfWeek - returns the day of week that the date occurred on.
                    GetDayOfWeek(success, args, engine);
                }

                else if (m_Name.ToString().Equals("Rnd"))
                {
                    // Random
                    Random(success, args, engine);
                }

                else if (m_Name.ToString().Equals("CTC"))
                {
                    // CastToContentRef
                    CastToContentRef(success, args, engine);
                }

                else if (m_Name.ToString().Equals("CTO"))
                {
                    // CastToObjectRef
                    CastToObjectRef(success, args, engine);
                }

                else if (m_Name.ToString().Equals("GSL"))
                {
                    // GetStringLength
                    GetStringLength(success, args, engine);
                }

                else if (m_Name.ToString().Equals("GSS"))
                {
                    // GetSubString
                    GetSubString(success, args, engine);
                }

                else if (m_Name.ToString().Equals("SSS"))
                {
                    // SearchSubString
                    SearchSubString(success, args, engine);
                }

                else if (m_Name.ToString().Equals("SES"))
                {
                    // SearchAndExtractSubString
                    SearchAndExtractSubString(success, args, engine);
                }

                else if (m_Name.ToString().Equals("GSI"))
                {
                    // SI_GetServiceIndex
                    SI_GetServiceIndex(success, args, engine);
                }

                else if (m_Name.ToString().Equals("TIn"))
                {
                    // SI_TuneIndex - Fork not allowed
                    SI_TuneIndex(success, args, engine);
                }
                else if (m_Name.ToString().Equals("TII"))
                {
                    // SI_TuneIndexInfo
                    SI_TuneIndexInfo(success, args, engine);
                }
                else if (m_Name.ToString().Equals("BSI"))
                {
                    // SI_GetBasicSI
                    SI_GetBasicSI(success, args, engine);
                }
                else if (m_Name.ToString().Equals("GBI"))
                {
                    // GetBootInfo
                    GetBootInfo(success, args, engine);
                }
                else if (m_Name.ToString().Equals("CCR"))
                {
                    // CheckContentRef
                    CheckContentRef(success, args, engine);
                }
                else if (m_Name.ToString().Equals("CGR"))
                {
                    // CheckGroupIDRef
                    CheckGroupIDRef(success, args, engine);
                }
                else if (m_Name.ToString().Equals("VTG"))
                {
                    // VideoToGraphics
                    VideoToGraphics(success, args, engine);
                }
                else if (m_Name.ToString().Equals("SWA"))
                {
                    // SetWidescreenAlignment
                    SetWidescreenAlignment(success, args, engine);
                }
                else if (m_Name.ToString().Equals("GDA"))
                {
                    // GetDisplayAspectRatio
                    GetDisplayAspectRatio(success, args, engine);
                }
                else if (m_Name.ToString().Equals("CIS"))
                {
                    // CI_SendMessage
                    CI_SendMessage(success, args, engine);
                }
                else if (m_Name.ToString().Equals("SSM"))
                {
                    // SetSubtitleMode
                    SetSubtitleMode(success, args, engine);
                }

                else if (m_Name.ToString().Equals("WAI"))
                {
                    // WhoAmI
                    WhoAmI(success, args, engine);
                }

                else if (m_Name.ToString().Equals("DBG"))
                {
                    // Debug - optional
                    Debug(success, args, engine);
                }
                else
                {
                    Logging.Assert(false);
                }
            }
            catch (MHEGException)
            {
                // If something went wrong set the succeeded flag to false
                SetSuccessFlag(success, false, engine);
                // And continue on.  In particular we need to deactivate.
            }
            Deactivation(engine);
            // At the moment we always treat Fork as Call.  If we do get a Fork we should signal that we're done.
            if (fIsFork)
            {
                engine.EventTriggered(this, EventAsyncStopped);
            }
        }
Ejemplo n.º 24
0
 public override void ContentPreparation(MHEngine engine)
 {
     // Pretend it's available.
     engine.EventTriggered(this, EventContentAvailable);
 }