Skip to content

Commit 1ff8495

Browse files
committed
Re-throw unrecoverable IOException from createEncoderByType
1 parent 60c610a commit 1ff8495

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

lib/src/main/java/net/ypresto/androidtranscoder/engine/MediaTranscoderEngine.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ private void setupMetadata() throws IOException {
148148
Log.d(TAG, "Duration (us): " + mDurationUs);
149149
}
150150

151-
private void setupTrackTranscoders(MediaFormatStrategy formatStrategy) throws IOException {
151+
private void setupTrackTranscoders(MediaFormatStrategy formatStrategy) {
152152
MediaExtractorUtils.TrackResult trackResult = MediaExtractorUtils.getFirstVideoAndAudioTrack(mExtractor);
153153
MediaFormat videoOutputFormat = formatStrategy.createVideoOutputFormat(trackResult.mVideoTrackFormat);
154154
MediaFormat audioOutputFormat = formatStrategy.createAudioOutputFormat(trackResult.mAudioTrackFormat);

lib/src/main/java/net/ypresto/androidtranscoder/engine/TrackTranscoder.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@
1717

1818
import android.media.MediaFormat;
1919

20-
import java.io.IOException;
21-
2220
public interface TrackTranscoder {
2321

24-
void setup() throws IOException;
22+
void setup();
2523

2624
/**
2725
* Get actual MediaFormat which is used to write to muxer.

lib/src/main/java/net/ypresto/androidtranscoder/engine/VideoTrackTranscoder.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,13 @@ public VideoTrackTranscoder(MediaExtractor extractor,
6262
}
6363

6464
@Override
65-
public void setup() throws IOException {
65+
public void setup() {
6666
mExtractor.selectTrack(mTrackIndex);
67-
mEncoder = MediaCodec.createEncoderByType(mOutputFormat.getString(MediaFormat.KEY_MIME));
67+
try {
68+
mEncoder = MediaCodec.createEncoderByType(mOutputFormat.getString(MediaFormat.KEY_MIME));
69+
} catch (IOException e) {
70+
throw new IllegalStateException(e);
71+
}
6872
mEncoder.configure(mOutputFormat, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
6973
mEncoderInputSurfaceWrapper = new InputSurface(mEncoder.createInputSurface());
7074
mEncoderInputSurfaceWrapper.makeCurrent();
@@ -80,7 +84,11 @@ public void setup() throws IOException {
8084
inputFormat.setInteger("rotation-degrees", 0);
8185
}
8286
mDecoderOutputSurfaceWrapper = new OutputSurface();
83-
mDecoder = MediaCodec.createDecoderByType(inputFormat.getString(MediaFormat.KEY_MIME));
87+
try {
88+
mDecoder = MediaCodec.createDecoderByType(inputFormat.getString(MediaFormat.KEY_MIME));
89+
} catch (IOException e) {
90+
throw new IllegalStateException(e);
91+
}
8492
mDecoder.configure(inputFormat, mDecoderOutputSurfaceWrapper.getSurface(), null, 0);
8593
mDecoder.start();
8694
mDecoderStarted = true;

0 commit comments

Comments
 (0)