WavExtractorTest and TsExtractorTest

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=123848524
This commit is contained in:
eguven 2016-06-02 03:42:21 -07:00 committed by Oliver Woodman
parent ed19a582a7
commit 94fa2ecfe5
7 changed files with 230 additions and 2 deletions

Binary file not shown.

View File

@ -0,0 +1,103 @@
seekMap:
isSeekable = false
duration = UNSET TIME
getPosition(0) = 0
numberOfTracks = 3
track 2:
format:
bitrate = -1
id = null
containerMimeType = null
sampleMimeType = video/mpeg2
maxInputSize = -1
requiresSecureDecryption = false
width = 1080
height = 720
frameRate = -1.0
rotationDegrees = -1
pixelWidthHeightRatio = 1.0
channelCount = -1
sampleRate = -1
pcmEncoding = -1
encoderDelay = -1
encoderPadding = -1
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
drmInitData = -
initializationData:
data = length 22, hash D3167F9
sample count = 2
sample 0:
time = 33366
flags = 1
data = length 36420, hash A653C4D9
sample 1:
time = 66733
flags = 0
data = length 52814, hash 8D54E344
track 3:
format:
bitrate = -1
id = null
containerMimeType = null
sampleMimeType = audio/mpeg-L2
maxInputSize = 4096
requiresSecureDecryption = false
width = -1
height = -1
frameRate = -1.0
rotationDegrees = -1
pixelWidthHeightRatio = -1.0
channelCount = 1
sampleRate = 44100
pcmEncoding = -1
encoderDelay = -1
encoderPadding = -1
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
drmInitData = -
initializationData:
sample count = 4
sample 0:
time = 90511
flags = 1
data = length 1253, hash 727FD1C6
sample 1:
time = 116633
flags = 1
data = length 1254, hash 787D6CCE
sample 2:
time = 142755
flags = 1
data = length 1254, hash 44B92592
sample 3:
time = 168877
flags = 1
data = length 1254, hash 3B315899
track 21:
format:
bitrate = -1
id = null
containerMimeType = null
sampleMimeType = application/id3
maxInputSize = -1
requiresSecureDecryption = false
width = -1
height = -1
frameRate = -1.0
rotationDegrees = -1
pixelWidthHeightRatio = -1.0
channelCount = -1
sampleRate = -1
pcmEncoding = -1
encoderDelay = -1
encoderPadding = -1
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
drmInitData = -
initializationData:
sample count = 0
tracksEnded = true

Binary file not shown.

View File

@ -0,0 +1,42 @@
seekMap:
isSeekable = true
duration = 1000000
getPosition(0) = 78
numberOfTracks = 1
track 0:
format:
bitrate = 705600
id = null
containerMimeType = null
sampleMimeType = audio/raw
maxInputSize = 32768
requiresSecureDecryption = false
width = -1
height = -1
frameRate = -1.0
rotationDegrees = -1
pixelWidthHeightRatio = -1.0
channelCount = 1
sampleRate = 44100
pcmEncoding = 2
encoderDelay = -1
encoderPadding = -1
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
drmInitData = -
initializationData:
sample count = 3
sample 0:
time = 884
flags = 1
data = length 32768, hash 9A8CEEBA
sample 1:
time = 372403
flags = 1
data = length 32768, hash C1717317
sample 2:
time = 743922
flags = 1
data = length 22664, hash 819F5F62
tracksEnded = true

View File

@ -0,0 +1,37 @@
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.exoplayer.extractor.ts;
import com.google.android.exoplayer.extractor.Extractor;
import com.google.android.exoplayer.testutil.TestUtil;
import android.test.InstrumentationTestCase;
/**
* Unit test for {@link TsExtractor}.
*/
public final class TsExtractorTest extends InstrumentationTestCase {
public void testSample() throws Exception {
TestUtil.assertOutput(new TestUtil.ExtractorFactory() {
@Override
public Extractor create() {
return new TsExtractor();
}
}, "ts/sample.mpeg", getInstrumentation());
}
}

View File

@ -0,0 +1,37 @@
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.exoplayer.extractor.wav;
import com.google.android.exoplayer.extractor.Extractor;
import com.google.android.exoplayer.testutil.TestUtil;
import android.test.InstrumentationTestCase;
/**
* Unit test for {@link WavExtractor}.
*/
public final class WavExtractorTest extends InstrumentationTestCase {
public void testSample() throws Exception {
TestUtil.assertOutput(new TestUtil.ExtractorFactory() {
@Override
public Extractor create() {
return new WavExtractor();
}
}, "wav/sample.wav", getInstrumentation());
}
}

View File

@ -15,6 +15,7 @@
*/
package com.google.android.exoplayer.testutil;
import com.google.android.exoplayer.C;
import com.google.android.exoplayer.Format;
import com.google.android.exoplayer.extractor.ExtractorInput;
import com.google.android.exoplayer.extractor.TrackOutput;
@ -23,6 +24,7 @@ import com.google.android.exoplayer.util.ParsableByteArray;
import android.test.MoreAsserts;
import junit.framework.Assert;
import java.io.EOFException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
@ -68,9 +70,16 @@ public final class FakeTrackOutput implements TrackOutput, Dumper.Dumpable {
public int sampleData(ExtractorInput input, int length, boolean allowEndOfInput)
throws IOException, InterruptedException {
byte[] newData = new byte[length];
input.readFully(newData, 0, length);
int bytesAppended = input.read(newData, 0, length);
if (bytesAppended == C.RESULT_END_OF_INPUT) {
if (allowEndOfInput) {
return C.RESULT_END_OF_INPUT;
}
throw new EOFException();
}
newData = Arrays.copyOf(newData, bytesAppended);
sampleData = TestUtil.joinByteArrays(sampleData, newData);
return length;
return bytesAppended;
}
@Override