Merge "MediaMuxer: throw exception if create() fails for muxer" am: f9a1e3c913
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1842097 Change-Id: I1f93532420a3409f2213f12e212efecefd35ba5f Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -335,13 +335,13 @@ final public class MediaMuxer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
|
||||||
* Creates a media muxer that writes to the specified path.
|
* Creates a media muxer that writes to the specified path.
|
||||||
|
* <p>The caller must not use the file {@code path} before calling {@link #stop}.
|
||||||
* @param path The path of the output media file.
|
* @param path The path of the output media file.
|
||||||
* @param format The format of the output media file.
|
* @param format The format of the output media file.
|
||||||
* @see android.media.MediaMuxer.OutputFormat
|
* @see android.media.MediaMuxer.OutputFormat
|
||||||
* @throws IllegalArgumentException if path is invalid or format is not supported.
|
* @throws IllegalArgumentException if path is invalid or format is not supported.
|
||||||
* @throws IOException if failed to open the file for write.
|
* @throws IOException if an error occurs while opening or creating the output file.
|
||||||
*/
|
*/
|
||||||
public MediaMuxer(@NonNull String path, @Format int format) throws IOException {
|
public MediaMuxer(@NonNull String path, @Format int format) throws IOException {
|
||||||
if (path == null) {
|
if (path == null) {
|
||||||
@@ -363,16 +363,19 @@ final public class MediaMuxer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Creates a media muxer that writes to the specified FileDescriptor.
|
||||||
* Creates a media muxer that writes to the specified FileDescriptor. File descriptor
|
* <p>The caller must not use the file referenced by the specified {@code fd} before calling
|
||||||
* must be seekable and writable. Application should not use the file referenced
|
* {@link #stop}.
|
||||||
* by this file descriptor until {@link #stop}. It is the application's responsibility
|
* <p>It is the caller's responsibility to close the file descriptor, which is safe to do so
|
||||||
* to close the file descriptor. It is safe to do so as soon as this call returns.
|
* as soon as this call returns.
|
||||||
* @param fd The FileDescriptor of the output media file.
|
* @param fd The FileDescriptor of the output media file. If {@code format} is
|
||||||
|
* {@link OutputFormat#MUXER_OUTPUT_WEBM}, {@code fd} must be open in read-write mode.
|
||||||
|
* Otherwise, write mode is sufficient, but read-write is also accepted.
|
||||||
* @param format The format of the output media file.
|
* @param format The format of the output media file.
|
||||||
* @see android.media.MediaMuxer.OutputFormat
|
* @see android.media.MediaMuxer.OutputFormat
|
||||||
* @throws IllegalArgumentException if fd is invalid or format is not supported.
|
* @throws IllegalArgumentException if {@code format} is not supported, or if {@code fd} is
|
||||||
* @throws IOException if failed to open the file for write.
|
* not open in the expected mode.
|
||||||
|
* @throws IOException if an error occurs while performing an IO operation.
|
||||||
*/
|
*/
|
||||||
public MediaMuxer(@NonNull FileDescriptor fd, @Format int format) throws IOException {
|
public MediaMuxer(@NonNull FileDescriptor fd, @Format int format) throws IOException {
|
||||||
setUpMediaMuxer(fd, format);
|
setUpMediaMuxer(fd, format);
|
||||||
|
|||||||
@@ -165,7 +165,11 @@ static jlong android_media_MediaMuxer_native_setup(
|
|||||||
|
|
||||||
MediaMuxer::OutputFormat fileFormat =
|
MediaMuxer::OutputFormat fileFormat =
|
||||||
static_cast<MediaMuxer::OutputFormat>(format);
|
static_cast<MediaMuxer::OutputFormat>(format);
|
||||||
sp<MediaMuxer> muxer = new MediaMuxer(fd, fileFormat);
|
sp<MediaMuxer> muxer = MediaMuxer::create(fd, fileFormat);
|
||||||
|
if (muxer == nullptr) {
|
||||||
|
jniThrowException(env, "java/lang/IllegalArgumentException", "Muxer creation failed");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
muxer->incStrong(clazz);
|
muxer->incStrong(clazz);
|
||||||
return reinterpret_cast<jlong>(muxer.get());
|
return reinterpret_cast<jlong>(muxer.get());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user