ProcessingTask.java revision 2a978f2b7b07ce4e5f6163910912e79fed38aff8
1/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.camera.processing;
18
19import android.content.Context;
20import android.location.Location;
21
22import com.android.camera.app.CameraServices;
23import com.android.camera.session.CaptureSession;
24
25/**
26 * An interface for tasks to be processed by a {@code ProcessingService}.
27 */
28public interface ProcessingTask {
29    /**
30     * The result returned by a {@code ProcessingTask}.
31     */
32    public class ProcessingResult {
33        public final boolean mSuccess;
34        public final CaptureSession mSession;
35
36        /**
37         * @param success whether the processing was successful.
38         * @param session the capture session for the processed task.
39         */
40        public ProcessingResult(boolean success, CaptureSession session) {
41            mSuccess = success;
42            mSession = session;
43        }
44    }
45
46    /**
47     * Classes implementing this interface can be informed when a task is done
48     * processing.
49     */
50    public interface ProcessingTaskDoneListener {
51        /**
52         * Called when a task is done processing.
53         *
54         * @param result the processing result.
55         */
56        public void onDone(ProcessingResult result);
57    }
58
59    /**
60     * Processes the given task. This will be usually called by a service.
61     *
62     * @param context the caller {@code Context}
63     * @param services the available {@code CameraServices}
64     * @param session the {@code CaptureSession}
65     * @return the {@code ProcessResult} with the result of the processing
66     */
67    public ProcessingResult process(Context context, CameraServices services,
68        CaptureSession session);
69
70    /**
71     * @return the name of the task. It can be null to indicate that the task
72     *         has no name.
73     */
74    public String getName();
75
76    /**
77     * @return The location of the media that is to be processed. Returns null,
78     *         if no location is available.
79     */
80    public Location getLocation();
81
82    /**
83     * @return The CaptureSession if it has been created, or null.
84     */
85    public CaptureSession getSession();
86
87    /** Sets a listener that is informed when this task is done processing. */
88    public void setDoneListener(ProcessingTaskDoneListener listener);
89}
90