I'm a dog breeder so that's the only species I can speak to, but dogs are a special case. They were the first animal to be domesticated, and they domesticated themselves because they were attracted to our garbage piles. They are a pack-social species with an intense curiosity and a strong sense of hierarchy, so it was not much of a stretch for them to adapt to a multi-species pack, and to respect the authority of the members who were clearly more capable of leading the pack to happiness and prosperity: the humans.
Of course individuals of the species Canis lupus surely differ from one another as much as any other creatures, and many (if not most, or perhaps nearly all) of the wolves were not attracted to this deal. However, the few who were (DNA analysis suggests that all dogs are descended from a very tiny number of original lazy adventurers) were quite happy with the arrangement, and their descendants still are.
Dogs do not regard their homes as "prisons" and in the vast majority of cases will return to it gladly if they're separated by accident. One of ours managed to squeeze through the open window of a parked car twelve miles from home, and was halfway home, going in exactly the right direction (better than I could have done), when someone spotted him and called us.
Dogs regard their family as their pack and their people as pack mates. They regard their chores as service to the pack, although many of them are downright fun anyway, such as herding cattle, barking at strangers, licking our faces when we're sad, or injecting a little mayhem into an otherwise boring day.
Cats also self-domesticated. During the early days of civilization, when agricultural technology became so efficient and productive that we needed to build granaries to store food, cats found the rodents in the granaries to be a steady source of food and they settled in. They soon found that grateful humans left tasty treats for them and even let them sleep inside their warm houses, in order to encourage them to stick around and keep doing the job.
Like most solitary predators, cats are incredibly lazy--sleeping about 16 hours per day--and greatly appreciate the life of leisure we provide for them.
OK, I said I only understood dogs and here I'm teaching you about cat psychology too. I've clearly had more experience with pets than you have or you wouldn't be asking such a patently absurd question.
We also have parrots and with birds the situation is much different. Birds exhibit a phenomenon known as "imprinting." When they first open their eyes (with parrots that's about one or two weeks after hatching), they figure that whoever or whatever is feeding them must be their parent, and they "imprint" on that species--and any other species that lives in the nesting area and is clearly accepted by the parents as family, like the dogs and cats.
So a hand-fed bird actually regards himself as a human, and so living among humans is not only not a "prison," it's his preference.
This can be regarded in many ways, but before you jump to the conclusion that we're taking the poor birds out of their natural habitat and forcing them to become civilized, remember that parrots are the most intelligent birds, probably more intelligent than any mammal except apes and some of the cetaceans. Parrots are active and curious, and love to learn new things. We made Rube Goldberg contraptions out of welding plates, nuts and bolts for one of our macaws, and she always figured out how to disassemble them. One day we stumbled onto a supply of left-handed nuts and bolts. It took her three days to figure that out, and she was so happy that she was bouncing up and down and squawking with glee.
A human habitation contains so many wonderful things to satisfy a parrot's curiosity that you have to lock them out of some of your rooms. One fellow came home and found his grand piano flat on the floor because his parrot had taken the legs off.
The only way we have of determining whether our companion animals are happy is whether they look and act happy. Our dogs, cats and parrots certainly do.