Merge "MediaMuxer: added WebM filetype; open output file RW."
This commit is contained in:
@@ -13422,6 +13422,7 @@ package android.media {
|
|||||||
|
|
||||||
public static final class MediaMuxer.OutputFormat {
|
public static final class MediaMuxer.OutputFormat {
|
||||||
field public static final int MUXER_OUTPUT_MPEG_4 = 0; // 0x0
|
field public static final int MUXER_OUTPUT_MPEG_4 = 0; // 0x0
|
||||||
|
field public static final int MUXER_OUTPUT_WEBM = 1; // 0x1
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MediaPlayer {
|
public class MediaPlayer {
|
||||||
|
|||||||
@@ -17,13 +17,11 @@
|
|||||||
package android.media;
|
package android.media;
|
||||||
|
|
||||||
import android.media.MediaCodec.BufferInfo;
|
import android.media.MediaCodec.BufferInfo;
|
||||||
|
|
||||||
import dalvik.system.CloseGuard;
|
import dalvik.system.CloseGuard;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileDescriptor;
|
import java.io.FileDescriptor;
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.RandomAccessFile;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -79,6 +77,7 @@ final public class MediaMuxer {
|
|||||||
private OutputFormat() {}
|
private OutputFormat() {}
|
||||||
/** MPEG4 media file format*/
|
/** MPEG4 media file format*/
|
||||||
public static final int MUXER_OUTPUT_MPEG_4 = 0;
|
public static final int MUXER_OUTPUT_MPEG_4 = 0;
|
||||||
|
public static final int MUXER_OUTPUT_WEBM = 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
// All the native functions are listed here.
|
// All the native functions are listed here.
|
||||||
@@ -120,20 +119,22 @@ final public class MediaMuxer {
|
|||||||
if (path == null) {
|
if (path == null) {
|
||||||
throw new IllegalArgumentException("path must not be 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");
|
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 {
|
try {
|
||||||
File file = new File(path);
|
file = new RandomAccessFile(path, "rws");
|
||||||
fos = new FileOutputStream(file);
|
FileDescriptor fd = file.getFD();
|
||||||
FileDescriptor fd = fos.getFD();
|
|
||||||
mNativeObject = nativeSetup(fd, format);
|
mNativeObject = nativeSetup(fd, format);
|
||||||
mState = MUXER_STATE_INITIALIZED;
|
mState = MUXER_STATE_INITIALIZED;
|
||||||
mCloseGuard.open("release");
|
mCloseGuard.open("release");
|
||||||
} finally {
|
} finally {
|
||||||
if (fos != null) {
|
if (file != null) {
|
||||||
fos.close();
|
file.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user