Shaka Packager SDK
Loading...
Searching...
No Matches
webvtt_util.h
1// Copyright 2013 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef PACKAGER_MEDIA_CODECS_WEBVTT_UTIL_H_
6#define PACKAGER_MEDIA_CODECS_WEBVTT_UTIL_H_
7
8#include <cstdint>
9#include <vector>
10
11namespace shaka {
12namespace media {
13
14// Utility function to create side data item for decoder buffer.
15template <typename T>
16void MakeSideData(T id_begin,
17 T id_end,
18 T settings_begin,
19 T settings_end,
20 std::vector<uint8_t>* side_data) {
21 // The DecoderBuffer only supports a single side data item. In the case of
22 // a WebVTT cue, we can have potentially two side data items. In order to
23 // avoid disrupting DecoderBuffer any more than we need to, we copy both
24 // side data items onto a single one, and terminate each with a NUL marker.
25 side_data->clear();
26 side_data->insert(side_data->end(), id_begin, id_end);
27 side_data->push_back(0);
28 side_data->insert(side_data->end(), settings_begin, settings_end);
29 side_data->push_back(0);
30}
31
32} // namespace media
33} // namespace shaka
34
35#endif // PACKAGER_MEDIA_CODECS_WEBVTT_UTIL_H_
All the methods that are virtual are virtual for mocking.