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