Skip to content

Commit

Permalink
Cherry-picked battery code
Browse files Browse the repository at this point in the history
  • Loading branch information
MallikarjunKamble committed Aug 9, 2024
1 parent 63edfdc commit 7d326a6
Show file tree
Hide file tree
Showing 8 changed files with 528 additions and 31 deletions.
3 changes: 3 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ dependencies {
implementation group: 'com.google.protobuf', name: 'protobuf-java-util', version: '3.12.0'
implementation 'com.google.code.gson:gson:2.8.0'
implementation 'com.google.protobuf:protobuf-java:3.19.4'
implementation 'androidx.activity:activity:1.5.1'
implementation 'androidx.activity:activity-ktx:1.5.1'
implementation 'androidx.fragment:fragment:1.3.4'
}


Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.BATTERY_STATS" />
<uses-feature android:name="android.hardware.camera.any" />
<uses-feature android:name="android.hardware.camera" android:required="true" />

Expand Down
35 changes: 25 additions & 10 deletions app/src/main/java/com/facebook/encapp/BufferTranscoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,19 @@ public String start() {
mStats.start();
try {
// start bufferTranscoding
bufferTranscoding(trackNum);
long startTime = System.currentTimeMillis();
long durationMs = 2 * 60 * 1000; // 30 minutes

while (System.currentTimeMillis() - startTime < durationMs) {
//mExtractor.setDataSource(mTest.getInput().getFilepath());
//trackNum = mExtractor.getTrackCount();
mExtractor.seekTo(0, MediaExtractor.SEEK_TO_CLOSEST_SYNC);
mExtractor.selectTrack(trackNum);

bufferTranscoding(trackNum);


}
} catch (Exception e) {
e.printStackTrace();
}
Expand Down Expand Up @@ -556,6 +568,7 @@ void bufferTranscoding(int trackIndex) throws IOException {
fo = new FileOutputStream(file);
}

int orgTrackIndex = trackIndex;
int estimatedSize = 1024;
byte[] headerArray = new byte[estimatedSize];
MediaMuxer muxer = null;
Expand Down Expand Up @@ -692,6 +705,8 @@ void bufferTranscoding(int trackIndex) throws IOException {
if(encOutputExtractDone){
Log.d(TAG, "encOutputExtractDone is true and getEncodedFrame() execution is over");
}
//if(trackIndex == (orgTrackIndex - 1))
// trackIndex = 0;
}
if(isx264Encoder) {
if (muxer != null) {
Expand Down Expand Up @@ -1119,19 +1134,19 @@ void submitFrameForEncoding(MediaMuxer muxer, int videoTrackIndex, FileOutputStr
wait(WAIT_TIME_SHORT_MS);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
encInpSubmitDone = true;
Log.d(TAG, "Submitted EOF for encoder ");
encInpSubmitDone = true;
Log.d(TAG, "Submitted EOF for encoder ");
Log.d(TAG, "Flag: " + decodedBufferInfo.flags + " Size: " + decodedBufferInfo.size + " presentationTimeUs: "+decodedBufferInfo.presentationTimeUs +
" submitted frame for enc: " + mInFramesCount);
}
" submitted frame for enc: " + mInFramesCount);
}
}else {
Log.d(TAG, "encInpBuffer is null");
}
Log.d(TAG, "encInpBuffer is null");
}

} else {
Log.d(TAG, "index value: " + index);
} else {
Log.d(TAG, "index value: " + index);
}
}
}
Expand Down
Loading

0 comments on commit 7d326a6

Please sign in to comment.