Microsoft DirectX 9.0 |
DVD discs, especially karaoke discs, might contain a database of text information to supplement the video or audio content. Such text on karaoke discs might include song titles, artist names, record labels, and so on. Versions of this text can be present in more than one language. These strings are optional; discs are not required to have them. If present they are organized in a way that closely mirrors the logical hierarchy of the DVD volume. Each string is preceded by a number that identifies what part of the disc structure it belongs to or gives some clue as to the content of the string.
There are two basic types of text strings: structure identifiers and content strings. Types with a value of 0x01 through 0x20 are structure identifiers. They are empty strings; the numerical code is used to identify the logical structure to which any following content strings belong. This structure corresponds very closely to the logical structure of a DVD disc contents: volume, title, chapter, and so on. The remaining types identify content strings that hold information that may be displayed to the viewer in a user interface. The exact way in which content strings are used is not closely defined, so DVD authors might use them in various ways.
Historically, DVD text strings have been used almost exclusively on karaoke discs, and these discs mostly use the 0x01 and 0x02 structure identifiers and the 0x30 type content string. But it is reasonable to assume that as time goes by, (1) more types of DVD-Video discs will contain text strings and (2) these strings will be organized in more complex ways in order to provide fuller descriptions of disc contents.
The following code shows how to determine the number of text string language blocks on the disc, and retrieve the human-readable string(s) that could be shown to the user to allow them to choose the language they are interested in. In this code the strings are added to an HTML SELECT element called "TextLanguageList." For more information on LCIDs and primary language IDs, see GetLangFromLangID
function GetTextLanguages()
{
//get the number of text blocks
var numLangs = DVD.GetDVDTextNumberOfLanguages();
var iLCID;
var iPrimaryLang;
var sLanguage;
var oOption;
for (j = 0; j < numLangs; j++)
{
//get the locale identifier for the language block
iLCID = DVD.GetDVDTextLanguageLCID(j);
//get the primary language ID from the LCID
iPrimaryLang = iLCID & 0x3FF;
//get the human-readable string from the primary language ID
sLanguage = DVD.GetLangFromLangID(iPrimaryLang);
//add it to the SELECT element on the HTML page
oOption = document.createElement("OPTION");
oOption.text = sLanguage;
document.all.TextLanguageList.add(oOption);
}
} //end function GetTextStrings
The following test code demonstrates how to enumerate the strings and examine the text string type. It just dumps the results into an HTML TEXTAREA element called "myTextArea" so you can see how the numeric string types are used to organize the content strings. A real application would probably create its own data structure to hold the strings, or else would display them in a more useful way for the viewer.
// iLanguage is the 0-based index for the language block
function GetTextStrings(iLanguage)
{
var numStrings, stringType, j;
numStrings = DVD.GetDVDTextNumberOfStrings(iLanguage);
for( j = 0; j < numStrings; j++)
{
stringType = DVD.GetDVDTextStringType(iLanguage, j);
if(stringType > 0x20) //there is actually some text to read here
{
myTextArea.value += (stringType + ": " + DVD.GetDVDTextString(iLanguage, j) + "\n");
}
else // It's a node indicating what level of the volume structure
// the following strings will apply to
{
myTextArea.value += (stringType + "\n");
}
}
} //end function GetTextStrings
This table lists a subset of the DVD text string types. All types with a value 0x20 and below are empty strings that merely indicate the node level in the disc's content data structure. The other strings are content strings. Most title and song names are type 0x30. The types in the Title, SubTitle and Original categories help to further identify the particular genre. The exact meaning and intended use of these categories is defined in a public document that can be downloaded from the DVD Forum's Web site.
Structure Identifiers
Volume | 0x01 | Indicates that the strings that follow pertain to the DVD volume. |
Title | 0x02 | Indicates that the strings that follow pertain to a title. |
ParentalID | 0x03 | Indicates that the strings that follow pertain to a particular parental ID. |
Chapter | 0x04 | Indicates that the strings that follow pertain to a chapter. |
Cell | 0x05 | Indicates that the strings that follow pertain to a cell (typically consisting of one scene from a movie). |
Stream Identifiers
Audio | 0x10 | Indicates that the strings that follow pertain to an audio stream. |
Subpicture | 0x11 | Indicates that the strings that follow pertain to a subpicture stream. |
Angle | 0x12 | Indicates that the strings that follow pertain to an angle block. |
Audio Channel Identifiers
Channel | 0x20 | Indicates that the strings that follow pertain to one channel in an audio stream. |
General Content Strings
Name | 0x30 | The most common identifer for title names, chapter names, song names, and so on |
Comments | 0x31 | General comments about the title, chapter, song, and so on |
Title Content Strings
Series | 0x38 | Additional information about the title, chapter, song, and so on |
Movie | 0x39 | Additional information about the title or chapter if this is a movie. |
Video | 0x3a | Additional information about the title or chapter if this is a video. |
Album | 0x3b | Additional information about the title or chapter if this is an album. |
Song | 0x3c | Additional information about the title or chapter if this is a song. |
Other | 0x3f | Additional information about the title or chapter if this belongs to some other genre or category. |
Secondary Title Content Strings
Series | 0x40 | Additional information about the title, chapter, song, and so on |
Movie | 0x41 | Additional information about the title or chapter if this is a movie. |
Video | 0x42 | Additional information about the title or chapter if this is a video. |
Album | 0x43 | Additional information about the title or chapter if this is an album. |
Song | 0x44 | Additional information about the title or chapter if this is a song. |
Other | 0x45 | Additional information about the title or chapter if this is this belongs to some other genre or category. |
Original Content Strings
Series | 0x48 | Additional information about the title, chapter, song, and so on |
Movie | 0x49 | Additional information about the title or chapter if this is a movie. |
Video | 0x4a | Additional information about the title or chapter if this is a video. |
Album | 0x4b | Additional information about the title or chapter if this is an album. |
Song | 0x4c | Additional information about the title or chapter if this is a song. |
Other | 0x4f | Additional information about the title or chapter if this is this belongs to some other genre or category. |
Other Info Content Strings
Other Scene | 0x50 | Additional information about an alternate scene in a movie title or chapter. |
Other Cut | 0x51 | Additional information about an alternate cut in a movie title or chapter. |
Other Take | 0x52 | Additional information about an alternate take in a movie title or chapter. |