Essentially the market splits this discounting into 2 parts; risk-free discounting and credit risk.
Take a market IRS in USD; it will fix on USD Libor (fixed in London). But Libor is a measure of unsecured interbank lending, and a standard IRS contract these days is cash collateralised and daily margined, so Libor isn't really a good fit, so the discounting instead is done using OIS rates (Fed funds in the US, Eonias in EUR, Sonias in UK etc). Margins generally accrue at OIS rates too, just to complete the circle. Thus we use OIS as a measure of the risk free rate term structure, and calculate the risk-free PV of a given set of cash flows.
The credit risk, on the other hand, is particular to a counterparty; it depends on the collateral arrangements we have with them and our perception of their riskiness. The collateralisation of a particular instrument will be written first into the contract (the Credit Support Annex to the ISDA contract for IRS) and secondly into collateral netting agreements between the counterparties. If we have a large portfolio of outstanding swaps between us, a lot of the exposure will net out and leave us needing less collateralisation. On the other hand, if we only actually exchange collateral rarely, or use lower quality collateral like CP or ABS, then it gets a bigger haircut and we need more of it, raising the cost of the collateral maintenance. This side of it is generally covered by a charge called the Credit Valuation Adjustment, which a desk in a bank will take responsibility for and charge other desks to receive the risk.
Thus a price might be 1.24% quoted, with a further 5bp CVA charge for a given counterparty.
Since the CVA desk takes our risk for a given price, we can value the instrument on a risk free basis first, then adjust it for the counterparty. Otherwise we would need to calculate all the credit default curves in order to discount an instrument separately for each counterparty.
An interesting effect of CVA is that if you only assume your counterparty is risky, and ignore your own credit risk (unilateral CVA), you will end up just discounting their flows and end up with a wider spread - you would need more compensation to take either side. However, if you discount your own cash flows too (bilateral CVA), you find that for example for an IRS, both legs are discounted, so the price itself does not move unless there is an asymmetry in your perception of your risk vs theirs.