incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From deedu...@apache.org
Subject [12/15] webworks commit: Sync native Capture implementation with cordova-js.
Date Tue, 03 Apr 2012 12:59:30 GMT
Sync native Capture implementation with cordova-js.


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/commit/fe003534
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/tree/fe003534
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/diff/fe003534

Branch: refs/heads/master
Commit: fe00353449aadd0b8883aa6256214fbf21af34a5
Parents: 29219e3
Author: Drew Walters <deedubbu@apache.org>
Authored: Fri Mar 9 15:52:01 2012 -0600
Committer: Drew Walters <deedubbu@apache.org>
Committed: Fri Mar 9 15:52:01 2012 -0600

----------------------------------------------------------------------
 .../cordova/media/AudioCaptureOperation.java       |   54 +++-
 .../org/apache/cordova/media/CaptureControl.java   |    6 +-
 .../org/apache/cordova/media/CaptureOperation.java |    4 +-
 .../cordova/media/ImageCaptureOperation.java       |    2 +-
 .../src/org/apache/cordova/media/MediaCapture.java |  252 +++++++--------
 .../cordova/media/VideoCaptureOperation.java       |    2 +-
 template/project/www/plugins.xml                   |    2 +-
 7 files changed, 180 insertions(+), 142 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/fe003534/framework/ext/src/org/apache/cordova/media/AudioCaptureOperation.java
----------------------------------------------------------------------
diff --git a/framework/ext/src/org/apache/cordova/media/AudioCaptureOperation.java b/framework/ext/src/org/apache/cordova/media/AudioCaptureOperation.java
index cbd274d..1060d90 100644
--- a/framework/ext/src/org/apache/cordova/media/AudioCaptureOperation.java
+++ b/framework/ext/src/org/apache/cordova/media/AudioCaptureOperation.java
@@ -19,6 +19,7 @@
 package org.apache.cordova.media;
 
 import java.io.IOException;
+import java.util.Date;
 
 import javax.microedition.io.Connector;
 import javax.microedition.io.file.FileConnection;
@@ -36,7 +37,7 @@ public class AudioCaptureOperation extends CaptureOperation {
     public static final String CONTENT_TYPE = "audio/";
 
     // maximum duration to capture media (milliseconds)
-    private long duration = 0;
+    private double duration = 0;
 
     // file system listener
     private AudioCaptureListener listener = null;
@@ -53,7 +54,7 @@ public class AudioCaptureOperation extends CaptureOperation {
      * @param queue
      *            the queue from which to retrieve captured media files
      */
-    public AudioCaptureOperation(int limit, long duration, String callbackId, MediaQueue
queue) {
+    public AudioCaptureOperation(long limit, double duration, String callbackId, MediaQueue
queue) {
         super(limit, callbackId, queue);
 
         if (duration > 0) {
@@ -103,19 +104,53 @@ public class AudioCaptureOperation extends CaptureOperation {
     protected void processFile(String filePath) {
         Logger.log(this.getClass().getName() + ": processing file: " + filePath);
 
+        // wait for file to finish writing and add it to captured files
+        addCaptureFile(getMediaFile(filePath));
+    }
+
+    /**
+     * Waits for file to be fully written to the file system before retrieving
+     * its file properties.
+     *
+     * @param filePath
+     *            Full path of the image file
+     * @throws IOException
+     */
+    private File getMediaFile(String filePath) {
         File file = new File(FileUtils.stripSeparator(filePath));
 
-        // grab file properties
+        // time begin waiting for file write
+        long start = (new Date()).getTime();
+
+        // wait for the file to be fully written, then grab its properties
         FileConnection fconn = null;
         try {
             fconn = (FileConnection) Connector.open(filePath, Connector.READ);
             if (fconn.exists()) {
-                long size = fconn.fileSize();
+                // wait for file to be fully written
+                long fileSize = fconn.fileSize();
+                long size = 0;
+                Thread thisThread = Thread.currentThread();
+                while (myThread == thisThread) {
+                    try {
+                        Thread.sleep(100);
+                    }
+                    catch (InterruptedException e) {
+                        break;
+                    }
+                    size = fconn.fileSize();
+                    if (fileSize != 0 && size == fileSize) {
+                        break;
+                    }
+                    fileSize = size;
+                }
                 Logger.log(this.getClass().getName() + ": " + filePath + " size="
-                        + Long.toString(size) + " bytes");
+                        + Long.toString(fileSize) + " bytes");
+
+                // retrieve file properties
                 file.setLastModifiedDate(fconn.lastModified());
                 file.setName(FileUtils.stripSeparator(fconn.getName()));
-                file.setSize(size);
+                file.setSize(fileSize);
                 file.setType(MIMETypeAssociations.getMIMEType(filePath));
             }
         }
@@ -128,6 +163,11 @@ public class AudioCaptureOperation extends CaptureOperation {
             } catch (IOException ignored) {}
         }
 
-        addCaptureFile(file);
+        // log time it took to write the file
+        long end = (new Date()).getTime();
+        Logger.log(this.getClass().getName() + ": wait time="
+                + Long.toString(end - start) + " ms");
+
+        return file;
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/fe003534/framework/ext/src/org/apache/cordova/media/CaptureControl.java
----------------------------------------------------------------------
diff --git a/framework/ext/src/org/apache/cordova/media/CaptureControl.java b/framework/ext/src/org/apache/cordova/media/CaptureControl.java
index b57b794..d26e2e5 100644
--- a/framework/ext/src/org/apache/cordova/media/CaptureControl.java
+++ b/framework/ext/src/org/apache/cordova/media/CaptureControl.java
@@ -83,7 +83,7 @@ public class CaptureControl {
      * @param callbackId
      *            the callback to be invoked with capture file properties
      */
-    public void startImageCaptureOperation(int limit, String callbackId) {
+    public void startImageCaptureOperation(long limit, String callbackId) {
         // setup a queue to receive image file paths
         MediaQueue queue = new MediaQueue();
 
@@ -104,7 +104,7 @@ public class CaptureControl {
      * @param callbackId
      *            the callback to be invoked with capture file properties
      */
-    public void startVideoCaptureOperation(int limit, String callbackId) {
+    public void startVideoCaptureOperation(long limit, String callbackId) {
         // setup a queue to receive video recording file paths
         MediaQueue queue = new MediaQueue();
 
@@ -128,7 +128,7 @@ public class CaptureControl {
      * @param callbackId
      *            the callback to be invoked with the capture results
      */
-    public void startAudioCaptureOperation(int limit, long duration, String callbackId) {
+    public void startAudioCaptureOperation(long limit, double duration, String callbackId)
{
         // setup a queue to receive recording file paths
         MediaQueue queue = new MediaQueue();
 

http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/fe003534/framework/ext/src/org/apache/cordova/media/CaptureOperation.java
----------------------------------------------------------------------
diff --git a/framework/ext/src/org/apache/cordova/media/CaptureOperation.java b/framework/ext/src/org/apache/cordova/media/CaptureOperation.java
index ab647c3..e6d0eff 100644
--- a/framework/ext/src/org/apache/cordova/media/CaptureOperation.java
+++ b/framework/ext/src/org/apache/cordova/media/CaptureOperation.java
@@ -28,7 +28,7 @@ import org.apache.cordova.util.Logger;
 
 public abstract class CaptureOperation implements Runnable {
     // max number of media files to capture
-    protected int limit = 1;
+    protected long limit = 1;
 
     // for sending results
     protected String callbackId = null;
@@ -55,7 +55,7 @@ public abstract class CaptureOperation implements Runnable {
      * @param queue
      *            the queue from which to retrieve captured media files
      */
-    public CaptureOperation(int limit, String callbackId, MediaQueue queue) {
+    public CaptureOperation(long limit, String callbackId, MediaQueue queue) {
         if (limit > 1) {
             this.limit = limit;
         }

http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/fe003534/framework/ext/src/org/apache/cordova/media/ImageCaptureOperation.java
----------------------------------------------------------------------
diff --git a/framework/ext/src/org/apache/cordova/media/ImageCaptureOperation.java b/framework/ext/src/org/apache/cordova/media/ImageCaptureOperation.java
index 980a1dd..36e61b9 100644
--- a/framework/ext/src/org/apache/cordova/media/ImageCaptureOperation.java
+++ b/framework/ext/src/org/apache/cordova/media/ImageCaptureOperation.java
@@ -47,7 +47,7 @@ public class ImageCaptureOperation extends CaptureOperation {
      * @param queue
      *            the queue from which to retrieve captured media files
      */
-    public ImageCaptureOperation(int limit, String callbackId, MediaQueue queue) {
+    public ImageCaptureOperation(long limit, String callbackId, MediaQueue queue) {
         super(limit, callbackId, queue);
 
         // listener to capture image files added to file system

http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/fe003534/framework/ext/src/org/apache/cordova/media/MediaCapture.java
----------------------------------------------------------------------
diff --git a/framework/ext/src/org/apache/cordova/media/MediaCapture.java b/framework/ext/src/org/apache/cordova/media/MediaCapture.java
index 326757a..1ab118e 100644
--- a/framework/ext/src/org/apache/cordova/media/MediaCapture.java
+++ b/framework/ext/src/org/apache/cordova/media/MediaCapture.java
@@ -28,6 +28,8 @@ import org.apache.cordova.api.Plugin;
 import org.apache.cordova.api.PluginResult;
 import org.apache.cordova.file.File;
 import org.apache.cordova.json4j.JSONArray;
+import org.apache.cordova.json4j.JSONException;
+import org.apache.cordova.json4j.JSONObject;
 import org.apache.cordova.util.Logger;
 import org.apache.cordova.util.StringUtils;
 
@@ -41,6 +43,8 @@ public class MediaCapture extends Plugin {
 
     public static String PROTOCOL_CAPTURE = "capture";
 
+    private static final String LOG_TAG = "MediaCapture: ";
+
     /**
      * Error codes.
      */
@@ -58,13 +62,11 @@ public class MediaCapture extends Plugin {
     /**
      * Possible actions.
      */
-    protected static final int ACTION_GET_SUPPORTED_AUDIO_MODES = 0;
-    protected static final int ACTION_GET_SUPPORTED_IMAGE_MODES = 1;
-    protected static final int ACTION_GET_SUPPORTED_VIDEO_MODES = 2;
-    protected static final int ACTION_CAPTURE_AUDIO = 3;
-    protected static final int ACTION_CAPTURE_IMAGE = 4;
-    protected static final int ACTION_CAPTURE_VIDEO = 5;
-    protected static final int ACTION_CANCEL_CAPTURES = 6;
+    protected static final String ACTION_GET_SUPPORTED_MODES = "captureModes";
+    protected static final String ACTION_CAPTURE_AUDIO = "captureAudio";
+    protected static final String ACTION_CAPTURE_IMAGE = "captureImage";
+    protected static final String ACTION_CAPTURE_VIDEO = "captureVideo";
+    protected static final String ACTION_CANCEL_CAPTURES = "stopCaptures";
 
     /**
      * Executes the requested action and returns a PluginResult.
@@ -78,27 +80,25 @@ public class MediaCapture extends Plugin {
      * @return A PluginResult object with a status and message.
      */
     public PluginResult execute(String action, JSONArray args, String callbackId) {
+        PluginResult result = null;
 
-        switch (getAction(action)) {
-        case ACTION_GET_SUPPORTED_AUDIO_MODES:
-            return getAudioCaptureModes();
-        case ACTION_GET_SUPPORTED_IMAGE_MODES:
-            return getImageCaptureModes();
-        case ACTION_GET_SUPPORTED_VIDEO_MODES:
-            return getVideoCaptureModes();
-        case ACTION_CAPTURE_AUDIO:
-            return captureAudio(args, callbackId);
-        case ACTION_CAPTURE_IMAGE:
-            return captureImage(args, callbackId);
-        case ACTION_CAPTURE_VIDEO:
-            return captureVideo(args, callbackId);
-        case ACTION_CANCEL_CAPTURES:
+        if (ACTION_GET_SUPPORTED_MODES.equals(action)) {
+            result = getCaptureModes();
+        } else if (ACTION_CAPTURE_AUDIO.equals(action)) {
+            result = captureAudio(args, callbackId);
+        } else if (ACTION_CAPTURE_IMAGE.equals(action)) {
+            result = captureImage(args, callbackId);
+        } else if (ACTION_CAPTURE_VIDEO.equals(action)) {
+            result = captureVideo(args, callbackId);
+        } else if (ACTION_CANCEL_CAPTURES.equals(action)) {
             CaptureControl.getCaptureControl().stopPendingOperations(true);
-            return new PluginResult(PluginResult.Status.OK);
+            result =  new PluginResult(PluginResult.Status.OK);
+        } else {
+            result = new PluginResult(PluginResult.Status.INVALID_ACTION,
+                "MediaCapture: invalid action " + action);
         }
 
-        return new PluginResult(PluginResult.Status.INVALID_ACTION,
-                "MediaCapture: invalid action " + action);
+        return result;
     }
 
     /**
@@ -119,52 +119,33 @@ public class MediaCapture extends Plugin {
     }
 
     /**
-     * Retrieves supported audio capture modes (content types).
-     * @return supported audio capture modes
+     * Return the supported capture modes for audio, image and video.
+     * @return supported capture modes.
      */
-    protected PluginResult getAudioCaptureModes() {
-        if (!isAudioCaptureSupported()) {
-            // if audio capture is not supported, return an empty array
-            // of capture modes
-            Logger.log(this.getClass().getName() + ": audio capture not supported");
-            return new PluginResult(PluginResult.Status.OK, "[]");
-        }
-
-        // get all supported capture content types
-        String[] contentTypes = getCaptureContentTypes();
-
-        // return audio content types only
-        JSONArray modes = new JSONArray();
-        for (int i = 0; i < contentTypes.length; i++) {
-            if (contentTypes[i].startsWith(AudioCaptureOperation.CONTENT_TYPE)) {
-                modes.add(new CaptureMode(contentTypes[i]).toJSONObject());
-            }
-        }
-
-        return new PluginResult(PluginResult.Status.OK, modes.toString());
-    }
-
-    /**
-     * Retrieves supported image capture modes (content type, width and height).
-     * @return supported image capture modes
-     */
-    protected PluginResult getImageCaptureModes() {
-        // get supported capture content types
-        String[] contentTypes = getCaptureContentTypes();
+    private PluginResult getCaptureModes() {
+        JSONArray audioModes = new JSONArray();
+        JSONArray imageModes = new JSONArray();
+        boolean audioSupported = isAudioCaptureSupported();
 
         // need to get the recording dimensions from supported image encodings
         String imageEncodings = System.getProperty("video.snapshot.encodings");
-        Logger.log(this.getClass().getName() + ": video.snapshot.encodings=" + imageEncodings);
+        Logger.log(this.getClass().getName() + ": video.snapshot.encodings="
+                + imageEncodings);
         String[] encodings = StringUtils.split(imageEncodings, "encoding=");
-
-        // find matching encodings and parse them for dimensions
-        // it's so annoying that we have to do this
         CaptureMode mode = null;
         Vector list = new Vector();
-        JSONArray modes = new JSONArray();
+
+        // get all supported capture content types for audio and image
+        String[] contentTypes = getCaptureContentTypes();
         for (int i = 0; i < contentTypes.length; i++) {
-            if (contentTypes[i].startsWith(ImageCaptureOperation.CONTENT_TYPE)) {
-                String type = contentTypes[i].substring(ImageCaptureOperation.CONTENT_TYPE.length());
+            if (audioSupported
+                    && contentTypes[i]
+                            .startsWith(AudioCaptureOperation.CONTENT_TYPE)) {
+                audioModes.add(new CaptureMode(contentTypes[i]).toJSONObject());
+            } else if (contentTypes[i]
+                    .startsWith(ImageCaptureOperation.CONTENT_TYPE)) {
+                String type = contentTypes[i]
+                        .substring(ImageCaptureOperation.CONTENT_TYPE.length());
                 for (int j = 0; j < encodings.length; j++) {
                     // format: "jpeg&width=2592&height=1944 "
                     String enc = encodings[j];
@@ -181,26 +162,39 @@ public class MediaCapture extends Plugin {
                         // don't want duplicates
                         if (!list.contains(mode)) {
                             list.addElement(mode);
-                            modes.add(mode.toJSONObject());
+                            imageModes.add(mode.toJSONObject());
                         }
                     }
                 }
             }
         }
 
-        return new PluginResult(PluginResult.Status.OK, modes.toString());
+        JSONObject captureModes = new JSONObject();
+        try {
+            captureModes.put("supportedAudioModes", audioModes.toString());
+            captureModes.put("supportedImageModes", imageModes.toString());
+            captureModes.put("supportedVideoModes", getVideoCaptureModes().toString());
+        } catch (JSONException e) {
+            Logger.error("JSONException: " + e.getMessage());
+            return new PluginResult(PluginResult.Status.JSON_EXCEPTION,
+                    "Failed to build supported capture modes.");
+        }
+
+        return new PluginResult(PluginResult.Status.OK, captureModes);
     }
 
     /**
      * Retrieves supported video capture modes (content type, width and height).
      * @return supported video capture modes
      */
-    protected PluginResult getVideoCaptureModes() {
+    protected JSONArray getVideoCaptureModes() {
+        JSONArray videoModes = new JSONArray();
+
         if (!isVideoCaptureSupported()) {
             // if the device does not support video capture, return an empty
             // array of capture modes
             Logger.log(this.getClass().getName() + ": video capture not supported");
-            return new PluginResult(PluginResult.Status.OK, "[]");
+            return videoModes;
         }
 
         /**
@@ -223,7 +217,6 @@ public class MediaCapture extends Plugin {
         String[] encodings = StringUtils.split(videoEncodings, "encoding=");
 
         // parse them into CaptureModes
-        JSONArray modes = new JSONArray();
         String enc = null;
         CaptureMode mode = null;
         Vector list = new Vector();
@@ -245,12 +238,12 @@ public class MediaCapture extends Plugin {
                 // don't want duplicates
                 if (!list.contains(mode)) {
                     list.addElement(mode);
-                    modes.add(mode.toJSONObject());
+                    videoModes.add(mode.toJSONObject());
                 }
             }
         }
 
-        return new PluginResult(PluginResult.Status.OK, modes.toString());
+        return videoModes;
     }
 
     /**
@@ -302,21 +295,28 @@ public class MediaCapture extends Plugin {
 
         // if audio is not being recorded, start audio capture
         if (!AudioControl.hasAudioRecorderApplication()) {
-            Logger.log(this.getClass().getName()
-                    + ": Audio recorder application is not installed.");
-            result = new PluginResult(PluginResult.Status.ERROR,
-                    CAPTURE_NOT_SUPPORTED);
-        }
-        else if (AudioControl.isAudioRecorderActive()) {
-            Logger.log(this.getClass().getName()
-                    + ": Audio recorder application is busy.");
-            result = new PluginResult(PluginResult.Status.ERROR,
-                    CAPTURE_APPLICATION_BUSY);
+            result = errorResult(CAPTURE_NOT_SUPPORTED,
+                    "Audio recorder application is not installed.");
+        } else if (AudioControl.isAudioRecorderActive()) {
+            result = errorResult(CAPTURE_APPLICATION_BUSY,
+                    "Audio recorder application is busy.");
         }
         else {
             // optional parameters
-            int limit = args.optInt(0, 1);
-            long duration = args.optLong(1, 0);
+            long limit = 1;
+            double duration = 0.0f;
+
+            try {
+                JSONObject options = args.getJSONObject(0);
+                if (options != null) {
+                    limit = options.optLong("limit", 1);
+                    duration = options.optDouble("duration", 0.0f);
+                }
+            } catch (JSONException e) {
+                // Eat it and use default value of 1.
+                Logger.log(this.getClass().getName()
+                        + ": Invalid captureAudio options format. " + e.getMessage());
+            }
 
             // start audio capture
             // start capture operation in the background
@@ -347,14 +347,23 @@ public class MediaCapture extends Plugin {
         PluginResult result = null;
 
         if (CameraControl.isCameraActive()) {
-            Logger.log(this.getClass().getName()
-                    + ": Camera application is busy.");
-            result = new PluginResult(PluginResult.Status.ERROR,
-                    CAPTURE_APPLICATION_BUSY);
+            result = errorResult(CAPTURE_APPLICATION_BUSY,
+                    "Camera application is busy.");
         }
         else {
             // optional parameters
-            int limit = args.optInt(0, 1);
+            long limit = 1;
+
+            try {
+                JSONObject options = args.getJSONObject(0);
+                if (options != null) {
+                    limit = options.optLong("limit", 1);
+                }
+            } catch (JSONException e) {
+                // Eat it and use default value of 1.
+                Logger.log(this.getClass().getName()
+                        + ": Invalid captureImage options format. " + e.getMessage());
+            }
 
             // start capture operation in the background
             CaptureControl.getCaptureControl().startImageCaptureOperation(
@@ -384,20 +393,26 @@ public class MediaCapture extends Plugin {
         PluginResult result = null;
 
         if (!isVideoCaptureSupported()) {
-            Logger.log(this.getClass().getName()
-                    + ": Video capture is not supported.");
-            result = new PluginResult(PluginResult.Status.ERROR,
-                    CAPTURE_NOT_SUPPORTED);
-        }
-        else if (CameraControl.isVideoRecorderActive()) {
-            Logger.log(this.getClass().getName()
-                    + ": Video recorder application is busy.");
-            result = new PluginResult(PluginResult.Status.ERROR,
-                    CAPTURE_APPLICATION_BUSY);
+            result = errorResult(CAPTURE_NOT_SUPPORTED,
+                    "Video capture is not supported.");
+        } else if (CameraControl.isVideoRecorderActive()) {
+            result = errorResult(CAPTURE_APPLICATION_BUSY,
+                    "Video recorder application is busy.");
         }
         else {
             // optional parameters
-            int limit = args.optInt(0, 1);
+            long limit = 1;
+
+            try {
+                JSONObject options = args.getJSONObject(0);
+                if (options != null) {
+                    limit = options.optLong("limit", 1);
+                }
+            } catch (JSONException e) {
+                // Eat it and use default value of 1.
+                Logger.log(this.getClass().getName()
+                        + ": Invalid captureVideo options format. " + e.getMessage());
+            }
 
             // start capture operation in the background
             CaptureControl.getCaptureControl().startVideoCaptureOperation(
@@ -430,7 +445,7 @@ public class MediaCapture extends Plugin {
         }
 
         // invoke the appropriate callback
-        result = new PluginResult(PluginResult.Status.OK, array.toString());
+        result = new PluginResult(PluginResult.Status.OK, array);
         success(result, callbackId);
     }
 
@@ -441,8 +456,7 @@ public class MediaCapture extends Plugin {
      *            the callback to receive the error
      */
     public static void captureError(String callbackId) {
-        error(new PluginResult(PluginResult.Status.ERROR,
-                CAPTURE_NO_MEDIA_FILES), callbackId);
+        error(errorResult(CAPTURE_NO_MEDIA_FILES, ""), callbackId);
     }
 
     /**
@@ -472,33 +486,17 @@ public class MediaCapture extends Plugin {
         CaptureControl.getCaptureControl().stopPendingOperations(true);
     }
 
-    /**
-     * Returns action to perform.
-     * @param action
-     * @return action to perform
-     */
-    protected static int getAction(String action) {
-        if ("getSupportedAudioModes".equals(action)) {
-            return ACTION_GET_SUPPORTED_AUDIO_MODES;
-        }
-        if ("getSupportedImageModes".equals(action)) {
-            return ACTION_GET_SUPPORTED_IMAGE_MODES;
-        }
-        if ("getSupportedVideoModes".equals(action)) {
-            return ACTION_GET_SUPPORTED_VIDEO_MODES;
-        }
-        if ("captureAudio".equals(action)) {
-            return ACTION_CAPTURE_AUDIO;
-        }
-        if ("captureImage".equals(action)) {
-            return ACTION_CAPTURE_IMAGE;
-        }
-        if ("captureVideo".equals(action)) {
-            return ACTION_CAPTURE_VIDEO;
-        }
-        if ("stopCaptures".equals(action)) {
-            return ACTION_CANCEL_CAPTURES;
+    private static PluginResult errorResult(int code, String message) {
+        Logger.log(LOG_TAG + message);
+
+        JSONObject obj = new JSONObject();
+        try {
+            obj.put("code", code);
+            obj.put("message", message);
+        } catch (JSONException e) {
+            // This will never happen
         }
-        return -1;
+
+        return new PluginResult(PluginResult.Status.ERROR, obj);
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/fe003534/framework/ext/src/org/apache/cordova/media/VideoCaptureOperation.java
----------------------------------------------------------------------
diff --git a/framework/ext/src/org/apache/cordova/media/VideoCaptureOperation.java b/framework/ext/src/org/apache/cordova/media/VideoCaptureOperation.java
index e671585..1a07d05 100644
--- a/framework/ext/src/org/apache/cordova/media/VideoCaptureOperation.java
+++ b/framework/ext/src/org/apache/cordova/media/VideoCaptureOperation.java
@@ -48,7 +48,7 @@ public class VideoCaptureOperation extends CaptureOperation {
      * @param queue
      *            the queue from which to retrieve captured media files
      */
-    public VideoCaptureOperation(int limit, String callbackId, MediaQueue queue) {
+    public VideoCaptureOperation(long limit, String callbackId, MediaQueue queue) {
         super(limit, callbackId, queue);
 
         // listener to capture image files added to file system

http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/fe003534/template/project/www/plugins.xml
----------------------------------------------------------------------
diff --git a/template/project/www/plugins.xml b/template/project/www/plugins.xml
index 41772da..d6e201f 100644
--- a/template/project/www/plugins.xml
+++ b/template/project/www/plugins.xml
@@ -10,6 +10,6 @@
   <plugin name="File"           value="org.apache.cordova.file.FileManager"/>
   <plugin name="FileTransfer"   value="org.apache.cordova.http.FileTransfer"/>
   <plugin name="Contact"        value="org.apache.cordova.pim.Contact"/>
-  <plugin name="MediaCapture"   value="org.apache.cordova.media.MediaCapture"/>
+  <plugin name="Capture"        value="org.apache.cordova.media.MediaCapture"/>
   <plugin name="Battery"        value="org.apache.cordova.battery.Battery"/>
 </plugins>


Mime
View raw message