Supervised user import: Listen for profile creation/deletion
[chromium-blink-merge.git] / media / formats / webm / webm_tracks_parser.h
blob2801a3e532254a06403bb48b67468c70d1303b1b
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.
5 #ifndef MEDIA_FORMATS_WEBM_WEBM_TRACKS_PARSER_H_
6 #define MEDIA_FORMATS_WEBM_WEBM_TRACKS_PARSER_H_
8 #include <map>
9 #include <set>
10 #include <string>
11 #include <vector>
13 #include "base/compiler_specific.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/time/time.h"
16 #include "media/base/audio_decoder_config.h"
17 #include "media/base/media_log.h"
18 #include "media/base/text_track_config.h"
19 #include "media/base/video_decoder_config.h"
20 #include "media/formats/webm/webm_audio_client.h"
21 #include "media/formats/webm/webm_content_encodings_client.h"
22 #include "media/formats/webm/webm_parser.h"
23 #include "media/formats/webm/webm_video_client.h"
25 namespace media {
27 // Parser for WebM Tracks element.
28 class MEDIA_EXPORT WebMTracksParser : public WebMParserClient {
29 public:
30 explicit WebMTracksParser(const LogCB& log_cb, bool ignore_text_tracks);
31 ~WebMTracksParser() override;
33 // Parses a WebM Tracks element in |buf|.
35 // Returns -1 if the parse fails.
36 // Returns 0 if more data is needed.
37 // Returns the number of bytes parsed on success.
38 int Parse(const uint8* buf, int size);
40 int64 audio_track_num() const { return audio_track_num_; }
41 int64 video_track_num() const { return video_track_num_; }
43 // If TrackEntry DefaultDuration field existed for the associated audio or
44 // video track, returns that value converted from ns to base::TimeDelta with
45 // precision not greater than |timecode_scale_in_us|. Defaults to
46 // kNoTimestamp().
47 base::TimeDelta GetAudioDefaultDuration(
48 const double timecode_scale_in_us) const;
49 base::TimeDelta GetVideoDefaultDuration(
50 const double timecode_scale_in_us) const;
52 const std::set<int64>& ignored_tracks() const { return ignored_tracks_; }
54 const std::string& audio_encryption_key_id() const {
55 return audio_encryption_key_id_;
58 const AudioDecoderConfig& audio_decoder_config() {
59 return audio_decoder_config_;
62 const std::string& video_encryption_key_id() const {
63 return video_encryption_key_id_;
66 const VideoDecoderConfig& video_decoder_config() {
67 return video_decoder_config_;
70 typedef std::map<int, TextTrackConfig> TextTracks;
72 const TextTracks& text_tracks() const {
73 return text_tracks_;
76 private:
77 // WebMParserClient implementation.
78 WebMParserClient* OnListStart(int id) override;
79 bool OnListEnd(int id) override;
80 bool OnUInt(int id, int64 val) override;
81 bool OnFloat(int id, double val) override;
82 bool OnBinary(int id, const uint8* data, int size) override;
83 bool OnString(int id, const std::string& str) override;
85 int64 track_type_;
86 int64 track_num_;
87 std::string track_name_;
88 std::string track_language_;
89 std::string codec_id_;
90 std::vector<uint8> codec_private_;
91 int64 seek_preroll_;
92 int64 codec_delay_;
93 int64 default_duration_;
94 scoped_ptr<WebMContentEncodingsClient> track_content_encodings_client_;
96 int64 audio_track_num_;
97 int64 audio_default_duration_;
98 int64 video_track_num_;
99 int64 video_default_duration_;
100 bool ignore_text_tracks_;
101 TextTracks text_tracks_;
102 std::set<int64> ignored_tracks_;
103 std::string audio_encryption_key_id_;
104 std::string video_encryption_key_id_;
105 LogCB log_cb_;
107 WebMAudioClient audio_client_;
108 AudioDecoderConfig audio_decoder_config_;
110 WebMVideoClient video_client_;
111 VideoDecoderConfig video_decoder_config_;
113 DISALLOW_COPY_AND_ASSIGN(WebMTracksParser);
116 } // namespace media
118 #endif // MEDIA_FORMATS_WEBM_WEBM_TRACKS_PARSER_H_