From 4662e586cd62eea85b9fd9ce977d845e37850778 Mon Sep 17 00:00:00 2001 From: olly Date: Thu, 16 Aug 2018 05:12:32 -0700 Subject: [PATCH 1/6] Add more information to unexpected assertion failure Issue: #4532 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=208968252 --- .../exoplayer2/upstream/DefaultAllocator.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/DefaultAllocator.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/DefaultAllocator.java index d9bd5873f0..06ca83dd93 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/DefaultAllocator.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/DefaultAllocator.java @@ -118,8 +118,18 @@ public final class DefaultAllocator implements Allocator { } for (Allocation allocation : allocations) { // Weak sanity check that the allocation probably originated from this pool. - Assertions.checkArgument(allocation.data == initialAllocationBlock - || allocation.data.length == individualAllocationSize); + if (allocation.data != initialAllocationBlock + && allocation.data.length != individualAllocationSize) { + throw new IllegalArgumentException( + "Unexpected allocation: " + + System.identityHashCode(allocation.data) + + ", " + + System.identityHashCode(initialAllocationBlock) + + ", " + + allocation.data.length + + ", " + + individualAllocationSize); + } availableAllocations[availableCount++] = allocation; } allocatedCount -= allocations.length; From 7572461115ed2dbd81793007df2219f49cfb5093 Mon Sep 17 00:00:00 2001 From: bachinger Date: Mon, 13 Aug 2018 12:45:26 -0700 Subject: [PATCH 2/6] adjust timestamps for cea608 and emsg in FMP4 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=208526775 --- .../extractor/mp4/FragmentedMp4Extractor.java | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/library/core/src/main/java/com/google/android/exoplayer2/extractor/mp4/FragmentedMp4Extractor.java b/library/core/src/main/java/com/google/android/exoplayer2/extractor/mp4/FragmentedMp4Extractor.java index 74181f8898..c7ec2378a1 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/extractor/mp4/FragmentedMp4Extractor.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/extractor/mp4/FragmentedMp4Extractor.java @@ -598,10 +598,13 @@ public final class FragmentedMp4Extractor implements Extractor { // Output the sample metadata. if (segmentIndexEarliestPresentationTimeUs != C.TIME_UNSET) { + long sampleTimeUs = segmentIndexEarliestPresentationTimeUs + presentationTimeDeltaUs; + if (timestampAdjuster != null) { + sampleTimeUs = timestampAdjuster.adjustSampleTimestamp(sampleTimeUs); + } for (TrackOutput emsgTrackOutput : emsgTrackOutputs) { emsgTrackOutput.sampleMetadata( - segmentIndexEarliestPresentationTimeUs + presentationTimeDeltaUs, - C.BUFFER_FLAG_KEY_FRAME, sampleSize, 0 /* offset */, null); + sampleTimeUs, C.BUFFER_FLAG_KEY_FRAME, sampleSize, /* offset= */ 0, null); } } else { // We need the first sample timestamp in the segment before we can output the metadata. @@ -1208,6 +1211,10 @@ public final class FragmentedMp4Extractor implements Extractor { Track track = currentTrackBundle.track; TrackOutput output = currentTrackBundle.output; int sampleIndex = currentTrackBundle.currentSampleIndex; + long sampleTimeUs = fragment.getSamplePresentationTime(sampleIndex) * 1000L; + if (timestampAdjuster != null) { + sampleTimeUs = timestampAdjuster.adjustSampleTimestamp(sampleTimeUs); + } if (track.nalUnitLengthFieldLength != 0) { // Zero the top three bytes of the array that we'll use to decode nal unit lengths, in case // they're only 1 or 2 bytes long. @@ -1248,8 +1255,7 @@ public final class FragmentedMp4Extractor implements Extractor { // If the format is H.265/HEVC the NAL unit header has two bytes so skip one more byte. nalBuffer.setPosition(MimeTypes.VIDEO_H265.equals(track.format.sampleMimeType) ? 1 : 0); nalBuffer.setLimit(unescapedLength); - CeaUtil.consume(fragment.getSamplePresentationTime(sampleIndex) * 1000L, nalBuffer, - cea608TrackOutputs); + CeaUtil.consume(sampleTimeUs, nalBuffer, cea608TrackOutputs); } else { // Write the payload of the NAL unit. writtenBytes = output.sampleData(input, sampleCurrentNalBytesRemaining, false); @@ -1265,11 +1271,6 @@ public final class FragmentedMp4Extractor implements Extractor { } } - long sampleTimeUs = fragment.getSamplePresentationTime(sampleIndex) * 1000L; - if (timestampAdjuster != null) { - sampleTimeUs = timestampAdjuster.adjustSampleTimestamp(sampleTimeUs); - } - @C.BufferFlags int sampleFlags = fragment.sampleIsSyncFrameTable[sampleIndex] ? C.BUFFER_FLAG_KEY_FRAME : 0; @@ -1298,10 +1299,17 @@ public final class FragmentedMp4Extractor implements Extractor { while (!pendingMetadataSampleInfos.isEmpty()) { MetadataSampleInfo sampleInfo = pendingMetadataSampleInfos.removeFirst(); pendingMetadataSampleBytes -= sampleInfo.size; + long metadataTimeUs = sampleTimeUs + sampleInfo.presentationTimeDeltaUs; + if (timestampAdjuster != null) { + metadataTimeUs = timestampAdjuster.adjustSampleTimestamp(metadataTimeUs); + } for (TrackOutput emsgTrackOutput : emsgTrackOutputs) { emsgTrackOutput.sampleMetadata( - sampleTimeUs + sampleInfo.presentationTimeDeltaUs, - C.BUFFER_FLAG_KEY_FRAME, sampleInfo.size, pendingMetadataSampleBytes, null); + metadataTimeUs, + C.BUFFER_FLAG_KEY_FRAME, + sampleInfo.size, + pendingMetadataSampleBytes, + null); } } } From e9e1c08cd262c162ae0d134b4a10c13c953706cf Mon Sep 17 00:00:00 2001 From: andrewlewis Date: Thu, 9 Aug 2018 08:55:36 -0700 Subject: [PATCH 3/6] Improve handling of consecutive empty ad groups Issue: #4030 Issue: #4280 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=208055792 --- RELEASENOTES.md | 6 ++++++ .../android/exoplayer2/ext/ima/ImaAdsLoader.java | 15 ++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index b643bacdb2..645fb3a97a 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -1,5 +1,11 @@ # Release notes # +### 2.8.4 ### + +* IMA: Improve handling of consecutive empty ad groups + ([#4030](https://github.com/google/ExoPlayer/issues/4030)), + ([#4280](https://github.com/google/ExoPlayer/issues/4280)). + ### 2.8.3 ### * IMA: diff --git a/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoader.java b/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoader.java index dc2df9eb71..15847d988a 100644 --- a/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoader.java +++ b/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoader.java @@ -619,8 +619,11 @@ public final class ImaAdsLoader extends Player.DefaultEventListener implements A } else if (fakeContentProgressElapsedRealtimeMs != C.TIME_UNSET) { long elapsedSinceEndMs = SystemClock.elapsedRealtime() - fakeContentProgressElapsedRealtimeMs; contentPositionMs = fakeContentProgressOffsetMs + elapsedSinceEndMs; - expectedAdGroupIndex = + int adGroupIndexForPosition = adPlaybackState.getAdGroupIndexForPositionUs(C.msToUs(contentPositionMs)); + if (adGroupIndexForPosition != C.INDEX_UNSET) { + expectedAdGroupIndex = adGroupIndexForPosition; + } } else if (imaAdState == IMA_AD_STATE_NONE && !playingAd && hasContentDuration) { contentPositionMs = player.getCurrentPosition(); // Update the expected ad group index for the current content position. The update is delayed @@ -1096,6 +1099,16 @@ public final class ImaAdsLoader extends Player.DefaultEventListener implements A if (pendingAdLoadError == null) { pendingAdLoadError = AdLoadException.createForAdGroup(error, adGroupIndex); } + // Discard the ad break, which makes sure we don't receive duplicate load error events. + adsManager.discardAdBreak(); + // Set the next expected ad group index so we can handle multiple load errors in a row. + adGroupIndex++; + if (adGroupIndex < adPlaybackState.adGroupCount) { + expectedAdGroupIndex = adGroupIndex; + } else { + expectedAdGroupIndex = C.INDEX_UNSET; + } + pendingContentPositionMs = C.TIME_UNSET; } private void handleAdPrepareError(int adGroupIndex, int adIndexInAdGroup, Exception exception) { From 5c118f974151229da3a9b739da28a3386fd79166 Mon Sep 17 00:00:00 2001 From: andrewlewis Date: Thu, 9 Aug 2018 08:59:17 -0700 Subject: [PATCH 4/6] Release ads loader on new intent in the demo app ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=208056265 --- .../java/com/google/android/exoplayer2/demo/PlayerActivity.java | 1 + 1 file changed, 1 insertion(+) diff --git a/demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java b/demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java index 565f7e300a..67c56127ee 100644 --- a/demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java +++ b/demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java @@ -188,6 +188,7 @@ public class PlayerActivity extends Activity @Override public void onNewIntent(Intent intent) { releasePlayer(); + releaseAdsLoader(); clearStartPosition(); setIntent(intent); } From e7bbdbf59d23c11547970a75d91089784231df05 Mon Sep 17 00:00:00 2001 From: andrewlewis Date: Thu, 9 Aug 2018 08:42:00 -0700 Subject: [PATCH 5/6] Enable IMA SDK debug mode if flag is set ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=208054150 --- .../com/google/android/exoplayer2/ext/ima/ImaAdsLoader.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoader.java b/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoader.java index 15847d988a..7c095ff2ef 100644 --- a/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoader.java +++ b/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoader.java @@ -376,6 +376,9 @@ public final class ImaAdsLoader extends Player.DefaultEventListener implements A adDisplayContainer.setPlayer(this); if (imaSdkSettings == null) { imaSdkSettings = imaSdkFactory.createImaSdkSettings(); + if (DEBUG) { + imaSdkSettings.setDebugMode(true); + } } imaSdkSettings.setPlayerType(IMA_SDK_SETTINGS_PLAYER_TYPE); imaSdkSettings.setPlayerVersion(IMA_SDK_SETTINGS_PLAYER_VERSION); From 37af6ac03cdcc2785db0d63e0635ed990f1cbf4b Mon Sep 17 00:00:00 2001 From: olly Date: Fri, 17 Aug 2018 05:06:54 -0700 Subject: [PATCH 6/6] Bump version to 2.8.4 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=209134753 --- constants.gradle | 4 ++-- .../com/google/android/exoplayer2/ExoPlayerLibraryInfo.java | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/constants.gradle b/constants.gradle index b8cfc7d2a4..08510e02ae 100644 --- a/constants.gradle +++ b/constants.gradle @@ -13,8 +13,8 @@ // limitations under the License. project.ext { // ExoPlayer version and version code. - releaseVersion = '2.8.3' - releaseVersionCode = 2803 + releaseVersion = '2.8.4' + releaseVersionCode = 2804 // Important: ExoPlayer specifies a minSdkVersion of 14 because various // components provided by the library may be of use on older devices. // However, please note that the core media playback functionality provided diff --git a/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerLibraryInfo.java b/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerLibraryInfo.java index 8de3385d1a..e18a897029 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerLibraryInfo.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerLibraryInfo.java @@ -29,11 +29,11 @@ public final class ExoPlayerLibraryInfo { /** The version of the library expressed as a string, for example "1.2.3". */ // Intentionally hardcoded. Do not derive from other constants (e.g. VERSION_INT) or vice versa. - public static final String VERSION = "2.8.3"; + public static final String VERSION = "2.8.4"; /** The version of the library expressed as {@code "ExoPlayerLib/" + VERSION}. */ // Intentionally hardcoded. Do not derive from other constants (e.g. VERSION) or vice versa. - public static final String VERSION_SLASHY = "ExoPlayerLib/2.8.3"; + public static final String VERSION_SLASHY = "ExoPlayerLib/2.8.4"; /** * The version of the library expressed as an integer, for example 1002003. @@ -43,7 +43,7 @@ public final class ExoPlayerLibraryInfo { * integer version 123045006 (123-045-006). */ // Intentionally hardcoded. Do not derive from other constants (e.g. VERSION) or vice versa. - public static final int VERSION_INT = 2008003; + public static final int VERSION_INT = 2008004; /** * Whether the library was compiled with {@link com.google.android.exoplayer2.util.Assertions}