Skip to content

Commit 883a998

Browse files
committed
Rename "codec" variable to "mediaCodec"
This will allow to use "codec" for the Codec type. PR #3757 <#3757>
1 parent 3c670dc commit 883a998

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java

+12-12
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public boolean consumeRotationChange() {
6464

6565
public void streamScreen() throws IOException, ConfigurationException {
6666
String videoMimeType = streamer.getCodec().getMimeType();
67-
MediaCodec codec = createCodec(videoMimeType, encoderName);
67+
MediaCodec mediaCodec = createMediaCodec(videoMimeType, encoderName);
6868
MediaFormat format = createFormat(videoMimeType, bitRate, maxFps, codecOptions);
6969
IBinder display = createDisplay();
7070
device.setRotationListener(this);
@@ -84,20 +84,20 @@ public void streamScreen() throws IOException, ConfigurationException {
8484

8585
Surface surface = null;
8686
try {
87-
codec.configure(format, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
88-
surface = codec.createInputSurface();
87+
mediaCodec.configure(format, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
88+
surface = mediaCodec.createInputSurface();
8989

9090
// does not include the locked video orientation
9191
Rect unlockedVideoRect = screenInfo.getUnlockedVideoSize().toRect();
9292
int videoRotation = screenInfo.getVideoRotation();
9393
int layerStack = device.getLayerStack();
9494
setDisplaySurface(display, surface, videoRotation, contentRect, unlockedVideoRect, layerStack);
9595

96-
codec.start();
96+
mediaCodec.start();
9797

98-
alive = encode(codec, streamer);
98+
alive = encode(mediaCodec, streamer);
9999
// do not call stop() on exception, it would trigger an IllegalStateException
100-
codec.stop();
100+
mediaCodec.stop();
101101
} catch (IllegalStateException | IllegalArgumentException e) {
102102
Ln.e("Encoding error: " + e.getClass().getName() + ": " + e.getMessage());
103103
if (!prepareRetry(device, screenInfo)) {
@@ -106,14 +106,14 @@ public void streamScreen() throws IOException, ConfigurationException {
106106
Ln.i("Retrying...");
107107
alive = true;
108108
} finally {
109-
codec.reset();
109+
mediaCodec.reset();
110110
if (surface != null) {
111111
surface.release();
112112
}
113113
}
114114
} while (alive);
115115
} finally {
116-
codec.release();
116+
mediaCodec.release();
117117
device.setRotationListener(null);
118118
SurfaceControl.destroyDisplay(display);
119119
}
@@ -210,7 +210,7 @@ private static MediaCodecInfo[] listEncoders(String videoMimeType) {
210210
return result.toArray(new MediaCodecInfo[result.size()]);
211211
}
212212

213-
private static MediaCodec createCodec(String videoMimeType, String encoderName) throws IOException, ConfigurationException {
213+
private static MediaCodec createMediaCodec(String videoMimeType, String encoderName) throws IOException, ConfigurationException {
214214
if (encoderName != null) {
215215
Ln.d("Creating encoder by name: '" + encoderName + "'");
216216
try {
@@ -220,9 +220,9 @@ private static MediaCodec createCodec(String videoMimeType, String encoderName)
220220
throw new ConfigurationException("Unknown encoder: " + encoderName);
221221
}
222222
}
223-
MediaCodec codec = MediaCodec.createEncoderByType(videoMimeType);
224-
Ln.d("Using encoder: '" + codec.getName() + "'");
225-
return codec;
223+
MediaCodec mediaCodec = MediaCodec.createEncoderByType(videoMimeType);
224+
Ln.d("Using encoder: '" + mediaCodec.getName() + "'");
225+
return mediaCodec;
226226
}
227227

228228
private static String buildUnknownEncoderMessage(String videoMimeType, String encoderName) {

0 commit comments

Comments
 (0)