1fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong/*
2fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong * Copyright (C) 2013 The Android Open Source Project
3fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong *
4fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong * Licensed under the Apache License, Version 2.0 (the "License");
5fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong * you may not use this file except in compliance with the License.
6fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong * You may obtain a copy of the License at
7fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong *
8fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong *      http://www.apache.org/licenses/LICENSE-2.0
9fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong *
10fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong * Unless required by applicable law or agreed to in writing, software
11fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong * distributed under the License is distributed on an "AS IS" BASIS,
12fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong * See the License for the specific language governing permissions and
14fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong * limitations under the License.
15fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong */
16fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong
17fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kongpackage com.android.camera.app;
18fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong
19fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kongimport android.content.ContentValues;
20fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kongimport android.location.Location;
21fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kongimport android.net.Uri;
22fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong
23fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kongimport com.android.camera.exif.ExifInterface;
24fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong
25fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong/**
26fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong * An interface defining the media saver which saves media files in the
27fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong * background.
28fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong */
29fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kongpublic interface MediaSaver {
30fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong
31fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong    /**
32fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * An interface defining the callback for task queue status changes.
33fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     */
34fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong    public interface QueueListener {
35fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong        /**
36fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong         * The callback when the queue status changes. Every time a new
37fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong         * {@link com.android.camera.app.MediaSaver.QueueListener} is set by
38fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong         * {@link #setQueueListener(com.android.camera.app.MediaSaver.QueueListener)}
39fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong         * this callback will be invoked to notify the current status of the
40fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong         * queue.
41fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong         *
42fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong         * @param full Whether the queue is full.
43fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong         */
44fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong        public void onQueueStatus(boolean full);
45fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong    }
46fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong
47fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong    /**
48fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * An interface defining the callback when a media is saved.
49fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     */
50fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong    public interface OnMediaSavedListener {
51fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong        /**
52fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong         * The callback when the saving is done in the background.
53fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong         * @param uri The final content Uri of the saved media.
54fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong         */
55fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong        public void onMediaSaved(Uri uri);
56fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong    }
57fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong
58fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong    /**
59fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * Checks whether the queue is full.
60fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     */
61fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong    boolean isQueueFull();
62fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong
63fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong    /**
64fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * Adds an image into {@link android.content.ContentResolver} and also
65fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * saves the file to the storage in the background.
6682d592f64966766ac4e4181e08b0d2989d4ed9c3Shashi Shekhar     * <p/>
6782d592f64966766ac4e4181e08b0d2989d4ed9c3Shashi Shekhar     * Equivalent to calling
6882d592f64966766ac4e4181e08b0d2989d4ed9c3Shashi Shekhar     * {@link #addImage(byte[], String, long, Location, int, int, int,
69b62fa4716df6bcc526f575006822e06dd8ea9b83Sascha Haeberling     * ExifInterface, OnMediaSavedListener, String)}
7082d592f64966766ac4e4181e08b0d2989d4ed9c3Shashi Shekhar     * with <code>image/jpeg</code> as <code>mimeType</code>.
71fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     *
72fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * @param data The JPEG image data.
73fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * @param title The title of the image.
74fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * @param date The date when the image is created.
75fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * @param loc The location where the image is created. Can be {@code null}.
76fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * @param width The width of the image data before the orientation is
77fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     *              applied.
78fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * @param height The height of the image data before the orientation is
79fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     *               applied.
80fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * @param orientation The orientation of the image. The value should be a
81fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     *                    degree of rotation in clockwise. Valid values are
82fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     *                    0, 90, 180 and 270.
83fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * @param exif The EXIF data of this image.
84fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * @param l A callback object used when the saving is done.
85fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     */
86fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong    void addImage(byte[] data, String title, long date, Location loc, int width, int height,
87b62fa4716df6bcc526f575006822e06dd8ea9b83Sascha Haeberling            int orientation, ExifInterface exif, OnMediaSavedListener l);
88fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong
89fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong    /**
90fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * Adds an image into {@link android.content.ContentResolver} and also
9182d592f64966766ac4e4181e08b0d2989d4ed9c3Shashi Shekhar     * saves the file to the storage in the background.
9282d592f64966766ac4e4181e08b0d2989d4ed9c3Shashi Shekhar     *
9382d592f64966766ac4e4181e08b0d2989d4ed9c3Shashi Shekhar     * @param data The image data.
9482d592f64966766ac4e4181e08b0d2989d4ed9c3Shashi Shekhar     * @param title The title of the image.
9582d592f64966766ac4e4181e08b0d2989d4ed9c3Shashi Shekhar     * @param date The date when the image is created.
9682d592f64966766ac4e4181e08b0d2989d4ed9c3Shashi Shekhar     * @param loc The location where the image is created. Can be {@code null}.
9782d592f64966766ac4e4181e08b0d2989d4ed9c3Shashi Shekhar     * @param width The width of the image data before the orientation is
9882d592f64966766ac4e4181e08b0d2989d4ed9c3Shashi Shekhar     *              applied.
9982d592f64966766ac4e4181e08b0d2989d4ed9c3Shashi Shekhar     * @param height The height of the image data before the orientation is
10082d592f64966766ac4e4181e08b0d2989d4ed9c3Shashi Shekhar     *               applied.
10182d592f64966766ac4e4181e08b0d2989d4ed9c3Shashi Shekhar     * @param orientation The orientation of the image. The value should be a
10282d592f64966766ac4e4181e08b0d2989d4ed9c3Shashi Shekhar     *                    degree of rotation in clockwise. Valid values are
10382d592f64966766ac4e4181e08b0d2989d4ed9c3Shashi Shekhar     *                    0, 90, 180 and 270.
10482d592f64966766ac4e4181e08b0d2989d4ed9c3Shashi Shekhar     * @param exif The EXIF data of this image.
10582d592f64966766ac4e4181e08b0d2989d4ed9c3Shashi Shekhar     * @param l A callback object used when the saving is done.
10682d592f64966766ac4e4181e08b0d2989d4ed9c3Shashi Shekhar     * @param mimeType The mimeType of the image.
10782d592f64966766ac4e4181e08b0d2989d4ed9c3Shashi Shekhar     */
10882d592f64966766ac4e4181e08b0d2989d4ed9c3Shashi Shekhar    void addImage(byte[] data, String title, long date, Location loc, int width, int height,
109b62fa4716df6bcc526f575006822e06dd8ea9b83Sascha Haeberling            int orientation, ExifInterface exif, OnMediaSavedListener l, String mimeType);
11082d592f64966766ac4e4181e08b0d2989d4ed9c3Shashi Shekhar
11182d592f64966766ac4e4181e08b0d2989d4ed9c3Shashi Shekhar    /**
11282d592f64966766ac4e4181e08b0d2989d4ed9c3Shashi Shekhar     * Adds an image into {@link android.content.ContentResolver} and also
113fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * saves the file to the storage in the background. The width and height
114fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * will be obtained directly from the image data.
115fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     *
116fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * @param data The JPEG image data.
117fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * @param title The title of the image.
118fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * @param date The date when the image is created.
119fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * @param loc The location where the image is created. Can be {@code null}.
120fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * @param orientation The orientation of the image. The value should be a
121fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     *                    degree of rotation in clockwise. Valid values are
122fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     *                    0, 90, 180 and 270.
123fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * @param exif The EXIF data of this image.
124fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * @param l A callback object used when the saving is done.
125fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     */
126fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong    void addImage(byte[] data, String title, long date, Location loc, int orientation,
127b62fa4716df6bcc526f575006822e06dd8ea9b83Sascha Haeberling            ExifInterface exif, OnMediaSavedListener l);
128fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong
129fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong    /**
130fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * Adds an image into {@link android.content.ContentResolver} and also
131fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * saves the file to the storage in the background. The time will be set by
132fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * {@link System#currentTimeMillis()}.
133fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * will be obtained directly from the image data.
134fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     *
135fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * @param data The JPEG image data.
136fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * @param title The title of the image.
137fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * @param loc The location where the image is created. Can be {@code null}.
138fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * @param width The width of the image data before the orientation is
139fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     *              applied.
140fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * @param height The height of the image data before the orientation is
141fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     *               applied.
142fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * @param orientation
143fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * @param exif The EXIF data of this image.
144fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * @param l A callback object used when the saving is done.
145fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     */
146fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong    void addImage(byte[] data, String title, Location loc, int width, int height, int orientation,
147b62fa4716df6bcc526f575006822e06dd8ea9b83Sascha Haeberling            ExifInterface exif, OnMediaSavedListener l);
148fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong
149fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong    /**
150fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * Adds the video data into the {@link android.content.ContentResolver} in
151fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * the background. Only the database is updated here. The file should
152fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * already be created by {@link android.media.MediaRecorder}.
153203abe5913394239a1e888d71d56597b68f84f62Andy Huibers     * @param path The path of the video file on the storage.
154fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * @param values The values to be stored in the database.
155fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * @param l A callback object used when the saving is done.
156fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     */
157b62fa4716df6bcc526f575006822e06dd8ea9b83Sascha Haeberling    void addVideo(String path, ContentValues values, OnMediaSavedListener l);
158fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong
159fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong    /**
160fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     * Sets the queue listener.
161fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong     */
162fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong    void setQueueListener(QueueListener l);
163fd4fc0e52ad69c2d486f5f46c2d465b4c4ba2849Angus Kong}
164