Get manufacturer url for a product

I am using CE 4.2.0. I want to retrieve manufacturer url(seo) for a product. How to do that? Actual target is to check for canonical url with this manfucaturer seo url( suppose current url) and set canonical url in header. But in detail page I am getting product canonical url and link url same i.e. main seo url. How to distinguish whether I have come from category to product detail page or manufcaturer to product detail page? Any help is appreciated.