@@ -201,8 +201,7 @@ public synchronized void queueInputTexture(
201
201
InputFrameInfo inputFrameInfo =
202
202
new InputFrameInfo (
203
203
textureProducer ,
204
- inputTexture ,
205
- presentationTimeUs ,
204
+ new TimedGlTextureInfo (inputTexture , presentationTimeUs ),
206
205
settings .getOverlaySettings (inputIndex , presentationTimeUs ));
207
206
inputSource .frameInfos .add (inputFrameInfo );
208
207
@@ -260,13 +259,15 @@ private synchronized void releaseExcessFramesInSecondaryStream(InputSource secon
260
259
// nextTimestampToComposite.
261
260
@ Nullable InputFrameInfo nextPrimaryFrame = primaryInputSource .frameInfos .peek ();
262
261
long nextTimestampToComposite =
263
- nextPrimaryFrame != null ? nextPrimaryFrame .presentationTimeUs : C .TIME_UNSET ;
262
+ nextPrimaryFrame != null
263
+ ? nextPrimaryFrame .timedGlTextureInfo .presentationTimeUs
264
+ : C .TIME_UNSET ;
264
265
265
266
int numberOfSecondaryFramesBeforeOrAtNextTargetTimestamp =
266
267
Iterables .size (
267
268
Iterables .filter (
268
269
secondaryInputSource .frameInfos ,
269
- frame -> frame .presentationTimeUs <= nextTimestampToComposite ));
270
+ frame -> frame .timedGlTextureInfo . presentationTimeUs <= nextTimestampToComposite ));
270
271
releaseFrames (
271
272
secondaryInputSource ,
272
273
/* numberOfFramesToRelease= */ max (
@@ -277,7 +278,7 @@ private synchronized void releaseFrames(InputSource inputSource, int numberOfFra
277
278
for (int i = 0 ; i < numberOfFramesToRelease ; i ++) {
278
279
InputFrameInfo frameInfoToRelease = inputSource .frameInfos .remove ();
279
280
frameInfoToRelease .textureProducer .releaseOutputTexture (
280
- frameInfoToRelease .presentationTimeUs );
281
+ frameInfoToRelease .timedGlTextureInfo . presentationTimeUs );
281
282
}
282
283
}
283
284
@@ -302,15 +303,15 @@ private synchronized void maybeComposite()
302
303
303
304
ImmutableList .Builder <Size > inputSizes = new ImmutableList .Builder <>();
304
305
for (int i = 0 ; i < framesToComposite .size (); i ++) {
305
- GlTextureInfo texture = framesToComposite .get (i ).texture ;
306
+ GlTextureInfo texture = framesToComposite .get (i ).timedGlTextureInfo . glTextureInfo ;
306
307
inputSizes .add (new Size (texture .width , texture .height ));
307
308
}
308
309
Size outputSize = settings .getOutputSize (inputSizes .build ());
309
310
outputTexturePool .ensureConfigured (
310
311
glObjectsProvider , outputSize .getWidth (), outputSize .getHeight ());
311
312
312
313
GlTextureInfo outputTexture = outputTexturePool .useTexture ();
313
- long outputPresentationTimestampUs = primaryInputFrame .presentationTimeUs ;
314
+ long outputPresentationTimestampUs = primaryInputFrame .timedGlTextureInfo . presentationTimeUs ;
314
315
outputTextureTimestamps .add (outputPresentationTimestampUs );
315
316
316
317
compositorGlProgram .drawFrame (framesToComposite , outputTexture );
@@ -369,16 +370,18 @@ private synchronized ImmutableList<InputFrameInfo> getFramesToComposite() {
369
370
Iterator <InputFrameInfo > frameInfosIterator = secondaryInputSource .frameInfos .iterator ();
370
371
while (frameInfosIterator .hasNext ()) {
371
372
InputFrameInfo candidateFrame = frameInfosIterator .next ();
372
- long candidateTimestampUs = candidateFrame .presentationTimeUs ;
373
+ long candidateTimestampUs = candidateFrame .timedGlTextureInfo . presentationTimeUs ;
373
374
long candidateAbsDistance =
374
- abs (candidateTimestampUs - primaryFrameToComposite .presentationTimeUs );
375
+ abs (
376
+ candidateTimestampUs
377
+ - primaryFrameToComposite .timedGlTextureInfo .presentationTimeUs );
375
378
376
379
if (candidateAbsDistance < minTimeDiffFromPrimaryUs ) {
377
380
minTimeDiffFromPrimaryUs = candidateAbsDistance ;
378
381
secondaryFrameToComposite = candidateFrame ;
379
382
}
380
383
381
- if (candidateTimestampUs > primaryFrameToComposite .presentationTimeUs
384
+ if (candidateTimestampUs > primaryFrameToComposite .timedGlTextureInfo . presentationTimeUs
382
385
|| (!frameInfosIterator .hasNext () && secondaryInputSource .isInputEnded )) {
383
386
framesToComposite .add (checkNotNull (secondaryFrameToComposite ));
384
387
break ;
@@ -503,7 +506,7 @@ private void ensureConfigured() throws VideoFrameProcessingException, GlUtil.GlE
503
506
504
507
private void blendOntoFocusedTexture (InputFrameInfo inputFrameInfo ) throws GlUtil .GlException {
505
508
GlProgram glProgram = checkNotNull (this .glProgram );
506
- GlTextureInfo inputTexture = inputFrameInfo .texture ;
509
+ GlTextureInfo inputTexture = inputFrameInfo .timedGlTextureInfo . glTextureInfo ;
507
510
glProgram .setSamplerTexIdUniform ("uTexSampler" , inputTexture .texId , /* texUnitIndex= */ 0 );
508
511
float [] transformationMatrix =
509
512
overlayMatrixProvider .getTransformationMatrix (
@@ -537,18 +540,15 @@ public InputSource() {
537
540
/** Holds information on a frame and how to release it. */
538
541
private static final class InputFrameInfo {
539
542
public final GlTextureProducer textureProducer ;
540
- public final GlTextureInfo texture ;
541
- public final long presentationTimeUs ;
543
+ public final TimedGlTextureInfo timedGlTextureInfo ;
542
544
public final OverlaySettings overlaySettings ;
543
545
544
546
public InputFrameInfo (
545
547
GlTextureProducer textureProducer ,
546
- GlTextureInfo texture ,
547
- long presentationTimeUs ,
548
+ TimedGlTextureInfo timedGlTextureInfo ,
548
549
OverlaySettings overlaySettings ) {
549
550
this .textureProducer = textureProducer ;
550
- this .texture = texture ;
551
- this .presentationTimeUs = presentationTimeUs ;
551
+ this .timedGlTextureInfo = timedGlTextureInfo ;
552
552
this .overlaySettings = overlaySettings ;
553
553
}
554
554
}
0 commit comments