FWIW, the "proper" course of action is to never make statements to an officer. Always be in the position of either asking questions or saying nothing at all (your "right" to silence). Unless there's reasonable suspicion on the part of the officer that you've committed a crime, you don't have to say or do anything they ask of you. So in your scenario, you could have simply asked "Am I suspected of a crime?", "Am I being detained?", "Am I free to go?". Just keep circling these three questions and if they don't confirm any, you're free to move along. If they answer yes to the first question, ask under what circumstance they have their suspicion, and make no statements.
All of that is assuming you had done (and were doing) absolutely nothing illegal. If you were, that changes the game. But also, with all that said, some cops will still be abusive assholes anyway and do exactly what they did to you (or worse)--the difference is, they'll become legally liable for that abuse (after the fact), rather than easily excusing it by your statements or actions. In your scenario, since you made statements (and especially if there was no recording of the confrontation), they can easily testify that you were verbally combatant, resisting arrest, or any of their assortment of BS rationales, and it'll be their word against yours. Never make statements.
You may be able to still file a complaint. Even if no legal consequences befall the officer(s) involved, there could be internal disciplinary action. When I was verbally abused by an officer in a situation that it was completely unjustified, I personally phoned the police department, found the voice mail for like the police chief or some shit, and left an informal complaint giving details about the circumstances and the officer involved. The guy called me back the next day, asked me some more questions, and actually told me he was pretty sure he knew exactly who it was and he wasn't surprised at the abuse at all (apparently a problem officer). He apologized for the incident, thanked me for my complaint, and was very kind about all of it... so even informal complaints may have some effect.
Last thing I'll say is just that all this shit is easier said than done. I get nervous as hell when dealing with police and it's hard to stay level-headed and remember all the right things to do in such a situation. It sounds like, all things considered, you did a good job handling your situation (you still walked free and didn't get your skull bashed in, which is an accomplishment these days). So, good job. It sucks to have to even deal with this kind of bullshit, but I think our peaceful non-compliance goes a long way in retaining some of our freedoms.
Reduce your government footprint.