Commit 62a35018 by hschlueter Committed by tonihei

Separate TransformerAudioRenderer and new AudioSamplePipeline.

`TransformerAudioRenderer` reads input and passes `DecoderInputBuffer`s to the `AudioSamplePipeline`. The `AudioSamplePipeline` handles all steps from decoding to encoding. `TransformerAudioRenderer` receives `DecoderInputBuffer`s from the `AudioSamplePipeline` and passes their data to the muxer.

`AudioSamplePipeline` implements a new interface `SamplePipeline`. A pass-through pipeline will be added in a future cl.

PiperOrigin-RevId: 407555102
parent 0e88f13e
/*
* Copyright 2021 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.exoplayer2.transformer;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.decoder.DecoderInputBuffer;
/**
* Pipeline for processing {@link DecoderInputBuffer DecoderInputBuffers}.
*
* <p>This pipeline can be used to implement transformations of audio or video samples.
*/
/* package */ interface SamplePipeline {
/** Returns a buffer if the pipeline is ready to accept input, and {@code null} otherwise. */
@Nullable
DecoderInputBuffer dequeueInputBuffer();
/**
* Informs the pipeline that its input buffer contains new input.
*
* <p>Should be called after filling the input buffer from {@link #dequeueInputBuffer()} with new
* input.
*/
void queueInputBuffer();
/**
* Process the input data and returns whether more data can be processed by calling this method
* again.
*/
boolean processData() throws ExoPlaybackException;
/** Returns the output format of the pipeline if available, and {@code null} otherwise. */
@Nullable
Format getOutputFormat();
/** Returns an output buffer if the pipeline has produced output, and {@code null} otherwise */
@Nullable
DecoderInputBuffer getOutputBuffer();
/**
* Releases the pipeline's output buffer.
*
* <p>Should be called when the output buffer from {@link #getOutputBuffer()} is no longer needed.
*/
void releaseOutputBuffer();
/** Returns whether the pipeline has ended. */
boolean isEnded();
/** Releases all resources held by the pipeline. */
void release();
}
...@@ -286,30 +286,6 @@ sample: ...@@ -286,30 +286,6 @@ sample:
isKeyFrame = true isKeyFrame = true
presentationTimeUs = 67627 presentationTimeUs = 67627
sample: sample:
trackIndex = 1
dataHashCode = -1830836678
size = 1051
isKeyFrame = false
presentationTimeUs = 500500
sample:
trackIndex = 1
dataHashCode = 1767407540
size = 874
isKeyFrame = false
presentationTimeUs = 467133
sample:
trackIndex = 1
dataHashCode = 918440283
size = 781
isKeyFrame = false
presentationTimeUs = 533866
sample:
trackIndex = 1
dataHashCode = -1408463661
size = 4725
isKeyFrame = false
presentationTimeUs = 700700
sample:
trackIndex = 0 trackIndex = 0
dataHashCode = -997198863 dataHashCode = -997198863
size = 238 size = 238
...@@ -401,6 +377,30 @@ sample: ...@@ -401,6 +377,30 @@ sample:
presentationTimeUs = 107644 presentationTimeUs = 107644
sample: sample:
trackIndex = 1 trackIndex = 1
dataHashCode = -1830836678
size = 1051
isKeyFrame = false
presentationTimeUs = 500500
sample:
trackIndex = 1
dataHashCode = 1767407540
size = 874
isKeyFrame = false
presentationTimeUs = 467133
sample:
trackIndex = 1
dataHashCode = 918440283
size = 781
isKeyFrame = false
presentationTimeUs = 533866
sample:
trackIndex = 1
dataHashCode = -1408463661
size = 4725
isKeyFrame = false
presentationTimeUs = 700700
sample:
trackIndex = 1
dataHashCode = 1569455924 dataHashCode = 1569455924
size = 1022 size = 1022
isKeyFrame = false isKeyFrame = false
......
...@@ -132,64 +132,148 @@ sample: ...@@ -132,64 +132,148 @@ sample:
presentationTimeUs = 0 presentationTimeUs = 0
sample: sample:
trackIndex = 0 trackIndex = 0
dataHashCode = -833872563 dataHashCode = 1000136444
size = 1732 size = 140
isKeyFrame = true isKeyFrame = true
presentationTimeUs = 416 presentationTimeUs = 416
sample: sample:
trackIndex = 0 trackIndex = 0
dataHashCode = -135901925 dataHashCode = 217961709
size = 380 size = 172
isKeyFrame = true isKeyFrame = true
presentationTimeUs = 36499 presentationTimeUs = 3332
sample:
trackIndex = 0
dataHashCode = -879376936
size = 176
isKeyFrame = true
presentationTimeUs = 6915
sample:
trackIndex = 0
dataHashCode = 1259979587
size = 192
isKeyFrame = true
presentationTimeUs = 10581
sample:
trackIndex = 0
dataHashCode = 907407225
size = 188
isKeyFrame = true
presentationTimeUs = 14581
sample:
trackIndex = 0
dataHashCode = -904354707
size = 176
isKeyFrame = true
presentationTimeUs = 18497
sample:
trackIndex = 0
dataHashCode = 1001385853
size = 172
isKeyFrame = true
presentationTimeUs = 22163
sample:
trackIndex = 0
dataHashCode = 1545716086
size = 196
isKeyFrame = true
presentationTimeUs = 25746
sample:
trackIndex = 0
dataHashCode = 358710839
size = 180
isKeyFrame = true
presentationTimeUs = 29829
sample:
trackIndex = 0
dataHashCode = -671124798
size = 140
isKeyFrame = true
presentationTimeUs = 33579
sample:
trackIndex = 0
dataHashCode = -945404910
size = 120
isKeyFrame = true
presentationTimeUs = 36495
sample:
trackIndex = 0
dataHashCode = 1881048379
size = 88
isKeyFrame = true
presentationTimeUs = 38995
sample:
trackIndex = 0
dataHashCode = 1059579897
size = 88
isKeyFrame = true
presentationTimeUs = 40828
sample:
trackIndex = 0
dataHashCode = 1496098648
size = 84
isKeyFrame = true
presentationTimeUs = 42661
sample: sample:
trackIndex = 0 trackIndex = 0
dataHashCode = 250093960 dataHashCode = 250093960
size = 751 size = 751
isKeyFrame = true isKeyFrame = true
presentationTimeUs = 44415 presentationTimeUs = 44411
sample: sample:
trackIndex = 0 trackIndex = 0
dataHashCode = 1895536226 dataHashCode = 1895536226
size = 1045 size = 1045
isKeyFrame = true isKeyFrame = true
presentationTimeUs = 59998 presentationTimeUs = 59994
sample: sample:
trackIndex = 0 trackIndex = 0
dataHashCode = 1723596464 dataHashCode = 1723596464
size = 947 size = 947
isKeyFrame = true isKeyFrame = true
presentationTimeUs = 81748 presentationTimeUs = 81744
sample: sample:
trackIndex = 0 trackIndex = 0
dataHashCode = -978803114 dataHashCode = -978803114
size = 946 size = 946
isKeyFrame = true isKeyFrame = true
presentationTimeUs = 101414 presentationTimeUs = 101410
sample: sample:
trackIndex = 0 trackIndex = 0
dataHashCode = 387377078 dataHashCode = 387377078
size = 946 size = 946
isKeyFrame = true isKeyFrame = true
presentationTimeUs = 121080 presentationTimeUs = 121076
sample: sample:
trackIndex = 0 trackIndex = 0
dataHashCode = -132658698 dataHashCode = -132658698
size = 901 size = 901
isKeyFrame = true isKeyFrame = true
presentationTimeUs = 140746 presentationTimeUs = 140742
sample: sample:
trackIndex = 0 trackIndex = 0
dataHashCode = 1495036471 dataHashCode = 1495036471
size = 899 size = 899
isKeyFrame = true isKeyFrame = true
presentationTimeUs = 159496 presentationTimeUs = 159492
sample: sample:
trackIndex = 0 trackIndex = 0
dataHashCode = 304440590 dataHashCode = 304440590
size = 878 size = 878
isKeyFrame = true isKeyFrame = true
presentationTimeUs = 178162 presentationTimeUs = 178158
sample:
trackIndex = 0
dataHashCode = -1955900344
size = 112
isKeyFrame = true
presentationTimeUs = 196408
sample:
trackIndex = 0
dataHashCode = 88896626
size = 116
isKeyFrame = true
presentationTimeUs = 198741
sample: sample:
trackIndex = 1 trackIndex = 1
dataHashCode = 2139021989 dataHashCode = 2139021989
...@@ -215,12 +299,6 @@ sample: ...@@ -215,12 +299,6 @@ sample:
isKeyFrame = false isKeyFrame = false
presentationTimeUs = 734083 presentationTimeUs = 734083
sample: sample:
trackIndex = 0
dataHashCode = -752661703
size = 228
isKeyFrame = true
presentationTimeUs = 196412
sample:
trackIndex = 1 trackIndex = 1
dataHashCode = -1554795381 dataHashCode = -1554795381
size = 205 size = 205
......
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