summaryrefslogtreecommitdiffstats
path: root/media/webm/webm_tracks_parser.h
blob: fe46c25a451982be9b256c812ab91a8b9cb03ac9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef MEDIA_WEBM_WEBM_TRACKS_PARSER_H_
#define MEDIA_WEBM_WEBM_TRACKS_PARSER_H_

#include "base/compiler_specific.h"
#include "base/time.h"
#include "media/webm/webm_parser.h"

namespace media {

// Parser for WebM Tracks element.
class WebMTracksParser : public WebMParserClient {
 public:
  WebMTracksParser(int64 timecode_scale);
  virtual ~WebMTracksParser();

  // Parses a WebM Tracks element in |buf|.
  //
  // Returns -1 if the parse fails.
  // Returns 0 if more data is needed.
  // Returns the number of bytes parsed on success.
  int Parse(const uint8* buf, int size);

  int64 audio_track_num() const { return audio_track_num_; }
  base::TimeDelta audio_default_duration() const {
    return audio_default_duration_;
  }

  int64 video_track_num() const { return video_track_num_; }
  base::TimeDelta video_default_duration() const {
    return video_default_duration_;
  }

 private:
  // WebMParserClient methods
  virtual WebMParserClient* OnListStart(int id) OVERRIDE;
  virtual bool OnListEnd(int id) OVERRIDE;
  virtual bool OnUInt(int id, int64 val) OVERRIDE;
  virtual bool OnBinary(int id, const uint8* data, int size) OVERRIDE;
  virtual bool OnString(int id, const std::string& str) OVERRIDE;

  int64 timecode_scale_;

  int64 track_type_;
  int64 track_num_;
  int64 track_default_duration_;
  int64 audio_track_num_;
  base::TimeDelta audio_default_duration_;
  int64 video_track_num_;
  base::TimeDelta video_default_duration_;

  DISALLOW_IMPLICIT_CONSTRUCTORS(WebMTracksParser);
};

}  // namespace media

#endif  // MEDIA_WEBM_WEBM_TRACKS_PARSER_H_