Shaka Packager SDK
Loading...
Searching...
No Matches
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 <cstdint>
11#include <memory>
12#include <string>
13
14#include <mkvmuxer/mkvmuxer.h>
15#include <mkvmuxer/mkvmuxertypes.h>
16
17#include <packager/file.h>
18#include <packager/file/file_closer.h>
19#include <packager/macros/classes.h>
20#include <packager/status.h>
21
22namespace shaka {
23namespace media {
24
26class MkvWriter : public mkvmuxer::IMkvWriter {
27 public:
28 MkvWriter();
29 ~MkvWriter() override;
30
35 Status Open(const std::string& name);
37 Status Close();
38
41 mkvmuxer::int32 Write(const void* buf, mkvmuxer::uint32 len) override;
44 mkvmuxer::int64 Position() const override;
47 mkvmuxer::int32 Position(mkvmuxer::int64 position) override;
49 bool Seekable() const override;
55 void ElementStartNotify(mkvmuxer::uint64 element_id,
56 mkvmuxer::int64 position) override;
57
60 int64_t WriteFromFile(File* source);
64 int64_t WriteFromFile(File* source, int64_t max_copy);
65
66 File* file() { return file_.get(); }
67
68 private:
69 std::unique_ptr<File, FileCloser> file_;
70 // Keep track of the position and whether we can seek.
71 mkvmuxer::int64 position_;
72 bool seekable_;
73
74 DISALLOW_COPY_AND_ASSIGN(MkvWriter);
75};
76
77} // namespace media
78} // namespace shaka
79
80#endif // PACKAGER_MEDIA_FORMATS_WEBM_MKV_WRITER_H_
An implementation of IMkvWriter using our File type.
Definition mkv_writer.h:26
mkvmuxer::int32 Write(const void *buf, mkvmuxer::uint32 len) override
Definition mkv_writer.cc:49
mkvmuxer::int64 Position() const override
Definition mkv_writer.cc:83
void ElementStartNotify(mkvmuxer::uint64 element_id, mkvmuxer::int64 position) override
bool Seekable() const override
Definition mkv_writer.cc:98
Status Open(const std::string &name)
Definition mkv_writer.cc:25
int64_t WriteFromFile(File *source)
Definition mkv_writer.cc:68
Status Close()
Closes the file. MUST call Open before calling any other methods.
Definition mkv_writer.cc:38
All the methods that are virtual are virtual for mocking.