Overview of the TV Ratings System
This topic applies to Windows XP Service Pack 1 only.
The Microsoft TV Ratings system provides a way for DirectShow programmers to access content ratings from a broadcast stream and use them to make decisions about whether or not to display the content. These ratings are mandatory on all US broadcast streams, and are contained in the extended data services (XDS) channel of line 21.
Microsoft provides the following filters for this system:
- XDS Codec filter
- Encrypter/Tagger filter
- Decrypter/Detagger filter
These filters host two objects that are provided by third-party developers:
- The XDSToRat (Ratings Decoder) object is hosted by the XDS Codec filter.
- The EvalRat (Ratings Evaluator) object is hosted by the Encrypter/Tagger filter and the Decrypter/Detagger filter.
The XDSToRat and EvalRat objects are both standard COM objects. The XDSToRat object exposes the IXDSToRat interface, and the EvalRat object exposes the IEvalRat interface.
Briefly, the TV Ratings system works as follows:
- The XDS Codec filter receives XDS data from the CC Decoder filter or some other source. It passes this data to the XDSToRat object, which is responsible for parsing the data into content ratings. The XDSToRat object returns the decoded ratings to the XDS Codec filter, which makes them available to the Encrypter/Tagger filter.
- The Encrypter/Tagger filter encrypts the media samples that it receives. It also tags the samples with ratings information, taken from the XDS Codec filter.
- The Decrypter/Detagger filter takes the ratings from the encrypted samples and passes them to the EvalRat object. The EvalRat object determines whether the content is allowed, based on the rating and the current permissions. If so, the Decrypter/Detagger filter decrypts the samples and passes them downstream for rendering. Otherwise, it blocks playback. The application sets permissions through an interface on the Decrypter/Detagger filter.
This architecture enables an application to create separate graphs for tuning and rendering, which is required when using the stream buffer engine. The tuning graph will contain the XDS Codec filter and the Encrypter/Tagger filter. The rendering graph will contain the Decrypter/Detagger filter.
Here is how the system works in more detail:
- The XDS Codec filter calls IXDSToRat::Init on the XDSToRat object, which sets the object to its initial state.
- The application uses the IDTFilter::put_BlockedRatingAttributes method on the Decrypter/Detagger filter to specify which ratings are permitted and which should be blocked. The Decrypter/Detagger filter passes this information to the EvalRat object. (For details, see Setting Allowable Viewing Levels.) This step can occur at any time.
- When the filter graph is running, the XDS Codec filter receives XDS packets from the line 21 stream. The XDS Codec filter sends the packets to the XDSRat object for parsing, two bytes at a time, by calling the IXDSToRat::ParseXDSBytePair method.
- If the XDSToRat object decodes a new rating, it returns this information and returns S_OK from the ParseXDSBytePair method. The XDS Codec stores the new rating and broadcasts a "new rating" event (EVENTID_XDSCodecNewXDSRating) to the entire filter graph, through the IBroadcastEvent interface.
- The Encrypter/Tagger filter listens for new rating events. Whenever it receives one, it gets the new rating from the XDS Codec filter. It uses this rating to tag the samples that it encrypts.
- The Decrypter/Detagger filter looks for ratings on the encrypted media samples. Whenever it finds a new rating, it broadcasts a "rating change" event (EVENTID_DTFilterRatingChange).
- The Decrypter/Detagger filter tests any new rating by calling IEvalRat::TestRating on the EvalRat object. If that rating is not allowed (by the permissions given in step 2), the Decrypter/Detagger filter blocks the stream and discards all samples, until the rating changes again.
- Whenever the Decrypter/Detagger filter blocks the stream, it broadcasts a "ratings block" event (EVENTID_DTFilterRatingsBlock). Whenever it unblocks the stream, it broadcasts a "ratings unblock" event (EVENTID_DTFilterRatingsUnBlock).
- If there is a discontinuity in the stream, such as a channel change, the XDS Codec filter calls IXDSToRat::Init again to reset the XDSToRat object. It also sets the current rating to "DontKnow" and broadcasts a "new rating" event (EVENTID_XDSCodecNewXDSRating).
The only actions the hosting application needs to take are:
- Setting the viewing permissions.
- Retrieving the current permissions.
- Displaying the current permissions to the user.
- Signaling to the user when the stream is blocked or unblocked.