DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs
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(scoped_refptr<StreamInfo>&)> NewStreamInfoCB;
24  typedef base::Callback<void(uint32_t, scoped_refptr<MediaSample>&)>
25  EmitSampleCB;
26 
27  EsParser(uint32_t pid) : pid_(pid) {}
28  virtual ~EsParser() {}
29 
30  // ES parsing.
31  // Should use kNoTimestamp when a timestamp is not valid.
32  virtual bool Parse(const uint8_t* buf,
33  int size,
34  int64_t pts,
35  int64_t dts) = 0;
36 
37  // Flush any pending buffer.
38  virtual void Flush() = 0;
39 
40  // Reset the state of the ES parser.
41  virtual void Reset() = 0;
42 
43  uint32_t pid() { return pid_; }
44 
45  private:
46  uint32_t pid_;
47 };
48 
49 } // namespace mp2t
50 } // namespace media
51 } // namespace edash_packager
52 
53 #endif