You don't make it clear what you're after. If you want to learn calculus well, neither will do the job alone. You'll have to do a bunch of study on your own to supplement what they teach you. Both the AP curriculum and community colleges tend to teach lots of technique and little theory, pretty much no proofs, so for a math major they aren't much good.
If you want college credit or placement (different things), it depends where you figure you'll go for your undergraduate degree. If it's a place like MIT or Caltech they'll just laugh at your CC class and tell you to take their real calculus class. Same for the AP class/test. However the AP class, if you get a 5 on the AP test, there is often a formal mechanism for getting placement or credit at many colleges. Check their web sites. For placement, many have tests you can take.
If you want your fellow students to be good, then a high school AP class often has better students than a CC class. That will be important for the level the class is taught at.
And, of course, your own situation may be different. Some CCs have better classes, or particularly good professors. Some high schools have awesome teachers who can help you go as far as you're willing to go. Research your local situation to see.