Table of Contents

Actions and Commands

A new EosCamera() call result in the following statements:

addPropertyMapping(Camera.Property.ShutterSpeed, PtpConstants.Property.EosShutterSpeed);
addPropertyMapping(Camera.Property.ApertureValue, PtpConstants.Property.EosApertureValue);
addPropertyMapping(Camera.Property.IsoSpeed, PtpConstants.Property.EosIsoSpeed);
addPropertyMapping(Camera.Property.Whitebalance, PtpConstants.Property.EosWhitebalance);
addPropertyMapping(Camera.Property.ShootingMode, PtpConstants.Property.EosShootingMode);
addPropertyMapping(Camera.Property.AvailableShots, PtpConstants.Property.EosAvailableShots);
addPropertyMapping(Camera.Property.ColorTemperature, PtpConstants.Property.EosColorTemperature);
addPropertyMapping(Camera.Property.FocusMode, PtpConstants.Property.EosAfMode);
addPropertyMapping(Camera.Property.PictureStyle, PtpConstants.Property.EosPictureStyle);
addPropertyMapping(Camera.Property.ExposureMeteringMode, PtpConstants.Property.EosMeteringMode);
addPropertyMapping(Camera.Property.ExposureCompensation, PtpConstants.Property.EosExposureCompensation);

Here, we see the camera getting initialized with settings from the App. But how?

As an example, let's analyze how a captured photo is fetched from the camera to the App. It starts in a Fragment (or Activity). For example:

public class PictureFragment extends SessionFragment implements Camera.RetrieveImageListener, GestureHandler

In the Fragment's onStart()we see an image being retrieved:

camera().retrieveImage(this, objectHandle);

where objectHandle is an integer which points to the imagefile on the camera. Inside the Fragment/Activity, it is still transparent which camera is being called. Of course, this is nailed down by the camera() call, which will return either an EosCamera or a NikonCamera. Both extend from the PtpCamera() class, where we find:

    public void retrieveImage(RetrieveImageListener listener, int objectHandle) {
        queue.add(new RetrieveImageAction(this, listener, objectHandle, pictureSampleSize));

RetrieveImageListener is an interface:

    public interface RetrieveImageListener {
        void onImageRetrieved(int objectHandle, Bitmap image);

The RetrieveImageAction() class has

    public void exec(IO io) {

        GetObjectCommand getObject = new GetObjectCommand(camera, objectHandle, sampleSize);

        if (getObject.getResponseCode() != Response.Ok || getObject.getBitmap() == null) {
            listener.onImageRetrieved(0, null);

        listener.onImageRetrieved(objectHandle, getObject.getBitmap());


Taking a closer look at the GetObjectCommand() class, we see a constructor:

public GetObjectCommand(PtpCamera camera, int objectHandle, int sampleSize) {
        this.objectHandle = objectHandle;
        options = new BitmapFactory.Options();
        if (sampleSize >= 1 && sampleSize 

and an encodeCommand() method

    public void encodeCommand(ByteBuffer b) {
        encodeCommand(b, PtpConstants.Operation.GetObject, objectHandle);

PtpConstants.Operation.GetObjectis of particlar interest. It is defined as follows:

public static final int GetObjectHandles = 0x1007; public static final int GetObjectInfo = 0x1008; public static final int GetObject = 0x1009; public static final int GetThumb = 0x100A; public static final int DeleteObject = 0x100B;

These must be the hexadecimal codes that the EosCamera or NikonCamera recognizes. If we wish to execute a command that CrazyMaik's App did not implement, we should probably construct similar RetrieveImageAction and GetObjectCommand classes. For example, to delete a file on the camera, we might try to implement DeleteImageAction and DeleteObjectCommand classes. As seen above, PtpConstants.Operation class actually specifies a hexadecimal constant for DeleteObject....