Skip to content

Commit

Permalink
Merge pull request google#6542 from google/dev-v2-r2.10.6
Browse files Browse the repository at this point in the history
r2.10.6
  • Loading branch information
ojw28 authored Oct 18, 2019
2 parents 176d211 + 2671ff0 commit 41b3fc1
Show file tree
Hide file tree
Showing 62 changed files with 989 additions and 345 deletions.
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,3 @@ extensions/cronet/jniLibs/*
!extensions/cronet/jniLibs/README.md
extensions/cronet/libs/*
!extensions/cronet/libs/README.md

# Cast receiver
cast_receiver_app/external-js
cast_receiver_app/bazel-cast_receiver_app
7 changes: 2 additions & 5 deletions .hgignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ libs
obj
lint.xml

# IntelliJ IDEA
# IntelliJ IDEA & Android Studio
.idea
*.iml
*.ipr
*.iws
classes
gen-external-apklibs
*.li

# Eclipse
.project
Expand Down Expand Up @@ -75,7 +76,3 @@ extensions/cronet/jniLibs/*
!extensions/cronet/jniLibs/README.md
extensions/cronet/libs/*
!extensions/cronet/libs/README.md

# Cast receiver
cast_receiver_app/external-js
cast_receiver_app/bazel-cast_receiver_app
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ branch:

```sh
git clone https://github.com/google/ExoPlayer.git
cd ExoPlayer
git checkout release-v2
```

Expand Down
27 changes: 27 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
# Release notes #

### 2.10.6 (2019-10-18) ###

* Add `Player.onPlaybackSuppressionReasonChanged` to allow listeners to
detect playbacks suppressions (e.g. transient audio focus loss) directly
([#6203](https://github.com/google/ExoPlayer/issues/6203)).
* DASH:
* Support `Label` elements
([#6297](https://github.com/google/ExoPlayer/issues/6297)).
* Support legacy audio channel configuration
([#6523](https://github.com/google/ExoPlayer/issues/6523)).
* HLS: Add support for ID3 in EMSG when using FMP4 streams
([spec](https://aomediacodec.github.io/av1-id3/)).
* MP3: Add workaround to avoid prematurely ending playback of some SHOUTcast
live streams ([#6537](https://github.com/google/ExoPlayer/issues/6537),
[#6315](https://github.com/google/ExoPlayer/issues/6315) and
[#5658](https://github.com/google/ExoPlayer/issues/5658)).
* Metadata: Expose the raw ICY metadata through `IcyInfo`
([#6476](https://github.com/google/ExoPlayer/issues/6476)).
* UI:
* Setting `app:played_color` on `PlayerView` and `PlayerControlView` no longer
adjusts the colors of the scrubber handle , buffered and unplayed parts of
the time bar. These can be set separately using `app:scrubber_color`,
`app:buffered_color` and `app_unplayed_color` respectively.
* Setting `app:ad_marker_color` on `PlayerView` and `PlayerControlView` no
longer adjusts the color of played ad markers. The color of played ad
markers can be set separately using `app:played_ad_marker_color`.

### 2.10.5 (2019-09-20) ###

* Add `Player.isPlaying` and `EventListener.onIsPlayingChanged` to check whether
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
classpath 'com.novoda:bintray-release:0.9'
classpath 'com.google.android.gms:strict-version-matcher-plugin:1.1.0'
classpath 'com.android.tools.build:gradle:3.5.1'
classpath 'com.novoda:bintray-release:0.9.1'
classpath 'com.google.android.gms:strict-version-matcher-plugin:1.2.0'
}
}
allprojects {
Expand Down
4 changes: 2 additions & 2 deletions constants.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
// limitations under the License.
project.ext {
// ExoPlayer version and version code.
releaseVersion = '2.10.5'
releaseVersionCode = 2010005
releaseVersion = '2.10.6'
releaseVersionCode = 2010006
minSdkVersion = 16
targetSdkVersion = 28
compileSdkVersion = 28
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.google.android.exoplayer2.BasePlayer;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.ExoPlayerLibraryInfo;
import com.google.android.exoplayer2.PlaybackParameters;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Timeline;
Expand Down Expand Up @@ -67,6 +68,10 @@
*/
public final class CastPlayer extends BasePlayer {

static {
ExoPlayerLibraryInfo.registerModule("goog.exo.cast");
}

private static final String TAG = "CastPlayer";

private static final int RENDERER_COUNT = 3;
Expand Down
7 changes: 3 additions & 4 deletions extensions/ffmpeg/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ follows:

```
cd "<path to exoplayer checkout>"
EXOPLAYER_ROOT="$(pwd)"
FFMPEG_EXT_PATH="${EXOPLAYER_ROOT}/extensions/ffmpeg/src/main"
FFMPEG_EXT_PATH="$(pwd)/extensions/ffmpeg/src/main/jni"
```

* Download the [Android NDK][] and set its location in an environment variable.
Expand Down Expand Up @@ -69,7 +68,7 @@ COMMON_OPTIONS="\
--enable-decoder=opus \
--enable-decoder=flac \
" && \
cd "${FFMPEG_EXT_PATH}/jni" && \
cd "${FFMPEG_EXT_PATH}" && \
(git -C ffmpeg pull || git clone git://source.ffmpeg.org/ffmpeg ffmpeg) && \
cd ffmpeg && git checkout release/4.0 && \
./configure \
Expand Down Expand Up @@ -112,7 +111,7 @@ make clean
built in the previous step. For example:

```
cd "${FFMPEG_EXT_PATH}"/jni && \
cd "${FFMPEG_EXT_PATH}" && \
${NDK_PATH}/ndk-build APP_ABI="armeabi-v7a arm64-v8a x86" -j4
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ParserException;
import com.google.android.exoplayer2.extractor.ExtractorInput;
import com.google.android.exoplayer2.extractor.SeekMap;
import com.google.android.exoplayer2.extractor.SeekPoint;
import com.google.android.exoplayer2.util.FlacStreamMetadata;
import com.google.android.exoplayer2.util.Util;
import java.io.IOException;
Expand Down Expand Up @@ -216,15 +218,25 @@ public long getNextFrameFirstSampleIndex() {
}

/**
* Maps a seek position in microseconds to a corresponding position (byte offset) in the flac
* Maps a seek position in microseconds to the corresponding {@link SeekMap.SeekPoints} in the
* stream.
*
* @param timeUs A seek position in microseconds.
* @return The corresponding position (byte offset) in the flac stream or -1 if the stream doesn't
* have a seek table.
* @return The corresponding {@link SeekMap.SeekPoints} obtained from the seek table, or {@code
* null} if the stream doesn't have a seek table.
*/
public long getSeekPosition(long timeUs) {
return flacGetSeekPosition(nativeDecoderContext, timeUs);
@Nullable
public SeekMap.SeekPoints getSeekPoints(long timeUs) {
long[] seekPoints = new long[4];
if (!flacGetSeekPoints(nativeDecoderContext, timeUs, seekPoints)) {
return null;
}
SeekPoint firstSeekPoint = new SeekPoint(seekPoints[0], seekPoints[1]);
SeekPoint secondSeekPoint =
seekPoints[2] == seekPoints[0]
? firstSeekPoint
: new SeekPoint(seekPoints[2], seekPoints[3]);
return new SeekMap.SeekPoints(firstSeekPoint, secondSeekPoint);
}

public String getStateString() {
Expand Down Expand Up @@ -283,7 +295,7 @@ private native int flacDecodeToArray(long context, byte[] outputArray)

private native long flacGetNextFrameFirstSampleIndex(long context);

private native long flacGetSeekPosition(long context, long timeUs);
private native boolean flacGetSeekPoints(long context, long timeUs, long[] outSeekPoints);

private native String flacGetStateString(long context);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,10 @@ private static FlacBinarySearchSeeker outputSeekMap(
FlacStreamMetadata streamMetadata,
long streamLength,
ExtractorOutput output) {
boolean hasSeekTable = decoderJni.getSeekPosition(/* timeUs= */ 0) != -1;
boolean haveSeekTable = decoderJni.getSeekPoints(/* timeUs= */ 0) != null;
FlacBinarySearchSeeker binarySearchSeeker = null;
SeekMap seekMap;
if (hasSeekTable) {
if (haveSeekTable) {
seekMap = new FlacSeekMap(streamMetadata.durationUs(), decoderJni);
} else if (streamLength != C.LENGTH_UNSET) {
long firstFramePosition = decoderJni.getDecodePosition();
Expand Down Expand Up @@ -341,8 +341,8 @@ public boolean isSeekable() {

@Override
public SeekPoints getSeekPoints(long timeUs) {
// TODO: Access the seek table via JNI to return two seek points when appropriate.
return new SeekPoints(new SeekPoint(timeUs, decoderJni.getSeekPosition(timeUs)));
@Nullable SeekPoints seekPoints = decoderJni.getSeekPoints(timeUs);
return seekPoints == null ? new SeekPoints(SeekPoint.START) : seekPoints;
}

@Override
Expand Down
13 changes: 9 additions & 4 deletions extensions/flac/src/main/jni/flac_jni.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <android/log.h>
#include <jni.h>

#include <array>
#include <cstdlib>
#include <cstring>

Expand Down Expand Up @@ -46,7 +47,6 @@ class JavaDataSource : public DataSource {
if (mid == NULL) {
jclass cls = env->GetObjectClass(flacDecoderJni);
mid = env->GetMethodID(cls, "read", "(Ljava/nio/ByteBuffer;)I");
env->DeleteLocalRef(cls);
}
}

Expand All @@ -57,7 +57,6 @@ class JavaDataSource : public DataSource {
// Exception is thrown in Java when returning from the native call.
result = -1;
}
env->DeleteLocalRef(byteBuffer);
return result;
}

Expand Down Expand Up @@ -200,9 +199,15 @@ DECODER_FUNC(jlong, flacGetNextFrameFirstSampleIndex, jlong jContext) {
return context->parser->getNextFrameFirstSampleIndex();
}

DECODER_FUNC(jlong, flacGetSeekPosition, jlong jContext, jlong timeUs) {
DECODER_FUNC(jboolean, flacGetSeekPoints, jlong jContext, jlong timeUs,
jlongArray outSeekPoints) {
Context *context = reinterpret_cast<Context *>(jContext);
return context->parser->getSeekPosition(timeUs);
std::array<int64_t, 4> result;
bool success = context->parser->getSeekPositions(timeUs, result);
if (success) {
env->SetLongArrayRegion(outSeekPoints, 0, result.size(), result.data());
}
return success;
}

DECODER_FUNC(jstring, flacGetStateString, jlong jContext) {
Expand Down
39 changes: 29 additions & 10 deletions extensions/flac/src/main/jni/flac_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -438,22 +438,41 @@ size_t FLACParser::readBuffer(void *output, size_t output_size) {
return bufferSize;
}

int64_t FLACParser::getSeekPosition(int64_t timeUs) {
bool FLACParser::getSeekPositions(int64_t timeUs,
std::array<int64_t, 4> &result) {
if (!mSeekTable) {
return -1;
return false;
}

int64_t sample = (timeUs * getSampleRate()) / 1000000LL;
if (sample >= getTotalSamples()) {
sample = getTotalSamples();
unsigned sampleRate = getSampleRate();
int64_t totalSamples = getTotalSamples();
int64_t targetSampleNumber = (timeUs * sampleRate) / 1000000LL;
if (targetSampleNumber >= totalSamples) {
targetSampleNumber = totalSamples - 1;
}

FLAC__StreamMetadata_SeekPoint* points = mSeekTable->points;
for (unsigned i = mSeekTable->num_points; i > 0; ) {
i--;
if (points[i].sample_number <= sample) {
return firstFrameOffset + points[i].stream_offset;
unsigned length = mSeekTable->num_points;

for (unsigned i = length; i != 0; i--) {
int64_t sampleNumber = points[i - 1].sample_number;
if (sampleNumber <= targetSampleNumber) {
result[0] = (sampleNumber * 1000000LL) / sampleRate;
result[1] = firstFrameOffset + points[i - 1].stream_offset;
if (sampleNumber == targetSampleNumber || i >= length) {
// exact seek, or no following seek point.
result[2] = result[0];
result[3] = result[1];
} else {
result[2] = (points[i].sample_number * 1000000LL) / sampleRate;
result[3] = firstFrameOffset + points[i].stream_offset;
}
return true;
}
}
return firstFrameOffset;
result[0] = 0;
result[1] = firstFrameOffset;
result[2] = 0;
result[3] = firstFrameOffset;
return true;
}
3 changes: 2 additions & 1 deletion extensions/flac/src/main/jni/include/flac_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include <stdint.h>

#include <array>
#include <cstdlib>
#include <string>
#include <vector>
Expand Down Expand Up @@ -82,7 +83,7 @@ class FLACParser {
bool decodeMetadata();
size_t readBuffer(void *output, size_t output_size);

int64_t getSeekPosition(int64_t timeUs);
bool getSeekPositions(int64_t timeUs, std::array<int64_t, 4> &result);

void flush() {
reset(mCurrentPos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -868,26 +868,27 @@ private boolean canDispatchMediaButtonEvent() {

private void rewind(Player player) {
if (player.isCurrentWindowSeekable() && rewindMs > 0) {
seekTo(player, player.getCurrentPosition() - rewindMs);
seekToOffset(player, /* offsetMs= */ -rewindMs);
}
}

private void fastForward(Player player) {
if (player.isCurrentWindowSeekable() && fastForwardMs > 0) {
seekTo(player, player.getCurrentPosition() + fastForwardMs);
seekToOffset(player, /* offsetMs= */ fastForwardMs);
}
}

private void seekTo(Player player, long positionMs) {
seekTo(player, player.getCurrentWindowIndex(), positionMs);
}

private void seekTo(Player player, int windowIndex, long positionMs) {
private void seekToOffset(Player player, long offsetMs) {
long positionMs = player.getCurrentPosition() + offsetMs;
long durationMs = player.getDuration();
if (durationMs != C.TIME_UNSET) {
positionMs = Math.min(positionMs, durationMs);
}
positionMs = Math.max(positionMs, 0);
seekTo(player, player.getCurrentWindowIndex(), positionMs);
}

private void seekTo(Player player, int windowIndex, long positionMs) {
controlDispatcher.dispatchSeekTo(player, windowIndex, positionMs);
}

Expand Down Expand Up @@ -1096,7 +1097,7 @@ public void onPlay() {
playbackPreparer.onPrepare(/* playWhenReady= */ true);
}
} else if (player.getPlaybackState() == Player.STATE_ENDED) {
controlDispatcher.dispatchSeekTo(player, player.getCurrentWindowIndex(), C.TIME_UNSET);
seekTo(player, player.getCurrentWindowIndex(), C.TIME_UNSET);
}
controlDispatcher.dispatchSetPlayWhenReady(
Assertions.checkNotNull(player), /* playWhenReady= */ true);
Expand All @@ -1113,7 +1114,7 @@ public void onPause() {
@Override
public void onSeekTo(long positionMs) {
if (canDispatchPlaybackAction(PlaybackStateCompat.ACTION_SEEK_TO)) {
seekTo(player, positionMs);
seekTo(player, player.getCurrentWindowIndex(), positionMs);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public RtmpDataSourceFactory(@Nullable TransferListener listener) {
}

@Override
public DataSource createDataSource() {
public RtmpDataSource createDataSource() {
RtmpDataSource dataSource = new RtmpDataSource();
if (listener != null) {
dataSource.addTransferListener(listener);
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Thu Apr 25 13:15:25 BST 2019
#Mon Oct 07 17:24:00 BST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
Loading

0 comments on commit 41b3fc1

Please sign in to comment.