Shaka Packager SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
stream_info.cc
1 // Copyright 2014 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/stream_info.h"
8 
9 #include <inttypes.h>
10 
11 #include "packager/base/logging.h"
12 #include "packager/base/strings/stringprintf.h"
13 
14 namespace shaka {
15 namespace media {
16 
17 StreamInfo::StreamInfo(StreamType stream_type, int track_id,
18  uint32_t time_scale, uint64_t duration, Codec codec,
19  const std::string& codec_string,
20  const uint8_t* codec_config, size_t codec_config_size,
21  const std::string& language, bool is_encrypted)
22  : stream_type_(stream_type),
23  track_id_(track_id),
24  time_scale_(time_scale),
25  duration_(duration),
26  codec_(codec),
27  codec_string_(codec_string),
28  language_(language),
29  is_encrypted_(is_encrypted) {
30  if (codec_config_size > 0) {
31  codec_config_.assign(codec_config, codec_config + codec_config_size);
32  }
33 }
34 
35 StreamInfo::~StreamInfo() {}
36 
37 std::string StreamInfo::ToString() const {
38  return base::StringPrintf(
39  "type: %s\n codec_string: %s\n time_scale: %d\n duration: "
40  "%" PRIu64 " (%.1f seconds)\n is_encrypted: %s\n",
41  (stream_type_ == kStreamAudio ? "Audio" : "Video"),
42  codec_string_.c_str(),
43  time_scale_, duration_,
44  static_cast<double>(duration_) / time_scale_,
45  is_encrypted_ ? "true" : "false");
46 }
47 
48 } // namespace media
49 } // namespace shaka
virtual std::string ToString() const
Definition: stream_info.cc:37