pipe which has non-uniform cross-section
You can certainly extrude a cross section along a curve and rotate that cross section, change its size and change the end cap. 

Try using a curve modifier with an array modifier and change the start/end caps:



You can also experiment with bevel curves and tapers:



In the old days we used to be able to transition between cross sections by using dupliframes to create multiple copies of a mesh along a curve at frame intervals (e.g. one every 10 frames) and then loft them together. Something like this: old Blenderartists thread but I'm not sure how you do that now. Maybe using the animation nodes add on. It's a starting point at least.

Hopefully somebody will have a better answer for you, but in the meantime this gives you something to work with.