2015-11-19 23:58:29 +00:00
|
|
|
// Copyright 2015 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_BASE_TEXT_STREAM_INFO_H_
|
|
|
|
#define PACKAGER_MEDIA_BASE_TEXT_STREAM_INFO_H_
|
|
|
|
|
|
|
|
#include "packager/media/base/stream_info.h"
|
2020-08-26 21:21:09 +00:00
|
|
|
#include "packager/media/base/text_sample.h"
|
2015-11-19 23:58:29 +00:00
|
|
|
|
2020-08-26 21:21:09 +00:00
|
|
|
#include <map>
|
2015-11-19 23:58:29 +00:00
|
|
|
#include <string>
|
|
|
|
|
2016-05-20 21:19:33 +00:00
|
|
|
namespace shaka {
|
2015-11-19 23:58:29 +00:00
|
|
|
namespace media {
|
|
|
|
|
2020-08-26 21:21:09 +00:00
|
|
|
struct TextRegion {
|
|
|
|
/// The width of the region; percent units are relative to the window.
|
|
|
|
TextNumber width{100, TextUnitType::kPercent};
|
|
|
|
/// The height of the region; percent units are relative to the window.
|
|
|
|
TextNumber height{100, TextUnitType::kPercent};
|
|
|
|
|
|
|
|
/// The x and y coordinates of the anchor point within the window. Percent
|
|
|
|
/// units are relative to the window. In WebVTT this is called the
|
|
|
|
/// "viewport region anchor".
|
|
|
|
TextNumber window_anchor_x{0, TextUnitType::kPercent};
|
|
|
|
TextNumber window_anchor_y{0, TextUnitType::kPercent};
|
|
|
|
/// The x and y coordinates of the anchor point within the region. Percent
|
|
|
|
/// units are relative to the region size. For example: if this is
|
|
|
|
/// (100, 100), then the bottom right of the region should be placed at the
|
|
|
|
/// window anchor point.
|
|
|
|
/// See https://www.w3.org/TR/webvtt1/#regions.
|
|
|
|
TextNumber region_anchor_x{0, TextUnitType::kPercent};
|
|
|
|
TextNumber region_anchor_y{0, TextUnitType::kPercent};
|
|
|
|
|
|
|
|
/// If true, cues are scrolled up when adding new cues; if false, cues are
|
|
|
|
/// added above existing cues or replace existing ones.
|
|
|
|
bool scroll = false;
|
|
|
|
};
|
|
|
|
|
2015-11-19 23:58:29 +00:00
|
|
|
class TextStreamInfo : public StreamInfo {
|
|
|
|
public:
|
|
|
|
/// No encryption supported.
|
|
|
|
/// @param track_id is the track ID of this stream.
|
|
|
|
/// @param time_scale is the time scale of this stream.
|
|
|
|
/// @param duration is the duration of this stream.
|
2017-02-14 21:40:09 +00:00
|
|
|
/// @param codec is the media codec.
|
|
|
|
/// @param codec_string is the codec in string format.
|
2016-06-27 19:30:32 +00:00
|
|
|
/// @param codec_config is configuration for this text stream. This could be
|
|
|
|
/// the metadata that applies to all the samples of this stream. This
|
|
|
|
/// may be empty.
|
2015-11-19 23:58:29 +00:00
|
|
|
/// @param width of the text. This may be 0.
|
|
|
|
/// @param height of the text. This may be 0.
|
2016-07-27 00:51:08 +00:00
|
|
|
/// @param language is the language of this stream. This may be empty.
|
|
|
|
TextStreamInfo(int track_id, uint32_t time_scale, uint64_t duration,
|
2017-02-14 21:40:09 +00:00
|
|
|
Codec codec,
|
2015-11-19 23:58:29 +00:00
|
|
|
const std::string& codec_string,
|
2016-07-27 00:51:08 +00:00
|
|
|
const std::string& codec_config, uint16_t width,
|
|
|
|
uint16_t height, const std::string& language);
|
2015-11-19 23:58:29 +00:00
|
|
|
|
2017-01-24 00:55:02 +00:00
|
|
|
~TextStreamInfo() override;
|
|
|
|
|
2015-11-19 23:58:29 +00:00
|
|
|
bool IsValidConfig() const override;
|
|
|
|
|
2017-09-12 17:24:24 +00:00
|
|
|
std::unique_ptr<StreamInfo> Clone() const override;
|
|
|
|
|
2015-11-19 23:58:29 +00:00
|
|
|
uint16_t width() const { return width_; }
|
|
|
|
uint16_t height() const { return height_; }
|
2020-08-26 21:21:09 +00:00
|
|
|
const std::map<std::string, TextRegion>& regions() const { return regions_; }
|
|
|
|
void AddRegion(const std::string& id, const TextRegion& region) {
|
|
|
|
regions_[id] = region;
|
|
|
|
}
|
|
|
|
const std::string& css_styles() const { return css_styles_; }
|
|
|
|
void set_css_styles(const std::string& styles) { css_styles_ = styles; }
|
2015-11-19 23:58:29 +00:00
|
|
|
|
|
|
|
private:
|
2020-08-26 21:21:09 +00:00
|
|
|
std::map<std::string, TextRegion> regions_;
|
|
|
|
std::string css_styles_;
|
2015-11-19 23:58:29 +00:00
|
|
|
uint16_t width_;
|
|
|
|
uint16_t height_;
|
|
|
|
|
|
|
|
// Allow copying. This is very light weight.
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace media
|
2016-05-20 21:19:33 +00:00
|
|
|
} // namespace shaka
|
2015-11-19 23:58:29 +00:00
|
|
|
|
|
|
|
#endif // PACKAGER_MEDIA_BASE_TEXT_STREAM_INFO_H_
|