static off_t input_avio_seek_time (input_plugin_t *this_gen, int time_offset, int origin) { avio_input_plugin_t *this = (avio_input_plugin_t *) this_gen; if (origin == SEEK_SET && this->pb && this->pb->seekable) { int64_t ts = (int64_t)time_offset * AV_TIME_BASE / 1000; off_t result = avio_seek_time(this->pb, -1, ts, 0); if (result >= 0) { this->preview_size = 0; this->curpos = result; return this->curpos; } } return -1; }
static int control(stream_t *s, int cmd, void *arg) { AVIOContext *avio = s->priv; int64_t size, ts; double pts; switch(cmd) { case STREAM_CTRL_GET_SIZE: size = avio_size(avio); if(size >= 0) { *(off_t *)arg = size; return 1; } break; case STREAM_CTRL_SEEK_TO_TIME: pts = *(double *)arg; ts = pts * AV_TIME_BASE; ts = avio_seek_time(avio, -1, ts, 0); if (ts >= 0) return 1; break; } return STREAM_UNSUPPORTED; }