Skip to content

Commit

Permalink
fix: clean up old code
Browse files Browse the repository at this point in the history
  • Loading branch information
Titozzz committed Sep 11, 2024
1 parent 87a5a41 commit b690315
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 36 deletions.
1 change: 0 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ dependencies {
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"

implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ import org.mp4parser.boxes.iso14496.part14.ESDescriptorBox
import org.mp4parser.boxes.iso14496.part15.AvcConfigurationBox
import org.mp4parser.boxes.sampleentry.AudioSampleEntry
import org.mp4parser.boxes.sampleentry.VisualSampleEntry
import java.nio.ByteBuffer
import java.util.*
import kotlin.reflect.jvm.isAccessible

class Track(id: Int, format: MediaFormat, audio: Boolean) {

Expand Down Expand Up @@ -172,39 +170,15 @@ class Track(id: Int, format: MediaFormat, audio: Boolean) {

val audioSpecificConfig = AudioSpecificConfig()

// Fix for com.googlecode.mp4parser:isoparser multiple version management
// Updates based on
// https://github.com/sannies/mp4parser/commit/9cf7f9185b294ac4fa1cd86be1915cd355d859eb#diff-5860894eeaba912c09de175e617d53d5beecebeadd2b64695ed736f9e598bf55
// and
// https://github.com/sannies/mp4parser/commit/b85f62274b56cc68d6c6e3dc2f9d4e23318e3341#diff-5860894eeaba912c09de175e617d53d5beecebeadd2b64695ed736f9e598bf55
//
val method = audioSpecificConfig::class.members.firstOrNull { it.name == "setOriginalAudioObjectType" }
if (method != null) {
// com.googlecode.mp4parser:isoparser is >= 1.1
method.isAccessible = true
method.call(audioSpecificConfig, 2)
audioSpecificConfig.setSamplingFrequencyIndex(
samplingFrequencyIndexMap[audioSampleEntry.sampleRate.toInt()]!!
)
audioSpecificConfig.setChannelConfiguration(audioSampleEntry.channelCount)
decoderConfigDescriptor.audioSpecificInfo = audioSpecificConfig
descriptor.decoderConfigDescriptor = decoderConfigDescriptor

esds.esDescriptor = descriptor
} else {
// com.googlecode.mp4parser:isoparser is < 1.1 (eg: 1.0.6)
audioSpecificConfig.setAudioObjectType(2)
audioSpecificConfig.setSamplingFrequencyIndex(
samplingFrequencyIndexMap[audioSampleEntry.sampleRate.toInt()]!!
)
audioSpecificConfig.setChannelConfiguration(audioSampleEntry.channelCount)
decoderConfigDescriptor.audioSpecificInfo = audioSpecificConfig
descriptor.decoderConfigDescriptor = decoderConfigDescriptor

val data = descriptor.serialize()
esds.esDescriptor = descriptor
esds.data = data
}
audioSpecificConfig.setOriginalAudioObjectType(2)
audioSpecificConfig.setSamplingFrequencyIndex(
samplingFrequencyIndexMap[audioSampleEntry.sampleRate.toInt()]!!
)
audioSpecificConfig.setChannelConfiguration(audioSampleEntry.channelCount)
decoderConfigDescriptor.audioSpecificInfo = audioSpecificConfig
descriptor.decoderConfigDescriptor = decoderConfigDescriptor

esds.esDescriptor = descriptor

audioSampleEntry.addBox(esds)
sampleDescriptionBox.addBox(audioSampleEntry)
Expand Down

0 comments on commit b690315

Please sign in to comment.