Shaka Packager SDK
webm_tracks_parser.h
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef PACKAGER_MEDIA_FORMATS_WEBM_WEBM_TRACKS_PARSER_H_
6 #define PACKAGER_MEDIA_FORMATS_WEBM_WEBM_TRACKS_PARSER_H_
7 
8 #include <map>
9 #include <memory>
10 #include <set>
11 #include <string>
12 #include <vector>
13 
14 #include <packager/macros/classes.h>
15 #include <packager/media/base/audio_stream_info.h>
16 #include <packager/media/base/text_track_config.h>
17 #include <packager/media/base/video_stream_info.h>
18 #include <packager/media/formats/webm/webm_audio_client.h>
19 #include <packager/media/formats/webm/webm_content_encodings_client.h>
20 #include <packager/media/formats/webm/webm_parser.h>
21 #include <packager/media/formats/webm/webm_video_client.h>
22 
23 namespace shaka {
24 namespace media {
25 
28  public:
29  explicit WebMTracksParser(bool ignore_text_tracks);
30  ~WebMTracksParser() override;
31 
36  int Parse(const uint8_t* buf, int size);
37 
38  int64_t audio_track_num() const { return audio_track_num_; }
39  int64_t video_track_num() const { return video_track_num_; }
40 
45  int64_t GetAudioDefaultDuration(const double timecode_scale_in_us) const;
46  int64_t GetVideoDefaultDuration(const double timecode_scale_in_us) const;
47 
48  const std::set<int64_t>& ignored_tracks() const { return ignored_tracks_; }
49 
50  const std::string& audio_encryption_key_id() const {
51  return audio_encryption_key_id_;
52  }
53 
54  std::shared_ptr<AudioStreamInfo> audio_stream_info() {
55  return audio_stream_info_;
56  }
57 
58  const std::string& video_encryption_key_id() const {
59  return video_encryption_key_id_;
60  }
61 
62  std::shared_ptr<VideoStreamInfo> video_stream_info() {
63  return video_stream_info_;
64  }
65 
66  typedef std::map<int, TextTrackConfig> TextTracks;
67 
68  const TextTracks& text_tracks() const {
69  return text_tracks_;
70  }
71 
72  const VPCodecConfigurationRecord& vp_config() const { return vp_config_; }
73 
74  private:
75  // WebMParserClient implementation.
76  WebMParserClient* OnListStart(int id) override;
77  bool OnListEnd(int id) override;
78  bool OnUInt(int id, int64_t val) override;
79  bool OnFloat(int id, double val) override;
80  bool OnBinary(int id, const uint8_t* data, int size) override;
81  bool OnString(int id, const std::string& str) override;
82 
83  int64_t track_type_;
84  int64_t track_num_;
85  std::string track_name_;
86  std::string track_language_;
87  std::string codec_id_;
88  std::vector<uint8_t> codec_private_;
89  int64_t seek_preroll_;
90  int64_t codec_delay_;
91  int64_t default_duration_;
92  std::unique_ptr<WebMContentEncodingsClient> track_content_encodings_client_;
93 
94  int64_t audio_track_num_;
95  int64_t audio_default_duration_;
96  int64_t video_track_num_;
97  int64_t video_default_duration_;
98  bool ignore_text_tracks_;
99  TextTracks text_tracks_;
100  std::set<int64_t> ignored_tracks_;
101  std::string audio_encryption_key_id_;
102  std::string video_encryption_key_id_;
103 
104  WebMAudioClient audio_client_;
105  std::shared_ptr<AudioStreamInfo> audio_stream_info_;
106 
107  WebMVideoClient video_client_;
108  VPCodecConfigurationRecord vp_config_;
109  std::shared_ptr<VideoStreamInfo> video_stream_info_;
110 
111  DISALLOW_COPY_AND_ASSIGN(WebMTracksParser);
112 };
113 
114 } // namespace media
115 } // namespace shaka
116 
117 #endif // PACKAGER_MEDIA_FORMATS_WEBM_WEBM_TRACKS_PARSER_H_
Class for parsing or writing VP codec configuration record.
Helper class used to parse an Audio element inside a TrackEntry element.
Parser for WebM Tracks element.
int64_t GetAudioDefaultDuration(const double timecode_scale_in_us) const
int Parse(const uint8_t *buf, int size)
Helper class used to parse a Video element inside a TrackEntry element.
All the methods that are virtual are virtual for mocking.
Definition: crypto_flags.cc:66