void CRendererMediaCodecSurface::AddVideoPicture(const VideoPicture &picture, int index, double currentClock)
{
  if (m_bConfigured && dynamic_cast<CMediaCodecVideoBuffer*>(picture.videoBuffer))
  {
    int64_t nanodiff(static_cast<int64_t>((picture.pts - currentClock) * 1000));
    dynamic_cast<CMediaCodecVideoBuffer*>(picture.videoBuffer)->RenderUpdate(m_surfDestRect,
      std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::steady_clock::now().time_since_epoch()).count() + nanodiff);
  }
}
Esempio n. 2
0
int udps_wait_function(struct sender_tracking *st, struct opt_s* opt)
{
  long wait;
#if(PREEMPTKERNEL)
  int err;
#endif
#ifdef HAVE_RATELIMITER
  if(opt->wait_nanoseconds > 0)
  {
    //clock_gettime(CLOCK_REALTIME, &now);
    GETTIME(st->now);
#if(SEND_DEBUG)
    COPYTIME(st->now,st->reference);
#endif
    wait = nanodiff(&(opt->wait_last_sent), &st->now);
#if(SEND_DEBUG)
#if(PLOTTABLE_SEND_DEBUG)
    //fprintf(st->out,"%ld %ld \n",spec_ops->total_captured_packets, wait);
#else
    fprintf(st->out, "UDP_STREAMER: %ld ns has passed since last->send\n", wait);
#endif
#endif
    ZEROTIME(st->req);
    SETNANOS(st->req,(opt->wait_nanoseconds-wait));
    if(GETNANOS(st->req) > 0){
#if(SEND_DEBUG)
#if(PLOTTABLE_SEND_DEBUG)
      fprintf(st->out, "%ld ", GETNANOS(st->req));
#else
      fprintf(st->out, "UDP_STREAMER: Sleeping %ld ns before sending packet\n", GETNANOS(st->req));
#endif
#endif	
#if!(PREEMPTKERNEL)
      /* First->sleep in minsleep sleeps to get rid of the bulk		*/
      while((unsigned long)GETNANOS(st->req) > st->minsleep){
	SLEEP_NANOS(st->onenano);
	SETNANOS(st->req,GETNANOS(st->req)-st->minsleep);
      }
      GETTIME(st->now);

      while(nanodiff(&(opt->wait_last_sent),&st->now) < opt->wait_nanoseconds){
	GETTIME(st->now);
      }
#else
      err = SLEEP_NANOS(st->req);
      if(err != 0){
	E("cant sleep");
	return -1;
      }

      GETTIME(st->now);
#endif /*PREEMPTKERNEL */

#if(SEND_DEBUG)
#if(PLOTTABLE_SEND_DEBUG)
      fprintf(st->out, "%ld\n", nanodiff(&st->reference, &st->now));
#else
      fprintf(st->out, "UDP_STREAMER: Really slept %lu\n", nanodiff(&st->reference, &st->now));
#endif
#endif
      nanoadd(&(opt->wait_last_sent), opt->wait_nanoseconds);	
    }
    else{
#if(SEND_DEBUG)
#if(PLOTTABLE_SEND_DEBUG)
      fprintf(st->out, "0 0\n");
#else
      fprintf(st->out, "Runaway timer! Resetting\n");
#endif
#endif
      COPYTIME(st->now,opt->wait_last_sent);
    }
  }
#endif //HAVE_RATELIMITER
  return 0;
}