How Asterisk records my SIP calls?

How does Asterisk records my SIP calls? Isnt SIP a traffic between the two peers? How does it records (traps) this traffic? :question:

Asterisk is a back to back user agent, so it is a peer to both parties and they are not direct peers of each other.

But in a SIP session doesnt the the peers starts to talk directly after all hand-shake?

With Asterisk there are two SIP sessions in a call. One between Asterisk and party A and one between Asterisk in party B. That’s what makes it a back to back user agent, rather than a proxy.

Even with proxy implementations, rather than back to back user agents, there is no requirement that the the intermediary remove itself from the signalling path, or from the speech path. Proxies in NAT firewalls often have to remain in both.

If the options and nature of the call allow it, Asterisk, will instruct the endpoints to send RTP directly between each other. Enabling voice recording is one of the contra-indications for this.