Browse Source

MT#55283 convert media_player to int64_t

Change-Id: If6ef6ce10a7a5e183a7cbf5c621828f2a0c0b3c7
pull/1938/head
Richard Fuchs 8 months ago
parent
commit
39e4d974ce
4 changed files with 33 additions and 33 deletions
  1. +7
    -7
      daemon/audio_player.c
  2. +19
    -19
      daemon/media_player.c
  3. +5
    -5
      daemon/t38.c
  4. +2
    -2
      include/media_player.h

+ 7
- 7
daemon/audio_player.c View File

@ -35,8 +35,8 @@ static bool audio_player_run(struct media_player *mp) {
if (!buf) {
if (!size) {
// error or not active: just reschedule
mp->next_run = timeval_add_usec(mp->next_run, ap->ptime_us);
timerthread_obj_schedule_abs(&mp->tt_obj, mp->next_run);
mp->next_run += ap->ptime_us;
timerthread_obj_schedule_abs(&mp->tt_obj, timeval_from_us(mp->next_run));
return false;
}
buf = g_alloca(size);
@ -162,16 +162,16 @@ void audio_player_start(struct call_media *m) {
media_player_set_media(mp, m);
if (mp->next_run.tv_sec) // already running?
if (mp->next_run) // already running?
return;
ilogs(transcoding, LOG_DEBUG, "Starting audio player");
ap->last_run = timeval_from_us(rtpe_now);
mp->next_run = timeval_from_us(rtpe_now);
mp->next_run = timeval_add_usec(mp->next_run, ap->ptime_us);
timerthread_obj_schedule_abs(&mp->tt_obj, mp->next_run);
mp->next_run = rtpe_now;
mp->next_run += ap->ptime_us;
timerthread_obj_schedule_abs(&mp->tt_obj, timeval_from_us(mp->next_run));
}
@ -199,7 +199,7 @@ bool audio_player_is_active(struct call_media *m) {
return false;
if (!m->audio_player->mp)
return false;
if (!m->audio_player->mp->next_run.tv_sec)
if (!m->audio_player->mp->next_run)
return false;
return true;
}


+ 19
- 19
daemon/media_player.c View File

@ -174,7 +174,7 @@ static void media_player_shutdown(struct media_player *mp) {
//ilog(LOG_DEBUG, "shutting down media_player");
timerthread_obj_deschedule(&mp->tt_obj);
mp->next_run.tv_sec = 0;
mp->next_run = 0;
if (mp->sink) {
unsigned int num = send_timer_flush(mp->sink->send_timer, mp->coder.handler);
@ -541,7 +541,7 @@ retry:;
// got a packet
struct media_player_cache_packet *pkt = entry->packets->pdata[read_idx];
long long us_dur = pkt->duration;
int64_t us_dur = pkt->duration;
mp->cache_read_idx++;
@ -568,7 +568,7 @@ retry:;
read_idx == 0, mp->seq++, 0, -1, 0);
mp->buffer_ts += pkt->duration_ts;
mp->sync_ts_tv = timeval_from_us(rtpe_now);
mp->sync_ts_tv = rtpe_now;
media_packet_encrypt(mp->crypt_handler->out->rtp_crypt, mp->sink, &packet);
@ -578,8 +578,8 @@ retry:;
mutex_unlock(&mp->sink->out_lock);
// schedule our next run
mp->next_run = timeval_add_usec(mp->next_run, us_dur);
timerthread_obj_schedule_abs(&mp->tt_obj, mp->next_run);
mp->next_run += us_dur;
timerthread_obj_schedule_abs(&mp->tt_obj, timeval_from_us(mp->next_run));
return false;
}
@ -655,17 +655,17 @@ static void media_player_cached_reader_start(struct media_player *mp, str_case_v
mp->coder.handler = codec_handler_make_dummy(&entry->coder.handler->dest_pt, mp->media, codec_set);
mp->run_func = media_player_read_decoded_packet;
mp->next_run = timeval_from_us(rtpe_now);
mp->next_run = rtpe_now;
mp->coder.duration = entry->coder.duration;
// if we played anything before, scale our sync TS according to the time
// that has passed
if (mp->sync_ts_tv.tv_sec) {
int64_t ts_diff_us = timeval_diff(timeval_from_us(rtpe_now), mp->sync_ts_tv);
if (mp->sync_ts_tv) {
int64_t ts_diff_us = rtpe_now - mp->sync_ts_tv;
mp->buffer_ts += fraction_divl(ts_diff_us * dst_pt->clock_rate / 1000000, &dst_pt->codec_def->default_clockrate_fact);
}
mp->sync_ts_tv = timeval_from_us(rtpe_now);
mp->sync_ts_tv = rtpe_now;
media_player_read_decoded_packet(mp);
}
@ -938,8 +938,8 @@ static int media_player_setup_common(struct media_player *mp, const rtp_payload_
// if we played anything before, scale our sync TS according to the time
// that has passed
if (mp->sync_ts_tv.tv_sec) {
int64_t ts_diff_us = timeval_diff(timeval_from_us(rtpe_now), mp->sync_ts_tv);
if (mp->sync_ts_tv) {
int64_t ts_diff_us = rtpe_now - mp->sync_ts_tv;
mp->sync_ts += fraction_divl(ts_diff_us * (*dst_pt)->clock_rate / 1000000, &(*dst_pt)->codec_def->default_clockrate_fact);
}
@ -1047,7 +1047,7 @@ void media_player_add_packet(struct media_player *mp, char *buf, size_t len,
struct codec_packet *p = packet.packets_out.head->data;
if (p->rtp) {
mp->sync_ts = ntohl(p->rtp->timestamp);
mp->sync_ts_tv = p->ttq_entry.when;
mp->sync_ts_tv = timeval_us(p->ttq_entry.when);
}
}
@ -1058,8 +1058,8 @@ void media_player_add_packet(struct media_player *mp, char *buf, size_t len,
ilog(LOG_ERR, "Error sending playback media to RTP sink");
mutex_unlock(&mp->sink->out_lock);
mp->next_run = timeval_add_usec(mp->next_run, us_dur);
timerthread_obj_schedule_abs(&mp->tt_obj, mp->next_run);
mp->next_run += us_dur;
timerthread_obj_schedule_abs(&mp->tt_obj, timeval_from_us(mp->next_run));
}
static int media_player_find_file_begin(struct media_player *mp) {
@ -1207,9 +1207,9 @@ static bool media_player_play_start(struct media_player *mp, const rtp_payload_t
if (media_player_cache_entry_init(mp, dst_pt, codec_set))
return true;
mp->next_run = timeval_from_us(rtpe_now);
mp->next_run = rtpe_now;
// give ourselves a bit of a head start with decoding
mp->next_run = timeval_add_usec(mp->next_run, -50000);
mp->next_run -= 50000;
// if start_pos is positive, try to seek to that position
if (mp->opts.start_pos > 0) {
@ -2002,7 +2002,7 @@ static void media_player_run(void *ptr) {
mutex_lock(&mp->lock);
bool finished = false;
if (mp->next_run.tv_sec)
if (mp->next_run)
finished = mp->run_func(mp);
mutex_unlock(&mp->lock);
@ -2011,7 +2011,7 @@ static void media_player_run(void *ptr) {
if (finished) {
rwlock_lock_w(&call->master_lock);
mp->next_run.tv_sec = 0;
mp->next_run = 0;
if (mp->opts.block_egress)
MEDIA_CLEAR(mp->media, BLOCK_EGRESS);
@ -2031,7 +2031,7 @@ bool media_player_is_active(struct call_monologue *ml) {
return false;
if (!ml->player)
return false;
if (!ml->player->next_run.tv_sec)
if (!ml->player->next_run)
return false;
return true;
}


+ 5
- 5
daemon/t38.c View File

@ -273,8 +273,8 @@ static bool t38_pcm_player(struct media_player *mp) {
if (num <= 0) {
ilog(LOG_DEBUG, "No T.38 PCM samples generated");
// use a fixed interval of 10 ms
mp->next_run = timeval_add_usec(mp->next_run, 10000);
timerthread_obj_schedule_abs(&mp->tt_obj, mp->next_run);
mp->next_run += 10000;
timerthread_obj_schedule_abs(&mp->tt_obj, timeval_from_us(mp->next_run));
mutex_unlock(&tg->lock);
return false;
}
@ -482,7 +482,7 @@ void t38_gateway_start(struct t38_gateway *tg, str_case_value_ht codec_set) {
// now start our player if we can or should
// already running?
if (tg->pcm_player->next_run.tv_sec)
if (tg->pcm_player->next_run)
return;
// only start our player only if we can send both ways
@ -504,8 +504,8 @@ void t38_gateway_start(struct t38_gateway *tg, str_case_value_ht codec_set) {
ilog(LOG_DEBUG, "Starting T.38 PCM player");
// start off PCM player
tg->pcm_player->next_run = timeval_from_us(rtpe_now);
timerthread_obj_schedule_abs(&tg->pcm_player->tt_obj, tg->pcm_player->next_run);
tg->pcm_player->next_run = rtpe_now;
timerthread_obj_schedule_abs(&tg->pcm_player->tt_obj, timeval_from_us(tg->pcm_player->next_run));
}


+ 2
- 2
include/media_player.h View File

@ -70,7 +70,7 @@ struct media_player {
struct packet_stream *sink;
const struct streamhandler *crypt_handler;
struct timeval next_run;
int64_t next_run;
media_player_opts_t opts;
@ -86,7 +86,7 @@ struct media_player {
unsigned long seq;
unsigned long buffer_ts;
unsigned long sync_ts;
struct timeval sync_ts_tv;
int64_t sync_ts_tv;
long long last_frame_ts;
};


Loading…
Cancel
Save