static int fill_buffer(stream_t *s, char *buf, int len) { int64_t pos; if (len < 2048) return -1; pos = dvd_read_sector(s, s->priv, buf); if (pos < 0) return -1; return 2048; // full sector }
static int fill_buffer(stream_t *s, char *but, int len) { if(s->type == STREAMTYPE_DVD) { off_t pos=dvd_read_sector(s->priv,s->buffer); if(pos>=0) { len=2048; // full sector s->pos=2048*pos-len; } else len=-1; // error } return len; }
static int fill_buffer(stream_t *s, char *buf, int len) { int64_t pos; if (len < 2048) return -1; pos = dvd_read_sector(s, s->priv, buf); if (pos < 0) return -1; // dvd_read_sector() sometimes internally skips disk-level blocks s->pos = 2048*(pos - 1); return 2048; // full sector }
static int dvd_seek_to_time(stream_t *stream, ifo_handle_t *vts_file, double sec) { unsigned int i, j, k, timeunit, ac_time, tmap_sector=0, cell_sector=0, vobu_sector=0; int t=0; double tm, duration; int64_t pos = -1; dvd_priv_t *d = stream->priv; vts_tmapt_t *vts_tmapt = vts_file->vts_tmapt; if(!vts_file->vts_tmapt || sec < 0) return 0; duration = (double) mp_get_titleset_length(d->vts_file, d->tt_srpt, d->cur_title) / 1000.0f; if(sec > duration) return 0; i=d->cur_pgc_idx; timeunit = vts_tmapt->tmap[i].tmu; for(j = 0; j < vts_tmapt->tmap[i].nr_of_entries; j++) { ac_time = timeunit * (j + 1); if(ac_time >= sec) break; tmap_sector = vts_tmapt->tmap[i].map_ent[j] & 0x7fffffff; } //search enclosing cell for(i=0; i<d->cur_pgc->nr_of_cells; i++) { if(tmap_sector >= d->cur_pgc->cell_playback[i].first_sector && tmap_sector <= d->cur_pgc->cell_playback[i].last_sector) { cell_sector = d->cur_pgc->cell_playback[i].first_sector; break; } } pos = ((int64_t)cell_sector)<<11; do_seek(stream, pos); do { char buf[2048]; if (dvd_read_sector(stream, stream->priv, buf) < 0) // skip break; t = mp_dvdtimetomsec(&d->dsi_pack.dsi_gi.c_eltm); } while(!t); tm = dvd_get_current_time(stream, -1); pos = ((int64_t)tmap_sector)<<11; do_seek(stream, pos); //now get current time in terms of the cell+cell time offset memset(&d->dsi_pack.dsi_gi.c_eltm, 0, sizeof(dvd_time_t)); while(tm <= sec) { char buf[2048]; if (dvd_read_sector(stream, stream->priv, buf) < 0) // skip break; pos += 2048; tm = dvd_get_current_time(stream, -1); }; tmap_sector = pos >> 11; //search closest VOBU sector k=(vts_file->vts_vobu_admap->last_byte + 1 - VOBU_ADMAP_SIZE)/4; //entries in the vobu admap for(i=1; i<k; i++) { if(vts_file->vts_vobu_admap->vobu_start_sectors[i] > tmap_sector) break; } vobu_sector = vts_file->vts_vobu_admap->vobu_start_sectors[i-1]; pos = ((int64_t)vobu_sector) << 11; do_seek(stream, pos); return 1; }
int main(void) { static dvd_priv_t dvd_priv; dvd_read_sector(&dvd_priv, 0); return 0; }