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 edash_packager {
17 namespace media {
18 
19 namespace {
20 std::string VideoCodecToString(VideoCodec video_codec) {
21  switch (video_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: " << video_codec;
44  return "UnknownVideoCodec";
45  }
46 }
47 
48 } // namespace
49 
51  uint32_t time_scale,
52  uint64_t duration,
53  VideoCodec codec,
54  const std::string& codec_string,
55  const std::string& language,
56  uint16_t width,
57  uint16_t height,
58  uint32_t pixel_width,
59  uint32_t pixel_height,
60  int16_t trick_play_rate,
61  uint8_t nalu_length_size,
62  const uint8_t* extra_data,
63  size_t extra_data_size,
64  bool is_encrypted)
65  : StreamInfo(kStreamVideo,
66  track_id,
67  time_scale,
68  duration,
69  codec_string,
70  language,
71  extra_data,
72  extra_data_size,
73  is_encrypted),
74  codec_(codec),
75  width_(width),
76  height_(height),
77  pixel_width_(pixel_width),
78  pixel_height_(pixel_height),
79  trick_play_rate_(trick_play_rate),
80  nalu_length_size_(nalu_length_size) {
81 }
82 
83 VideoStreamInfo::~VideoStreamInfo() {}
84 
86  return codec_ != kUnknownVideoCodec &&
87  width_ > 0 && width_ <= limits::kMaxDimension &&
88  height_ > 0 && height_ <= limits::kMaxDimension &&
89  (nalu_length_size_ <= 2 || nalu_length_size_ == 4);
90 }
91 
92 std::string VideoStreamInfo::ToString() const {
93  return base::StringPrintf(
94  "%s codec: %s\n width: %d\n height: %d\n pixel_aspect_ratio: %d:%d\n "
95  "trick_play_rate: %d\n nalu_length_size: %d\n",
96  StreamInfo::ToString().c_str(), VideoCodecToString(codec_).c_str(),
97  width_, height_, pixel_width_, pixel_height_, trick_play_rate_,
98  nalu_length_size_);
99 }
100 
101 } // namespace media
102 } // namespace edash_packager
std::string ToString() const override
Abstract class holds stream information.
Definition: stream_info.h:26
virtual std::string ToString() const
Definition: stream_info.cc:40
VideoStreamInfo(int track_id, uint32_t time_scale, uint64_t duration, VideoCodec codec, const std::string &codec_string, const std::string &language, 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 uint8_t *extra_data, size_t extra_data_size, bool is_encrypted)