1a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling/*
2a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling * Copyright (C) 2013 The Android Open Source Project
3a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling *
4a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling * Licensed under the Apache License, Version 2.0 (the "License");
5a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling * you may not use this file except in compliance with the License.
6a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling * You may obtain a copy of the License at
7a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling *
8a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling *      http://www.apache.org/licenses/LICENSE-2.0
9a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling *
10a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling * Unless required by applicable law or agreed to in writing, software
11a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling * distributed under the License is distributed on an "AS IS" BASIS,
12a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling * See the License for the specific language governing permissions and
14a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling * limitations under the License.
15a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling */
16a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling
17a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberlingpackage com.android.camera.session;
18a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling
193830d419691ef865f01b362fee9618bac2aa8888Sascha Haeberlingimport android.graphics.Bitmap;
20a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberlingimport android.location.Location;
21a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberlingimport android.net.Uri;
22a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling
23a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberlingimport com.android.camera.exif.ExifInterface;
24e7c53cc907f5bb40c8d112830d12ac494e4c68c5I-Jong Linimport com.android.camera.stats.CaptureSessionStatsCollector;
25abf1e994d236a65180eecfcb6997003ab12795dfSascha Haeberlingimport com.android.camera.util.Size;
26231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohdeimport com.google.common.annotations.VisibleForTesting;
2737036186326fb68c27063f97305405d3667a5eb3Sascha Haeberlingimport com.google.common.base.Optional;
2837036186326fb68c27063f97305405d3667a5eb3Sascha Haeberlingimport com.google.common.util.concurrent.ListenableFuture;
29a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling
30231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohdeimport javax.annotation.Nonnull;
31231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohdeimport javax.annotation.Nullable;
32231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde
33a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling/**
34a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling * A session is an item that is in progress of being created and saved, such as
35a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling * a photo sphere or HDR+ photo.
36a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling */
37a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberlingpublic interface CaptureSession {
38e48cd5405840c530d4beefca84674c4919a77edbSascha Haeberling
39e48cd5405840c530d4beefca84674c4919a77edbSascha Haeberling    /** Classes implementing this interface can produce a capture session. */
40e48cd5405840c530d4beefca84674c4919a77edbSascha Haeberling    public static interface CaptureSessionCreator {
41e48cd5405840c530d4beefca84674c4919a77edbSascha Haeberling        /** Creates and starts a new capture session. */
42e48cd5405840c530d4beefca84674c4919a77edbSascha Haeberling        public CaptureSession createAndStartEmpty();
43e48cd5405840c530d4beefca84674c4919a77edbSascha Haeberling    }
44e48cd5405840c530d4beefca84674c4919a77edbSascha Haeberling
454a400d7f09ea0655d4730e904892e3a9d96993ebSascha Haeberling    /**
464a400d7f09ea0655d4730e904892e3a9d96993ebSascha Haeberling     * Classes implementing this interface can listen to progress updates of
474a400d7f09ea0655d4730e904892e3a9d96993ebSascha Haeberling     * this session.
484a400d7f09ea0655d4730e904892e3a9d96993ebSascha Haeberling     */
494a400d7f09ea0655d4730e904892e3a9d96993ebSascha Haeberling    public static interface ProgressListener {
504a400d7f09ea0655d4730e904892e3a9d96993ebSascha Haeberling        /**
514a400d7f09ea0655d4730e904892e3a9d96993ebSascha Haeberling         * Called when the progress is changed.
524a400d7f09ea0655d4730e904892e3a9d96993ebSascha Haeberling         *
534a400d7f09ea0655d4730e904892e3a9d96993ebSascha Haeberling         * @param progressPercent The current progress in percent.
544a400d7f09ea0655d4730e904892e3a9d96993ebSascha Haeberling         */
554a400d7f09ea0655d4730e904892e3a9d96993ebSascha Haeberling        public void onProgressChanged(int progressPercent);
564a400d7f09ea0655d4730e904892e3a9d96993ebSascha Haeberling
574a400d7f09ea0655d4730e904892e3a9d96993ebSascha Haeberling        /**
584a400d7f09ea0655d4730e904892e3a9d96993ebSascha Haeberling         * Called when the progress message is changed.
594a400d7f09ea0655d4730e904892e3a9d96993ebSascha Haeberling         *
600460ef28c6970d646260584b7df0b2b3157a67eeSascha Haeberling         * @param messageId The current progress message ID.
614a400d7f09ea0655d4730e904892e3a9d96993ebSascha Haeberling         */
620460ef28c6970d646260584b7df0b2b3157a67eeSascha Haeberling        public void onStatusMessageChanged(int messageId);
634a400d7f09ea0655d4730e904892e3a9d96993ebSascha Haeberling    }
64a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling
65231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde    /**
66231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde     * Classes implementing this interface can listen to progress updates of
67231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde     * this session.
68231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde     */
69231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde    public static interface ImageLifecycleListener {
70231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde        /**
71231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde         * Occurs when, for a particular image type, an image capture has
72231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde         * started. This method is always executed, and will always be called
73231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde         * first.
74231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde         */
75231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde        public void onCaptureStarted();
76231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde
77231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde        /**
78231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde         * Occurs when the tiny thumbnail bytes are received.
79231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde         */
80231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde        public void onTinyThumb();
81231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde
82231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde        /**
83231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde         * Occurs when the medium thumbnail bytes are received.
84231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde         */
85231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde        public void onMediumThumb();
86231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde
87231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde        /**
88231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde         * Occurs when rendering/processing/encoding starts for the full size image.
89231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde         */
90231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde        public void onProcessingStarted();
91231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde
92231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde        /**
93231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde         * Occurs when the rendering/processing/encoding for the full size image
94231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde         * is completed.
95231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde         */
96231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde        public void onProcessingComplete();
97231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde
98231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde        /**
99231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde         * This occurs after all the bytes are physically on disk.
100231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde         */
101231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde        public void onCapturePersisted();
102646e84f85a3f463ce094ad5a9caca261277f0d0ePaul Rohde
103646e84f85a3f463ce094ad5a9caca261277f0d0ePaul Rohde        /**
104646e84f85a3f463ce094ad5a9caca261277f0d0ePaul Rohde         * This occurs if a capture session is created but is later canceled for
105646e84f85a3f463ce094ad5a9caca261277f0d0ePaul Rohde         * some reason.
106646e84f85a3f463ce094ad5a9caca261277f0d0ePaul Rohde         */
107646e84f85a3f463ce094ad5a9caca261277f0d0ePaul Rohde        public void onCaptureCanceled();
108dad39b12816f05468476804b7caf3ef39a4aa682Sascha Haeberling
109dad39b12816f05468476804b7caf3ef39a4aa682Sascha Haeberling        /**
110dad39b12816f05468476804b7caf3ef39a4aa682Sascha Haeberling         * This occurs if a capture session is created but failed to persist the
111dad39b12816f05468476804b7caf3ef39a4aa682Sascha Haeberling         * final image.
112dad39b12816f05468476804b7caf3ef39a4aa682Sascha Haeberling         */
113dad39b12816f05468476804b7caf3ef39a4aa682Sascha Haeberling        public void onCaptureFailed();
114231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde    }
115231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde
116298c06604bbf390da2fe1775f5ed834a592d5bb0Sascha Haeberling    /** Returns the title/name of this session. */
117298c06604bbf390da2fe1775f5ed834a592d5bb0Sascha Haeberling    public String getTitle();
118298c06604bbf390da2fe1775f5ed834a592d5bb0Sascha Haeberling
11993be42a997b008fbd098ce8ad8e8bf1eb775b3f6Sascha Haeberling    /** Returns the location of this session or null. */
12093be42a997b008fbd098ce8ad8e8bf1eb775b3f6Sascha Haeberling    public Location getLocation();
12193be42a997b008fbd098ce8ad8e8bf1eb775b3f6Sascha Haeberling
12293be42a997b008fbd098ce8ad8e8bf1eb775b3f6Sascha Haeberling    /** Sets the location of this session. */
12393be42a997b008fbd098ce8ad8e8bf1eb775b3f6Sascha Haeberling    public void setLocation(Location location);
12493be42a997b008fbd098ce8ad8e8bf1eb775b3f6Sascha Haeberling
125a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling    /**
126a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling     * Set the progress in percent for the current session. If set to or left at
127a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling     * 0, no progress bar is shown.
128a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling     */
129a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling    public void setProgress(int percent);
130a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling
131a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling    /**
132a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling     * Returns the progress of this session in percent.
133a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling     */
134a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling    public int getProgress();
135a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling
136a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling    /**
137a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling     * Returns the current progress message.
138a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling     */
1390460ef28c6970d646260584b7df0b2b3157a67eeSascha Haeberling    public int getProgressMessageId();
140a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling
141a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling    /**
142abf1e994d236a65180eecfcb6997003ab12795dfSascha Haeberling     * Changes the progress status message of this session.
143abf1e994d236a65180eecfcb6997003ab12795dfSascha Haeberling     *
1440460ef28c6970d646260584b7df0b2b3157a67eeSascha Haeberling     * @param messageId the ID of the new message
145abf1e994d236a65180eecfcb6997003ab12795dfSascha Haeberling     */
1460460ef28c6970d646260584b7df0b2b3157a67eeSascha Haeberling    public void setProgressMessage(int messageId);
147abf1e994d236a65180eecfcb6997003ab12795dfSascha Haeberling
148abf1e994d236a65180eecfcb6997003ab12795dfSascha Haeberling    /**
149abf1e994d236a65180eecfcb6997003ab12795dfSascha Haeberling     * For an ongoing session, this updates the currently displayed thumbnail.
150abf1e994d236a65180eecfcb6997003ab12795dfSascha Haeberling     *
151abf1e994d236a65180eecfcb6997003ab12795dfSascha Haeberling     * @param bitmap the thumbnail to be shown while the session is in progress.
152abf1e994d236a65180eecfcb6997003ab12795dfSascha Haeberling     */
153abf1e994d236a65180eecfcb6997003ab12795dfSascha Haeberling    public void updateThumbnail(Bitmap bitmap);
154abf1e994d236a65180eecfcb6997003ab12795dfSascha Haeberling
155abf1e994d236a65180eecfcb6997003ab12795dfSascha Haeberling    /**
1566dd5840e86bffecba8a7f52327b9c1085caeb7d2Sascha Haeberling     * For an ongoing session, this updates the capture indicator thumbnail.
1576dd5840e86bffecba8a7f52327b9c1085caeb7d2Sascha Haeberling     *
1586dd5840e86bffecba8a7f52327b9c1085caeb7d2Sascha Haeberling     * @param bitmap the thumbnail to be shown while the session is in progress.
1596dd5840e86bffecba8a7f52327b9c1085caeb7d2Sascha Haeberling     *            update the capture indicator
1606dd5840e86bffecba8a7f52327b9c1085caeb7d2Sascha Haeberling     * @param rotationDegrees the rotation of the thumbnail in degrees
1616dd5840e86bffecba8a7f52327b9c1085caeb7d2Sascha Haeberling     */
1626dd5840e86bffecba8a7f52327b9c1085caeb7d2Sascha Haeberling    public void updateCaptureIndicatorThumbnail(Bitmap bitmap, int rotationDegrees);
1636dd5840e86bffecba8a7f52327b9c1085caeb7d2Sascha Haeberling
1646dd5840e86bffecba8a7f52327b9c1085caeb7d2Sascha Haeberling    /**
165abf1e994d236a65180eecfcb6997003ab12795dfSascha Haeberling     * Starts an empty session with the given placeholder size.
166abf1e994d236a65180eecfcb6997003ab12795dfSascha Haeberling     *
167231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde     * @param listener receives events as the session progresses.
168231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde     * @param pictureSize the size, in pixels of the empty placeholder.
169abf1e994d236a65180eecfcb6997003ab12795dfSascha Haeberling     */
170231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde    public void startEmpty(@Nullable ImageLifecycleListener listener, @Nonnull Size pictureSize);
171abf1e994d236a65180eecfcb6997003ab12795dfSascha Haeberling
172abf1e994d236a65180eecfcb6997003ab12795dfSascha Haeberling    /**
173a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling     * Starts the session by adding a placeholder to the filmstrip and adding
174a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling     * notifications.
175a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling     *
176231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde     * @param listener receives events as the session progresses.
177a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling     * @param placeholder a valid encoded bitmap to be used as the placeholder.
1780460ef28c6970d646260584b7df0b2b3157a67eeSascha Haeberling     * @param progressMessageId the message to be used to the progress
179a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling     *            notification initially. This can later be changed using
1800460ef28c6970d646260584b7df0b2b3157a67eeSascha Haeberling     *            {@link #setProgressMessage(int)}.
181a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling     */
182231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde    public void startSession(@Nullable ImageLifecycleListener listener, @Nonnull byte[] placeholder,
183231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde          int progressMessageId);
184a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling
185a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling    /**
1863830d419691ef865f01b362fee9618bac2aa8888Sascha Haeberling     * Starts the session by adding a placeholder to the filmstrip and adding
1873830d419691ef865f01b362fee9618bac2aa8888Sascha Haeberling     * notifications.
1883830d419691ef865f01b362fee9618bac2aa8888Sascha Haeberling     *
189231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde     * @param listener receives events as the session progresses.
1903830d419691ef865f01b362fee9618bac2aa8888Sascha Haeberling     * @param placeholder a valid bitmap to be used as the placeholder.
1910460ef28c6970d646260584b7df0b2b3157a67eeSascha Haeberling     * @param progressMessageId the message to be used to the progress
1923830d419691ef865f01b362fee9618bac2aa8888Sascha Haeberling     *            notification initially. This can later be changed using
1930460ef28c6970d646260584b7df0b2b3157a67eeSascha Haeberling     *            {@link #setProgressMessage(int)}.
1943830d419691ef865f01b362fee9618bac2aa8888Sascha Haeberling     */
195231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde    @VisibleForTesting
196231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde    public void startSession(@Nullable ImageLifecycleListener listener, @Nonnull Bitmap placeholder,
197231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde          int progressMessageId);
1983830d419691ef865f01b362fee9618bac2aa8888Sascha Haeberling
1993830d419691ef865f01b362fee9618bac2aa8888Sascha Haeberling    /**
200a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling     * Starts the session by marking the item as in-progress and adding
201a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling     * notifications.
202a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling     *
203231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde     * @param listener receives events as the session progresses.
204a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling     * @param uri the URI of the item to be re-processed.
2050460ef28c6970d646260584b7df0b2b3157a67eeSascha Haeberling     * @param progressMessageId the message to be used to the progress
206a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling     *            notification initially. This can later be changed using
2070460ef28c6970d646260584b7df0b2b3157a67eeSascha Haeberling     *            {@link #setProgressMessage(int)}.
208a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling     */
209231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde    public void startSession(@Nullable ImageLifecycleListener listener, @Nonnull Uri uri,
210231b1c0679892e431bac9fe4461d5fb235e362b1Paul Rohde          int progressMessageId);
211a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling
212a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling    /**
213a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling     * Cancel the session without a final result. The session will be removed
214a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling     * from the film strip, progress notifications will be cancelled.
215a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling     */
216a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling    public void cancel();
217a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling
218a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling    /**
219a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling     * Finish the session by saving the image to disk. Will add the final item
220a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling     * in the film strip and remove the progress notifications.
22137036186326fb68c27063f97305405d3667a5eb3Sascha Haeberling     *
22237036186326fb68c27063f97305405d3667a5eb3Sascha Haeberling     * @param data the data of the data (e.g. JPEG bytes) that should be written
22337036186326fb68c27063f97305405d3667a5eb3Sascha Haeberling     *            to disk.
22437036186326fb68c27063f97305405d3667a5eb3Sascha Haeberling     * @param width the width of the media item, in pixels.
22537036186326fb68c27063f97305405d3667a5eb3Sascha Haeberling     * @param height the height of the media item, in pixels.
22637036186326fb68c27063f97305405d3667a5eb3Sascha Haeberling     * @param orientation the orientaiton of the media item, in degrees.
22737036186326fb68c27063f97305405d3667a5eb3Sascha Haeberling     * @param exif the EXIF information for this media item.
22837036186326fb68c27063f97305405d3667a5eb3Sascha Haeberling     * @return A future that will provide the URI once the item is saved. URI
22937036186326fb68c27063f97305405d3667a5eb3Sascha Haeberling     *         might be absent if the data could not be saved successfull, which
23037036186326fb68c27063f97305405d3667a5eb3Sascha Haeberling     *         in turn means if a URI is returned it is guaranteed that the
23137036186326fb68c27063f97305405d3667a5eb3Sascha Haeberling     *         media item was successfully written to disk.
23237036186326fb68c27063f97305405d3667a5eb3Sascha Haeberling     */
23337036186326fb68c27063f97305405d3667a5eb3Sascha Haeberling    public ListenableFuture<Optional<Uri>> saveAndFinish(byte[] data, int width, int height,
23437036186326fb68c27063f97305405d3667a5eb3Sascha Haeberling            int orientation, ExifInterface exif);
235a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling
236a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling    /**
23724069e7a9cc9b4f908f18a71301285ccf5e164f6Sascha Haeberling     * Will create and return a {@link StackSaver} for saving out a number of
23824069e7a9cc9b4f908f18a71301285ccf5e164f6Sascha Haeberling     * media items to a stack. The name of the stack will be the title of this
23924069e7a9cc9b4f908f18a71301285ccf5e164f6Sascha Haeberling     * capture session.
24024069e7a9cc9b4f908f18a71301285ccf5e164f6Sascha Haeberling     */
24124069e7a9cc9b4f908f18a71301285ccf5e164f6Sascha Haeberling    public StackSaver getStackSaver();
24224069e7a9cc9b4f908f18a71301285ccf5e164f6Sascha Haeberling
24324069e7a9cc9b4f908f18a71301285ccf5e164f6Sascha Haeberling    /**
244995083b53be47e1e27133e403da0b63a03d07ea7Alan Newberger     * Finishes the session. Resources may be held during notification of
245976bba4cfffb0089d4b7c61e16b90f506dbf1a2bSascha Haeberling     * finished state, {@link #finalizeSession()} must be called to fully complete
246995083b53be47e1e27133e403da0b63a03d07ea7Alan Newberger     * the session.
247a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling     */
248a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling    public void finish();
249a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling
250a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling    /**
251995083b53be47e1e27133e403da0b63a03d07ea7Alan Newberger     * Finish the session and indicate it failed. Resources may be held during
252976bba4cfffb0089d4b7c61e16b90f506dbf1a2bSascha Haeberling     * notification of finished state, {@link #finalizeSession()} must be called to
253995083b53be47e1e27133e403da0b63a03d07ea7Alan Newberger     * fully complete the session.
254597c1a093f840af3c42e00af05da01ef124dc846Sascha Haeberling     */
2550460ef28c6970d646260584b7df0b2b3157a67eeSascha Haeberling    public void finishWithFailure(int failureMessageId, boolean removeFromFilmstrip);
256597c1a093f840af3c42e00af05da01ef124dc846Sascha Haeberling
257597c1a093f840af3c42e00af05da01ef124dc846Sascha Haeberling    /**
258995083b53be47e1e27133e403da0b63a03d07ea7Alan Newberger     * All processing complete, finalize the session and remove any resources.
259995083b53be47e1e27133e403da0b63a03d07ea7Alan Newberger     */
260976bba4cfffb0089d4b7c61e16b90f506dbf1a2bSascha Haeberling    public void finalizeSession();
261995083b53be47e1e27133e403da0b63a03d07ea7Alan Newberger
262995083b53be47e1e27133e403da0b63a03d07ea7Alan Newberger    /**
26363a8c9467824ef8aa2039b7e27831b0533d8e5d9Sascha Haeberling     * Returns the file to where the final output of this session should be
2648111aa0a298688da560dcac6bc4c3f92b878dbc7Sascha Haeberling     * stored. This is only available after startSession has been called and
2658111aa0a298688da560dcac6bc4c3f92b878dbc7Sascha Haeberling     * will become unavailable after finish() was called.
266a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling     */
26763a8c9467824ef8aa2039b7e27831b0533d8e5d9Sascha Haeberling    public TemporarySessionFile getTempOutputFile();
268a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling
269a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling    /**
27024069e7a9cc9b4f908f18a71301285ccf5e164f6Sascha Haeberling     * Returns the URI to the final output of this session. This is only
27124069e7a9cc9b4f908f18a71301285ccf5e164f6Sascha Haeberling     * available after startSession has been called.
272298c06604bbf390da2fe1775f5ed834a592d5bb0Sascha Haeberling     */
273298c06604bbf390da2fe1775f5ed834a592d5bb0Sascha Haeberling    public Uri getUri();
274298c06604bbf390da2fe1775f5ed834a592d5bb0Sascha Haeberling
275298c06604bbf390da2fe1775f5ed834a592d5bb0Sascha Haeberling    /**
27663a8c9467824ef8aa2039b7e27831b0533d8e5d9Sascha Haeberling     * Updates the preview from the file created from
27763a8c9467824ef8aa2039b7e27831b0533d8e5d9Sascha Haeberling     * {@link #getTempOutputFile()}.
278571a8c389798bd3f01429f6be34cd3e606ab34dfAngus Kong     */
279636bce5ed9771df424a5ca46586648a11018179bSascha Haeberling    public void updatePreview();
280571a8c389798bd3f01429f6be34cd3e606ab34dfAngus Kong
281571a8c389798bd3f01429f6be34cd3e606ab34dfAngus Kong    /**
2824a400d7f09ea0655d4730e904892e3a9d96993ebSascha Haeberling     * Adds a progress listener to this session.
2834a400d7f09ea0655d4730e904892e3a9d96993ebSascha Haeberling     */
2844a400d7f09ea0655d4730e904892e3a9d96993ebSascha Haeberling    public void addProgressListener(ProgressListener listener);
2854a400d7f09ea0655d4730e904892e3a9d96993ebSascha Haeberling
2864a400d7f09ea0655d4730e904892e3a9d96993ebSascha Haeberling    /**
2874a400d7f09ea0655d4730e904892e3a9d96993ebSascha Haeberling     * Removes the given progress listener from this session.
2884a400d7f09ea0655d4730e904892e3a9d96993ebSascha Haeberling     */
2894a400d7f09ea0655d4730e904892e3a9d96993ebSascha Haeberling    public void removeProgressListener(ProgressListener listener);
290e7c53cc907f5bb40c8d112830d12ac494e4c68c5I-Jong Lin
291e7c53cc907f5bb40c8d112830d12ac494e4c68c5I-Jong Lin    /**
292e7c53cc907f5bb40c8d112830d12ac494e4c68c5I-Jong Lin     * Returns the associated StatsCollector Object
293e7c53cc907f5bb40c8d112830d12ac494e4c68c5I-Jong Lin     * @return
294e7c53cc907f5bb40c8d112830d12ac494e4c68c5I-Jong Lin     */
295e7c53cc907f5bb40c8d112830d12ac494e4c68c5I-Jong Lin    public CaptureSessionStatsCollector getCollector();
296a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberling}
297