DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
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 <vector>
9 
10 namespace shaka {
11 namespace media {
12 
13 // Utility function to create side data item for decoder buffer.
14 template<typename T>
15 void MakeSideData(T id_begin, T id_end,
16  T settings_begin, T settings_end,
17  std::vector<uint8>* side_data) {
18  // The DecoderBuffer only supports a single side data item. In the case of
19  // a WebVTT cue, we can have potentially two side data items. In order to
20  // avoid disrupting DecoderBuffer any more than we need to, we copy both
21  // side data items onto a single one, and terminate each with a NUL marker.
22  side_data->clear();
23  side_data->insert(side_data->end(), id_begin, id_end);
24  side_data->push_back(0);
25  side_data->insert(side_data->end(), settings_begin, settings_end);
26  side_data->push_back(0);
27 }
28 
29 } // namespace media
30 } // namespace shaka
31 
32 #endif // PACKAGER_MEDIA_CODECS_WEBVTT_UTIL_H_