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