WoW API: GetNumDisplayChannels
channelCount = GetNumDisplayChannels();
This function returns the number of channels and headers currently displayed by ChannelFrame. Usually used to loop through all available channels/headers to perfom API GetChannelDisplayInfo on them.
Note that this function only retrieves the number of visible channels/headers! Those subchannels that are hidden by a collapsed header are not counted.
This is part of the World of Warcraft API