Exactly. This is an example of a commitment strategy (
http://plato.stanford.edu/entries/game-theory/#Com), and it was only credible because others were watching. Reputation is a very common way we make credible commitments when we deal with one another, but the results might have been different without an audience.
It's funny that the one-shot prisoner's dilemma is used so often as an example of rational self-interest leading to suboptimal outcomes or formal modeling failing to capture real behavior. This is true only for the most stylized models and simplest games. Really rational players will choose to restructure the rules and play a better game! Since prisoner's dilemmas were bad games, we figured out how to make credible commitments and overcome them. Since talk is cheap, we developed things like punishment and social norms to enforce commitments.
Adding things like iteration, reputation, and punishment to simple games leads to complex cooperative outcomes that reflect real behavior—and we can model them by adding a few simple rules. I think it's a fascinating and optimistic view of human history: modern market-exchange societies are the outcome of a long process of figuring out how to turn bad-outcome games that encourage defection into positive-sum cooperative ones that benefit everyone. Yet we are still biased to ignore all the cooperation around us and see selfishness (here's one of my favorite papers on this subject: http://papers.ssrn.com/sol3/papers.cfm?abstract_id=929048).
I've also found it a very valuable personal insight. When you find yourself playing a bad game, don't settle for choosing the least harmful payoff. Figure out how to change the rules.