using skyscraper5.Mpeg2.Psi;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace skyscraper8.DvbSis
{
    public class SisPatContainer : IPatEventHandler
    {
        public ushort? TransportStreamId { get; private set; }
        public int? NetworkPid { get; private set; }
        
        public ReadOnlyDictionary<int,ushort> ProgramMappings
        {
            get
            {
                if (_ProgramMappings == null)
                {
                    return new ReadOnlyDictionary<int, ushort>(new Dictionary<int, ushort>());
                }
                return _ProgramMappings.AsReadOnly();
            }
        }
        private Dictionary<int,ushort> _ProgramMappings;

        public void NetworkPidFromPat(int networkPid)
        {
            NetworkPid = networkPid;
        }

        public void ProgramMapPidFromPat(int pmtPid, ushort programNumber)
        {
            if (_ProgramMappings == null)
                _ProgramMappings = new Dictionary<int,ushort>();
            _ProgramMappings.Add(pmtPid, programNumber);
        }

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