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>
|
|
|
|
|
|
|
|
#include "packager/file/file.h"
|
|
|
|
|
|
|
|
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:
|
2018-07-03 23:52:05 +00:00
|
|
|
explicit WebVttFileBuffer(uint32_t transport_stream_timestamp_offset_ms);
|
2018-05-21 16:58:02 +00:00
|
|
|
virtual ~WebVttFileBuffer() = default;
|
|
|
|
|
|
|
|
void Reset();
|
|
|
|
void Append(const TextSample& sample);
|
|
|
|
|
|
|
|
bool WriteTo(File* file);
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
2018-07-03 23:52:05 +00:00
|
|
|
const uint32_t transport_stream_timestamp_offset_ = 0;
|
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_
|