DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs Enumerator
es_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_MP2T_ES_PARSER_H_
6 #define MEDIA_FORMATS_MP2T_ES_PARSER_H_
7 
8 #include <stdint.h>
9 
10 #include "packager/base/callback.h"
11 #include "packager/base/memory/ref_counted.h"
12 
13 namespace edash_packager {
14 namespace media {
15 
16 class MediaSample;
17 class StreamInfo;
18 
19 namespace mp2t {
20 
21 class EsParser {
22  public:
23  typedef base::Callback<void(const scoped_refptr<StreamInfo>&)>
24  NewStreamInfoCB;
25  typedef base::Callback<void(uint32_t, const scoped_refptr<MediaSample>&)>
26  EmitSampleCB;
27 
28  EsParser(uint32_t pid) : pid_(pid) {}
29  virtual ~EsParser() {}
30 
31  // ES parsing.
32  // Should use kNoTimestamp when a timestamp is not valid.
33  virtual bool Parse(const uint8_t* buf,
34  int size,
35  int64_t pts,
36  int64_t dts) = 0;
37 
38  // Flush any pending buffer.
39  virtual void Flush() = 0;
40 
41  // Reset the state of the ES parser.
42  virtual void Reset() = 0;
43 
44  uint32_t pid() { return pid_; }
45 
46  private:
47  uint32_t pid_;
48 };
49 
50 } // namespace mp2t
51 } // namespace media
52 } // namespace edash_packager
53 
54 #endif