package cn.i2edu.dubbing_lib.util

import android.os.Handler
import android.os.Message
import cn.i2edu.dubbing_lib.callback.MixinHandlerCallback
import java.lang.ref.WeakReference

enum class HandlerMessage(var value: Int) {
    START_MIX_IN(0X3999),
    AUDIO_SYN_FINISHED(0X4001),
    AUDIO_MIX_VIDIO_FINISHED(0X4002),
    AUDIO_DECODE_FINISHED(0x4003),
    AUDIO_ENCODE_FINISHED(0x4004),
}

class MixinHandler<T : MixinHandlerCallback>(util: T) : Handler() {
    private val plugin: WeakReference<T> = WeakReference(util)

    override fun handleMessage(msg: Message) {
        if (plugin.get() != null) {
            plugin.get()?.onHandleMessage(msg)
        }
    }
}