2022-08-26 15:44:59 +00:00
|
|
|
// Copyright 2017 Google LLC. All rights reserved.
|
2017-06-09 15:30:16 +00:00
|
|
|
//
|
|
|
|
// 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
|
|
|
|
|
2023-10-10 23:51:11 +00:00
|
|
|
#include <packager/media/base/text_sample.h>
|
2017-06-09 15:30:16 +00:00
|
|
|
|
2020-08-26 20:47:14 +00:00
|
|
|
#include <algorithm>
|
|
|
|
#include <functional>
|
|
|
|
|
2023-10-13 19:42:47 +00:00
|
|
|
#include <absl/log/log.h>
|
2017-06-09 15:30:16 +00:00
|
|
|
|
|
|
|
namespace shaka {
|
|
|
|
namespace media {
|
|
|
|
|
2020-08-24 22:23:15 +00:00
|
|
|
bool TextFragment::is_empty() const {
|
2020-08-26 20:47:14 +00:00
|
|
|
return std::all_of(sub_fragments.begin(), sub_fragments.end(),
|
|
|
|
std::mem_fn(&TextFragment::is_empty)) &&
|
2020-11-20 21:03:16 +00:00
|
|
|
body.empty() && image.empty();
|
2017-06-09 15:30:16 +00:00
|
|
|
}
|
|
|
|
|
2020-08-24 22:23:15 +00:00
|
|
|
TextSample::TextSample(const std::string& id,
|
|
|
|
int64_t start_time,
|
|
|
|
int64_t end_time,
|
|
|
|
const TextSettings& settings,
|
|
|
|
const TextFragment& body)
|
|
|
|
: id_(id),
|
|
|
|
start_time_(start_time),
|
|
|
|
duration_(end_time - start_time),
|
|
|
|
settings_(settings),
|
|
|
|
body_(body) {}
|
2017-06-09 15:30:16 +00:00
|
|
|
|
2020-08-24 22:23:15 +00:00
|
|
|
int64_t TextSample::EndTime() const {
|
|
|
|
return start_time_ + duration_;
|
2017-06-09 15:30:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace media
|
|
|
|
} // namespace shaka
|