Make media object inherit from enable_shared_from_this

Change-Id: Ia851ad02106af93eea68f64ef56150cccc633b28
Cpp templates: Make factories return a pointer

Change-Id: I9695a5ee04414e7034866f81c35772b8cbce12a9