What you are looking for is Digitrax Transponding or the Lenz RailComm. The NMRA DCC standard is RP S-9.3.2 "Bi-directional Communication". The Lenz is NMRA compliant. The decoders in each locomotive have to be so equipped to report channel, speed, and direction back to the command station.
Now having said that. One can work around this with enough software to layout interfaces. At the museum, we set the control software at the start that says loco 123 is in block 7 and its direction. So when control software sees the next block in that direction go occupied, it moves loco 123 to that block. The issue is obviously two trains facing each other and the intermediate block goes occupied, which one is it. Our control system looks at the turnouts to see which side is aligned to that track. Our control system will also not allow two occupied sidings to be aligned to the connecting track at the same time. When one thinks about it there are more scenarios that can be problematic, but more blocks yield fewer situations. For example we have a block just for the turnout. So it is easy to detect which train is headed for that connecting block. ETC. The layout has run on automatic control every Sunday for over 9 years now without a collision. The museum runs nine trains simultaneously, so for just two loco's I would think it could be much simpler.
No, I have not used this on my personal layout mostly because I don't have one :-(