diff options
Diffstat (limited to 'tests/chapters/test.c')
| -rw-r--r-- | tests/chapters/test.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/chapters/test.c b/tests/chapters/test.c new file mode 100644 index 0000000..c6982e6 --- /dev/null +++ b/tests/chapters/test.c @@ -0,0 +1,37 @@ +#include <stdio.h> +#include <string.h> +#include "config.h" +#include "metadata.h" +#include "misc.h" +#include "chapters.h" +/* minimal UTF-8 encoder like rockbox's */ +unsigned char* utf8encode(unsigned long c, unsigned char *u){ + if(c<0x80){*u++=c;} else if(c<0x800){*u++=0xc0|(c>>6);*u++=0x80|(c&63);} + else {*u++=0xe0|(c>>12);*u++=0x80|((c>>6)&63);*u++=0x80|(c&63);} return u; } +long seeked=-2; int nexts, prevs, nomore; +void system_sound_play(enum system_sound s){(void)s; nomore++;} +struct mp3entry cur; struct mp3entry *audio_current_track(void){return &cur;} +void audio_next(void){nexts++;} void audio_prev(void){prevs++;} +void audio_pre_ff_rewind(void){} void audio_ff_rewind(long ms){seeked=ms;} +bool playlist_check(int s){(void)s; return true;} +int main(int argc, char **argv){ + for (int a=1;a<argc;a++){ + memset(&cur,0,sizeof cur); strcpy(cur.path, argv[a]); cur.codectype=AFMT_MP4_AAC; + int n = chapters_update(&cur); + printf("== %s: %d chapters\n", argv[a], n); + char buf[100]; + for (int i=0;i<n;i++) if (i<6 || i>n-3) printf(" %3d %8lu ms [%s]\n", i+1, chapters_start(i), chapters_title(i,buf,sizeof buf)); + if (n>2){ + cur.elapsed = chapters_start(1)+1000; chapters_skip(&cur,-1,3000); printf(" prev 1s into ch2 -> %ld\n", seeked); + cur.elapsed = chapters_start(1)+10000; chapters_skip(&cur,-1,3000); printf(" prev 10s into ch2 -> %ld\n", seeked); + cur.elapsed = chapters_start(1)+10000; chapters_skip(&cur,1,3000); printf(" next from ch2 -> %ld\n", seeked); + cur.elapsed = chapters_start(n-1)+10; nomore=0; chapters_skip(&cur,1,3000); printf(" next from last -> nomore=%d\n", nomore); + cur.elapsed = chapters_start(2)+5; printf(" index at ch3+5ms = %d, current title [%s]\n", chapters_index(cur.elapsed), chapters_current_title(&cur)); + printf(" next title [%s]\n", chapters_next_title(&cur)); printf(" changed: %d %d\n", chapters_changed(&cur), chapters_changed(&cur)); + } else if (n==0) { + nexts=prevs=0; cur.elapsed=1000; chapters_skip(&cur,-1,3000); chapters_skip(&cur,1,3000); + cur.elapsed=10000; seeked=-2; chapters_skip(&cur,-1,3000); + printf(" no chapters: prev@1s->prevs=%d next->nexts=%d prev@10s->seek %ld\n", prevs, nexts, seeked); + } + } +} |
