Instead of casting a ray from the camera to
the character, try casting a ray from
your character's head (or a point just above it, or elsewhere as appropriate for your game) to where the camera would be assuming no walls. If the ray hits something... stop at that point, and place the camera there instead. Like this:
P = Player
- = hit ray
C = final Camera position
W = Wall
V = 'virtual' camera position, where it would be if the wall wasn't there
Hope that makes sense. That's the simplest solution but there are (obviously) complications. For example, that'll give a very 'jerky' effect... the camera will be 10m from the player, but then a wall gets in the way, bam! it jumps to 5m from the player. So, you'll want to cast more rays, to the left and right of where the camera really "is", so it can detect there will be a hit if the camera is rotated and start moving forward before the wall actually gets in the way (and back when the wall disappears, etc).
Also, what it the thing it hits is just a lamp-post or something? You don't really want the camera to be blocked by something so thin, just let the player be partially obscured by it, no worries. But then, if you don't hit it at all, you could end up with the camera inside it! So there's two choices... ignore it, but add a special case for when you're inside it; or, detach the camera completely. Treat it as a separate entity rather than something cast by a ray. It'll need AI to keep the character in view. Much more complicated but could give better results... if you get it right...!
I worked on a 3D third person camera for the Xbox 360 launch title Kameo: Elements of Power, and these kinds of issues took up probably 40-50% of my time for three years! It's not a trivial problem. (Although, Kameo had 11 different player characters and over 20 different camera modes... your game may be simpler). On the other hand, many
games get away with cameras much less intelligent than Kameo's, and (as with with all things) you can get 90% of the way there in 10% of the time. Good luck!