The second method of event detection is for the stream handler to monitor the time, independent of the PDD. This method is less accurate and not as efficient as requesting the PDD to monitor the time. It involves implementing an algorithm that constantly monitors real-time. When the stream handler detects the appropriate time, it reports the event to the Sync/Stream Manager as shown in the following example.
RC SHDReportEvent(PSHD_REPORTEVENT pRptEvent) { PSTREAM pSTREAM; ulRC rc; if (rc = GetStreamEntry(&pSTREAM, pRptEvent->hStream)) return(rc); pSTREAM->ulStreamTime = pRptEvent->ulStreamTime; /* Update stream time */ /******************************************************************/ /* Stream handler detected event and notified the SSM. */ /******************************************************************/ while (pEVENT != NULL) { /* process all possible events */ if (pEVENT->hEvent == pRptEvent->hEvent) { /*********************************************/ /* Poll the current time to determine if the */ /* event time is now. */ /*********************************************/ if (mmtimeCurrTime >= pTimeEvcb->mmtimeStream) { pTimeEvcb->mmtimeStream = mmtimeCurrTime; RptEvent.ulFunction = SMH_REPORTEVENT; RptEvent.hid = pSTREAM->hid; RptEvent.hevent = pEVENT->hEvent; RptEvent.pevcbEvent = &(pEVENT->evcb); /******************************************/ /* Call the Sync/Stream Manager to report */ /* event arrival. */ /******************************************/ VideoSH.pSMHEntryPoint(&RptEvent); /* report it */ } pEVENT = pEVENT->pNext; } /* end while */ return(NO_ERROR); }
Note that when you develop a stream handler, the stream handler should be able to support all time formats.
Note: Most physical device drivers use milliseconds as their reference; however, cuepoints initiated by the application come in as a request to the stream handler in the time format, MMTIME. Therefore, the stream handler must be able to convert from MMTIME to milliseconds and vice versa.