DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs Enumerator
mkv_writer.h
1 // Copyright 2015 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_FORMATS_WEBM_MKV_WRITER_H_
8 #define MEDIA_FORMATS_WEBM_MKV_WRITER_H_
9 
10 #include <string>
11 
12 #include "packager/base/memory/scoped_ptr.h"
13 #include "packager/media/base/status.h"
14 #include "packager/media/file/file_closer.h"
15 #include "packager/third_party/libwebm/src/mkvmuxer.hpp"
16 
17 namespace edash_packager {
18 namespace media {
19 
21 class MkvWriter : public mkvmuxer::IMkvWriter {
22  public:
23  MkvWriter();
24  ~MkvWriter() override;
25 
30  Status Open(const std::string& name);
31 
34  mkvmuxer::int32 Write(const void* buf, mkvmuxer::uint32 len) override;
37  mkvmuxer::int64 Position() const override;
40  mkvmuxer::int32 Position(mkvmuxer::int64 position) override;
42  bool Seekable() const override;
48  void ElementStartNotify(mkvmuxer::uint64 element_id,
49  mkvmuxer::int64 position) override;
50 
53  int64_t WriteFromFile(File* source);
57  int64_t WriteFromFile(File* source, uint64_t max_copy);
58 
59  File* file() { return file_.get(); }
60 
61  private:
62  scoped_ptr<File, FileCloser> file_;
63  // Keep track of the position and whether we can seek.
64  mkvmuxer::int64 position_;
65  bool seekable_;
66 
67  DISALLOW_COPY_AND_ASSIGN(MkvWriter);
68 };
69 
70 } // namespace media
71 } // namespace edash_packager
72 
73 #endif // MEDIA_FORMATS_WEBM_MKV_WRITER_H_
An implementation of IMkvWriter using our File type.
Definition: mkv_writer.h:21
mkvmuxer::int64 Position() const override
Definition: mkv_writer.cc:63
Define an abstract file interface.
Definition: file.h:23
int64_t WriteFromFile(File *source)
Definition: mkv_writer.cc:48
bool Seekable() const override
Definition: mkv_writer.cc:78
Status Open(const std::string &name)
Definition: mkv_writer.cc:16
mkvmuxer::int32 Write(const void *buf, mkvmuxer::uint32 len) override
Definition: mkv_writer.cc:29
void ElementStartNotify(mkvmuxer::uint64 element_id, mkvmuxer::int64 position) override
Definition: mkv_writer.cc:82