Shaka Packager SDK
mkv_writer.h
1 // Copyright 2015 Google LLC. 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 PACKAGER_MEDIA_FORMATS_WEBM_MKV_WRITER_H_
8 #define PACKAGER_MEDIA_FORMATS_WEBM_MKV_WRITER_H_
9 
10 #include <memory>
11 #include <string>
12 
13 #include <mkvmuxer/mkvmuxer.h>
14 
15 #include <packager/file/file_closer.h>
16 #include <packager/macros/classes.h>
17 #include <packager/status.h>
18 
19 namespace shaka {
20 namespace media {
21 
23 class MkvWriter : public mkvmuxer::IMkvWriter {
24  public:
25  MkvWriter();
26  ~MkvWriter() override;
27 
32  Status Open(const std::string& name);
34  Status Close();
35 
38  mkvmuxer::int32 Write(const void* buf, mkvmuxer::uint32 len) override;
41  mkvmuxer::int64 Position() const override;
44  mkvmuxer::int32 Position(mkvmuxer::int64 position) override;
46  bool Seekable() const override;
52  void ElementStartNotify(mkvmuxer::uint64 element_id,
53  mkvmuxer::int64 position) override;
54 
57  int64_t WriteFromFile(File* source);
61  int64_t WriteFromFile(File* source, int64_t max_copy);
62 
63  File* file() { return file_.get(); }
64 
65  private:
66  std::unique_ptr<File, FileCloser> file_;
67  // Keep track of the position and whether we can seek.
68  mkvmuxer::int64 position_;
69  bool seekable_;
70 
71  DISALLOW_COPY_AND_ASSIGN(MkvWriter);
72 };
73 
74 } // namespace media
75 } // namespace shaka
76 
77 #endif // PACKAGER_MEDIA_FORMATS_WEBM_MKV_WRITER_H_
An implementation of IMkvWriter using our File type.
Definition: mkv_writer.h:23
mkvmuxer::int32 Write(const void *buf, mkvmuxer::uint32 len) override
Definition: mkv_writer.cc:42
mkvmuxer::int64 Position() const override
Definition: mkv_writer.cc:76
void ElementStartNotify(mkvmuxer::uint64 element_id, mkvmuxer::int64 position) override
Definition: mkv_writer.cc:95
bool Seekable() const override
Definition: mkv_writer.cc:91
Status Open(const std::string &name)
Definition: mkv_writer.cc:18
int64_t WriteFromFile(File *source)
Definition: mkv_writer.cc:61
Status Close()
Closes the file. MUST call Open before calling any other methods.
Definition: mkv_writer.cc:31
All the methods that are virtual are virtual for mocking.
Definition: crypto_flags.cc:66