Shaka Packager SDK
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 PACKAGER_MEDIA_FORMATS_MP2T_ES_PARSER_H_
6 #define PACKAGER_MEDIA_FORMATS_MP2T_ES_PARSER_H_
7 
8 #include <stdint.h>
9 
10 #include "packager/base/callback.h"
11 
12 namespace shaka {
13 namespace media {
14 
15 class MediaSample;
16 class StreamInfo;
17 class TextSample;
18 
19 namespace mp2t {
20 
21 class EsParser {
22  public:
23  typedef base::Callback<void(std::shared_ptr<StreamInfo>)> NewStreamInfoCB;
24  typedef base::Callback<void(std::shared_ptr<MediaSample>)> EmitSampleCB;
25  typedef base::Callback<void(std::shared_ptr<TextSample>)> EmitTextSampleCB;
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 bool 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 shaka
52 
53 #endif
All the methods that are virtual are virtual for mocking.