The authors of Crunching Numbers explain the calculation of league revenue (used for calculating salary cap) beginning on page 23. The league revenue is split between the owners and players following prescribed formulas.
The 2011 CBA developed a formula tied to total revenues that is used to calculate Player Costs. While these formulas are beyond the scope of anything we need to know regarding the salary cap, it is still good to have a fundamental understanding of some of the components that go into the revenue calculation.
League revenues are divided into three revenue buckets, which are distributed in various proportions to the equation.