Shaka Packager SDK
Loading...
Searching...
No Matches
seek_head.h
1// Copyright 2015 Google LLC. 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 PACKAGER_MEDIA_FORMATS_WEBM_SEEK_HEAD_H_
8#define PACKAGER_MEDIA_FORMATS_WEBM_SEEK_HEAD_H_
9
10#include <cstdint>
11#include <vector>
12
13#include <mkvmuxer/mkvmuxer.h>
14#include <mkvmuxer/mkvmuxertypes.h>
15
16namespace shaka {
17namespace media {
18
21class SeekHead {
22 public:
23 SeekHead();
24 ~SeekHead();
25
28 bool Write(mkvmuxer::IMkvWriter* writer);
30 bool WriteVoid(mkvmuxer::IMkvWriter* writer);
31
32 void set_cluster_pos(uint64_t pos) { cluster_pos_ = pos; }
33 void set_cues_pos(uint64_t pos) { cues_pos_ = pos; }
34 void set_info_pos(uint64_t pos) { info_pos_ = pos; }
35 void set_tracks_pos(uint64_t pos) { tracks_pos_ = pos; }
36
37 private:
38 SeekHead(const SeekHead&) = delete;
39 SeekHead& operator=(const SeekHead&) = delete;
40
41 struct SeekElement {
42 mkvmuxer::uint64 id;
43 mkvmuxer::uint64 position;
44 mkvmuxer::uint64 size;
45
46 SeekElement(uint64_t seek_id, uint64_t seek_position)
47 : id(seek_id), position(seek_position), size(0) {}
48 };
49
50 // Create seek element vector from positions.
51 std::vector<SeekElement> CreateSeekElements();
52
53 // In practice, these positions, if set, will never be 0, so we use a zero
54 // value to denote that they are not set.
55 uint64_t cluster_pos_ = 0;
56 uint64_t cues_pos_ = 0;
57 uint64_t info_pos_ = 0;
58 uint64_t tracks_pos_ = 0;
59 bool wrote_void_ = false;
60 const uint64_t total_void_size_ = 0;
61};
62
63} // namespace media
64} // namespace shaka
65
66#endif // PACKAGER_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:87
bool Write(mkvmuxer::IMkvWriter *writer)
Definition seek_head.cc:54
All the methods that are virtual are virtual for mocking.