diff --git a/layout/media/symbols.def.in b/layout/media/symbols.def.in index 7202e616c49..2c669602f74 100644 --- a/layout/media/symbols.def.in +++ b/layout/media/symbols.def.in @@ -9,6 +9,7 @@ nestegg_destroy nestegg_duration nestegg_free_packet nestegg_init +nestegg_offset_seek nestegg_packet_count nestegg_packet_data nestegg_packet_track diff --git a/media/libnestegg/README_MOZILLA b/media/libnestegg/README_MOZILLA index 1e32ade9e60..5581982c397 100644 --- a/media/libnestegg/README_MOZILLA +++ b/media/libnestegg/README_MOZILLA @@ -5,4 +5,4 @@ Makefile.in build files for the Mozilla build system. The nestegg git repository is: git://github.com/kinetiknz/nestegg.git -The git commit ID used was a4dd140a8c1073d8d5ef7848f83730e12bdfcf18. +The git commit ID used was ce207d5b7566da2900e728b776a918ff3ab3dbb0. diff --git a/media/libnestegg/include/nestegg.h b/media/libnestegg/include/nestegg.h index 705d16e5321..c7cc74cfec0 100644 --- a/media/libnestegg/include/nestegg.h +++ b/media/libnestegg/include/nestegg.h @@ -194,6 +194,15 @@ int nestegg_get_cue_point(nestegg * context, unsigned int cluster_num, int64_t max_offset, int64_t * start_pos, int64_t * end_pos); +/** Seek to @a offset. Stream will seek directly to offset. + Should be used to seek to the start of a resync point, i.e. cluster; the + parser will not be able to understand other offsets. + @param context Stream context initialized by #nestegg_init. + @param offset Absolute offset in bytes. + @retval 0 Success. + @retval -1 Error. */ +int nestegg_offset_seek(nestegg * context, uint64_t offset); + /** Seek @a track to @a tstamp. Stream seek will terminate at the earliest key point in the stream at or before @a tstamp. Other tracks in the stream will output packets with unspecified but nearby timestamps. diff --git a/media/libnestegg/src/nestegg.c b/media/libnestegg/src/nestegg.c index e9544159c83..7f213951bfc 100644 --- a/media/libnestegg/src/nestegg.c +++ b/media/libnestegg/src/nestegg.c @@ -1647,6 +1647,27 @@ nestegg_get_cue_point(nestegg * ctx, unsigned int cluster_num, int64_t max_offse return 0; } +int +nestegg_offset_seek(nestegg * ctx, uint64_t offset) +{ + int r; + + /* Seek and set up parser state for segment-level element (Cluster). */ + r = ne_io_seek(ctx->io, offset, NESTEGG_SEEK_SET); + if (r != 0) + return -1; + ctx->last_id = 0; + ctx->last_size = 0; + + while (ctx->ancestor) + ne_ctx_pop(ctx); + + ne_ctx_push(ctx, ne_top_level_elements, ctx); + ne_ctx_push(ctx, ne_segment_elements, &ctx->segment); + + return 0; +} + int nestegg_track_seek(nestegg * ctx, unsigned int track, uint64_t tstamp) { @@ -1691,17 +1712,7 @@ nestegg_track_seek(nestegg * ctx, unsigned int track, uint64_t tstamp) } /* Seek and set up parser state for segment-level element (Cluster). */ - r = ne_io_seek(ctx->io, ctx->segment_offset + seek_pos, NESTEGG_SEEK_SET); - if (r != 0) - return -1; - ctx->last_id = 0; - ctx->last_size = 0; - - while (ctx->ancestor) - ne_ctx_pop(ctx); - - ne_ctx_push(ctx, ne_top_level_elements, ctx); - ne_ctx_push(ctx, ne_segment_elements, &ctx->segment); + r = nestegg_offset_seek(ctx, ctx->segment_offset + seek_pos); ctx->log(ctx, NESTEGG_LOG_DEBUG, "seek: parsing cluster elements"); r = ne_parse(ctx, NULL, -1); if (r != 1)