Bug 816726 - Return timestamp in nestegg_get_cue_point to support DASH-WebM Seeking r=kinetik
authorSteve Workman <sworkman@mozilla.com>
Thu, 13 Dec 2012 11:42:44 -0800
changeset 115964 e7b09b636bbfff9f583fdeb114f1ec7acb26fa38
parent 115963 90b2c0cb4a91da8527f5ca701f53eeb5bdc6919a
child 115965 5b6583b20a8016431d583f23e6c3384e5f8d0d9d
push id24034
push useremorley@mozilla.com
push dateFri, 14 Dec 2012 15:28:57 +0000
treeherdermozilla-central@50d8f411d305 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskinetik
bugs816726
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 816726 - Return timestamp in nestegg_get_cue_point to support DASH-WebM Seeking r=kinetik
content/media/webm/WebMReader.cpp
media/libnestegg/README_MOZILLA
media/libnestegg/include/nestegg.h
media/libnestegg/src/nestegg.c
--- a/content/media/webm/WebMReader.cpp
+++ b/content/media/webm/WebMReader.cpp
@@ -404,17 +404,18 @@ nsresult WebMReader::ReadMetadata(VideoI
       }
     } while (!done);
   }
 #endif
 
   // We can't seek in buffered regions if we have no cues.
   bool haveCues;
   int64_t dummy = -1;
-  haveCues = nestegg_get_cue_point(mContext, 0, -1, &dummy, &dummy) == 0;
+  haveCues = nestegg_get_cue_point(mContext, 0, -1, &dummy, &dummy,
+                                   (uint64_t*)&dummy) == 0;
   mDecoder->SetMediaSeekable(haveCues);
 
   *aInfo = mInfo;
 
   *aTags = nullptr;
 
 #ifdef MOZ_DASH
   mDecoder->OnReadMetadataCompleted();
--- a/media/libnestegg/README_MOZILLA
+++ b/media/libnestegg/README_MOZILLA
@@ -1,8 +1,8 @@
 The source from this directory was copied from the nestegg
 git repository using the update.sh script.  The only changes
 made were those applied by update.sh and the addition of
 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 ce207d5b7566da2900e728b776a918ff3ab3dbb0.
+The git commit ID used was 37c8ec972f6908e884b2e3be6eaf7915dbe4e278.
--- a/media/libnestegg/include/nestegg.h
+++ b/media/libnestegg/include/nestegg.h
@@ -183,21 +183,22 @@ int nestegg_track_count(nestegg * contex
 
 /** Query the start and end offset for a particular cluster.
     @param context     Stream context initialized by #nestegg_init.
     @param cluster_num Zero-based cluster number; order they appear in cues.
     @param max_offset  Optional maximum offset to be read. Set -1 to ignore.
     @param start_pos   Starting offset of the cluster. -1 means non-existant.
     @param end_pos     Starting offset of the cluster. -1 means non-existant or
                        final cluster.
+    @param tstamp      Starting timestamp of the cluster.
     @retval  0 Success.
     @retval -1 Error. */
 int nestegg_get_cue_point(nestegg * context, unsigned int cluster_num,
                           int64_t max_offset, int64_t * start_pos,
-                          int64_t * end_pos);
+                          int64_t * end_pos, uint64_t * tstamp);
 
 /** 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. */
--- a/media/libnestegg/src/nestegg.c
+++ b/media/libnestegg/src/nestegg.c
@@ -1585,57 +1585,63 @@ int
 nestegg_track_count(nestegg * ctx, unsigned int * tracks)
 {
   *tracks = ctx->track_count;
   return 0;
 }
 
 int
 nestegg_get_cue_point(nestegg * ctx, unsigned int cluster_num, int64_t max_offset,
-                      int64_t * start_pos, int64_t * end_pos)
+                      int64_t * start_pos, int64_t * end_pos, uint64_t * tstamp)
 {
   int range_obtained = 0;
   unsigned int cluster_count = 0;
   struct cue_point * cue_point;
   struct cue_track_positions * pos;
-  uint64_t seek_pos, t;
+  uint64_t seek_pos, t, tc_scale, time;
   struct ebml_list_node * cues_node = ctx->segment.cues.cue_point.head;
   struct ebml_list_node * cue_pos_node = NULL;
   unsigned int track = 0, track_count = 0;
 
-  if (!start_pos || !end_pos)
+  if (!start_pos || !end_pos || !tstamp)
     return -1;
 
   /* Initialise return values */
   *start_pos = -1;
-  *end_pos   = -1;
+  *end_pos = -1;
+  *tstamp = 0;
 
   if (!cues_node) {
     ne_init_cue_points(ctx, max_offset);
     cues_node = ctx->segment.cues.cue_point.head;
     /* Verify cues have been added to context. */
     if (!cues_node)
       return -1;
   }
 
   nestegg_track_count(ctx, &track_count);
 
+  tc_scale = ne_get_timecode_scale(ctx);
+
   while (cues_node && !range_obtained) {
     assert(cues_node->id == ID_CUE_POINT);
     cue_point = cues_node->data;
     cue_pos_node = cue_point->cue_track_positions.head;
     while (cue_pos_node) {
       assert(cue_pos_node->id == ID_CUE_TRACK_POSITIONS);
       pos = cue_pos_node->data;
       for (track = 0; track < track_count; track++) {
         if (ne_get_uint(pos->track, &t) == 0 && t - 1 == track) {
           if (ne_get_uint(pos->cluster_position, &seek_pos) != 0)
             return -1;
           if (cluster_count == cluster_num) {
             *start_pos = ctx->segment_offset+seek_pos;
+            if (ne_get_uint(cue_point->time, &time) != 0)
+              return -1;
+            *tstamp = time * tc_scale;
           } else if (cluster_count == cluster_num+1) {
             *end_pos = (ctx->segment_offset+seek_pos)-1;
             range_obtained = 1;
             break;
           }
           cluster_count++;
         }
       }