1// Copyright (c) 2012 The WebM project authors. All Rights Reserved.
2//
3// Use of this source code is governed by a BSD-style license
4// that can be found in the LICENSE file in the root of the source
5// tree. An additional intellectual property rights grant can be found
6// in the file PATENTS.  All contributing project authors may
7// be found in the AUTHORS file in the root of the source tree.
8
9#ifndef MKVWRITER_HPP
10#define MKVWRITER_HPP
11
12#include <stdio.h>
13
14#include "mkvmuxer.hpp"
15#include "mkvmuxertypes.hpp"
16
17namespace mkvmuxer {
18
19// Default implementation of the IMkvWriter interface on Windows.
20class MkvWriter : public IMkvWriter {
21 public:
22  MkvWriter();
23  MkvWriter(FILE* fp);
24  virtual ~MkvWriter();
25
26  // IMkvWriter interface
27  virtual int64 Position() const;
28  virtual int32 Position(int64 position);
29  virtual bool Seekable() const;
30  virtual int32 Write(const void* buffer, uint32 length);
31  virtual void ElementStartNotify(uint64 element_id, int64 position);
32
33  // Creates and opens a file for writing. |filename| is the name of the file
34  // to open. This function will overwrite the contents of |filename|. Returns
35  // true on success.
36  bool Open(const char* filename);
37
38  // Closes an opened file.
39  void Close();
40
41 private:
42  // File handle to output file.
43  FILE* file_;
44  bool writer_owns_file_;
45
46  LIBWEBM_DISALLOW_COPY_AND_ASSIGN(MkvWriter);
47};
48
49}  //end namespace mkvmuxer
50
51#endif // MKVWRITER_HPP
52