Shaka Packager SDK
text_sample.cc
1 // Copyright 2017 Google Inc. All rights reserved.
2 //
3 // Use of this source code is governed by a BSD-style
4 // license that can be found in the LICENSE file or at
5 // https://developers.google.com/open-source/licenses/bsd
6 
7 #include "packager/media/base/text_sample.h"
8 
9 #include "packager/base/logging.h"
10 
11 namespace shaka {
12 namespace media {
13 
14 int64_t TextSample::EndTime() const {
15  return start_time_ + duration_;
16 }
17 
18 void TextSample::SetTime(int64_t start_time, int64_t end_time) {
19  DCHECK_GE(start_time, 0);
20  DCHECK_GT(end_time, 0);
21  DCHECK_LT(start_time, end_time);
22  start_time_ = start_time;
23  duration_ = end_time - start_time;
24 }
25 
26 void TextSample::AppendStyle(const std::string& style) {
27  if (settings_.length()) {
28  settings_ += " ";
29  }
30  settings_ += style;
31 }
32 
33 void TextSample::AppendPayload(const std::string& payload) {
34  if (payload_.length()) {
35  payload_ += "\n";
36  }
37  payload_ += payload;
38 }
39 
40 } // namespace media
41 } // namespace shaka
All the methods that are virtual are virtual for mocking.