Through-the-lens (TTL) metering is a photographic term describing a feature of cameras capable of measuring light levels in a scene through their taking lenses, as opposed to a separate metering window. This information can then be used to select a proper exposure (average luminance), and control the amount of light emitted by a flash connected to the camera.
Through-the-lens metering is most often associated with single-lens reflex (SLR) cameras.
In most film and digital SLRs, the light sensor(s) for exposure metering are incorporated into the pentaprism or pentamirror, the mechanism by which a SLR allows the viewfinder to see directly through the lens. As the mirror is flipped up, no light can reach there during exposure, therefore, these light sensors can be used for ambient light TTL metering only. In newer SLRs as well as in almost all DSLRs, they can also be utilized for preflash TTL metering, where the metering is carried out before the mirror flips up using a preflash and the necessary amount of flash light is precalculated and then applied during the exposure without any real-time feedback.
There were a few particularly sophisticated film SLRs including the Olympus OM-2, the Pentax LX, the Nikon F3, and the Minolta 9000, where metering cells located at the bottom of the mirror box were used for ambient light metering, depending on model either instead or in addition to metering cells in the roof of the camera. Depending on model, the light was reflected down there either by a secondary mirror behind the half-transparent main mirror, a special reflective coating of the first shutter curtain, the surface of the film itself, or combinations thereof.
Metering cells located at the bottom of the mirror box using light reflected off the film are also used in all film SLRs supporting a form of real-time TTL flash metering.
Some early Pentax DSLRs could use this same configuration for TTL flash metering as well, but since the reflectance properties of image sensors differ significantly from those of film, this method proved to be unreliable in practice. Therefore, digital SLR cameras typically don't support any real-time TTL flash metering and must use preflash metering instead. The ambient and flash light metering is then carried out by a metering module located in the roof of the camera (see above).
Digital SLRs supporting live view or video will use the read out of the image sensor itself for exposure metering in these modes. This also applies to Sony's SLT digital cameras, which use the image sensor for exposure metering all the time. Up to the time of this writing (2012), no digital SLR or SLT camera on the market supported any form of real-time TTL flash metering using the image sensor. However, it can be expected that such methods will be introduced as image sensor technology progresses, given the advantages of metering with real-time feedback and without preflash.
TTL metering systems have been incorporated into other types of cameras as well. Most digital "point-and-shoot cameras" use TTL metering, performed by the imaging sensor itself.
In many advanced modern cameras multiple 'segments' are used to acquire the amount of light in different places of the picture. Depending on the mode the photographer has selected, this information is then used to correctly set the exposure. With a simple spot meter, a single spot on the picture is selected. The camera sets the exposure in order to get that particular spot properly exposed. On some modern SLR systems the spot metering area or zone can be coupled to the actual focusing area selected offering more flexibility and less need to use exposure lock systems. With multiple segment metering (also known as matrix or honeycomb metering), the values of the different segments are combined and weighted to set the correct exposure. Implementations of these metering modes vary between cameras and manufacturers, making it difficult to predict how a scene will be exposed when switching cameras.
Off the film metering 
In the 1970s Olympus marketed the OM-2 camera, which measured the exposure directly off the film (OTF). In OTF metering used by Olympus, metering was performed in one of two ways — or a combination of both — depending upon the shutter speed in use.
In the OM-2's Auto Dynamic Metering (ADM) system the first shutter curtain had the lens-facing side coated with a computer generated pattern of white blocks to emulate an average scene. As the mirror flipped-up the metering cell in the base of the mirror box measured the light reflected from the subject bouncing off this pattern of blocks. The timing of the release of the second curtain was adjusted in real time during the actual exposure. As the shutter speed increased, the actual light reflecting off the film surface was measured and the timing of the second curtain's release adjusted accordingly. This gave cameras equipped with this system the ability to adjust to changes in lighting during the actual exposure which was useful for specialist applications such as photomicrography and astronomical photography.
Leica later used a variation of this system, as did Pentax with their Integrated Direct Metering (IDM) in the LX camera. A variation of this "OTF" system was used on early Olympus E-Series digital cameras to fine-tune the exposure just before the first curtain was released; for this to work, the first curtain was coated in a neutral grey colour.
Through the lens flash metering 
The process of calculating the correct amount of flash light can also be done 'through the lens'. This is being done in a significantly different way than non-flash 'through the lens' metering. The actual metering itself happens in two different ways, depending on the medium. Digital TTL works differently than analog TTL.
The analog version of TTL works as follows: when the incoming light hits the film, a part of it is reflected towards a sensor. This sensor controls the flash. If enough light is captured, the flash is stopped. During early testing of this system by Minolta and Olympus it was found that not all brands and types of film reflect the light to the same amount although the actual difference between brands was less than half a stop. The one exception was Polaroid's instant slide film which had a black surface and could not be used in TTL flash mode. Nevertheless, for most applications analogue TTL flash exposure metering was more advanced and accurate than systems used previously and permitted far more flexibility - with bounced flash exposures in particular being more accurate than manually calculated equivalents.
With digital, this way of direct reflection metering is not possible any more since a CMOS or CCD chip, used to collect the light, is not reflective enough. There are a few older digital cameras which still use the analog technique, but these are getting rare. The Fujifilm S1 and S3 are the most known to use this technique.
Digital TTL works as follows: Before the actual exposure one or more small flashes, called "preflashes", are emitted. The light returning through the lens is measured and this value is used to calculate the amount of light necessary for the actual exposure. Multiple pre-flashes can be used to improve the flash output. Canon refers to this technique as "E-TTL" and has later improved the system with "E-TTL II". The first form of digital TTL by Nikon, called "D-TTL", was used in a few early models. Since then, the superior "i-TTL" system has been used.
When using front-curtain flash (when the flash fires immediately after the shutter opens), the preflashes and main flash appear as one to the human eye, since there is very little time between them. When using rear-curtain flash (when the flash fires at the end of the exposure) and a slow shutter speed, the distinction between the main flash and the preflashes is more obvious.
Some cameras and flash units take more information into account when calculating the necessary flash output, including the distance of the subject to the lens. This improves the lighting when a subject is placed in front of a background. If the lens is focused on the subject, the flash will be controlled to allow for proper exposure on the subject, thus leaving the background underexposed. Alternatively, if the lens is focused on the background, the background will be properly exposed, leaving the subject in the foreground typically overexposed. This technique requires both a camera capable of calculating the distance information, as well as the lens being capable of communicating the focal distance to the body. Nikon refers to this technique as "3D matrix metering", although different camera manufacturers use different terms for this technique. Canon incorporated this technique in E-TTL II.
More advanced TTL flash techniques include off-camera flash lighting, where one or more flash units are located at different locations around the subject. In this case a 'commander' unit (which can be integrated in the camera body) is used to control all of the remote units. The commander unit usually controls the remote flashes by using flashes of visible or infrared light, although TTL-capable radio triggering systems are available. The photographer can normally vary the light ratios between the different flashes. The technique of using preflashes to get a proper exposure is still used in automatic flash modes.