package com.amazon.ads.ema.api.model;

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

/**
 * Display audio status from CEC query
 */
public class AudioStatus implements Parcelable {
    public static final Creator<AudioStatus> CREATOR = new Creator<>() {
        @Override
        public AudioStatus createFromParcel(Parcel in) {
            return new AudioStatus(in);
        }

        @Override
        public AudioStatus[] newArray(int size) {
            return new AudioStatus[size];
        }
    };
    public int volume;                  // Volume level 0-100 (from CEC query)
    public boolean muted;               // Mute state (from CEC query)
    public boolean canControl;          // Can control via CEC
    public long lastUpdatedMs;          // Last query timestamp (epoch millis)

    public AudioStatus() {
    }

    protected AudioStatus(Parcel in) {
        volume = in.readInt();
        muted = in.readByte() != 0;
        canControl = in.readByte() != 0;
        lastUpdatedMs = in.readLong();
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(volume);
        dest.writeByte((byte) (muted ? 1 : 0));
        dest.writeByte((byte) (canControl ? 1 : 0));
        dest.writeLong(lastUpdatedMs);
    }

    @Override
    public int describeContents() {
        return 0;
    }
}
