Update code based on code review result

* remove field mimeType in Ac4Util.java
 * change constant CHANNEL_COUNT_2 to private in Ac4Util.java
This commit is contained in:
ybai001 2019-01-31 11:31:19 +08:00
parent 3ea71f8ab8
commit 8f32c29cc6
2 changed files with 5 additions and 11 deletions

View file

@ -33,10 +33,6 @@ public final class Ac4Util {
*/ */
public static final class SyncFrameInfo { public static final class SyncFrameInfo {
/**
* The sample mime type of the bitstream is {@link MimeTypes#AUDIO_AC4}.
*/
public final String mimeType;
/** /**
* The bitstream version. * The bitstream version.
*/ */
@ -59,13 +55,11 @@ public final class Ac4Util {
public final int sampleCount; public final int sampleCount;
private SyncFrameInfo( private SyncFrameInfo(
String mimeType,
int bitstreamVersion, int bitstreamVersion,
int channelCount, int channelCount,
int sampleRate, int sampleRate,
int frameSize, int frameSize,
int sampleCount) { int sampleCount) {
this.mimeType = mimeType;
this.bitstreamVersion = bitstreamVersion; this.bitstreamVersion = bitstreamVersion;
this.channelCount = channelCount; this.channelCount = channelCount;
this.sampleRate = sampleRate; this.sampleRate = sampleRate;
@ -78,7 +72,7 @@ public final class Ac4Util {
* The channel count of AC-4 stream. * The channel count of AC-4 stream.
*/ */
// TODO: Parse AC-4 stream channel count. // TODO: Parse AC-4 stream channel count.
public static final int CHANNEL_COUNT_2 = 2; private static final int CHANNEL_COUNT_2 = 2;
/** /**
* The header size for AC-4 parser. Only needs to be as big as we need to read, not the full * The header size for AC-4 parser. Only needs to be as big as we need to read, not the full
* header size. * header size.
@ -207,8 +201,7 @@ public final class Ac4Util {
break; break;
} }
} }
return new SyncFrameInfo( return new SyncFrameInfo(bitstreamVersion, CHANNEL_COUNT_2, sampleRate, frameSize, sampleCount);
MimeTypes.AUDIO_AC4, bitstreamVersion, CHANNEL_COUNT_2, sampleRate, frameSize, sampleCount);
} }
/** /**

View file

@ -23,6 +23,7 @@ import com.google.android.exoplayer2.audio.Ac4Util.SyncFrameInfo;
import com.google.android.exoplayer2.extractor.ExtractorOutput; import com.google.android.exoplayer2.extractor.ExtractorOutput;
import com.google.android.exoplayer2.extractor.TrackOutput; import com.google.android.exoplayer2.extractor.TrackOutput;
import com.google.android.exoplayer2.extractor.ts.TsPayloadReader.TrackIdGenerator; import com.google.android.exoplayer2.extractor.ts.TsPayloadReader.TrackIdGenerator;
import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.exoplayer2.util.ParsableBitArray; import com.google.android.exoplayer2.util.ParsableBitArray;
import com.google.android.exoplayer2.util.ParsableByteArray; import com.google.android.exoplayer2.util.ParsableByteArray;
import java.lang.annotation.Documented; import java.lang.annotation.Documented;
@ -198,8 +199,8 @@ public final class Ac4Reader implements ElementaryStreamReader {
SyncFrameInfo frameInfo = Ac4Util.parseAc4SyncframeInfo(headerScratchBits); SyncFrameInfo frameInfo = Ac4Util.parseAc4SyncframeInfo(headerScratchBits);
if (format == null || frameInfo.channelCount != format.channelCount if (format == null || frameInfo.channelCount != format.channelCount
|| frameInfo.sampleRate != format.sampleRate || frameInfo.sampleRate != format.sampleRate
|| frameInfo.mimeType != format.sampleMimeType) { || !MimeTypes.AUDIO_AC4.equals(format.sampleMimeType)) {
format = Format.createAudioSampleFormat(trackFormatId, frameInfo.mimeType, null, format = Format.createAudioSampleFormat(trackFormatId, MimeTypes.AUDIO_AC4, null,
Format.NO_VALUE, Format.NO_VALUE, frameInfo.channelCount, frameInfo.sampleRate, null, Format.NO_VALUE, Format.NO_VALUE, frameInfo.channelCount, frameInfo.sampleRate, null,
null, 0, language); null, 0, language);
output.format(format); output.format(format);