diff --git a/gradlew.bat b/gradlew.bat index aec99730b4..8a0b282aa6 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,90 +1,90 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windowz variants - -if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/library/src/androidTest/java/com/google/android/exoplayer/MediaFormatTest.java b/library/src/androidTest/java/com/google/android/exoplayer/MediaFormatTest.java index 836ca27048..c3270298a7 100644 --- a/library/src/androidTest/java/com/google/android/exoplayer/MediaFormatTest.java +++ b/library/src/androidTest/java/com/google/android/exoplayer/MediaFormatTest.java @@ -15,11 +15,11 @@ */ package com.google.android.exoplayer; +import com.google.android.exoplayer.util.Util; + import android.annotation.SuppressLint; import android.annotation.TargetApi; -import com.google.android.exoplayer.util.Util; - import junit.framework.TestCase; import java.nio.ByteBuffer; @@ -47,19 +47,16 @@ public final class MediaFormatTest extends TestCase { testConversionToFrameworkFormatV16(MediaFormat.createVideoFormat( null, "video/xyz", 5000, 102400, 1000L, 1280, 720, initData)); testConversionToFrameworkFormatV16(MediaFormat.createVideoFormat( - null, "video/xyz", 5000, MediaFormat.NO_VALUE, C.UNKNOWN_TIME_US, 1280, 720, - null)); + null, "video/xyz", 5000, MediaFormat.NO_VALUE, C.UNKNOWN_TIME_US, 1280, 720, null)); testConversionToFrameworkFormatV16(MediaFormat.createAudioFormat( null, "audio/xyz", 500, 128, 1000L, 5, 44100, initData, null)); testConversionToFrameworkFormatV16(MediaFormat.createAudioFormat( - null, "audio/xyz", 500, MediaFormat.NO_VALUE, C.UNKNOWN_TIME_US, 5, 44100, - null, null)); + null, "audio/xyz", 500, MediaFormat.NO_VALUE, C.UNKNOWN_TIME_US, 5, 44100, null, null)); testConversionToFrameworkFormatV16( - MediaFormat.createTextFormat(null, "text/xyz", MediaFormat.NO_VALUE, 1000L, - "eng")); + MediaFormat.createTextFormat(null, "text/xyz", MediaFormat.NO_VALUE, 1000L, "eng")); testConversionToFrameworkFormatV16( - MediaFormat.createTextFormat(null, "text/xyz", MediaFormat.NO_VALUE, - C.UNKNOWN_TIME_US, null)); + MediaFormat.createTextFormat(null, "text/xyz", MediaFormat.NO_VALUE, C.UNKNOWN_TIME_US, + null)); } @SuppressLint("InlinedApi") diff --git a/library/src/main/java/com/google/android/exoplayer/FrameworkSampleSource.java b/library/src/main/java/com/google/android/exoplayer/FrameworkSampleSource.java index e83738c4c1..9fb4d8c216 100644 --- a/library/src/main/java/com/google/android/exoplayer/FrameworkSampleSource.java +++ b/library/src/main/java/com/google/android/exoplayer/FrameworkSampleSource.java @@ -315,10 +315,10 @@ public final class FrameworkSampleSource implements SampleSource, SampleSourceRe } long durationUs = format.containsKey(android.media.MediaFormat.KEY_DURATION) ? format.getLong(android.media.MediaFormat.KEY_DURATION) : C.UNKNOWN_TIME_US; - MediaFormat mediaFormat = new MediaFormat(null, mimeType, MediaFormat.NO_VALUE, - maxInputSize, durationUs, width, height, rotationDegrees, MediaFormat.NO_VALUE, - channelCount, sampleRate, language, MediaFormat.OFFSET_SAMPLE_RELATIVE, initializationData, - false, MediaFormat.NO_VALUE, MediaFormat.NO_VALUE); + MediaFormat mediaFormat = new MediaFormat(null, mimeType, MediaFormat.NO_VALUE, maxInputSize, + durationUs, width, height, rotationDegrees, MediaFormat.NO_VALUE, channelCount, sampleRate, + language, MediaFormat.OFFSET_SAMPLE_RELATIVE, initializationData, false, + MediaFormat.NO_VALUE, MediaFormat.NO_VALUE); mediaFormat.setFrameworkFormatV16(format); return mediaFormat; } diff --git a/library/src/main/java/com/google/android/exoplayer/MediaFormat.java b/library/src/main/java/com/google/android/exoplayer/MediaFormat.java index 2a81d92472..4f30163a1f 100644 --- a/library/src/main/java/com/google/android/exoplayer/MediaFormat.java +++ b/library/src/main/java/com/google/android/exoplayer/MediaFormat.java @@ -15,12 +15,12 @@ */ package com.google.android.exoplayer; -import android.annotation.SuppressLint; -import android.annotation.TargetApi; - import com.google.android.exoplayer.util.Assertions; import com.google.android.exoplayer.util.Util; +import android.annotation.SuppressLint; +import android.annotation.TargetApi; + import java.nio.ByteBuffer; import java.util.Arrays; import java.util.Collections; @@ -40,8 +40,7 @@ public final class MediaFormat { public static final long OFFSET_SAMPLE_RELATIVE = Long.MAX_VALUE; /** - * The identifier for the track represented by the format, or null if unknown or not - * applicable. + * The identifier for the track represented by the format, or null if unknown or not applicable. */ public final String trackId; /** @@ -229,8 +228,8 @@ public final class MediaFormat { subsampleOffsetUs, initializationData, adaptive, maxWidth, maxHeight); } - public MediaFormat copyAsAdaptive() { - return new MediaFormat(null, mimeType, NO_VALUE, NO_VALUE, durationUs, NO_VALUE, NO_VALUE, + public MediaFormat copyAsAdaptive(String trackId) { + return new MediaFormat(trackId, mimeType, NO_VALUE, NO_VALUE, durationUs, NO_VALUE, NO_VALUE, NO_VALUE, NO_VALUE, NO_VALUE, NO_VALUE, null, OFFSET_SAMPLE_RELATIVE, null, true, maxWidth, maxHeight); } diff --git a/library/src/main/java/com/google/android/exoplayer/dash/DashChunkSource.java b/library/src/main/java/com/google/android/exoplayer/dash/DashChunkSource.java index 50e10e378d..a7e13ddc87 100644 --- a/library/src/main/java/com/google/android/exoplayer/dash/DashChunkSource.java +++ b/library/src/main/java/com/google/android/exoplayer/dash/DashChunkSource.java @@ -567,7 +567,7 @@ public class DashChunkSource implements ChunkSource, Output { Log.w(TAG, "Skipped adaptive track (unknown media format)"); return; } - tracks.add(new ExposedTrack(trackFormat.copyAsAdaptive(), adaptationSetIndex, + tracks.add(new ExposedTrack(trackFormat.copyAsAdaptive(null), adaptationSetIndex, representationFormats, maxWidth, maxHeight)); } diff --git a/library/src/main/java/com/google/android/exoplayer/extractor/mp3/Mp3Extractor.java b/library/src/main/java/com/google/android/exoplayer/extractor/mp3/Mp3Extractor.java index 03f761d5b2..7a07c76bb1 100644 --- a/library/src/main/java/com/google/android/exoplayer/extractor/mp3/Mp3Extractor.java +++ b/library/src/main/java/com/google/android/exoplayer/extractor/mp3/Mp3Extractor.java @@ -332,10 +332,9 @@ public final class Mp3Extractor implements Extractor { if (seeker == null) { setupSeeker(extractorInput, headerPosition); extractorOutput.seekMap(seeker); - trackOutput.format(MediaFormat.createAudioFormat(null, - synchronizedHeader.mimeType, MediaFormat.NO_VALUE, MpegAudioHeader.MAX_FRAME_SIZE_BYTES, - seeker.getDurationUs(), synchronizedHeader.channels, synchronizedHeader.sampleRate, null, - null)); + trackOutput.format(MediaFormat.createAudioFormat(null, synchronizedHeader.mimeType, + MediaFormat.NO_VALUE, MpegAudioHeader.MAX_FRAME_SIZE_BYTES, seeker.getDurationUs(), + synchronizedHeader.channels, synchronizedHeader.sampleRate, null, null)); } return headerPosition; diff --git a/library/src/main/java/com/google/android/exoplayer/extractor/mp4/AtomParsers.java b/library/src/main/java/com/google/android/exoplayer/extractor/mp4/AtomParsers.java index a7807aeab0..9b01f5f6fc 100644 --- a/library/src/main/java/com/google/android/exoplayer/extractor/mp4/AtomParsers.java +++ b/library/src/main/java/com/google/android/exoplayer/extractor/mp4/AtomParsers.java @@ -744,17 +744,20 @@ import java.util.List; // TODO: Choose the right AC-3 track based on the contents of dac3/dec3. // TODO: Add support for encryption (by setting out.trackEncryptionBoxes). parent.setPosition(Atom.HEADER_SIZE + childStartPosition); - out.mediaFormat = Ac3Util.parseAnnexFAc3Format(parent, trackId, durationUs, language); + out.mediaFormat = Ac3Util.parseAnnexFAc3Format(parent, Integer.toString(trackId), + durationUs, language); return; } else if (atomType == Atom.TYPE_ec_3 && childAtomType == Atom.TYPE_dec3) { parent.setPosition(Atom.HEADER_SIZE + childStartPosition); - out.mediaFormat = Ac3Util.parseAnnexFEAc3Format(parent, trackId, durationUs, language); + out.mediaFormat = Ac3Util.parseAnnexFEAc3Format(parent, Integer.toString(trackId), + durationUs, language); return; } else if ((atomType == Atom.TYPE_dtsc || atomType == Atom.TYPE_dtse || atomType == Atom.TYPE_dtsh || atomType == Atom.TYPE_dtsl) && childAtomType == Atom.TYPE_ddts) { - out.mediaFormat = MediaFormat.createAudioFormat(Integer.toString(trackId), mimeType, MediaFormat.NO_VALUE, - MediaFormat.NO_VALUE, durationUs, channelCount, sampleRate, null, language); + out.mediaFormat = MediaFormat.createAudioFormat(Integer.toString(trackId), mimeType, + MediaFormat.NO_VALUE, MediaFormat.NO_VALUE, durationUs, channelCount, sampleRate, null, + language); return; } childPosition += childAtomSize; diff --git a/library/src/main/java/com/google/android/exoplayer/extractor/ts/Ac3Reader.java b/library/src/main/java/com/google/android/exoplayer/extractor/ts/Ac3Reader.java index baa4687450..364cf5b254 100644 --- a/library/src/main/java/com/google/android/exoplayer/extractor/ts/Ac3Reader.java +++ b/library/src/main/java/com/google/android/exoplayer/extractor/ts/Ac3Reader.java @@ -155,8 +155,7 @@ import com.google.android.exoplayer.util.ParsableByteArray; sampleSize = Ac3Util.parseFrameSize(headerScratchBits); if (mediaFormat == null) { headerScratchBits.setPosition(0); - mediaFormat = Ac3Util.parseFrameAc3Format(headerScratchBits, MediaFormat.NO_VALUE, - C.UNKNOWN_TIME_US, null); + mediaFormat = Ac3Util.parseFrameAc3Format(headerScratchBits, null, C.UNKNOWN_TIME_US, null); output.format(mediaFormat); bitrate = Ac3Util.getBitrate(sampleSize, mediaFormat.sampleRate); } diff --git a/library/src/main/java/com/google/android/exoplayer/extractor/ts/AdtsReader.java b/library/src/main/java/com/google/android/exoplayer/extractor/ts/AdtsReader.java index ba3d69e024..f55f99c244 100644 --- a/library/src/main/java/com/google/android/exoplayer/extractor/ts/AdtsReader.java +++ b/library/src/main/java/com/google/android/exoplayer/extractor/ts/AdtsReader.java @@ -170,10 +170,9 @@ import java.util.Collections; Pair audioParams = CodecSpecificDataUtil.parseAacAudioSpecificConfig( audioSpecificConfig); - MediaFormat mediaFormat = MediaFormat.createAudioFormat(null, - MimeTypes.AUDIO_AAC, MediaFormat.NO_VALUE, MediaFormat.NO_VALUE, C.UNKNOWN_TIME_US, - audioParams.second, audioParams.first, Collections.singletonList(audioSpecificConfig), - null); + MediaFormat mediaFormat = MediaFormat.createAudioFormat(null, MimeTypes.AUDIO_AAC, + MediaFormat.NO_VALUE, MediaFormat.NO_VALUE, C.UNKNOWN_TIME_US, audioParams.second, + audioParams.first, Collections.singletonList(audioSpecificConfig), null); frameDurationUs = (C.MICROS_PER_SECOND * 1024L) / mediaFormat.sampleRate; output.format(mediaFormat); hasOutputFormat = true; diff --git a/library/src/main/java/com/google/android/exoplayer/extractor/ts/H264Reader.java b/library/src/main/java/com/google/android/exoplayer/extractor/ts/H264Reader.java index efa3a8e5a2..2490803b87 100644 --- a/library/src/main/java/com/google/android/exoplayer/extractor/ts/H264Reader.java +++ b/library/src/main/java/com/google/android/exoplayer/extractor/ts/H264Reader.java @@ -210,10 +210,9 @@ import java.util.List; SpsData parsedSpsData = CodecSpecificDataUtil.parseSpsNalUnit(bitArray); // Construct and output the format. - output.format(MediaFormat.createVideoFormat(null, MimeTypes.VIDEO_H264, - MediaFormat.NO_VALUE, MediaFormat.NO_VALUE, C.UNKNOWN_TIME_US, parsedSpsData.width, - parsedSpsData.height, initializationData, MediaFormat.NO_VALUE, - parsedSpsData.pixelWidthAspectRatio)); + output.format(MediaFormat.createVideoFormat(null, MimeTypes.VIDEO_H264, MediaFormat.NO_VALUE, + MediaFormat.NO_VALUE, C.UNKNOWN_TIME_US, parsedSpsData.width, parsedSpsData.height, + initializationData, MediaFormat.NO_VALUE, parsedSpsData.pixelWidthAspectRatio)); hasOutputFormat = true; } diff --git a/library/src/main/java/com/google/android/exoplayer/extractor/ts/H265Reader.java b/library/src/main/java/com/google/android/exoplayer/extractor/ts/H265Reader.java index 47bc512a27..7756bd13ac 100644 --- a/library/src/main/java/com/google/android/exoplayer/extractor/ts/H265Reader.java +++ b/library/src/main/java/com/google/android/exoplayer/extractor/ts/H265Reader.java @@ -294,10 +294,9 @@ import java.util.Collections; } } - output.format(MediaFormat.createVideoFormat(null, MimeTypes.VIDEO_H265, - MediaFormat.NO_VALUE, MediaFormat.NO_VALUE, C.UNKNOWN_TIME_US, picWidthInLumaSamples, - picHeightInLumaSamples, Collections.singletonList(csd), MediaFormat.NO_VALUE, - pixelWidthHeightRatio)); + output.format(MediaFormat.createVideoFormat(null, MimeTypes.VIDEO_H265, MediaFormat.NO_VALUE, + MediaFormat.NO_VALUE, C.UNKNOWN_TIME_US, picWidthInLumaSamples, picHeightInLumaSamples, + Collections.singletonList(csd), MediaFormat.NO_VALUE, pixelWidthHeightRatio)); hasOutputFormat = true; } diff --git a/library/src/main/java/com/google/android/exoplayer/extractor/ts/Id3Reader.java b/library/src/main/java/com/google/android/exoplayer/extractor/ts/Id3Reader.java index ffbeafc295..c7ec2f7dc4 100644 --- a/library/src/main/java/com/google/android/exoplayer/extractor/ts/Id3Reader.java +++ b/library/src/main/java/com/google/android/exoplayer/extractor/ts/Id3Reader.java @@ -35,8 +35,8 @@ import com.google.android.exoplayer.util.ParsableByteArray; public Id3Reader(TrackOutput output) { super(output); - output.format(MediaFormat.createFormatForMimeType(null, - MimeTypes.APPLICATION_ID3, MediaFormat.NO_VALUE, C.UNKNOWN_TIME_US)); + output.format(MediaFormat.createFormatForMimeType(null, MimeTypes.APPLICATION_ID3, + MediaFormat.NO_VALUE, C.UNKNOWN_TIME_US)); } @Override diff --git a/library/src/main/java/com/google/android/exoplayer/extractor/webm/WebmExtractor.java b/library/src/main/java/com/google/android/exoplayer/extractor/webm/WebmExtractor.java index a8e74b539d..97717c7016 100644 --- a/library/src/main/java/com/google/android/exoplayer/extractor/webm/WebmExtractor.java +++ b/library/src/main/java/com/google/android/exoplayer/extractor/webm/WebmExtractor.java @@ -1227,17 +1227,18 @@ public final class WebmExtractor implements Extractor { } MediaFormat format; - // TODO: Read the name of the track from the header of the webm container and - // supply this as id instead of trackId? + // TODO: Consider reading the name elements of the tracks and, if present, incorporating them + // into the trackId passed when creating the formats. if (MimeTypes.isAudio(mimeType)) { - format = MediaFormat.createAudioFormat(Integer.toString(trackId), mimeType, MediaFormat.NO_VALUE, - maxInputSize, durationUs, channelCount, sampleRate, initializationData, language); + format = MediaFormat.createAudioFormat(Integer.toString(trackId), mimeType, + MediaFormat.NO_VALUE, maxInputSize, durationUs, channelCount, sampleRate, + initializationData, language); } else if (MimeTypes.isVideo(mimeType)) { - format = MediaFormat.createVideoFormat(Integer.toString(trackId), mimeType, MediaFormat.NO_VALUE, - maxInputSize, durationUs, width, height, initializationData); + format = MediaFormat.createVideoFormat(Integer.toString(trackId), mimeType, + MediaFormat.NO_VALUE, maxInputSize, durationUs, width, height, initializationData); } else if (MimeTypes.APPLICATION_SUBRIP.equals(mimeType)) { - format = MediaFormat.createTextFormat(Integer.toString(trackId), mimeType, MediaFormat.NO_VALUE, durationUs, - language); + format = MediaFormat.createTextFormat(Integer.toString(trackId), mimeType, + MediaFormat.NO_VALUE, durationUs, language); } else { throw new ParserException("Unexpected MIME type."); } diff --git a/library/src/main/java/com/google/android/exoplayer/hls/HlsSampleSource.java b/library/src/main/java/com/google/android/exoplayer/hls/HlsSampleSource.java index 4eaa685e7f..9667427dee 100644 --- a/library/src/main/java/com/google/android/exoplayer/hls/HlsSampleSource.java +++ b/library/src/main/java/com/google/android/exoplayer/hls/HlsSampleSource.java @@ -144,7 +144,7 @@ public final class HlsSampleSource implements SampleSource, SampleSourceReader, for (int i = 0; i < trackCount; i++) { MediaFormat format = extractor.getMediaFormat(i).copyWithDurationUs(durationUs); if (MimeTypes.isVideo(format.mimeType)) { - format = format.copyAsAdaptive(); + format = format.copyAsAdaptive(null); } trackFormat[i] = format; } diff --git a/library/src/main/java/com/google/android/exoplayer/smoothstreaming/SmoothStreamingChunkSource.java b/library/src/main/java/com/google/android/exoplayer/smoothstreaming/SmoothStreamingChunkSource.java index 1dc88ca25d..1482f83e3e 100644 --- a/library/src/main/java/com/google/android/exoplayer/smoothstreaming/SmoothStreamingChunkSource.java +++ b/library/src/main/java/com/google/android/exoplayer/smoothstreaming/SmoothStreamingChunkSource.java @@ -368,7 +368,7 @@ public class SmoothStreamingChunkSource implements ChunkSource, maxHeight = Math.max(maxHeight, mediaFormat.height); } Arrays.sort(formats, new DecreasingBandwidthComparator()); - MediaFormat adaptiveMediaFormat = maxHeightMediaFormat.copyAsAdaptive(); + MediaFormat adaptiveMediaFormat = maxHeightMediaFormat.copyAsAdaptive(null); tracks.add(new ExposedTrack(adaptiveMediaFormat, element, formats, maxWidth, maxHeight)); } @@ -398,9 +398,8 @@ public class SmoothStreamingChunkSource implements ChunkSource, int mp4TrackType; switch (element.type) { case StreamElement.TYPE_VIDEO: - mediaFormat = MediaFormat.createVideoFormat(format.id, format.mimeType, - format.bitrate, MediaFormat.NO_VALUE, durationUs, format.width, format.height, - Arrays.asList(csdArray)); + mediaFormat = MediaFormat.createVideoFormat(format.id, format.mimeType, format.bitrate, + MediaFormat.NO_VALUE, durationUs, format.width, format.height, Arrays.asList(csdArray)); mp4TrackType = Track.TYPE_vide; break; case StreamElement.TYPE_AUDIO: @@ -411,14 +410,14 @@ public class SmoothStreamingChunkSource implements ChunkSource, csd = Collections.singletonList(CodecSpecificDataUtil.buildAacAudioSpecificConfig( format.audioSamplingRate, format.audioChannels)); } - mediaFormat = MediaFormat.createAudioFormat(format.id, format.mimeType, - format.bitrate, MediaFormat.NO_VALUE, durationUs, format.audioChannels, - format.audioSamplingRate, csd, format.language); + mediaFormat = MediaFormat.createAudioFormat(format.id, format.mimeType, format.bitrate, + MediaFormat.NO_VALUE, durationUs, format.audioChannels, format.audioSamplingRate, csd, + format.language); mp4TrackType = Track.TYPE_soun; break; case StreamElement.TYPE_TEXT: - mediaFormat = MediaFormat.createTextFormat(format.id, format.mimeType, - format.bitrate, durationUs, format.language); + mediaFormat = MediaFormat.createTextFormat(format.id, format.mimeType, format.bitrate, + durationUs, format.language); mp4TrackType = Track.TYPE_text; break; default: diff --git a/library/src/main/java/com/google/android/exoplayer/util/Ac3Util.java b/library/src/main/java/com/google/android/exoplayer/util/Ac3Util.java index 041983fc67..069ba6248d 100644 --- a/library/src/main/java/com/google/android/exoplayer/util/Ac3Util.java +++ b/library/src/main/java/com/google/android/exoplayer/util/Ac3Util.java @@ -38,12 +38,12 @@ public final class Ac3Util { * ETSI TS 102 366 Annex F. * * @param data The AC3SpecificBox. - * @param trackId The identifier for the track in its container, or {@link MediaFormat#NO_VALUE}. + * @param trackId The track identifier to set on the format, or null. * @param durationUs The duration to set on the format, in microseconds. * @param language The language to set on the format. * @return The AC-3 format parsed from data in the header. */ - public static MediaFormat parseAnnexFAc3Format(ParsableByteArray data, int trackId, + public static MediaFormat parseAnnexFAc3Format(ParsableByteArray data, String trackId, long durationUs, String language) { // fscod (sample rate code) int fscod = (data.readUnsignedByte() & 0xC0) >> 6; @@ -55,7 +55,7 @@ public final class Ac3Util { if ((nextByte & 0x04) != 0) { channelCount++; } - return MediaFormat.createAudioFormat(Integer.toString(trackId), MimeTypes.AUDIO_AC3, MediaFormat.NO_VALUE, + return MediaFormat.createAudioFormat(trackId, MimeTypes.AUDIO_AC3, MediaFormat.NO_VALUE, MediaFormat.NO_VALUE, durationUs, channelCount, sampleRate, null, language); } @@ -64,12 +64,12 @@ public final class Ac3Util { * ETSI TS 102 366 Annex F. * * @param data The EC3SpecificBox. - * @param trackId The identifier for the track in its container, or {@link MediaFormat#NO_VALUE}. + * @param trackId The track identifier to set on the format, or null. * @param durationUs The duration to set on the format, in microseconds. * @param language The language to set on the format. * @return The E-AC-3 format parsed from data in the header. */ - public static MediaFormat parseAnnexFEAc3Format(ParsableByteArray data, int trackId, + public static MediaFormat parseAnnexFEAc3Format(ParsableByteArray data, String trackId, long durationUs, String language) { data.skipBytes(2); // Skip data_rate and num_ind_sub. @@ -85,7 +85,7 @@ public final class Ac3Util { if ((nextByte & 0x01) != 0) { channelCount++; } - return MediaFormat.createAudioFormat(Integer.toString(trackId), MimeTypes.AUDIO_EC3, MediaFormat.NO_VALUE, + return MediaFormat.createAudioFormat(trackId, MimeTypes.AUDIO_EC3, MediaFormat.NO_VALUE, MediaFormat.NO_VALUE, durationUs, channelCount, sampleRate, null, language); } @@ -94,13 +94,13 @@ public final class Ac3Util { * word. * * @param data Data to parse, positioned at the start of the syncword. - * @param trackId The identifier for the track in its container, or {@link MediaFormat#NO_VALUE}. + * @param trackId The track identifier to set on the format, or null. * @param durationUs The duration to set on the format, in microseconds. * @param language The language to set on the format. * @return The AC-3 format parsed from data in the header. */ - public static MediaFormat parseFrameAc3Format(ParsableBitArray data, int trackId, long durationUs, - String language) { + public static MediaFormat parseFrameAc3Format(ParsableBitArray data, String trackId, + long durationUs, String language) { // Skip syncword and crc1. data.skipBits(4 * 8); @@ -117,7 +117,7 @@ public final class Ac3Util { data.skipBits(2); // dsurmod } boolean lfeon = data.readBit(); - return MediaFormat.createAudioFormat(Integer.toString(trackId), MimeTypes.AUDIO_AC3, MediaFormat.NO_VALUE, + return MediaFormat.createAudioFormat(trackId, MimeTypes.AUDIO_AC3, MediaFormat.NO_VALUE, MediaFormat.NO_VALUE, durationUs, CHANNEL_COUNTS[acmod] + (lfeon ? 1 : 0), SAMPLE_RATES[fscod], null, language); } diff --git a/library/src/main/java/com/google/android/exoplayer/util/MimeTypes.java b/library/src/main/java/com/google/android/exoplayer/util/MimeTypes.java index d89a7179df..2afd172e95 100644 --- a/library/src/main/java/com/google/android/exoplayer/util/MimeTypes.java +++ b/library/src/main/java/com/google/android/exoplayer/util/MimeTypes.java @@ -15,8 +15,6 @@ */ package com.google.android.exoplayer.util; -import android.text.TextUtils; - /** * Defines common MIME types and helper methods. */