package com.tencent.liteav.demo.superplayer.util

import org.fourthline.cling.model.meta.Device

object CastorUtil {
    interface Listener {
        fun onDevice(device: Device<*, *, *>)
    }

    var castDevice: Device<*, *, *>? = null

    private val listeners: MutableList<Listener> = mutableListOf()

    public fun addListener(listener: Listener) {
        listeners.add(listener)
    }

    public fun removeListener(listener: Listener) {
        listeners.remove(listener)
    }

    public fun selectDevice(device: Device<*, *, *>?) {
        castDevice = device
        if(device != null) {
            for (listener in listeners) {
                listener.onDevice(device)
            }
        }
    }
}