40 lines
1.2 KiB
C++
40 lines
1.2 KiB
C++
// Copyright 2017 Google Inc. All rights reserved.
|
|
//
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file or at
|
|
// https://developers.google.com/open-source/licenses/bsd
|
|
|
|
#ifndef PACKAGER_MEDIA_FORMATS_WEBVTT_UTILS_H_
|
|
#define PACKAGER_MEDIA_FORMATS_WEBVTT_UTILS_H_
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <list>
|
|
#include <memory>
|
|
#include <string>
|
|
|
|
#include "packager/base/strings/string_piece.h"
|
|
#include "packager/media/base/text_sample.h"
|
|
|
|
namespace shaka {
|
|
namespace media {
|
|
|
|
// Parse a timestamp into milliseconds using the two patterns defined by WebVtt:
|
|
// LONG : ##:##:##.### (long can have 2 or more hour digits)
|
|
// SHORT : ##:##:###
|
|
bool WebVttTimestampToMs(const base::StringPiece& source, uint64_t* out);
|
|
|
|
// Create a long form timestamp encoded as a string.
|
|
std::string MsToWebVttTimestamp(uint64_t ms);
|
|
|
|
/// Converts the given text settings to a WebVTT settings string.
|
|
std::string WebVttSettingsToString(const TextSettings& settings);
|
|
|
|
/// Converts the given TextFragment to a WebVTT cue body string.
|
|
std::string WebVttFragmentToString(const TextFragment& fragment);
|
|
|
|
} // namespace media
|
|
} // namespace shaka
|
|
|
|
#endif // PACKAGER_MEDIA_FORMATS_WEBVTT_UTILS_H_
|