package com.omixlab.lckcontrol.shared

import android.os.Parcel
import android.os.Parcelable

data class StreamingConfig(
    val videoBitrate: Int = 6_000_000,
    val videoCodec: String = "h264",
    val audioBitrate: Int = 128_000,
    val audioSampleRate: Int = 48_000,
    val audioChannels: Int = 2,
    val keyFrameInterval: Int = 2,
) : Parcelable {

    constructor(parcel: Parcel) : this(
        videoBitrate = parcel.readInt(),
        videoCodec = parcel.readString() ?: "h264",
        audioBitrate = parcel.readInt(),
        audioSampleRate = parcel.readInt(),
        audioChannels = parcel.readInt(),
        keyFrameInterval = parcel.readInt(),
    )

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeInt(videoBitrate)
        parcel.writeString(videoCodec)
        parcel.writeInt(audioBitrate)
        parcel.writeInt(audioSampleRate)
        parcel.writeInt(audioChannels)
        parcel.writeInt(keyFrameInterval)
    }

    override fun describeContents(): Int = 0

    companion object CREATOR : Parcelable.Creator<StreamingConfig> {
        override fun createFromParcel(parcel: Parcel) = StreamingConfig(parcel)
        override fun newArray(size: Int) = arrayOfNulls<StreamingConfig>(size)
    }
}
