summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Shih <robertshih@google.com>2014-03-10 19:02:34 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-03-10 19:02:34 +0000
commitf0768d71bdba1db5bf70fbe9aa587ae7e652df21 (patch)
tree0e7d5d922e407ab801edb25b101e81f389b6527e
parent02c7f9582b78c6150da7470ce68bbdcdb7635d56 (diff)
parent1797dc93fb203762eecbc9c026b77263e4e4a4f5 (diff)
downloadframeworks_base-f0768d71bdba1db5bf70fbe9aa587ae7e652df21.zip
frameworks_base-f0768d71bdba1db5bf70fbe9aa587ae7e652df21.tar.gz
frameworks_base-f0768d71bdba1db5bf70fbe9aa587ae7e652df21.tar.bz2
Merge "MediaMuxer: added WebM filetype; open output file RW."
-rw-r--r--api/current.txt1
-rw-r--r--media/java/android/media/MediaMuxer.java21
2 files changed, 12 insertions, 10 deletions
diff --git a/api/current.txt b/api/current.txt
index 9d87336..62154b8 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -13422,6 +13422,7 @@ package android.media {
public static final class MediaMuxer.OutputFormat {
field public static final int MUXER_OUTPUT_MPEG_4 = 0; // 0x0
+ field public static final int MUXER_OUTPUT_WEBM = 1; // 0x1
}
public class MediaPlayer {
diff --git a/media/java/android/media/MediaMuxer.java b/media/java/android/media/MediaMuxer.java
index e5c97e7..f518ab2 100644
--- a/media/java/android/media/MediaMuxer.java
+++ b/media/java/android/media/MediaMuxer.java
@@ -17,13 +17,11 @@
package android.media;
import android.media.MediaCodec.BufferInfo;
-
import dalvik.system.CloseGuard;
-import java.io.File;
import java.io.FileDescriptor;
-import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.util.Map;
@@ -79,6 +77,7 @@ final public class MediaMuxer {
private OutputFormat() {}
/** MPEG4 media file format*/
public static final int MUXER_OUTPUT_MPEG_4 = 0;
+ public static final int MUXER_OUTPUT_WEBM = 1;
};
// All the native functions are listed here.
@@ -120,20 +119,22 @@ final public class MediaMuxer {
if (path == null) {
throw new IllegalArgumentException("path must not be null");
}
- if (format != OutputFormat.MUXER_OUTPUT_MPEG_4) {
+ if (format != OutputFormat.MUXER_OUTPUT_MPEG_4 &&
+ format != OutputFormat.MUXER_OUTPUT_WEBM) {
throw new IllegalArgumentException("format is invalid");
}
- FileOutputStream fos = null;
+ // Use RandomAccessFile so we can open the file with RW access;
+ // RW access allows the native writer to memory map the output file.
+ RandomAccessFile file = null;
try {
- File file = new File(path);
- fos = new FileOutputStream(file);
- FileDescriptor fd = fos.getFD();
+ file = new RandomAccessFile(path, "rws");
+ FileDescriptor fd = file.getFD();
mNativeObject = nativeSetup(fd, format);
mState = MUXER_STATE_INITIALIZED;
mCloseGuard.open("release");
} finally {
- if (fos != null) {
- fos.close();
+ if (file != null) {
+ file.close();
}
}
}