use of org.checkerframework.checker.nullness.qual.RequiresNonNull in project ExoPlayer by google.
the class TransformerBaseRenderer method feedPipelineFromInput.
/**
* Attempts to read input data and pass the input data to the sample pipeline.
*
* @return Whether it may be possible to read more data immediately by calling this method again.
* @throws TransformationException If a {@link SamplePipeline} problem occurs.
*/
@RequiresNonNull("samplePipeline")
private boolean feedPipelineFromInput() throws TransformationException {
@Nullable DecoderInputBuffer samplePipelineInputBuffer = samplePipeline.dequeueInputBuffer();
if (samplePipelineInputBuffer == null) {
return false;
}
@ReadDataResult int result = readSource(getFormatHolder(), samplePipelineInputBuffer, /* readFlags= */
0);
switch(result) {
case C.RESULT_BUFFER_READ:
samplePipelineInputBuffer.flip();
if (samplePipelineInputBuffer.isEndOfStream()) {
samplePipeline.queueInputBuffer();
return false;
}
mediaClock.updateTimeForTrackType(getTrackType(), samplePipelineInputBuffer.timeUs);
samplePipelineInputBuffer.timeUs -= streamOffsetUs;
checkStateNotNull(samplePipelineInputBuffer.data);
maybeQueueSampleToPipeline(samplePipelineInputBuffer);
return true;
case C.RESULT_FORMAT_READ:
throw new IllegalStateException("Format changes are not supported.");
case C.RESULT_NOTHING_READ:
default:
return false;
}
}
use of org.checkerframework.checker.nullness.qual.RequiresNonNull in project ExoPlayer by google.
the class TransformerActivity method createTransformer.
@RequiresNonNull({ "playerView", "debugTextView", "informationTextView", "transformationStopwatch", "progressViewGroup", "debugFrame" })
private Transformer createTransformer(@Nullable Bundle bundle, String filePath) {
Transformer.Builder transformerBuilder = new Transformer.Builder(/* context= */
this);
if (bundle != null) {
TransformationRequest.Builder requestBuilder = new TransformationRequest.Builder();
requestBuilder.setFlattenForSlowMotion(bundle.getBoolean(ConfigurationActivity.SHOULD_FLATTEN_FOR_SLOW_MOTION));
@Nullable String audioMimeType = bundle.getString(ConfigurationActivity.AUDIO_MIME_TYPE);
if (audioMimeType != null) {
requestBuilder.setAudioMimeType(audioMimeType);
}
@Nullable String videoMimeType = bundle.getString(ConfigurationActivity.VIDEO_MIME_TYPE);
if (videoMimeType != null) {
requestBuilder.setVideoMimeType(videoMimeType);
}
int resolutionHeight = bundle.getInt(ConfigurationActivity.RESOLUTION_HEIGHT, /* defaultValue= */
C.LENGTH_UNSET);
if (resolutionHeight != C.LENGTH_UNSET) {
requestBuilder.setResolution(resolutionHeight);
}
Matrix transformationMatrix = getTransformationMatrix(bundle);
if (!transformationMatrix.isIdentity()) {
requestBuilder.setTransformationMatrix(transformationMatrix);
}
requestBuilder.experimental_setEnableHdrEditing(bundle.getBoolean(ConfigurationActivity.ENABLE_HDR_EDITING));
transformerBuilder.setTransformationRequest(requestBuilder.build()).setRemoveAudio(bundle.getBoolean(ConfigurationActivity.SHOULD_REMOVE_AUDIO)).setRemoveVideo(bundle.getBoolean(ConfigurationActivity.SHOULD_REMOVE_VIDEO));
}
return transformerBuilder.addListener(new Transformer.Listener() {
@Override
public void onTransformationCompleted(MediaItem mediaItem) {
TransformerActivity.this.onTransformationCompleted(filePath);
}
@Override
public void onTransformationError(MediaItem mediaItem, TransformationException exception) {
TransformerActivity.this.onTransformationError(exception);
}
}).setDebugViewProvider(new DemoDebugViewProvider()).build();
}
use of org.checkerframework.checker.nullness.qual.RequiresNonNull in project ExoPlayer by google.
the class ConfigurationActivity method startTransformation.
@RequiresNonNull({ "removeAudioCheckbox", "removeVideoCheckbox", "flattenForSlowMotionCheckbox", "audioMimeSpinner", "videoMimeSpinner", "resolutionHeightSpinner", "translateSpinner", "scaleSpinner", "rotateSpinner", "enableHdrEditingCheckBox" })
private void startTransformation(View view) {
Intent transformerIntent = new Intent(this, TransformerActivity.class);
Bundle bundle = new Bundle();
bundle.putBoolean(SHOULD_REMOVE_AUDIO, removeAudioCheckbox.isChecked());
bundle.putBoolean(SHOULD_REMOVE_VIDEO, removeVideoCheckbox.isChecked());
bundle.putBoolean(SHOULD_FLATTEN_FOR_SLOW_MOTION, flattenForSlowMotionCheckbox.isChecked());
String selectedAudioMimeType = String.valueOf(audioMimeSpinner.getSelectedItem());
if (!SAME_AS_INPUT_OPTION.equals(selectedAudioMimeType)) {
bundle.putString(AUDIO_MIME_TYPE, selectedAudioMimeType);
}
String selectedVideoMimeType = String.valueOf(videoMimeSpinner.getSelectedItem());
if (!SAME_AS_INPUT_OPTION.equals(selectedVideoMimeType)) {
bundle.putString(VIDEO_MIME_TYPE, selectedVideoMimeType);
}
String selectedResolutionHeight = String.valueOf(resolutionHeightSpinner.getSelectedItem());
if (!SAME_AS_INPUT_OPTION.equals(selectedResolutionHeight)) {
bundle.putInt(RESOLUTION_HEIGHT, Integer.parseInt(selectedResolutionHeight));
}
String selectedTranslate = String.valueOf(translateSpinner.getSelectedItem());
if (!SAME_AS_INPUT_OPTION.equals(selectedTranslate)) {
List<String> translateXY = Arrays.asList(selectedTranslate.split(", "));
checkState(translateXY.size() == 2);
bundle.putFloat(TRANSLATE_X, Float.parseFloat(translateXY.get(0)));
bundle.putFloat(TRANSLATE_Y, Float.parseFloat(translateXY.get(1)));
}
String selectedScale = String.valueOf(scaleSpinner.getSelectedItem());
if (!SAME_AS_INPUT_OPTION.equals(selectedScale)) {
List<String> scaleXY = Arrays.asList(selectedScale.split(", "));
checkState(scaleXY.size() == 2);
bundle.putFloat(SCALE_X, Float.parseFloat(scaleXY.get(0)));
bundle.putFloat(SCALE_Y, Float.parseFloat(scaleXY.get(1)));
}
String selectedRotate = String.valueOf(rotateSpinner.getSelectedItem());
if (!SAME_AS_INPUT_OPTION.equals(selectedRotate)) {
bundle.putFloat(ROTATE_DEGREES, Float.parseFloat(selectedRotate));
}
bundle.putBoolean(ENABLE_HDR_EDITING, enableHdrEditingCheckBox.isChecked());
transformerIntent.putExtras(bundle);
@Nullable Uri intentUri = getIntent().getData();
transformerIntent.setData(intentUri != null ? intentUri : Uri.parse(INPUT_URIS[inputUriPosition]));
startActivity(transformerIntent);
}
use of org.checkerframework.checker.nullness.qual.RequiresNonNull in project ExoPlayer by google.
the class TransformerVideoRenderer method maybeQueueSampleToPipeline.
/**
* Queues the input buffer to the sample pipeline unless it should be dropped because of slow
* motion flattening.
*
* @param inputBuffer The {@link DecoderInputBuffer}.
* @throws TransformationException If a {@link SamplePipeline} problem occurs.
*/
@Override
@RequiresNonNull({ "samplePipeline", "#1.data" })
protected void maybeQueueSampleToPipeline(DecoderInputBuffer inputBuffer) throws TransformationException {
ByteBuffer data = inputBuffer.data;
boolean shouldDropSample = sefSlowMotionFlattener != null && sefSlowMotionFlattener.dropOrTransformSample(inputBuffer);
if (shouldDropSample) {
data.clear();
} else {
samplePipeline.queueInputBuffer();
}
}
use of org.checkerframework.checker.nullness.qual.RequiresNonNull in project ExoPlayer by google.
the class H264Reader method endNalUnit.
@RequiresNonNull({ "output", "sampleReader" })
private void endNalUnit(long position, int offset, int discardPadding, long pesTimeUs) {
if (!hasOutputFormat || sampleReader.needsSpsPps()) {
sps.endNalUnit(discardPadding);
pps.endNalUnit(discardPadding);
if (!hasOutputFormat) {
if (sps.isCompleted() && pps.isCompleted()) {
List<byte[]> initializationData = new ArrayList<>();
initializationData.add(Arrays.copyOf(sps.nalData, sps.nalLength));
initializationData.add(Arrays.copyOf(pps.nalData, pps.nalLength));
NalUnitUtil.SpsData spsData = NalUnitUtil.parseSpsNalUnit(sps.nalData, 3, sps.nalLength);
NalUnitUtil.PpsData ppsData = NalUnitUtil.parsePpsNalUnit(pps.nalData, 3, pps.nalLength);
String codecs = CodecSpecificDataUtil.buildAvcCodecString(spsData.profileIdc, spsData.constraintsFlagsAndReservedZero2Bits, spsData.levelIdc);
output.format(new Format.Builder().setId(formatId).setSampleMimeType(MimeTypes.VIDEO_H264).setCodecs(codecs).setWidth(spsData.width).setHeight(spsData.height).setPixelWidthHeightRatio(spsData.pixelWidthHeightRatio).setInitializationData(initializationData).build());
hasOutputFormat = true;
sampleReader.putSps(spsData);
sampleReader.putPps(ppsData);
sps.reset();
pps.reset();
}
} else if (sps.isCompleted()) {
NalUnitUtil.SpsData spsData = NalUnitUtil.parseSpsNalUnit(sps.nalData, 3, sps.nalLength);
sampleReader.putSps(spsData);
sps.reset();
} else if (pps.isCompleted()) {
NalUnitUtil.PpsData ppsData = NalUnitUtil.parsePpsNalUnit(pps.nalData, 3, pps.nalLength);
sampleReader.putPps(ppsData);
pps.reset();
}
}
if (sei.endNalUnit(discardPadding)) {
int unescapedLength = NalUnitUtil.unescapeStream(sei.nalData, sei.nalLength);
seiWrapper.reset(sei.nalData, unescapedLength);
// NAL prefix and nal_unit() header.
seiWrapper.setPosition(4);
seiReader.consume(pesTimeUs, seiWrapper);
}
boolean sampleIsKeyFrame = sampleReader.endNalUnit(position, offset, hasOutputFormat, randomAccessIndicator);
if (sampleIsKeyFrame) {
// This is either an IDR frame or the first I-frame since the random access indicator, so mark
// it as a keyframe. Clear the flag so that subsequent non-IDR I-frames are not marked as
// keyframes until we see another random access indicator.
randomAccessIndicator = false;
}
}
Aggregations