  In this paper, we prove the Gan-Gross-Prasad conjecture and the Ichino-Ikeda
conjecture for unitary groups $U_n\times U_{n+1}$ in all the endoscopic cases.
Our main technical innovation is the computation of the contributions of
certain cuspidal data, called $*$-generic, to the Jacquet-Rallis trace formula
for linear groups. We offer two different computations of these contributions:
one, based on truncation, is expressed in terms of regularized Rankin-Selberg
periods of Eisenstein series and Flicker-Rallis intertwining periods. The
other, built upon Zeta integrals, is expressed in terms of functionals on the
Whittaker model. A direct proof of the equality between the two expressions is
also given. Finally several useful auxiliary results about the spectral
expansion of the Jacquet-Rallis trace formula are provided.
