Who actually adds the advertisements on YouTube? Google/Youtube, or the publisher, or both?

I’ve always had this question in my mind, every time I try to come up with an assumption I think it might not be right.
I am inclined to think the process is a little more complex than just placing an Ad, some videos show Ads exactly at the instance when someone in the video finishes a sentence for example, and this is the most common placement/ timing for an Ad to start, other Ads may come randomly, and so on.

But the question is really not focused on when the Ad starts, I Just would like to know who places the Ad in the first place? Who chooses whether the video contains Ads or not?.

Thank you