Skip to content

Commit

Permalink
Rename BufferProcessor to AudioProcessor.
Browse files Browse the repository at this point in the history
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=148763781
  • Loading branch information
andrewlewis authored and ojw28 committed Feb 28, 2017
1 parent 91639b2 commit d58008e
Show file tree
Hide file tree
Showing 12 changed files with 120 additions and 128 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.audio.AudioProcessor;
import com.google.android.exoplayer2.audio.AudioRendererEventListener;
import com.google.android.exoplayer2.audio.BufferProcessor;
import com.google.android.exoplayer2.audio.SimpleDecoderAudioRenderer;
import com.google.android.exoplayer2.drm.ExoMediaCrypto;
import com.google.android.exoplayer2.util.MimeTypes;
Expand All @@ -43,12 +43,11 @@ public FfmpegAudioRenderer() {
* @param eventHandler A handler to use when delivering events to {@code eventListener}. May be
* null if delivery of events is not required.
* @param eventListener A listener of events. May be null if delivery of events is not required.
* @param bufferProcessors Optional {@link BufferProcessor}s which will process PCM audio buffers
* before they are output.
* @param audioProcessors Optional {@link AudioProcessor}s that will process audio before output.
*/
public FfmpegAudioRenderer(Handler eventHandler, AudioRendererEventListener eventListener,
BufferProcessor... bufferProcessors) {
super(eventHandler, eventListener, bufferProcessors);
AudioProcessor... audioProcessors) {
super(eventHandler, eventListener, audioProcessors);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

import android.os.Handler;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.audio.AudioProcessor;
import com.google.android.exoplayer2.audio.AudioRendererEventListener;
import com.google.android.exoplayer2.audio.BufferProcessor;
import com.google.android.exoplayer2.audio.SimpleDecoderAudioRenderer;
import com.google.android.exoplayer2.drm.ExoMediaCrypto;
import com.google.android.exoplayer2.util.MimeTypes;
Expand All @@ -38,12 +38,11 @@ public LibflacAudioRenderer() {
* @param eventHandler A handler to use when delivering events to {@code eventListener}. May be
* null if delivery of events is not required.
* @param eventListener A listener of events. May be null if delivery of events is not required.
* @param bufferProcessors Optional {@link BufferProcessor}s which will process PCM audio buffers
* before they are output.
* @param audioProcessors Optional {@link AudioProcessor}s that will process audio before output.
*/
public LibflacAudioRenderer(Handler eventHandler, AudioRendererEventListener eventListener,
BufferProcessor... bufferProcessors) {
super(eventHandler, eventListener, bufferProcessors);
AudioProcessor... audioProcessors) {
super(eventHandler, eventListener, audioProcessors);
}

@Override
Expand Down
11 changes: 5 additions & 6 deletions extensions/gvr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
## Description ##

The GVR extension wraps the [Google VR SDK for Android][]. It provides a
GvrBufferProcessor, which uses [GvrAudioSurround][] to provide binaural
rendering of surround sound and ambisonic soundfields.
GvrAudioProcessor, which uses [GvrAudioSurround][] to provide binaural rendering
of surround sound and ambisonic soundfields.

## Instructions ##

If using SimpleExoPlayer, override SimpleExoPlayer.buildBufferProcessors to
return a GvrBufferProcessor.
If using SimpleExoPlayer, override SimpleExoPlayer.buildAudioProcessors to
return a GvrAudioProcessor.

If constructing renderers directly, pass a GvrBufferProcessor to
If constructing renderers directly, pass a GvrAudioProcessor to
MediaCodecAudioRenderer's constructor.

[Google VR SDK for Android]: https://developers.google.com/vr/android/
[GvrAudioSurround]: https://developers.google.com/vr/android/reference/com/google/vr/sdk/audio/GvrAudioSurround

Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@

import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.audio.BufferProcessor;
import com.google.android.exoplayer2.audio.AudioProcessor;
import com.google.vr.sdk.audio.GvrAudioSurround;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

/**
* Buffer processor that uses {@code GvrAudioSurround} to provide binaural rendering of surround
* sound and ambisonic soundfields.
* An {@link AudioProcessor} that uses {@code GvrAudioSurround} to provide binaural rendering of
* surround sound and ambisonic soundfields.
*/
public final class GvrBufferProcessor implements BufferProcessor {
public final class GvrAudioProcessor implements AudioProcessor {

private static final int FRAMES_PER_OUTPUT_BUFFER = 1024;
private static final int OUTPUT_CHANNEL_COUNT = 2;
Expand All @@ -43,7 +43,7 @@ public final class GvrBufferProcessor implements BufferProcessor {
private float y;
private float z;

public GvrBufferProcessor() {
public GvrAudioProcessor() {
// Use the identity for the initial orientation.
w = 1f;
sampleRateHz = Format.NO_VALUE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

import android.os.Handler;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.audio.AudioProcessor;
import com.google.android.exoplayer2.audio.AudioRendererEventListener;
import com.google.android.exoplayer2.audio.BufferProcessor;
import com.google.android.exoplayer2.audio.SimpleDecoderAudioRenderer;
import com.google.android.exoplayer2.drm.DrmSessionManager;
import com.google.android.exoplayer2.drm.ExoMediaCrypto;
Expand All @@ -40,26 +40,24 @@ public LibopusAudioRenderer() {
* @param eventHandler A handler to use when delivering events to {@code eventListener}. May be
* null if delivery of events is not required.
* @param eventListener A listener of events. May be null if delivery of events is not required.
* @param bufferProcessors Optional {@link BufferProcessor}s which will process PCM audio buffers
* before they are output.
* @param audioProcessors Optional {@link AudioProcessor}s that will process audio before output.
*/
public LibopusAudioRenderer(Handler eventHandler, AudioRendererEventListener eventListener,
BufferProcessor... bufferProcessors) {
super(eventHandler, eventListener, bufferProcessors);
AudioProcessor... audioProcessors) {
super(eventHandler, eventListener, audioProcessors);
}

/**
* @param eventHandler A handler to use when delivering events to {@code eventListener}. May be
* null if delivery of events is not required.
* @param eventListener A listener of events. May be null if delivery of events is not required.
* @param bufferProcessors Optional {@link BufferProcessor}s which will process PCM audio
* buffers before they are output.
* @param audioProcessors Optional {@link AudioProcessor}s that will process audio before output.
*/
public LibopusAudioRenderer(Handler eventHandler, AudioRendererEventListener eventListener,
DrmSessionManager<ExoMediaCrypto> drmSessionManager, boolean playClearSamplesWithoutKeys,
BufferProcessor... bufferProcessors) {
AudioProcessor... audioProcessors) {
super(eventHandler, eventListener, null, drmSessionManager, playClearSamplesWithoutKeys,
bufferProcessors);
audioProcessors);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import android.view.SurfaceView;
import android.view.TextureView;
import com.google.android.exoplayer2.audio.AudioCapabilities;
import com.google.android.exoplayer2.audio.AudioProcessor;
import com.google.android.exoplayer2.audio.AudioRendererEventListener;
import com.google.android.exoplayer2.audio.BufferProcessor;
import com.google.android.exoplayer2.audio.MediaCodecAudioRenderer;
import com.google.android.exoplayer2.decoder.DecoderCounters;
import com.google.android.exoplayer2.drm.DrmSessionManager;
Expand Down Expand Up @@ -625,7 +625,7 @@ private void buildRenderers(Context context, Handler mainHandler,
buildVideoRenderers(context, mainHandler, drmSessionManager, extensionRendererMode,
componentListener, allowedVideoJoiningTimeMs, out);
buildAudioRenderers(context, mainHandler, drmSessionManager, extensionRendererMode,
componentListener, buildBufferProcessors(), out);
componentListener, buildAudioProcessors(), out);
buildTextRenderers(context, mainHandler, extensionRendererMode, componentListener, out);
buildMetadataRenderers(context, mainHandler, extensionRendererMode, componentListener, out);
buildMiscellaneousRenderers(context, mainHandler, extensionRendererMode, out);
Expand Down Expand Up @@ -685,16 +685,16 @@ protected void buildVideoRenderers(Context context, Handler mainHandler,
* not be used for DRM protected playbacks.
* @param extensionRendererMode The extension renderer mode.
* @param eventListener An event listener.
* @param bufferProcessors An array of {@link BufferProcessor}s which will process PCM audio
* buffers before they are output. May be empty.
* @param audioProcessors An array of {@link AudioProcessor}s that will process PCM audio buffers
* before output. May be empty.
* @param out An array to which the built renderers should be appended.
*/
protected void buildAudioRenderers(Context context, Handler mainHandler,
DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
@ExtensionRendererMode int extensionRendererMode, AudioRendererEventListener eventListener,
BufferProcessor[] bufferProcessors, ArrayList<Renderer> out) {
AudioProcessor[] audioProcessors, ArrayList<Renderer> out) {
out.add(new MediaCodecAudioRenderer(MediaCodecSelector.DEFAULT, drmSessionManager, true,
mainHandler, eventListener, AudioCapabilities.getCapabilities(context), bufferProcessors));
mainHandler, eventListener, AudioCapabilities.getCapabilities(context), audioProcessors));

if (extensionRendererMode == EXTENSION_RENDERER_MODE_OFF) {
return;
Expand All @@ -708,9 +708,9 @@ protected void buildAudioRenderers(Context context, Handler mainHandler,
Class<?> clazz =
Class.forName("com.google.android.exoplayer2.ext.opus.LibopusAudioRenderer");
Constructor<?> constructor = clazz.getConstructor(Handler.class,
AudioRendererEventListener.class, BufferProcessor[].class);
AudioRendererEventListener.class, AudioProcessor[].class);
Renderer renderer = (Renderer) constructor.newInstance(mainHandler, componentListener,
bufferProcessors);
audioProcessors);
out.add(extensionRendererIndex++, renderer);
Log.i(TAG, "Loaded LibopusAudioRenderer.");
} catch (ClassNotFoundException e) {
Expand All @@ -723,9 +723,9 @@ protected void buildAudioRenderers(Context context, Handler mainHandler,
Class<?> clazz =
Class.forName("com.google.android.exoplayer2.ext.flac.LibflacAudioRenderer");
Constructor<?> constructor = clazz.getConstructor(Handler.class,
AudioRendererEventListener.class, BufferProcessor[].class);
AudioRendererEventListener.class, AudioProcessor[].class);
Renderer renderer = (Renderer) constructor.newInstance(mainHandler, componentListener,
bufferProcessors);
audioProcessors);
out.add(extensionRendererIndex++, renderer);
Log.i(TAG, "Loaded LibflacAudioRenderer.");
} catch (ClassNotFoundException e) {
Expand All @@ -738,9 +738,9 @@ protected void buildAudioRenderers(Context context, Handler mainHandler,
Class<?> clazz =
Class.forName("com.google.android.exoplayer2.ext.ffmpeg.FfmpegAudioRenderer");
Constructor<?> constructor = clazz.getConstructor(Handler.class,
AudioRendererEventListener.class, BufferProcessor[].class);
AudioRendererEventListener.class, AudioProcessor[].class);
Renderer renderer = (Renderer) constructor.newInstance(mainHandler, componentListener,
bufferProcessors);
audioProcessors);
out.add(extensionRendererIndex++, renderer);
Log.i(TAG, "Loaded FfmpegAudioRenderer.");
} catch (ClassNotFoundException e) {
Expand Down Expand Up @@ -794,11 +794,10 @@ protected void buildMiscellaneousRenderers(Context context, Handler mainHandler,
}

/**
* Builds an array of {@link BufferProcessor}s which will process PCM audio buffers before they
* are output.
* Builds an array of {@link AudioProcessor}s that will process PCM audio before output.
*/
protected BufferProcessor[] buildBufferProcessors() {
return new BufferProcessor[0];
protected AudioProcessor[] buildAudioProcessors() {
return new AudioProcessor[0];
}

// Internal methods.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
import java.nio.ByteOrder;

/**
* Interface for processors of audio buffers.
* Interface for audio processors.
*/
public interface BufferProcessor {
public interface AudioProcessor {

/**
* Exception thrown when a processor can't be configured for a given input format.
* Exception thrown when a processor can't be configured for a given input audio format.
*/
final class UnhandledFormatException extends Exception {

Expand All @@ -42,7 +42,7 @@ public UnhandledFormatException(int sampleRateHz, int channelCount, @C.Encoding
ByteBuffer EMPTY_BUFFER = ByteBuffer.allocateDirect(0).order(ByteOrder.nativeOrder());

/**
* Configures the processor to process input buffers with the specified format. After calling this
* Configures the processor to process input audio with the specified format. After calling this
* method, {@link #isActive()} returns whether the processor needs to handle buffers; if not, the
* processor will not accept any buffers until it is reconfigured. Returns {@code true} if the
* processor must be flushed, or if the value returned by {@link #isActive()} has changed as a
Expand Down Expand Up @@ -111,7 +111,7 @@ boolean configure(int sampleRateHz, int channelCount, @C.Encoding int encoding)
boolean isEnded();

/**
* Clears any state in preparation for receiving a new stream of buffers.
* Clears any state in preparation for receiving a new stream of input buffers.
*/
void flush();

Expand Down
Loading

0 comments on commit d58008e

Please sign in to comment.