Endoscopy Theory of Automorphic Forms