Skip to content

Commit

Permalink
Adds support to non-fixed camera resolutions
Browse files Browse the repository at this point in the history
  • Loading branch information
César Coelho committed Nov 4, 2022
1 parent 227289f commit 552c247
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ public interface CameraAdapterInterface {
*/
boolean isUnitAvailable();

/**
* @return true if the camera has only a fixed set of resolutions. They can
* then be retrieved with the getAvailableResolutions() method.
*/
boolean hasFixedResolutions();

/**
* @return The resolutions supported by the Camera Adapter
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public class CameraProviderServiceImpl extends CameraInheritanceSkeleton {
public synchronized void init(COMServicesProvider comServices,
CameraAdapterInterface adapter) throws MALException {
long timestamp = System.currentTimeMillis();

if (!initialiased) {
if (MALContextFactory.lookupArea(MALHelper.MAL_AREA_NAME, MALHelper.MAL_AREA_VERSION) == null) {
MALHelper.init(MALContextFactory.getElementFactoryRegistry());
Expand Down Expand Up @@ -216,20 +216,23 @@ private void isCapturePossible(final CameraSettings settings) throws MALInteract
PlatformHelper.DEVICE_IN_USE_ERROR_NUMBER, null));
}
final PixelResolutionList availableResolutions = adapter.getAvailableResolutions();
boolean isResolutionAvailable = false;

// Do we have the resolution requested?
for (PixelResolution availableResolution : availableResolutions) {
if (settings.getResolution().equals(availableResolution)) {
isResolutionAvailable = true;
break;
if (adapter.hasFixedResolutions()) {
boolean isResolutionAvailable = false;

// Do we have the resolution requested?
for (PixelResolution availableResolution : availableResolutions) {
if (settings.getResolution().equals(availableResolution)) {
isResolutionAvailable = true;
break;
}
}
}

// If not, then send the available resolutions to the consumer so they can pick...
if (!isResolutionAvailable) {
throw new MALInteractionException(new MALStandardError(
COMHelper.INVALID_ERROR_NUMBER, availableResolutions));
// If not, then send the available resolutions to the consumer so they can pick...
if (!isResolutionAvailable) {
throw new MALInteractionException(new MALStandardError(
COMHelper.INVALID_ERROR_NUMBER, availableResolutions));
}
}

boolean isFormatsAvailable = false;
Expand Down Expand Up @@ -360,7 +363,7 @@ public GetPropertiesResponse getProperties(MALInteraction interaction) throws
}

@Override
public void preprocessPicture(Picture inputPicture, CameraSettings settings,
public void preprocessPicture(Picture inputPicture, CameraSettings settings,
PreprocessPictureInteraction interaction) throws MALInteractionException, MALException {
throw new UnsupportedOperationException("Not supported yet.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,9 @@ public boolean isUnitAvailable()
return pcAdapter.isDeviceEnabled(DeviceType.CAMERA);
}

@Override
public boolean hasFixedResolutions()
{
return true;
}
}

0 comments on commit 552c247

Please sign in to comment.