DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
video_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/video_stream_info.h"
8 
9 #include "packager/base/logging.h"
10 #include "packager/base/strings/string_number_conversions.h"
11 #include "packager/base/strings/string_util.h"
12 #include "packager/base/strings/stringprintf.h"
13 #include "packager/media/base/limits.h"
14 
15 namespace shaka {
16 namespace media {
17 
18 namespace {
19 std::string VideoCodecToString(Codec codec) {
20  switch (codec) {
21  case kCodecH264:
22  return "H264";
23  case kCodecHEV1:
24  return "HEV1";
25  case kCodecHVC1:
26  return "HVC1";
27  case kCodecVC1:
28  return "VC1";
29  case kCodecMPEG2:
30  return "MPEG2";
31  case kCodecMPEG4:
32  return "MPEG4";
33  case kCodecTheora:
34  return "Theora";
35  case kCodecVP8:
36  return "VP8";
37  case kCodecVP9:
38  return "VP9";
39  case kCodecVP10:
40  return "VP10";
41  default:
42  NOTIMPLEMENTED() << "Unknown Video Codec: " << codec;
43  return "UnknownCodec";
44  }
45 }
46 
47 } // namespace
48 
50  int track_id, uint32_t time_scale, uint64_t duration, Codec codec,
51  const std::string& codec_string, const uint8_t* codec_config,
52  size_t codec_config_size, uint16_t width, uint16_t height,
53  uint32_t pixel_width, uint32_t pixel_height, int16_t trick_play_rate,
54  uint8_t nalu_length_size, const std::string& language, bool is_encrypted)
55  : StreamInfo(kStreamVideo, track_id, time_scale, duration, codec,
56  codec_string, codec_config, codec_config_size, language,
57  is_encrypted),
58  width_(width),
59  height_(height),
60  pixel_width_(pixel_width),
61  pixel_height_(pixel_height),
62  trick_play_rate_(trick_play_rate),
63  nalu_length_size_(nalu_length_size) {}
64 
65 VideoStreamInfo::~VideoStreamInfo() {}
66 
68  return codec() != kUnknownCodec && width_ > 0 &&
69  width_ <= limits::kMaxDimension && height_ > 0 &&
70  height_ <= limits::kMaxDimension &&
71  (nalu_length_size_ <= 2 || nalu_length_size_ == 4);
72 }
73 
74 std::string VideoStreamInfo::ToString() const {
75  return base::StringPrintf(
76  "%s codec: %s\n width: %d\n height: %d\n pixel_aspect_ratio: %d:%d\n "
77  "trick_play_rate: %d\n nalu_length_size: %d\n",
78  StreamInfo::ToString().c_str(), VideoCodecToString(codec()).c_str(),
79  width_, height_, pixel_width_, pixel_height_, trick_play_rate_,
80  nalu_length_size_);
81 }
82 
83 } // namespace media
84 } // namespace shaka
Abstract class holds stream information.
Definition: stream_info.h:58
bool IsValidConfig() const override
virtual std::string ToString() const
Definition: stream_info.cc:37
std::string ToString() const override
VideoStreamInfo(int track_id, uint32_t time_scale, uint64_t duration, Codec codec, const std::string &codec_string, const uint8_t *codec_config, size_t codec_config_size, uint16_t width, uint16_t height, uint32_t pixel_width, uint32_t pixel_height, int16_t trick_play_rate, uint8_t nalu_length_size, const std::string &language, bool is_encrypted)