Redigera

Dela via


To Support Multiple Languages

[The feature associated with this page, Windows Media Format 11 SDK, is a legacy feature. It has been superseded by Source Reader and Sink Writer. Source Reader and Sink Writer have been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use Source Reader and Sink Writer instead of Windows Media Format 11 SDK, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]

You can support multiple languages both in streams and in metadata. The core of multiple language support in the Windows Media Format SDK is the IWMLanguageList interface, which maintains a list of the languages supported. The language list gives each supported language an index, which is used in various objects in the SDK when dealing with the multiple languages.

The IWMLanguageList::AddLanguageByRFC1766String method adds a language to the list. You can identify the languages already in the list by obtaining the total number of languages with IWMLanguageList::GetLanguageCount and then looping through the languages calling IWMLanguageList::GetLanguageDetails for each. The language index is zero based.

To Configure Mutual Exclusion by Language

Configuring a simple mutual exclusion object by language is very simple. Each stream is now associated with a language. The language associated with a stream can be set using IWMStreamConfig3::SetLanguage. After all of the mutually exclusive streams are configured, simply create a mutual exclusion object as you would for any other type. Then call IWMMutualExclusion::SetType passing CLSID_WMMUTEX_Language for the type.

Streams that are mutually exclusive by language become more complicated when the exclusive streams are also mutually exclusive by bit rate. In this case you must use mutually exclusive records, by performing the following steps:

  1. Create a mutual exclusion object for the streams of differing bit rates in each language. For more information about creating a mutual exclusion object by bit rate, see Using Multiple Bit Rate Mutual Exclusion.
  2. Create a mutual exclusion object. Call IWMMutualExclusion::SetType and pass CLSID_WMMUTEX_Language to specify exclusivity by language.
  3. Obtain a pointer to the IWMMutualExclusion2 interface of the mutual exclusion object created in step 2 by calling the QueryInterface method of IWMMutualExclusion.
  4. Call the IWMMutualExclusion2::AddRecord method once for each language, to create stream records that will be mutually exclusive.
  5. For each record created in step 4, add the streams of the appropriate language with calls to IWMMutualExclusion2::AddStreamForRecord.

To Read Files with Multiple Languages

The reader object provides methods to identify the available languages of streams in a file. You can retrieve the number of supported languages for an output by calling IWMReaderAdvanced4::GetLanguageCount. You can then retrieve details about each language with calls to IWMReaderAdvanced4::GetLanguage.

You can specify the language to play by passing the index of that language to the reader with a call to IWMReaderAdvanced2::SetOutputSetting. This will select the specified language while maintaining automatic stream selection for any other mutual exclusion objects in the file.

Advanced Topics

IWMLanguageList Interface

IWMMutualExclusion Interface

IWMMutualExclusion2 Interface

IWMReaderAdvanced2 Interface

IWMReaderAdvanced4 Interface

IWMStreamConfig3 Interface