diff options
author | Yuichi Araki <yaraki@google.com> | 2016-09-28 15:55:16 +0900 |
---|---|---|
committer | Yuichi Araki <yaraki@google.com> | 2016-09-29 13:41:40 +0900 |
commit | 1d8dd86182dc050b4efd352fd95a02fd8da87505 (patch) | |
tree | 364d3188d14851cf51edec997178c91097483a6d /common | |
parent | 3879041fb93e3a9e2fcc68f0407b412ac8b3838c (diff) | |
download | android-1d8dd86182dc050b4efd352fd95a02fd8da87505.tar.gz |
Media samples fixit
Fix lint errors in some media samples.
Change-Id: I00708b09d93388656926229e6b1065f4ca6c4210
Diffstat (limited to 'common')
-rw-r--r-- | common/src/java/com/example/android/common/media/CameraHelper.java | 3 | ||||
-rw-r--r-- | common/src/java/com/example/android/common/media/MediaCodecWrapper.java | 28 |
2 files changed, 11 insertions, 20 deletions
diff --git a/common/src/java/com/example/android/common/media/CameraHelper.java b/common/src/java/com/example/android/common/media/CameraHelper.java index b578767d..daf9fc5a 100644 --- a/common/src/java/com/example/android/common/media/CameraHelper.java +++ b/common/src/java/com/example/android/common/media/CameraHelper.java @@ -26,6 +26,7 @@ import java.io.File; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; +import java.util.Locale; /** * Camera related utilities. @@ -172,7 +173,7 @@ public class CameraHelper { } // Create a media file name - String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); + String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US).format(new Date()); File mediaFile; if (type == MEDIA_TYPE_IMAGE){ mediaFile = new File(mediaStorageDir.getPath() + File.separator + diff --git a/common/src/java/com/example/android/common/media/MediaCodecWrapper.java b/common/src/java/com/example/android/common/media/MediaCodecWrapper.java index a4833740..5b69079f 100644 --- a/common/src/java/com/example/android/common/media/MediaCodecWrapper.java +++ b/common/src/java/com/example/android/common/media/MediaCodecWrapper.java @@ -24,6 +24,7 @@ import android.view.Surface; import java.io.IOException; import java.nio.ByteBuffer; import java.util.ArrayDeque; +import java.util.Locale; import java.util.Queue; /** @@ -74,17 +75,14 @@ public class MediaCodecWrapper { // is valid if and only if its index is currently contained in mAvailableOutputBuffers. private MediaCodec.BufferInfo[] mOutputBufferInfo; - // An (optional) stream that will receive decoded data. - private OutputSampleListener mOutputSampleListener; - private MediaCodecWrapper(MediaCodec codec) { mDecoder = codec; codec.start(); mInputBuffers = codec.getInputBuffers(); mOutputBuffers = codec.getOutputBuffers(); mOutputBufferInfo = new MediaCodec.BufferInfo[mOutputBuffers.length]; - mAvailableInputBuffers = new ArrayDeque<Integer>(mOutputBuffers.length); - mAvailableOutputBuffers = new ArrayDeque<Integer>(mInputBuffers.length); + mAvailableInputBuffers = new ArrayDeque<>(mOutputBuffers.length); + mAvailableOutputBuffers = new ArrayDeque<>(mInputBuffers.length); } /** @@ -115,10 +113,9 @@ public class MediaCodecWrapper { // Making sure we don't block ourselves due to a bad implementation of the callback by // using a handler provided by client. - Looper looper; mHandler = handler; if (outputFormatChangedListener != null && mHandler == null) { - if ((looper = Looper.myLooper()) != null) { + if (Looper.myLooper() != null) { mHandler = new Handler(); } else { throw new IllegalArgumentException( @@ -197,7 +194,7 @@ public class MediaCodecWrapper { // we can't write our sample to a lesser capacity input buffer. if (size > buffer.capacity()) { - throw new MediaCodecWrapper.WriteException(String.format( + throw new MediaCodecWrapper.WriteException(String.format(Locale.US, "Insufficient capacity in MediaCodec buffer: " + "tried to write %d, buffer capacity is %d.", input.remaining(), @@ -219,7 +216,7 @@ public class MediaCodecWrapper { return result; } - static MediaCodec.CryptoInfo cryptoInfo= new MediaCodec.CryptoInfo(); + private static MediaCodec.CryptoInfo sCryptoInfo = new MediaCodec.CryptoInfo(); /** * Write a media sample to the decoder. @@ -244,7 +241,6 @@ public class MediaCodecWrapper { final long presentationTimeUs, int flags) { boolean result = false; - boolean isEos = false; if (!mAvailableInputBuffers.isEmpty()) { int index = mAvailableInputBuffers.remove(); @@ -261,8 +257,8 @@ public class MediaCodecWrapper { if (!isSecure) { mDecoder.queueInputBuffer(index, 0, size, presentationTimeUs, flags); } else { - extractor.getSampleCryptoInfo(cryptoInfo); - mDecoder.queueSecureInputBuffer(index, 0, cryptoInfo, presentationTimeUs, flags); + extractor.getSampleCryptoInfo(sCryptoInfo); + mDecoder.queueSecureInputBuffer(index, 0, sCryptoInfo, presentationTimeUs, flags); } result = true; @@ -311,12 +307,6 @@ public class MediaCodecWrapper { if (!mAvailableOutputBuffers.isEmpty()) { int index = mAvailableOutputBuffers.remove(); - if (render && mOutputSampleListener != null) { - ByteBuffer buffer = mOutputBuffers[index]; - MediaCodec.BufferInfo info = mOutputBufferInfo[index]; - mOutputSampleListener.outputSample(this, info, buffer); - } - // releases the buffer back to the codec mDecoder.releaseOutputBuffer(index, render); } @@ -365,7 +355,7 @@ public class MediaCodecWrapper { // handled INFO_TRY_AGAIN_LATER, INFO_OUTPUT_FORMAT_CHANGED & // INFO_OUTPUT_BUFFERS_CHANGED i.e all the other possible return codes but // asserting index value anyways for future-proofing the code. - if(index >= 0) { + if (index >= 0) { mOutputBufferInfo[index] = info; mAvailableOutputBuffers.add(index); } else { |