using skyscraper5.Dvb.Psi;
using skyscraper5.Dvb.Psi.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace skyscraper8.DvbSis
{
    public class SisSdtContainer : ISdtEventHandler
    {
        public ushort? NetworkId { get; private set; }
        public ushort? TransportStreamId { get; private set; }

        private List<Tuple<ushort,ushort,SdtService>> sdtServices;
        public void OnSdtService(ushort transportStreamId, ushort originalNetworkId, SdtService sdtService)
        {
            if (sdtServices == null)
                sdtServices = new List<Tuple<ushort, ushort, SdtService>>();

            sdtServices.Add(new Tuple<ushort,ushort,SdtService>(transportStreamId,originalNetworkId,sdtService));
        }

        public void SetNetworkId(ushort networkId)
        {
            this.NetworkId = networkId;
        }

        public void SetTransportStreamId(ushort transportStreamId)
        {
            this.TransportStreamId = transportStreamId;
        }

        public IReadOnlyList<Tuple<ushort, ushort, SdtService>> Services
        {
            get
            {
                if (sdtServices == null)
                    return new List<Tuple<ushort, ushort, SdtService>>().AsReadOnly();

                return sdtServices.AsReadOnly();
            }
        }
    }
}
