DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs Enumerator
demuxer.h
1 // Copyright 2014 Google Inc. All rights reserved.
2 //
3 // Use of this source code is governed by a BSD-style
4 // license that can be found in the LICENSE file or at
5 // https://developers.google.com/open-source/licenses/bsd
6 
7 #ifndef MEDIA_BASE_DEMUXER_H_
8 #define MEDIA_BASE_DEMUXER_H_
9 
10 #include <vector>
11 
12 #include "packager/base/memory/ref_counted.h"
13 #include "packager/base/memory/scoped_ptr.h"
14 #include "packager/media/base/container_names.h"
15 #include "packager/media/base/status.h"
16 
17 namespace edash_packager {
18 namespace media {
19 
20 class Decryptor;
21 class File;
22 class KeySource;
23 class MediaParser;
24 class MediaSample;
25 class MediaStream;
26 class StreamInfo;
27 
30 class Demuxer {
31  public:
35  explicit Demuxer(const std::string& file_name);
36  ~Demuxer();
37 
42  void SetKeySource(scoped_ptr<KeySource> key_source);
43 
50 
53  Status Run();
54 
56  Status Parse();
57 
60  void Cancel();
61 
66  const std::vector<MediaStream*>& streams() { return streams_; }
67 
70  MediaContainerName container_name() { return container_name_; }
71 
72  private:
73  // Parser event handlers.
74  void ParserInitEvent(const std::vector<scoped_refptr<StreamInfo> >& streams);
75  bool NewSampleEvent(uint32_t track_id,
76  const scoped_refptr<MediaSample>& sample);
77 
78  std::string file_name_;
79  File* media_file_;
80  bool init_event_received_;
81  Status init_parsing_status_;
82  scoped_ptr<MediaParser> parser_;
83  std::vector<MediaStream*> streams_;
84  MediaContainerName container_name_;
85  scoped_ptr<uint8_t[]> buffer_;
86  scoped_ptr<KeySource> key_source_;
87  bool cancelled_;
88 
89  DISALLOW_COPY_AND_ASSIGN(Demuxer);
90 };
91 
92 } // namespace media
93 } // namespace edash_packager
94 
95 #endif // MEDIA_BASE_DEMUXER_H_
MediaContainerName container_name()
Definition: demuxer.h:70
void SetKeySource(scoped_ptr< KeySource > key_source)
Definition: demuxer.cc:47
Define an abstract file interface.
Definition: file.h:22
const std::vector< MediaStream * > & streams()
Definition: demuxer.h:66
Status Parse()
Read from the source and send it to the parser.
Definition: demuxer.cc:170
Demuxer(const std::string &file_name)
Definition: demuxer.cc:32