Convert between flag types
spotlessApply
This commit is contained in:
+15
-5
@@ -87,6 +87,17 @@ class MetadataStripper {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun extractorToCodecFlags(sampleFlags: Int): Int {
|
||||||
|
var flags = 0
|
||||||
|
if (sampleFlags and MediaExtractor.SAMPLE_FLAG_SYNC != 0) {
|
||||||
|
flags = flags or MediaCodec.BUFFER_FLAG_KEY_FRAME
|
||||||
|
}
|
||||||
|
if (sampleFlags and MediaExtractor.SAMPLE_FLAG_PARTIAL_FRAME != 0) {
|
||||||
|
flags = flags or MediaCodec.BUFFER_FLAG_PARTIAL_FRAME
|
||||||
|
}
|
||||||
|
return flags
|
||||||
|
}
|
||||||
|
|
||||||
fun stripImageMetadata(
|
fun stripImageMetadata(
|
||||||
uri: Uri,
|
uri: Uri,
|
||||||
context: Context,
|
context: Context,
|
||||||
@@ -158,7 +169,7 @@ class MetadataStripper {
|
|||||||
bufferInfo.offset = 0
|
bufferInfo.offset = 0
|
||||||
bufferInfo.size = sampleSize
|
bufferInfo.size = sampleSize
|
||||||
bufferInfo.presentationTimeUs = extractor.sampleTime
|
bufferInfo.presentationTimeUs = extractor.sampleTime
|
||||||
bufferInfo.flags = extractor.sampleFlags
|
bufferInfo.flags = extractorToCodecFlags(extractor.sampleFlags)
|
||||||
|
|
||||||
muxer.writeSampleData(outputTrack, buffer, bufferInfo)
|
muxer.writeSampleData(outputTrack, buffer, bufferInfo)
|
||||||
extractor.advance()
|
extractor.advance()
|
||||||
@@ -228,7 +239,7 @@ class MetadataStripper {
|
|||||||
bufferInfo.offset = 0
|
bufferInfo.offset = 0
|
||||||
bufferInfo.size = sampleSize
|
bufferInfo.size = sampleSize
|
||||||
bufferInfo.presentationTimeUs = extractor.sampleTime
|
bufferInfo.presentationTimeUs = extractor.sampleTime
|
||||||
bufferInfo.flags = extractor.sampleFlags
|
bufferInfo.flags = extractorToCodecFlags(extractor.sampleFlags)
|
||||||
|
|
||||||
muxer.writeSampleData(outputTrack, buffer, bufferInfo)
|
muxer.writeSampleData(outputTrack, buffer, bufferInfo)
|
||||||
extractor.advance()
|
extractor.advance()
|
||||||
@@ -252,12 +263,11 @@ class MetadataStripper {
|
|||||||
uri: Uri,
|
uri: Uri,
|
||||||
mimeType: String?,
|
mimeType: String?,
|
||||||
context: Context,
|
context: Context,
|
||||||
): Uri {
|
): Uri =
|
||||||
return when {
|
when {
|
||||||
mimeType?.startsWith("image/", ignoreCase = true) == true -> stripImageMetadata(uri, context)
|
mimeType?.startsWith("image/", ignoreCase = true) == true -> stripImageMetadata(uri, context)
|
||||||
mimeType?.startsWith("video/", ignoreCase = true) == true -> stripVideoMetadata(uri, context)
|
mimeType?.startsWith("video/", ignoreCase = true) == true -> stripVideoMetadata(uri, context)
|
||||||
mimeType?.startsWith("audio/", ignoreCase = true) == true -> stripAudioMetadata(uri, context)
|
mimeType?.startsWith("audio/", ignoreCase = true) == true -> stripAudioMetadata(uri, context)
|
||||||
else -> uri
|
else -> uri
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user