VirtualBox

source: vbox/trunk/src/VBox/Main/include/EBMLWriter.h@ 98964

Last change on this file since 98964 was 98103, checked in by vboxsync, 2 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
  • Property svn:mergeinfo set to (toggle deleted branches)
    /branches/VBox-3.0/src/VBox/Frontends/VBoxHeadless/VideoCapture/EbmlWriter.h58652,​70973
    /branches/VBox-3.2/src/VBox/Frontends/VBoxHeadless/VideoCapture/EbmlWriter.h66309,​66318
    /branches/VBox-4.0/src/VBox/Frontends/VBoxHeadless/VideoCapture/EbmlWriter.h70873
    /branches/VBox-4.1/src/VBox/Frontends/VBoxHeadless/VideoCapture/EbmlWriter.h74233
    /branches/VBox-4.2/src/VBox/Main/src-client/EbmlWriter.h91503-91504,​91506-91508,​91510,​91514-91515,​91521
    /branches/VBox-4.3/src/VBox/Main/src-client/EbmlWriter.h91223
    /branches/VBox-4.3/trunk/src/VBox/Main/src-client/EbmlWriter.h91223
    /branches/dsen/gui/src/VBox/Frontends/VBoxHeadless/VideoCapture/EbmlWriter.h79076-79078,​79089,​79109-79110,​79112-79113,​79127-79130,​79134,​79141,​79151,​79155,​79157-79159,​79193,​79197
    /branches/dsen/gui2/src/VBox/Frontends/VBoxHeadless/VideoCapture/EbmlWriter.h79224,​79228,​79233,​79235,​79258,​79262-79263,​79273,​79341,​79345,​79354,​79357,​79387-79388,​79559-79569,​79572-79573,​79578,​79581-79582,​79590-79591,​79598-79599,​79602-79603,​79605-79606,​79632,​79635,​79637,​79644
    /branches/dsen/gui3/src/VBox/Frontends/VBoxHeadless/VideoCapture/EbmlWriter.h79645-79692
File size: 3.4 KB
Line 
1/* $Id: EBMLWriter.h 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * EBMLWriter.h - EBML writer.
4 */
5
6/*
7 * Copyright (C) 2013-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef MAIN_INCLUDED_EBMLWriter_h
29#define MAIN_INCLUDED_EBMLWriter_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34#include <stack>
35
36#include <iprt/critsect.h>
37#include <iprt/file.h>
38
39#include <VBox/com/string.h>
40
41
42/** No flags set. */
43#define VBOX_EBMLWRITER_FLAG_NONE 0
44/** The file handle was inherited. */
45#define VBOX_EBMLWRITER_FLAG_HANDLE_INHERITED RT_BIT(0)
46
47class EBMLWriter
48{
49public:
50 typedef uint32_t EbmlClassId;
51
52private:
53
54 struct EbmlSubElement
55 {
56 uint64_t offset;
57 EbmlClassId classId;
58 EbmlSubElement(uint64_t offs, EbmlClassId cid) : offset(offs), classId(cid) {}
59 };
60
61 /** Stack of EBML sub elements. */
62 std::stack<EbmlSubElement> m_Elements;
63 /** The file's handle. */
64 RTFILE m_hFile;
65 /** The file's name (path). */
66 com::Utf8Str m_strFile;
67 /** Flags. */
68 uint32_t m_fFlags;
69
70public:
71
72 EBMLWriter(void)
73 : m_hFile(NIL_RTFILE)
74 , m_fFlags(VBOX_EBMLWRITER_FLAG_NONE) { }
75
76 virtual ~EBMLWriter(void) { close(); }
77
78public:
79
80 int createEx(const char *a_pszFile, PRTFILE phFile);
81
82 int create(const char *a_pszFile, uint64_t fOpen);
83
84 void close(void);
85
86 /** Returns the file name. */
87 const com::Utf8Str& getFileName(void) { return m_strFile; }
88
89 /** Returns file size. */
90 uint64_t getFileSize(void) { return RTFileTell(m_hFile); }
91
92 /** Get reference to file descriptor */
93 inline const RTFILE &getFile(void) { return m_hFile; }
94
95 /** Returns available space on storage. */
96 uint64_t getAvailableSpace(void);
97
98 /**
99 * Returns whether the file is open or not.
100 *
101 * @returns True if open, false if not.
102 */
103 bool isOpen(void) { return RTFileIsValid(m_hFile); }
104
105public:
106
107 EBMLWriter &subStart(EbmlClassId classId);
108
109 EBMLWriter &subEnd(EbmlClassId classId);
110
111 EBMLWriter &serializeString(EbmlClassId classId, const char *str);
112
113 EBMLWriter &serializeUnsignedInteger(EbmlClassId classId, uint64_t parm, size_t size = 0);
114
115 EBMLWriter &serializeFloat(EbmlClassId classId, float value);
116
117 EBMLWriter &serializeData(EbmlClassId classId, const void *pvData, size_t cbData);
118
119 int write(const void *data, size_t size);
120
121 void writeUnsignedInteger(uint64_t value, size_t size = sizeof(uint64_t));
122
123 void writeClassId(EbmlClassId parm);
124
125 void writeSize(uint64_t parm);
126
127 static inline size_t getSizeOfUInt(uint64_t arg);
128
129private:
130
131 void operator=(const EBMLWriter &);
132};
133
134#endif /* !MAIN_INCLUDED_EBMLWriter_h */
135
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette