Skip to content

Commit c279b9e

Browse files
committed
io.appium.settings: recording: Cosmetical naming and log updates
Signed-off-by: sirmordred <[email protected]>
1 parent 92eb6c0 commit c279b9e

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

app/src/main/java/io/appium/settings/recorder/RecorderConstant.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,6 @@ public class RecorderConstant {
7272
Pair.create(320, 240),
7373
Pair.create(176, 144)
7474
);
75+
// 1048576 Bps == 1 Mbps (1024*1024)
76+
public static final float BPS_IN_MBPS = 1048576f;
7577
}

app/src/main/java/io/appium/settings/recorder/RecorderService.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,15 @@ public int onStartCommand(final Intent intent, final int flags, final int startI
8989
(MediaProjectionManager) getSystemService(Context.MEDIA_PROJECTION_SERVICE);
9090

9191
if (mMediaProjectionManager != null) {
92-
startScreenRecord(mMediaProjectionManager, intent);
92+
startRecord(mMediaProjectionManager, intent);
9393
} else {
9494
Log.e(TAG, "onStartCommand: " +
9595
"Unable to retrieve MediaProjectionManager instance");
9696
result = START_NOT_STICKY;
9797
}
9898
} else if (ACTION_RECORDING_STOP.equals(action)) {
9999
Log.v(TAG, "onStartCommand: Received recording stop intent, stopping recording");
100-
stopScreenRecord();
100+
stopRecord();
101101
result = START_NOT_STICKY;
102102
} else {
103103
Log.v(TAG, "onStartCommand: Received unknown recording intent with action: "
@@ -109,10 +109,10 @@ public int onStartCommand(final Intent intent, final int flags, final int startI
109109
}
110110

111111
/**
112-
* start screen recording
112+
* start recording
113113
*/
114114
@RequiresApi(api = Build.VERSION_CODES.Q)
115-
private void startScreenRecord(MediaProjectionManager mediaProjectionManager,
115+
private void startRecord(MediaProjectionManager mediaProjectionManager,
116116
final Intent intent) {
117117
if (recorderThread != null) {
118118
if (recorderThread.isRecordingRunning()) {
@@ -186,9 +186,9 @@ but if phone or tablet is in portrait mode (usually it is),
186186
}
187187

188188
/**
189-
* stop screen recording
189+
* stop recording
190190
*/
191-
private void stopScreenRecord() {
191+
private void stopRecord() {
192192
if (recorderThread != null) {
193193
recorderThread.stopRecording();
194194
recorderThread = null;

app/src/main/java/io/appium/settings/recorder/RecorderThread.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939

4040
import androidx.annotation.RequiresApi;
4141

42+
import static io.appium.settings.recorder.RecorderConstant.BPS_IN_MBPS;
4243
import static io.appium.settings.recorder.RecorderConstant.NANOSECONDS_IN_MICROSECOND;
4344
import static io.appium.settings.recorder.RecorderConstant.NO_TIMESTAMP_SET;
4445
import static io.appium.settings.recorder.RecorderConstant.NO_TRACK_INDEX_SET;
@@ -143,7 +144,7 @@ private VirtualDisplay initVirtualDisplay(MediaProjection mediaProjection,
143144

144145
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
145146
private MediaCodec initAudioCodec(int sampleRate) throws IOException {
146-
// Encoded video resolution matches virtual display. TODO set channelCount 2 try stereo quality
147+
// TODO set channelCount 2 try stereo quality
147148
MediaFormat encoderFormat = MediaFormat.createAudioFormat(MediaFormat.MIMETYPE_AUDIO_AAC,
148149
sampleRate, RecorderConstant.AUDIO_CODEC_CHANNEL_COUNT);
149150
encoderFormat.setInteger(MediaFormat.KEY_BIT_RATE,
@@ -242,11 +243,8 @@ private long getPresentationTimeUs() {
242243
}
243244

244245
private int calculateBitRate(int width, int height, int frameRate) {
245-
final int bitrate = (int) (RecorderConstant.BITRATE_MULTIPLIER *
246+
return (int) (RecorderConstant.BITRATE_MULTIPLIER *
246247
frameRate * width * height);
247-
Log.i(TAG, String.format("Recording starting with bitrate=%5.2f[Mbps]",
248-
bitrate / 1024f / 1024f));
249-
return bitrate;
250248
}
251249

252250
private void startMuxerIfSetUp(MediaMuxer muxer) {
@@ -361,6 +359,10 @@ public void run() {
361359
int videoBitrate = videoEncoderCapabilities.getBitrateRange()
362360
.clamp(calculateBitRate(this.videoWidth, this.videoHeight, videoFrameRate));
363361

362+
Log.i(TAG, String.format("Recording starting with frame rate = %d FPS " +
363+
"and bitrate = %5.2f Mbps",
364+
videoFrameRate, videoBitrate / BPS_IN_MBPS));
365+
364366
MediaFormat videoEncoderFormat =
365367
initVideoEncoderFormat(RECORDING_DEFAULT_VIDEO_MIME_TYPE,
366368
this.videoWidth, this.videoHeight, videoBitrate, videoFrameRate);

0 commit comments

Comments
 (0)