2018-05-21 16:58:02 +00:00
|
|
|
// Copyright 2018 Google LLC 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_WEBVTT_FILE_BUFFER_H_
|
|
|
|
#define PACKAGER_MEDIA_FORMATS_WEBVTT_WEBVTT_FILE_BUFFER_H_
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
2023-12-01 17:32:19 +00:00
|
|
|
#include <packager/file.h>
|
2018-05-21 16:58:02 +00:00
|
|
|
|
|
|
|
namespace shaka {
|
|
|
|
namespace media {
|
|
|
|
|
|
|
|
class TextSample;
|
|
|
|
|
|
|
|
// A class to abstract writing a webvtt file to disk. This class will handle
|
|
|
|
// all the formatting requirements for a webvtt file.
|
|
|
|
class WebVttFileBuffer {
|
|
|
|
public:
|
2021-08-04 18:56:44 +00:00
|
|
|
WebVttFileBuffer(int32_t transport_stream_timestamp_offset_ms,
|
2018-08-17 20:27:59 +00:00
|
|
|
const std::string& style_region_config);
|
2018-05-21 16:58:02 +00:00
|
|
|
virtual ~WebVttFileBuffer() = default;
|
|
|
|
|
|
|
|
void Reset();
|
|
|
|
void Append(const TextSample& sample);
|
|
|
|
|
2021-02-04 22:02:33 +00:00
|
|
|
bool WriteTo(File* file, uint64_t* size);
|
2018-05-21 16:58:02 +00:00
|
|
|
|
|
|
|
// Get the number of samples that have been appended to this file.
|
|
|
|
size_t sample_count() const { return sample_count_; }
|
|
|
|
|
|
|
|
private:
|
2018-05-23 22:02:07 +00:00
|
|
|
WebVttFileBuffer(const WebVttFileBuffer&) = delete;
|
|
|
|
WebVttFileBuffer& operator=(const WebVttFileBuffer&) = delete;
|
|
|
|
|
2021-08-04 18:56:44 +00:00
|
|
|
const int32_t transport_stream_timestamp_offset_ = 0;
|
2018-08-17 20:27:59 +00:00
|
|
|
const std::string style_region_config_;
|
2018-05-21 16:58:02 +00:00
|
|
|
std::string buffer_;
|
|
|
|
size_t sample_count_ = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace media
|
|
|
|
} // namespace shaka
|
|
|
|
|
|
|
|
#endif // PACKAGER_MEDIA_FORMATS_WEBVTT_WEBVTT_FILE_BUFFER_H_
|