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 SisEitContainer : IEitEventHandler
    {
        public void OnEitEvent(EitEvent eitEvent)
        {
            if (_eitEvents == null)
                _eitEvents = new List<EitEvent>();

            _eitEvents.Add(eitEvent);
        }

        public void SetNetworkId(ushort networkId, bool forceOverwrite = false)
        {
            NetworkId = networkId;
        }

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

        public ushort? TransportStreamId { get; private set; }
        public ushort? NetworkId { get; private set; }

        public IReadOnlyList<EitEvent> Events
        {
            get
            {
                if (_eitEvents == null)
                    return new List<EitEvent>();
                return _eitEvents.AsReadOnly();
            }
        }

        private List<EitEvent> _eitEvents;
    }
}
