1 // Copyright (c) 2012 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_WEBM_WEBM_TRACKS_PARSER_H_
6 #define MEDIA_WEBM_WEBM_TRACKS_PARSER_H_
12 #include "base/compiler_specific.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "media/base/audio_decoder_config.h"
15 #include "media/base/media_log.h"
16 #include "media/base/video_decoder_config.h"
17 #include "media/webm/webm_audio_client.h"
18 #include "media/webm/webm_content_encodings_client.h"
19 #include "media/webm/webm_parser.h"
20 #include "media/webm/webm_video_client.h"
24 // Parser for WebM Tracks element.
25 class WebMTracksParser
: public WebMParserClient
{
27 explicit WebMTracksParser(const LogCB
& log_cb
);
28 virtual ~WebMTracksParser();
30 // Parses a WebM Tracks element in |buf|.
32 // Returns -1 if the parse fails.
33 // Returns 0 if more data is needed.
34 // Returns the number of bytes parsed on success.
35 int Parse(const uint8
* buf
, int size
);
37 int64
audio_track_num() const { return audio_track_num_
; }
38 int64
video_track_num() const { return video_track_num_
; }
39 const std::set
<int64
>& ignored_tracks() const { return ignored_tracks_
; }
41 const std::string
& audio_encryption_key_id() const {
42 return audio_encryption_key_id_
;
45 const AudioDecoderConfig
& audio_decoder_config() {
46 return audio_decoder_config_
;
49 const std::string
& video_encryption_key_id() const {
50 return video_encryption_key_id_
;
53 const VideoDecoderConfig
& video_decoder_config() {
54 return video_decoder_config_
;
57 const std::set
<int>& text_tracks() const {
62 // WebMParserClient implementation.
63 virtual WebMParserClient
* OnListStart(int id
) OVERRIDE
;
64 virtual bool OnListEnd(int id
) OVERRIDE
;
65 virtual bool OnUInt(int id
, int64 val
) OVERRIDE
;
66 virtual bool OnFloat(int id
, double val
) OVERRIDE
;
67 virtual bool OnBinary(int id
, const uint8
* data
, int size
) OVERRIDE
;
68 virtual bool OnString(int id
, const std::string
& str
) OVERRIDE
;
72 std::string codec_id_
;
73 std::vector
<uint8
> codec_private_
;
74 scoped_ptr
<WebMContentEncodingsClient
> track_content_encodings_client_
;
76 int64 audio_track_num_
;
77 int64 video_track_num_
;
78 std::set
<int> text_tracks_
;
79 std::set
<int64
> ignored_tracks_
;
80 std::string audio_encryption_key_id_
;
81 std::string video_encryption_key_id_
;
84 WebMAudioClient audio_client_
;
85 AudioDecoderConfig audio_decoder_config_
;
87 WebMVideoClient video_client_
;
88 VideoDecoderConfig video_decoder_config_
;
90 DISALLOW_COPY_AND_ASSIGN(WebMTracksParser
);
95 #endif // MEDIA_WEBM_WEBM_TRACKS_PARSER_H_