Bug 1368907 - Part2 - Rename GeckoHlsSample to GeckoHLSSample. r?jolin
MozReview-Commit-ID: 9pNf5IHzdL0
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoHLSDemuxerWrapper.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoHLSDemuxerWrapper.java
@@ -2,17 +2,16 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko.media;
import android.util.Log;
-import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.util.MimeTypes;
import java.util.concurrent.ConcurrentLinkedQueue;
import org.mozilla.gecko.annotation.WrapForJNI;
import org.mozilla.gecko.mozglue.JNIObject;
@@ -153,27 +152,27 @@ public final class GeckoHLSDemuxerWrappe
this.mPlayer.addDemuxerWrapperCallbackListener(callback);
} catch (Exception e) {
Log.e(LOGTAG, "Constructing GeckoHLSDemuxerWrapper ... error", e);
callback.onError(GeckoHlsPlayer.DemuxerError.UNKNOWN.code());
}
}
@WrapForJNI
- private GeckoHlsSample[] getSamples(int mediaType, int number) {
- ConcurrentLinkedQueue<GeckoHlsSample> samples = null;
+ private GeckoHLSSample[] getSamples(int mediaType, int number) {
+ ConcurrentLinkedQueue<GeckoHLSSample> samples = null;
// getA/VSamples will always return a non-null instance.
if (mediaType == TrackType.VIDEO.value()) {
samples = mPlayer.getVideoSamples(number);
} else if (mediaType == TrackType.AUDIO.value()) {
samples = mPlayer.getAudioSamples(number);
}
assertTrue(samples.size() <= number);
- return samples.toArray(new GeckoHlsSample[samples.size()]);
+ return samples.toArray(new GeckoHLSSample[samples.size()]);
}
@WrapForJNI
private long getNextKeyFrameTime() {
assertTrue(mPlayer != null);
return mPlayer.getNextKeyFrameTime();
}
new file mode 100644
--- /dev/null
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoHLSSample.java
@@ -0,0 +1,86 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+package org.mozilla.gecko.media;
+
+import android.media.MediaCodec;
+import android.media.MediaCodec.BufferInfo;
+import android.media.MediaCodec.CryptoInfo;
+
+import org.mozilla.gecko.annotation.WrapForJNI;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+public final class GeckoHLSSample {
+ public static final GeckoHLSSample EOS;
+ static {
+ BufferInfo eosInfo = new BufferInfo();
+ eosInfo.set(0, 0, Long.MIN_VALUE, MediaCodec.BUFFER_FLAG_END_OF_STREAM);
+ EOS = new GeckoHLSSample(null, eosInfo, null, 0);
+ }
+
+ // Indicate the index of format which is used by this sample.
+ @WrapForJNI
+ final public int formatIndex;
+
+ @WrapForJNI
+ public long duration;
+
+ @WrapForJNI
+ final public BufferInfo info;
+
+ @WrapForJNI
+ final public CryptoInfo cryptoInfo;
+
+ private ByteBuffer buffer = null;
+
+ @WrapForJNI
+ public void writeToByteBuffer(ByteBuffer dest) throws IOException {
+ if (buffer != null && dest != null && info.size > 0) {
+ dest.put(buffer);
+ }
+ }
+
+ @WrapForJNI
+ public boolean isEOS() {
+ return (info.flags & MediaCodec.BUFFER_FLAG_END_OF_STREAM) != 0;
+ }
+
+ @WrapForJNI
+ public boolean isKeyFrame() {
+ return (info.flags & MediaCodec.BUFFER_FLAG_KEY_FRAME) != 0;
+ }
+
+ public static GeckoHLSSample create(ByteBuffer src, BufferInfo info, CryptoInfo cryptoInfo,
+ int formatIndex) {
+ return new GeckoHLSSample(src, info, cryptoInfo, formatIndex);
+ }
+
+ private GeckoHLSSample(ByteBuffer buffer, BufferInfo info, CryptoInfo cryptoInfo,
+ int formatIndex) {
+ this.formatIndex = formatIndex;
+ duration = Long.MAX_VALUE;
+ this.buffer = buffer;
+ this.info = info;
+ this.cryptoInfo = cryptoInfo;
+ }
+
+ @Override
+ public String toString() {
+ if (isEOS()) {
+ return "EOS GeckoHLSSample";
+ }
+
+ StringBuilder str = new StringBuilder();
+ str.append("{ info=").
+ append("{ offset=").append(info.offset).
+ append(", size=").append(info.size).
+ append(", pts=").append(info.presentationTimeUs).
+ append(", duration=").append(duration).
+ append(", flags=").append(Integer.toHexString(info.flags)).append(" }").
+ append(" }");
+ return str.toString();
+ }
+}
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoHlsAudioRenderer.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoHlsAudioRenderer.java
@@ -2,17 +2,16 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko.media;
import android.media.MediaCodec;
import android.media.MediaCodec.BufferInfo;
import android.media.MediaCodec.CryptoInfo;
-import android.os.Handler;
import android.util.Log;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.RendererCapabilities;
import com.google.android.exoplayer2.decoder.DecoderInputBuffer;
import com.google.android.exoplayer2.mediacodec.MediaCodecInfo;
import com.google.android.exoplayer2.mediacodec.MediaCodecSelector;
@@ -104,17 +103,17 @@ public class GeckoHlsAudioRenderer exten
@Override
protected void handleFormatRead(DecoderInputBuffer bufferForRead) {
onInputFormatChanged(mFormatHolder.format);
}
@Override
protected void handleEndOfStream(DecoderInputBuffer bufferForRead) {
mInputStreamEnded = true;
- mDemuxedInputSamples.offer(GeckoHlsSample.EOS);
+ mDemuxedInputSamples.offer(GeckoHLSSample.EOS);
}
@Override
protected void handleSamplePreparation(DecoderInputBuffer bufferForRead) {
int size = bufferForRead.data.limit();
byte[] realData = new byte[size];
bufferForRead.data.get(realData, 0, size);
ByteBuffer buffer = ByteBuffer.wrap(realData);
@@ -127,17 +126,17 @@ public class GeckoHlsAudioRenderer exten
int flags = 0;
flags |= bufferForRead.isKeyFrame() ? MediaCodec.BUFFER_FLAG_KEY_FRAME : 0;
flags |= bufferForRead.isEndOfStream() ? MediaCodec.BUFFER_FLAG_END_OF_STREAM : 0;
bufferInfo.set(0, size, bufferForRead.timeUs, flags);
assertTrue(mFormats.size() >= 0);
// We add a new format in the list once format changes, so the formatIndex
// should indicate to the last(latest) format.
- GeckoHlsSample sample = GeckoHlsSample.create(buffer,
+ GeckoHLSSample sample = GeckoHLSSample.create(buffer,
bufferInfo,
cryptoInfo,
mFormats.size() - 1);
mDemuxedInputSamples.offer(sample);
if (DEBUG) {
Log.d(LOGTAG, "Demuxed sample PTS : " +
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoHlsPlayer.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoHlsPlayer.java
@@ -4,28 +4,25 @@
package org.mozilla.gecko.media;
import android.content.Context;
import android.net.Uri;
import android.os.Handler;
import android.text.TextUtils;
import android.util.Log;
-import android.view.Surface;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.ExoPlayerFactory;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.PlaybackParameters;
import com.google.android.exoplayer2.RendererCapabilities;
import com.google.android.exoplayer2.Timeline;
-import com.google.android.exoplayer2.decoder.DecoderCounters;
-import com.google.android.exoplayer2.mediacodec.MediaCodecSelector;
import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.TrackGroup;
import com.google.android.exoplayer2.source.TrackGroupArray;
import com.google.android.exoplayer2.source.hls.HlsMediaSource;
import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection;
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
import com.google.android.exoplayer2.trackselection.MappingTrackSelector.MappedTrackInfo;
import com.google.android.exoplayer2.trackselection.TrackSelection;
@@ -547,24 +544,24 @@ public class GeckoHlsPlayer implements E
public boolean isLiveStream() {
return !mIsTimelineStatic;
}
// =======================================================================
// API for GeckoHlsDemuxerWrapper
// =======================================================================
- public ConcurrentLinkedQueue<GeckoHlsSample> getVideoSamples(int number) {
+ public ConcurrentLinkedQueue<GeckoHLSSample> getVideoSamples(int number) {
return mVRenderer != null ? mVRenderer.getQueuedSamples(number) :
- new ConcurrentLinkedQueue<GeckoHlsSample>();
+ new ConcurrentLinkedQueue<GeckoHLSSample>();
}
- public ConcurrentLinkedQueue<GeckoHlsSample> getAudioSamples(int number) {
+ public ConcurrentLinkedQueue<GeckoHLSSample> getAudioSamples(int number) {
return mARenderer != null ? mARenderer.getQueuedSamples(number) :
- new ConcurrentLinkedQueue<GeckoHlsSample>();
+ new ConcurrentLinkedQueue<GeckoHLSSample>();
}
public long getDuration() {
assertTrue(mPlayer != null);
if (isLiveStream()) {
return 0L;
}
// Value returned by getDuration() is in milliseconds.
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoHlsRendererBase.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoHlsRendererBase.java
@@ -25,17 +25,17 @@ public abstract class GeckoHlsRendererBa
* GeckoHlsVideoRenderer, and we still wants to log message in the base class
* GeckoHlsRendererBase, so neither 'static' nor 'final' are applied to them.
*/
protected boolean DEBUG;
protected String LOGTAG;
// Notify GeckoHlsPlayer about renderer's status, i.e. data has arrived.
protected GeckoHlsPlayer.ComponentEventDispatcher mPlayerEventDispatcher;
- protected ConcurrentLinkedQueue<GeckoHlsSample> mDemuxedInputSamples = new ConcurrentLinkedQueue<>();
+ protected ConcurrentLinkedQueue<GeckoHLSSample> mDemuxedInputSamples = new ConcurrentLinkedQueue<>();
protected ByteBuffer mInputBuffer = null;
protected ArrayList<Format> mFormats = new ArrayList<Format>();
protected boolean mInitialized = false;
protected boolean mWaitingForData = true;
protected boolean mInputStreamEnded = false;
protected long mFirstSampleStartTime = Long.MIN_VALUE;
@@ -59,49 +59,49 @@ public abstract class GeckoHlsRendererBa
mPlayerEventDispatcher = eventDispatcher;
}
private boolean isQueuedEnoughData() {
if (mDemuxedInputSamples.isEmpty()) {
return false;
}
- Iterator<GeckoHlsSample> iter = mDemuxedInputSamples.iterator();
+ Iterator<GeckoHLSSample> iter = mDemuxedInputSamples.iterator();
long firstPTS = 0;
if (iter.hasNext()) {
- GeckoHlsSample sample = iter.next();
+ GeckoHLSSample sample = iter.next();
firstPTS = sample.info.presentationTimeUs;
}
long lastPTS = firstPTS;
while (iter.hasNext()) {
- GeckoHlsSample sample = iter.next();
+ GeckoHLSSample sample = iter.next();
lastPTS = sample.info.presentationTimeUs;
}
return Math.abs(lastPTS - firstPTS) > QUEUED_INPUT_SAMPLE_DURATION_THRESHOLD;
}
public Format getFormat(int index) {
assertTrue(index >= 0);
Format fmt = index < mFormats.size() ? mFormats.get(index) : null;
if (DEBUG) { Log.d(LOGTAG, "getFormat : index = " + index + ", format : " + fmt); }
return fmt;
}
public long getFirstSamplePTS() { return mFirstSampleStartTime; }
- public synchronized ConcurrentLinkedQueue<GeckoHlsSample> getQueuedSamples(int number) {
- ConcurrentLinkedQueue<GeckoHlsSample> samples =
- new ConcurrentLinkedQueue<GeckoHlsSample>();
+ public synchronized ConcurrentLinkedQueue<GeckoHLSSample> getQueuedSamples(int number) {
+ ConcurrentLinkedQueue<GeckoHLSSample> samples =
+ new ConcurrentLinkedQueue<GeckoHLSSample>();
int queuedSize = mDemuxedInputSamples.size();
for (int i = 0; i < queuedSize; i++) {
if (i >= number) {
break;
}
- GeckoHlsSample sample = mDemuxedInputSamples.poll();
+ GeckoHLSSample sample = mDemuxedInputSamples.poll();
samples.offer(sample);
}
if (samples.isEmpty()) {
if (DEBUG) { Log.d(LOGTAG, "getQueuedSamples isEmpty, mWaitingForData = true !"); }
mWaitingForData = true;
} else if (mFirstSampleStartTime == Long.MIN_VALUE) {
mFirstSampleStartTime = samples.peek().info.presentationTimeUs;
if (DEBUG) { Log.d(LOGTAG, "mFirstSampleStartTime = " + mFirstSampleStartTime); }
@@ -167,19 +167,19 @@ public abstract class GeckoHlsRendererBa
}
if (DEBUG) { Log.d(LOGTAG, "Initializing ... "); }
createInputBuffer();
mInitialized = true;
}
/*
* The place we get demuxed data from HlsMediaSource(ExoPlayer).
- * The data will then be converted to GeckoHlsSample and deliver to
+ * The data will then be converted to GeckoHLSSample and deliver to
* GeckoHlsDemuxerWrapper for further use.
- * If the return value is ture, that means a GeckoHlsSample is queued
+ * If the return value is ture, that means a GeckoHLSSample is queued
* successfully. We can try to feed more samples into queue.
* If the return value is false, that means we might encounter following
* situation 1) not initialized 2) input stream is ended 3) queue is full.
* 4) format changed. 5) exception happened.
*/
protected synchronized boolean feedInputBuffersQueue() {
if (!mInitialized || mInputStreamEnded || isQueuedEnoughData()) {
// Need to reinitialize the renderer or the input stream has ended
deleted file mode 100644
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoHlsSample.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-package org.mozilla.gecko.media;
-
-import android.media.MediaCodec;
-import android.media.MediaCodec.BufferInfo;
-import android.media.MediaCodec.CryptoInfo;
-
-import org.mozilla.gecko.annotation.WrapForJNI;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-public final class GeckoHlsSample {
- public static final GeckoHlsSample EOS;
- static {
- BufferInfo eosInfo = new BufferInfo();
- eosInfo.set(0, 0, Long.MIN_VALUE, MediaCodec.BUFFER_FLAG_END_OF_STREAM);
- EOS = new GeckoHlsSample(null, eosInfo, null, 0);
- }
-
- // Indicate the index of format which is used by this sample.
- @WrapForJNI
- final public int formatIndex;
-
- @WrapForJNI
- public long duration;
-
- @WrapForJNI
- final public BufferInfo info;
-
- @WrapForJNI
- final public CryptoInfo cryptoInfo;
-
- private ByteBuffer buffer = null;
-
- @WrapForJNI
- public void writeToByteBuffer(ByteBuffer dest) throws IOException {
- if (buffer != null && dest != null && info.size > 0) {
- dest.put(buffer);
- }
- }
-
- @WrapForJNI
- public boolean isEOS() {
- return (info.flags & MediaCodec.BUFFER_FLAG_END_OF_STREAM) != 0;
- }
-
- @WrapForJNI
- public boolean isKeyFrame() {
- return (info.flags & MediaCodec.BUFFER_FLAG_KEY_FRAME) != 0;
- }
-
- public static GeckoHlsSample create(ByteBuffer src, BufferInfo info, CryptoInfo cryptoInfo,
- int formatIndex) {
- return new GeckoHlsSample(src, info, cryptoInfo, formatIndex);
- }
-
- private GeckoHlsSample(ByteBuffer buffer, BufferInfo info, CryptoInfo cryptoInfo,
- int formatIndex) {
- this.formatIndex = formatIndex;
- duration = Long.MAX_VALUE;
- this.buffer = buffer;
- this.info = info;
- this.cryptoInfo = cryptoInfo;
- }
-
- @Override
- public String toString() {
- if (isEOS()) {
- return "EOS GeckoHlsSample";
- }
-
- StringBuilder str = new StringBuilder();
- str.append("{ info=").
- append("{ offset=").append(info.offset).
- append(", size=").append(info.size).
- append(", pts=").append(info.presentationTimeUs).
- append(", duration=").append(duration).
- append(", flags=").append(Integer.toHexString(info.flags)).append(" }").
- append(" }");
- return str.toString();
- }
-}
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoHlsVideoRenderer.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoHlsVideoRenderer.java
@@ -2,17 +2,16 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko.media;
import android.media.MediaCodec;
import android.media.MediaCodec.BufferInfo;
import android.media.MediaCodec.CryptoInfo;
-import android.os.Handler;
import android.util.Log;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.decoder.DecoderInputBuffer;
import com.google.android.exoplayer2.mediacodec.MediaCodecInfo;
import com.google.android.exoplayer2.mediacodec.MediaCodecSelector;
import com.google.android.exoplayer2.mediacodec.MediaCodecUtil;
@@ -39,17 +38,17 @@ public class GeckoHlsVideoRenderer exten
private boolean mRendererReconfigured;
private RECONFIGURATION_STATE mRendererReconfigurationState = RECONFIGURATION_STATE.NONE;
// A list of the formats which may be included in the bitstream.
private Format[] mStreamFormats;
// The max width/height/inputBufferSize for specific codec format.
private CodecMaxValues mCodecMaxValues;
// A temporary queue for samples whose duration is not calculated yet.
- private ConcurrentLinkedQueue<GeckoHlsSample> mDemuxedNoDurationSamples =
+ private ConcurrentLinkedQueue<GeckoHLSSample> mDemuxedNoDurationSamples =
new ConcurrentLinkedQueue<>();
// Contain CSD-0(SPS)/CSD-1(PPS) information (in AnnexB format) for
// prepending each keyframe. When video format changes, this information
// changes accordingly.
private byte[] mCSDInfo = null;
public GeckoHlsVideoRenderer(GeckoHlsPlayer.ComponentEventDispatcher eventDispatcher) {
@@ -194,17 +193,17 @@ public class GeckoHlsVideoRenderer exten
if (DEBUG) { Log.d(LOGTAG, "[feedInput][QUEUE_PENDING] isEndOfStream."); }
// We received a new format immediately before the end of the stream. We need to clear
// the corresponding reconfiguration data from the current buffer, but re-write it into
// a subsequent buffer if there are any (e.g. if the user seeks backwards).
bufferForRead.clear();
mRendererReconfigurationState = RECONFIGURATION_STATE.WRITE_PENDING;
}
mInputStreamEnded = true;
- GeckoHlsSample sample = GeckoHlsSample.EOS;
+ GeckoHLSSample sample = GeckoHLSSample.EOS;
calculatDuration(sample);
}
@Override
protected void handleSamplePreparation(DecoderInputBuffer bufferForRead) {
int csdInfoSize = mCSDInfo != null ? mCSDInfo.length : 0;
int dataSize = bufferForRead.data.limit();
int size = bufferForRead.isKeyFrame() ? csdInfoSize + dataSize : dataSize;
@@ -226,17 +225,17 @@ public class GeckoHlsVideoRenderer exten
int flags = 0;
flags |= bufferForRead.isKeyFrame() ? MediaCodec.BUFFER_FLAG_KEY_FRAME : 0;
flags |= bufferForRead.isEndOfStream() ? MediaCodec.BUFFER_FLAG_END_OF_STREAM : 0;
bufferInfo.set(0, size, bufferForRead.timeUs, flags);
assertTrue(mFormats.size() > 0);
// We add a new format in the list once format changes, so the formatIndex
// should indicate to the last(latest) format.
- GeckoHlsSample sample = GeckoHlsSample.create(buffer,
+ GeckoHLSSample sample = GeckoHLSSample.create(buffer,
bufferInfo,
cryptoInfo,
mFormats.size() - 1);
// There's no duration information from the ExoPlayer's sample, we need
// to calculate it.
calculatDuration(sample);
mRendererReconfigurationState = RECONFIGURATION_STATE.NONE;
@@ -294,33 +293,33 @@ public class GeckoHlsVideoRenderer exten
if (DEBUG) { Log.d(LOGTAG, "mCSDInfo [" + Utils.bytesToHex(mCSDInfo) + "]"); }
}
@Override
protected void notifyPlayerInputFormatChanged(Format newFormat) {
mPlayerEventDispatcher.onVideoInputFormatChanged(newFormat);
}
- private void calculateSamplesWithin(GeckoHlsSample[] samples, int range) {
+ private void calculateSamplesWithin(GeckoHLSSample[] samples, int range) {
// Calculate the first 'range' elements.
for (int i = 0; i < range; i++) {
// Comparing among samples in the window.
for (int j = -2; j < 14; j++) {
if (i + j >= 0 &&
i + j < range &&
samples[i + j].info.presentationTimeUs > samples[i].info.presentationTimeUs) {
samples[i].duration =
Math.min(samples[i].duration,
samples[i + j].info.presentationTimeUs - samples[i].info.presentationTimeUs);
}
}
}
}
- private void calculatDuration(GeckoHlsSample inputSample) {
+ private void calculatDuration(GeckoHLSSample inputSample) {
/*
* NOTE :
* Since we customized renderer as a demuxer. Here we're not able to
* obtain duration from the DecoderInputBuffer as there's no duration inside.
* So we calcualte it by referring to nearby samples' timestamp.
* A temporary queue |mDemuxedNoDurationSamples| is used to queue demuxed
* samples from HlsMediaSource which have no duration information at first.
* We're choosing 16 as the comparing window size, because it's commonly
@@ -335,39 +334,39 @@ public class GeckoHlsVideoRenderer exten
* here, let's say sample -2 to 13.
*/
if (inputSample != null) {
mDemuxedNoDurationSamples.offer(inputSample);
}
int sizeOfNoDura = mDemuxedNoDurationSamples.size();
// A calculation window we've ever found suitable for both HLS TS & FMP4.
int range = sizeOfNoDura >= 17 ? 17 : sizeOfNoDura;
- GeckoHlsSample[] inputArray =
- mDemuxedNoDurationSamples.toArray(new GeckoHlsSample[sizeOfNoDura]);
+ GeckoHLSSample[] inputArray =
+ mDemuxedNoDurationSamples.toArray(new GeckoHLSSample[sizeOfNoDura]);
if (range >= 17 && !mInputStreamEnded) {
calculateSamplesWithin(inputArray, range);
- GeckoHlsSample toQueue = mDemuxedNoDurationSamples.poll();
+ GeckoHLSSample toQueue = mDemuxedNoDurationSamples.poll();
mDemuxedInputSamples.offer(toQueue);
if (DEBUG) {
Log.d(LOGTAG, "Demuxed sample PTS : " +
toQueue.info.presentationTimeUs + ", duration :" +
toQueue.duration + ", isKeyFrame(" +
toQueue.isKeyFrame() + ", formatIndex(" +
toQueue.formatIndex + "), queue size : " +
mDemuxedInputSamples.size() + ", NoDuQueue size : " +
mDemuxedNoDurationSamples.size());
}
} else if (mInputStreamEnded) {
calculateSamplesWithin(inputArray, sizeOfNoDura);
// NOTE : We're not able to calculate the duration for the last sample.
// A workaround here is to assign a close duration to it.
long prevDuration = 33333;
- GeckoHlsSample sample = null;
+ GeckoHLSSample sample = null;
for (sample = mDemuxedNoDurationSamples.poll(); sample != null; sample = mDemuxedNoDurationSamples.poll()) {
if (sample.duration == Long.MAX_VALUE) {
sample.duration = prevDuration;
if (DEBUG) { Log.d(LOGTAG, "Adjust the PTS of the last sample to " + sample.duration + " (us)"); }
}
prevDuration = sample.duration;
if (DEBUG) {
Log.d(LOGTAG, "last loop to offer samples - PTS : " +
@@ -379,17 +378,17 @@ public class GeckoHlsVideoRenderer exten
}
}
// Return the time of first keyframe sample in the queue.
// If there's no key frame in the queue, return the MAX_VALUE so
// MFR won't mistake for that which the decode is getting slow.
public long getNextKeyFrameTime() {
long nextKeyFrameTime = Long.MAX_VALUE;
- for (GeckoHlsSample sample : mDemuxedInputSamples) {
+ for (GeckoHLSSample sample : mDemuxedInputSamples) {
if (sample != null &&
(sample.info.flags & MediaCodec.BUFFER_FLAG_KEY_FRAME) != 0) {
nextKeyFrameTime = sample.info.presentationTimeUs;
break;
}
}
return nextKeyFrameTime;
}