@@ -64,7 +64,7 @@ public boolean consumeRotationChange() {
64
64
65
65
public void streamScreen () throws IOException , ConfigurationException {
66
66
String videoMimeType = streamer .getCodec ().getMimeType ();
67
- MediaCodec codec = createCodec (videoMimeType , encoderName );
67
+ MediaCodec mediaCodec = createMediaCodec (videoMimeType , encoderName );
68
68
MediaFormat format = createFormat (videoMimeType , bitRate , maxFps , codecOptions );
69
69
IBinder display = createDisplay ();
70
70
device .setRotationListener (this );
@@ -84,20 +84,20 @@ public void streamScreen() throws IOException, ConfigurationException {
84
84
85
85
Surface surface = null ;
86
86
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 ();
89
89
90
90
// does not include the locked video orientation
91
91
Rect unlockedVideoRect = screenInfo .getUnlockedVideoSize ().toRect ();
92
92
int videoRotation = screenInfo .getVideoRotation ();
93
93
int layerStack = device .getLayerStack ();
94
94
setDisplaySurface (display , surface , videoRotation , contentRect , unlockedVideoRect , layerStack );
95
95
96
- codec .start ();
96
+ mediaCodec .start ();
97
97
98
- alive = encode (codec , streamer );
98
+ alive = encode (mediaCodec , streamer );
99
99
// do not call stop() on exception, it would trigger an IllegalStateException
100
- codec .stop ();
100
+ mediaCodec .stop ();
101
101
} catch (IllegalStateException | IllegalArgumentException e ) {
102
102
Ln .e ("Encoding error: " + e .getClass ().getName () + ": " + e .getMessage ());
103
103
if (!prepareRetry (device , screenInfo )) {
@@ -106,14 +106,14 @@ public void streamScreen() throws IOException, ConfigurationException {
106
106
Ln .i ("Retrying..." );
107
107
alive = true ;
108
108
} finally {
109
- codec .reset ();
109
+ mediaCodec .reset ();
110
110
if (surface != null ) {
111
111
surface .release ();
112
112
}
113
113
}
114
114
} while (alive );
115
115
} finally {
116
- codec .release ();
116
+ mediaCodec .release ();
117
117
device .setRotationListener (null );
118
118
SurfaceControl .destroyDisplay (display );
119
119
}
@@ -210,7 +210,7 @@ private static MediaCodecInfo[] listEncoders(String videoMimeType) {
210
210
return result .toArray (new MediaCodecInfo [result .size ()]);
211
211
}
212
212
213
- private static MediaCodec createCodec (String videoMimeType , String encoderName ) throws IOException , ConfigurationException {
213
+ private static MediaCodec createMediaCodec (String videoMimeType , String encoderName ) throws IOException , ConfigurationException {
214
214
if (encoderName != null ) {
215
215
Ln .d ("Creating encoder by name: '" + encoderName + "'" );
216
216
try {
@@ -220,9 +220,9 @@ private static MediaCodec createCodec(String videoMimeType, String encoderName)
220
220
throw new ConfigurationException ("Unknown encoder: " + encoderName );
221
221
}
222
222
}
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 ;
226
226
}
227
227
228
228
private static String buildUnknownEncoderMessage (String videoMimeType , String encoderName ) {
0 commit comments