Implementing a Guide Store Loader Using the TIF (C++)
This topic applies to Windows XP Home Edition and Windows XP Professional only.
This topic describes a typical implementation of a Guide Store Loader that obtains its data from the BDA MPEG-2 Transport Information Filter (TIF).
The loader object implements the following interfaces:
- IGuideDataLoader. Methods of this interface are called by the application to connect and disconnect the TIF and the loader. The loader can also perform other necessary initialization in the IGuideDataLoader::Init method.
- IGuideDataEvent. Methods of this interface are called by the TIF to respond to changes in data.
The loader also creates a GuideStore object for writing data to the repository.
An application can use the loader with the TIF by taking the following steps:
- Load the video control.
- Create the loader object and pass it a pointer to the IMSVidCtl interface. If your application is written in Visual Basic, the loader will require an automation-compatible interface to receive the MSVidCtl object.
- The loader uses the IMSVidCtl interface to obtain IMSVidGraphSegmentContainer using QueryInterface and calls the get_Graph method to obtain a pointer to the filter graph. Enumerate the filters in the usual way (see Enumerating Devices and Filters) and call QueryInterface using each returned IBaseFilter pointer until you find the one that supports IGuideData.
- Obtain the IGuideDataLoader interface.
- Initialize the loader by calling IGuideDataLoader::Init, passing in a pointer to the IGuideData interface.
The TIF now sends events to the loader when data changes occur, and the loader responds in its implementation of the IGuideDataEvent interface by updating the Guide Store database. To obtain current data, the loader uses the methods of the IGuideData interface it obtained during initialization.
For example, when new schedule entries are reported by the TIF, the loader's IGuideDataEvent::ScheduleEntryChanged method is called. The loader might then take the following steps:
- Call IGuideData::GetScheduleEntryIDs to retrieve a collection of all schedule entry identifiers. This collection supports the COM IEnumVARIANT interface for enumeration.
- For each schedule entry in the collection, call IGuideData::GetScheduleEntryProperties to retrieve the IEnumGuideDataProperties interface of a collection of metaproperties for that entry.
- Iterate through the collection of metaproperties to find the value of the "Description.ID" metaproperty.
- Call IScheduleEntries::get_ItemWithKey to find an object in the Guide Store repository that has a matching "Description.ID" metaproperty value. (This method is called on an ordered ScheduleEntries collection previously obtained by using IScheduleEntries::get_ItemsByKey, where the key was the "Description.ID" metaproperty type.)
- If a matching ScheduleEntry object exists, update its properties; if it does not, create it.