Example: Display Info

The Video Output Service provides configuration functionality for the video outputs available on the IP-STB. The IP-STB can have zero or more HD outputs, and zero or more SD outputs. Typical outputs are HDMI, Component Video, and SCART.

This example retrieves information from the display connected to a video output. The Video Output Service also allows the setting and examining of output configurations (resolutions), but this is addressed in the next example.

First, check the number of video outputs. Different IP-STBs have different capabilities:

vs = toi.videoOutputService;
voconfig = vs.getVideoConfiguration();
numOutputs = voconfig.getVideoOutputs().length;

By pressing a number key on the remote control, you can choose the video output to query. The chosen output getDisplayInfo() function returns a structure containing information about the display attached to that video output.

displayInfo = voconfig.getDisplayInfo(currentVideoOutput);

Video modes

The displayInfo structure contains an array of supported video modes (the EDID received from the device, when available, or a list of modes chosen to override the native ones...) The example displays these on the TV screen with the following code.

First, an old list may be displayed, so it is removed. All child elements to the "supportedModes" DOM element are removed:

// remove any previous mode strings
while (element.childNodes.length > 0 ) {
  element.removeChild(element.firstChild);
}

Next, the video configuration has its getDisplayInfo() function called, and the video output whose display we are interested in is passed as an argument. Finally, for each element in the supportedVideoModes array, a tspan element is created and added to the "supportedModes" element. As each supported video mode definition is a number, it is coverted to a string with the res2string() function. See the documentation for ToiVideoOutputConfiguration to see these deifnitions.

// ask the chosen video output for displayInfo. The returned struct holds
// info on the attached display
var displayInfo = voconfig.getDisplayInfo(currentVideoOutput);
for (var i=0; i<displayInfo.supportedVideoModes.length; i++) {
  var t = document.createElement("tspan");
  t.setAttribute("x","0");
  t.setAttribute("dy", "16");
  t.textContent = res2string(displayInfo.supportedVideoModes[i]);
  element.appendChild(t);
}

The rest of the displayInfo struct is shown in a similar manner.