2022-08-26 15:44:59 +00:00
|
|
|
// Copyright 2014 Google LLC. All rights reserved.
|
2014-02-14 23:21:05 +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
|
2013-09-24 04:17:12 +00:00
|
|
|
|
2023-10-10 23:51:11 +00:00
|
|
|
#include <packager/media/base/stream_info.h>
|
2013-09-24 04:17:12 +00:00
|
|
|
|
2023-10-11 08:49:50 +00:00
|
|
|
#include <cinttypes>
|
2014-06-20 21:45:09 +00:00
|
|
|
|
2023-10-09 23:21:41 +00:00
|
|
|
#include <absl/strings/str_format.h>
|
|
|
|
#include <glog/logging.h>
|
2023-10-11 08:49:50 +00:00
|
|
|
|
2023-10-10 23:51:11 +00:00
|
|
|
#include <packager/macros.h>
|
|
|
|
#include <packager/media/base/timestamp.h>
|
2013-09-24 04:17:12 +00:00
|
|
|
|
2016-05-20 21:19:33 +00:00
|
|
|
namespace shaka {
|
2013-09-24 04:17:12 +00:00
|
|
|
namespace media {
|
|
|
|
|
2018-06-19 16:52:54 +00:00
|
|
|
std::string StreamTypeToString(StreamType type) {
|
|
|
|
switch (type) {
|
|
|
|
case kStreamUnknown:
|
|
|
|
return "Unknown";
|
|
|
|
case kStreamVideo:
|
|
|
|
return "Video";
|
|
|
|
case kStreamAudio:
|
|
|
|
return "Audio";
|
|
|
|
case kStreamText:
|
|
|
|
return "Text";
|
|
|
|
}
|
|
|
|
|
2022-11-04 22:46:41 +00:00
|
|
|
NOTIMPLEMENTED() << "Unhandled StreamType with value "
|
|
|
|
<< static_cast<int>(type);
|
2018-06-19 16:52:54 +00:00
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2018-06-19 16:58:29 +00:00
|
|
|
StreamInfo::StreamInfo(StreamType stream_type,
|
|
|
|
int track_id,
|
2021-08-04 18:56:44 +00:00
|
|
|
int32_t time_scale,
|
|
|
|
int64_t duration,
|
2018-06-19 16:58:29 +00:00
|
|
|
Codec codec,
|
2013-10-14 20:55:48 +00:00
|
|
|
const std::string& codec_string,
|
2018-06-19 16:58:29 +00:00
|
|
|
const uint8_t* codec_config,
|
|
|
|
size_t codec_config_size,
|
|
|
|
const std::string& language,
|
|
|
|
bool is_encrypted)
|
2013-09-24 04:17:12 +00:00
|
|
|
: stream_type_(stream_type),
|
|
|
|
track_id_(track_id),
|
|
|
|
time_scale_(time_scale),
|
2013-10-14 20:55:48 +00:00
|
|
|
duration_(duration),
|
2016-07-27 00:51:08 +00:00
|
|
|
codec_(codec),
|
2013-10-14 20:55:48 +00:00
|
|
|
codec_string_(codec_string),
|
|
|
|
language_(language),
|
2013-09-24 04:17:12 +00:00
|
|
|
is_encrypted_(is_encrypted) {
|
2016-06-27 19:30:32 +00:00
|
|
|
if (codec_config_size > 0) {
|
|
|
|
codec_config_.assign(codec_config, codec_config + codec_config_size);
|
2014-07-14 21:35:57 +00:00
|
|
|
}
|
2013-09-24 04:17:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StreamInfo::~StreamInfo() {}
|
|
|
|
|
2013-10-14 20:55:48 +00:00
|
|
|
std::string StreamInfo::ToString() const {
|
2020-12-11 20:58:26 +00:00
|
|
|
std::string duration;
|
|
|
|
if (duration_ == kInfiniteDuration) {
|
|
|
|
duration = "Infinite";
|
|
|
|
} else {
|
2022-11-04 22:46:41 +00:00
|
|
|
duration = absl::StrFormat("%" PRIu64 " (%.1f seconds)", duration_,
|
|
|
|
static_cast<double>(duration_) / time_scale_);
|
2020-12-11 20:58:26 +00:00
|
|
|
}
|
|
|
|
|
2022-11-04 22:46:41 +00:00
|
|
|
return absl::StrFormat(
|
2015-06-17 22:42:56 +00:00
|
|
|
"type: %s\n codec_string: %s\n time_scale: %d\n duration: "
|
2020-12-11 20:58:26 +00:00
|
|
|
"%s\n is_encrypted: %s\n",
|
|
|
|
StreamTypeToString(stream_type_).c_str(), codec_string_.c_str(),
|
|
|
|
time_scale_, duration.c_str(), is_encrypted_ ? "true" : "false");
|
2013-09-24 04:17:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace media
|
2016-05-20 21:19:33 +00:00
|
|
|
} // namespace shaka
|