Skip to main content

Scaling video using HAVi APIs

6 replies [Last post]
snmukkala
Offline
Joined: 2010-06-02
Points: 0

I am trying to use HAVi APIs to scale the video. I create a new HVideoConfigTemplate with my SCREEN_RECTANGLE and tried to get the best HVideoConfiguration. The best video configuration has the full SCREEN resolution instead of my requested rectangle.

Here is the code which i am using

HScreen defaultHScreen = HScreen.getDefaultHScreen();
HVideoDevice defaultVideoDevice = defaultHScreen.getDefaultHVideoDevice();
HVideoConfigTemplate videoConfig = defaultVideoDevice.getCurrentConfiguration().getConfigTemplate();
Dimension dimension;
HScreenRectangle desiredRectangle = new HScreenRectangle(0.5f, 0.0f, 0.5f, 0.5f);
print(" GOING TO SCREEN = " + desiredRectangle.x + "," + desiredRectangle.y + "=>" + desiredRectangle.width + "," + desiredRectangle.height);
TimeUtils.sleepFor(TeTimeDuration.seconds(10));

/* Get the matching configuration for our preferences */
HVideoConfigTemplate newTemplate = new HVideoConfigTemplate();
newTemplate.setPreference(HScreenConfigTemplate.SCREEN_RECTANGLE, desiredRectangle, HScreenConfigTemplate.PREFERRED);
HVideoConfiguration matchedConfiguration = defaultVideoDevice.getBestConfiguration(newTemplate);

if(matchedConfiguration != null) {
HScreenRectangle rectangle = (HScreenRectangle) matchedConfiguration.getConfigTemplate().getPreferenceObject(HScreenConfigTemplate.SCREEN_RECTANGLE);
print(" -- screen Rectangle = " + rectangle.x + "," + rectangle.y + "=>" + rectangle.width + "," + rectangle.height); // here it is 0, 0, 1.0, 1.0 instead of 0.5, 0.0, 0.5, 0.5

try {
defaultVideoDevice.reserveDevice(this);
defaultVideoDevice.setVideoConfiguration(matchedConfiguration);
defaultVideoDevice.releaseDevice();
} catch (HPermissionDeniedException e) {
e.printStackTrace();
} catch (HConfigurationException e) {
e.printStackTrace();
}
}
else {
print("No Matching configuration found");
}

videoConfig = defaultVideoDevice.getCurrentConfiguration().getConfigTemplate();
dimension = (Dimension) videoConfig.getPreferenceObject(HScreenConfigTemplate.PIXEL_RESOLUTION);
print("AFTER SETTING VIDEO CONFIGURATION -- Config pixel resolution = " + dimension.width + "x" + dimension.height);

This is in continuation to issue https://ocap-ri.dev.java.net/issues/show_bug.cgi?id=270

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
sarendt
Offline
Joined: 2009-07-21
Points: 0

All the configurations are full screen, so that's why you get a full screen config in response to your call.

If you want to scale video, instead of looking for a quarter screen configuration, you can use a VideoTransformation set in the service context. Have a look at the DVRExercisor code (RI_Stack/apps/qa/org/cablelabs/xlet/DvrExercisor) for an example. The DVRExercisor scales the video to quarter screen. The VideoTransformation is in the init method of DvrTest.java.

darypola
Offline
Joined: 2010-06-17
Points: 0

Are you saying that this feature is unimplemented on HAVi and there are no plans to implement it in the future?
Is there a list of features defined by the HAVi spec that are supported or planned on the RI so the developers won't have to write a test code each time they want to know if something supported or not?

Thanks!

sarendt
Offline
Joined: 2009-07-21
Points: 0

Let me go off and investigate this -- I'll get back to you

sarendt
Offline
Joined: 2009-07-21
Points: 0

We're discussing this internally right now -- it seems reasonable that the RI should support returning a quarter-screen configuration from getBestConfig, but I am unable to locate anything in the Havi, MHP or OCAP spec that requires it. Can you point me to the appropriate place in the specs to look? Thanks!

sarendt
Offline
Joined: 2009-07-21
Points: 0

After looking into it, it looks like there is a hole in the spec in that this behavior is not specified, so the CableLabs spec team will be looking into adding this. In the meantime, you can use the workaround I mentioned a few posts ago (i.e., have a look at DVRExercisor for another way to get quarter screen).

darypola
Offline
Joined: 2010-06-17
Points: 0

Thanks for the update. We already have the workaround in place.
Just for the reference: what is the spec we should look into to read about the current behavior? There is not much about HAVi support in the main OCAP 1.1.3 spec. Is there a separate document for that?