Commit 00068c89 by Oliver Woodman

Add vpx extension playback test.

parent 783467b8
...@@ -50,7 +50,7 @@ import java.nio.ByteBuffer; ...@@ -50,7 +50,7 @@ import java.nio.ByteBuffer;
opusHeader.sampleRate, opusHeader.channelCount, opusHeader.numStreams, opusHeader.sampleRate, opusHeader.channelCount, opusHeader.numStreams,
opusHeader.numCoupled, opusHeader.gain, opusHeader.streamMap); opusHeader.numCoupled, opusHeader.gain, opusHeader.streamMap);
if (nativeDecoderContext == 0) { if (nativeDecoderContext == 0) {
throw new OpusDecoderException("failed to initialize opus decoder"); throw new OpusDecoderException("Failed to initialize decoder");
} }
} }
...@@ -68,7 +68,7 @@ import java.nio.ByteBuffer; ...@@ -68,7 +68,7 @@ import java.nio.ByteBuffer;
int outputSize) throws OpusDecoderException { int outputSize) throws OpusDecoderException {
int result = opusDecode(nativeDecoderContext, inputBuffer, inputSize, outputBuffer, outputSize); int result = opusDecode(nativeDecoderContext, inputBuffer, inputSize, outputBuffer, outputSize);
if (result < 0) { if (result < 0) {
throw new OpusDecoderException(opusGetErrorMessage(result)); throw new OpusDecoderException("Decode error: " + opusGetErrorMessage(result));
} }
return result; return result;
} }
......
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="src" path="java"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry combineaccessrules="false" kind="src" path="/ExoPlayerExt-VP9"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ExoPlayerExt-VP9Tests</name>
<comment></comment>
<projects>
<project>ExoPlayerLib</project>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<filteredResources>
<filter>
<id>0</id>
<name></name>
<type>14</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-name-matches-true-false-BUILD</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2014 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.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.google.android.exoplayer.ext.vp9.test">
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="23"/>
<application android:debuggable="true"
android:allowBackup="false"
tools:ignore="MissingApplicationIcon,HardcodedDebugMode">
<uses-library android:name="android.test.runner"/>
</application>
<instrumentation
android:targetPackage="com.google.android.exoplayer.ext.vp9.test"
android:name="android.test.InstrumentationTestRunner"
tools:replace="android:targetPackage"/>
</manifest>
/*
* Copyright (C) 2014 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.ext.vp9;
import com.google.android.exoplayer.ExoPlaybackException;
import com.google.android.exoplayer.ExoPlayer;
import com.google.android.exoplayer.extractor.ExtractorSampleSource;
import com.google.android.exoplayer.extractor.webm.WebmExtractor;
import com.google.android.exoplayer.upstream.DefaultAllocator;
import com.google.android.exoplayer.upstream.DefaultUriDataSource;
import com.google.android.exoplayer.util.Util;
import android.content.Context;
import android.net.Uri;
import android.os.Looper;
import android.test.InstrumentationTestCase;
/**
* Playback tests using {@link LibvpxVideoTrackRenderer}.
*/
public class VpxPlaybackTest extends InstrumentationTestCase {
private static final String BEAR_URI = "asset:///bear-vp9.webm";
private static final String BEAR_ODD_DIMENSIONS_URI = "asset:///bear-vp9-odd-dimensions.webm";
private static final String INVALID_BITSTREAM_URI = "asset:///invalid-bitstream.webm";
public void testBasicPlayback() throws ExoPlaybackException {
playUri(BEAR_URI);
}
public void testOddDimensionsPlayback() throws ExoPlaybackException {
playUri(BEAR_ODD_DIMENSIONS_URI);
}
public void testInvalidBitstream() {
try {
playUri(INVALID_BITSTREAM_URI);
fail();
} catch (Exception e) {
assertNotNull(e.getCause());
assertTrue(e.getCause() instanceof VpxDecoderException);
}
}
private void playUri(String uri) throws ExoPlaybackException {
TestPlaybackThread thread = new TestPlaybackThread(Uri.parse(uri),
getInstrumentation().getContext());
thread.start();
try {
thread.join();
} catch (InterruptedException e) {
fail(); // Should never happen.
}
if (thread.playbackException != null) {
throw thread.playbackException;
}
}
private static class TestPlaybackThread extends Thread implements ExoPlayer.Listener {
private static final int BUFFER_SEGMENT_SIZE = 64 * 1024;
private static final int BUFFER_SEGMENT_COUNT = 16;
private final Context context;
private final Uri uri;
private ExoPlayer player;
private ExoPlaybackException playbackException;
public TestPlaybackThread(Uri uri, Context context) {
this.uri = uri;
this.context = context;
}
@Override
public void run() {
Looper.prepare();
player = ExoPlayer.Factory.newInstance(1);
player.addListener(this);
ExtractorSampleSource sampleSource = new ExtractorSampleSource(
uri, new DefaultUriDataSource(context, Util.getUserAgent(context, "ExoPlayerExtVP9Test")),
new DefaultAllocator(BUFFER_SEGMENT_SIZE), BUFFER_SEGMENT_SIZE * BUFFER_SEGMENT_COUNT,
new WebmExtractor());
LibvpxVideoTrackRenderer videoRenderer = new LibvpxVideoTrackRenderer(sampleSource, true);
player.sendMessage(videoRenderer, LibvpxVideoTrackRenderer.MSG_SET_OUTPUT_BUFFER_RENDERER,
new VpxVideoSurfaceView(context));
player.prepare(videoRenderer);
player.setPlayWhenReady(true);
Looper.loop();
}
@Override
public void onPlayWhenReadyCommitted () {
// Do nothing.
}
@Override
public void onPlayerError(ExoPlaybackException error) {
playbackException = error;
}
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
if (playbackState == ExoPlayer.STATE_ENDED
|| (playbackState == ExoPlayer.STATE_IDLE && playbackException != null)) {
releasePlayerAndQuitLooper();
}
}
private void releasePlayerAndQuitLooper() {
player.release();
Looper.myLooper().quit();
}
}
}
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-23
This file is needed to make sure the res directory is present.
The file is ignored by the Android toolchain because its name starts with a dot.
...@@ -49,7 +49,7 @@ import java.nio.ByteBuffer; ...@@ -49,7 +49,7 @@ import java.nio.ByteBuffer;
public VpxDecoder() throws VpxDecoderException { public VpxDecoder() throws VpxDecoderException {
vpxDecContext = vpxInit(); vpxDecContext = vpxInit();
if (vpxDecContext == 0) { if (vpxDecContext == 0) {
throw new VpxDecoderException("libvpx initialization error: failed to initialize decoder"); throw new VpxDecoderException("Failed to initialize decoder");
} }
} }
...@@ -65,7 +65,7 @@ import java.nio.ByteBuffer; ...@@ -65,7 +65,7 @@ import java.nio.ByteBuffer;
public int decode(ByteBuffer encoded, int size, VpxOutputBuffer outputBuffer) public int decode(ByteBuffer encoded, int size, VpxOutputBuffer outputBuffer)
throws VpxDecoderException { throws VpxDecoderException {
if (vpxDecode(vpxDecContext, encoded, size) != 0) { if (vpxDecode(vpxDecContext, encoded, size) != 0) {
throw new VpxDecoderException("libvpx decode error: " + vpxGetErrorMessage(vpxDecContext)); throw new VpxDecoderException("Decode error: " + vpxGetErrorMessage(vpxDecContext));
} }
return vpxGetFrame(vpxDecContext, outputBuffer); return vpxGetFrame(vpxDecContext, outputBuffer);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment