Context. Planets are thought to form in protoplanetary accretion disks around young stars. Detecting a giant planet still embedded in a protoplanetary disk would be very important and give observational constraints on the planet-formation process. However, detecting these planets with the radial velocity technique is problematic owing to the strong stellar activity of these young objects. Aims. We intend to provide an indirect method to detect Jovian planets by studying near infrared emission spectra originating in the protoplanetary disks around T Tauri stars. Our idea is to investigate whether a massive planet could induce any observable effect on the spectral lines emerging in the disks atmosphere. As a tracer molecule we propose CO, which is excited in the ro-vibrational fundamental band in the disk atmosphere to a distance of ∼2−3 AU (depending on the stellar mass) where terrestrial planets are thought to form. Methods. We developed a semi-analytical model to calculate synthetic molecular spectral line profiles in a protoplanetary disk using a double layer disk model heated on the outside by irradiation by the central star and in the midplane by viscous dissipation due to accretion. 2D gas dynamics were incorporated in the calculation of synthetic spectral lines. The motions of gas parcels were calculated by the publicly available hydrodynamical code FARGO which was developed to study planet-disk interactions. Results. We demonstrate that a massive planet embedded in a protoplanetary disk strongly influences the originally circular Keplerian gas dynamics. The perturbed motion of the gas can be detected by comparing the CO line profiles in emission, which emerge from planet-bearing to those of planet-free disk models. The planet signal has two major characteristics: a permanent line profile asymmetry, and short timescale variability correlated with the orbital phase of the giant planet. We have found that the strength of the asymmetry depends on the physical parameters of the star-planet-disk system, such as the disk inclination angle, the planetary and stellar masses, the orbital distance, and the size of the disk inner cavity. The permanent line profile asymmetry is caused by a disk in an eccentric state in the gap opened by the giant planet. However, the variable component is a consequence of the local dynamical perturbation by the orbiting giant planet. We show that a forming giant planet, still embedded in the protoplanetary disk, can be detected using contemporary or future high-resolution near-IR spectrographs like VLT/CRIRES and ELT/METIS.