DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs Enumerator
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 MEDIA_FORMATS_WEBM_WEBM_TRACKS_PARSER_H_
6 #define MEDIA_FORMATS_WEBM_WEBM_TRACKS_PARSER_H_
7 
8 #include <map>
9 #include <set>
10 #include <string>
11 #include <vector>
12 
13 #include "packager/base/compiler_specific.h"
14 #include "packager/base/memory/scoped_ptr.h"
15 #include "packager/base/time/time.h"
16 #include "packager/media/base/audio_stream_info.h"
17 #include "packager/media/base/text_track_config.h"
18 #include "packager/media/base/video_stream_info.h"
19 #include "packager/media/formats/webm/webm_audio_client.h"
20 #include "packager/media/formats/webm/webm_content_encodings_client.h"
21 #include "packager/media/formats/webm/webm_parser.h"
22 #include "packager/media/formats/webm/webm_video_client.h"
23 
24 namespace edash_packager {
25 namespace media {
26 
29  public:
30  explicit WebMTracksParser(bool ignore_text_tracks);
31  ~WebMTracksParser() override;
32 
37  int Parse(const uint8_t* buf, int size);
38 
39  int64_t audio_track_num() const { return audio_track_num_; }
40  int64_t video_track_num() const { return video_track_num_; }
41 
46  int64_t GetAudioDefaultDuration(const double timecode_scale_in_us) const;
47  int64_t GetVideoDefaultDuration(const double timecode_scale_in_us) const;
48 
49  const std::set<int64_t>& ignored_tracks() const { return ignored_tracks_; }
50 
51  const std::string& audio_encryption_key_id() const {
52  return audio_encryption_key_id_;
53  }
54 
55  scoped_refptr<AudioStreamInfo> audio_stream_info() {
56  return audio_stream_info_;
57  }
58 
59  const std::string& video_encryption_key_id() const {
60  return video_encryption_key_id_;
61  }
62 
63  scoped_refptr<VideoStreamInfo> video_stream_info() {
64  return video_stream_info_;
65  }
66 
67  typedef std::map<int, TextTrackConfig> TextTracks;
68 
69  const TextTracks& text_tracks() const {
70  return text_tracks_;
71  }
72 
73  private:
74  // WebMParserClient implementation.
75  WebMParserClient* OnListStart(int id) override;
76  bool OnListEnd(int id) override;
77  bool OnUInt(int id, int64_t val) override;
78  bool OnFloat(int id, double val) override;
79  bool OnBinary(int id, const uint8_t* data, int size) override;
80  bool OnString(int id, const std::string& str) override;
81 
82  int64_t track_type_;
83  int64_t track_num_;
84  std::string track_name_;
85  std::string track_language_;
86  std::string codec_id_;
87  std::vector<uint8_t> codec_private_;
88  int64_t seek_preroll_;
89  int64_t codec_delay_;
90  int64_t default_duration_;
91  scoped_ptr<WebMContentEncodingsClient> track_content_encodings_client_;
92 
93  int64_t audio_track_num_;
94  int64_t audio_default_duration_;
95  int64_t video_track_num_;
96  int64_t video_default_duration_;
97  bool ignore_text_tracks_;
98  TextTracks text_tracks_;
99  std::set<int64_t> ignored_tracks_;
100  std::string audio_encryption_key_id_;
101  std::string video_encryption_key_id_;
102 
103  WebMAudioClient audio_client_;
104  scoped_refptr<AudioStreamInfo> audio_stream_info_;
105 
106  WebMVideoClient video_client_;
107  scoped_refptr<VideoStreamInfo> video_stream_info_;
108 
109  DISALLOW_COPY_AND_ASSIGN(WebMTracksParser);
110 };
111 
112 } // namespace media
113 } // namespace edash_packager
114 
115 #endif // MEDIA_FORMATS_WEBM_WEBM_TRACKS_PARSER_H_
Parser for WebM Tracks element.
Helper class used to parse a Video element inside a TrackEntry element.
int Parse(const uint8_t *buf, int size)
int64_t GetAudioDefaultDuration(const double timecode_scale_in_us) const
Helper class used to parse an Audio element inside a TrackEntry element.