DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
seek_head.h
1 // Copyright 2015 Google Inc. All rights reserved.
2 //
3 // Use of this source code is governed by a BSD-style
4 // license that can be found in the LICENSE file or at
5 // https://developers.google.com/open-source/licenses/bsd
6 
7 #ifndef MEDIA_FORMATS_WEBM_SEEK_HEAD_H_
8 #define MEDIA_FORMATS_WEBM_SEEK_HEAD_H_
9 
10 #include <stdint.h>
11 #include <vector>
12 
13 #include "packager/third_party/libwebm/src/mkvmuxer.hpp"
14 
15 namespace shaka {
16 namespace media {
17 
20 class SeekHead {
21  public:
22  SeekHead();
23  ~SeekHead();
24 
27  bool Write(mkvmuxer::IMkvWriter* writer);
29  bool WriteVoid(mkvmuxer::IMkvWriter* writer);
30 
31  void set_cluster_pos(uint64_t pos) { cluster_pos_ = pos; }
32  void set_cues_pos(uint64_t pos) { cues_pos_ = pos; }
33  void set_info_pos(uint64_t pos) { info_pos_ = pos; }
34  void set_tracks_pos(uint64_t pos) { tracks_pos_ = pos; }
35 
36  private:
37  SeekHead(const SeekHead&) = delete;
38  SeekHead& operator=(const SeekHead&) = delete;
39 
40  struct SeekElement {
41  mkvmuxer::uint64 id;
42  mkvmuxer::uint64 position;
43  mkvmuxer::uint64 size;
44 
45  SeekElement(uint64_t seek_id, uint64_t seek_position)
46  : id(seek_id), position(seek_position), size(0) {}
47  };
48 
49  // Create seek element vector from positions.
50  std::vector<SeekElement> CreateSeekElements();
51 
52  // In practice, these positions, if set, will never be 0, so we use a zero
53  // value to denote that they are not set.
54  uint64_t cluster_pos_ = 0;
55  uint64_t cues_pos_ = 0;
56  uint64_t info_pos_ = 0;
57  uint64_t tracks_pos_ = 0;
58  bool wrote_void_ = false;
59  const uint64_t total_void_size_ = 0;
60 };
61 
62 } // namespace media
63 } // namespace shaka
64 
65 #endif // MEDIA_FORMATS_WEBM_SEEK_HEAD_H_
bool WriteVoid(mkvmuxer::IMkvWriter *writer)
Writes a void element large enough to fit the SeekHead.
Definition: seek_head.cc:80
bool Write(mkvmuxer::IMkvWriter *writer)
Definition: seek_head.cc:47