Shaka Packager SDK
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 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 "packager/file/file_closer.h"
14 #include "packager/status.h"
15 #include "packager/third_party/libwebm/src/mkvmuxer.hpp"
16 
17 namespace shaka {
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);
32  Status Close();
33 
36  mkvmuxer::int32 Write(const void* buf, mkvmuxer::uint32 len) override;
39  mkvmuxer::int64 Position() const override;
42  mkvmuxer::int32 Position(mkvmuxer::int64 position) override;
44  bool Seekable() const override;
50  void ElementStartNotify(mkvmuxer::uint64 element_id,
51  mkvmuxer::int64 position) override;
52 
55  int64_t WriteFromFile(File* source);
59  int64_t WriteFromFile(File* source, int64_t max_copy);
60 
61  File* file() { return file_.get(); }
62 
63  private:
64  std::unique_ptr<File, FileCloser> file_;
65  // Keep track of the position and whether we can seek.
66  mkvmuxer::int64 position_;
67  bool seekable_;
68 
69  DISALLOW_COPY_AND_ASSIGN(MkvWriter);
70 };
71 
72 } // namespace media
73 } // namespace shaka
74 
75 #endif // PACKAGER_MEDIA_FORMATS_WEBM_MKV_WRITER_H_
shaka::media::MkvWriter::ElementStartNotify
void ElementStartNotify(mkvmuxer::uint64 element_id, mkvmuxer::int64 position) override
Definition: mkv_writer.cc:93
shaka::media::MkvWriter::Open
Status Open(const std::string &name)
Definition: mkv_writer.cc:16
shaka
All the methods that are virtual are virtual for mocking.
Definition: gflags_hex_bytes.cc:11
shaka::media::MkvWriter::Write
mkvmuxer::int32 Write(const void *buf, mkvmuxer::uint32 len) override
Definition: mkv_writer.cc:40
shaka::Status
Definition: status.h:110
shaka::media::MkvWriter::Position
mkvmuxer::int64 Position() const override
Definition: mkv_writer.cc:74
shaka::media::MkvWriter::Close
Status Close()
Closes the file. MUST call Open before calling any other methods.
Definition: mkv_writer.cc:29
shaka::File
Define an abstract file interface.
Definition: file.h:28
shaka::media::MkvWriter::WriteFromFile
int64_t WriteFromFile(File *source)
Definition: mkv_writer.cc:59
shaka::media::MkvWriter::Seekable
bool Seekable() const override
Definition: mkv_writer.cc:89
shaka::media::MkvWriter
An implementation of IMkvWriter using our File type.
Definition: mkv_writer.h:21