OpenShot Library | libopenshot-audio  0.1.9
juce_GZIPCompressorOutputStream.h
1 
2 /** @weakgroup juce_core-zip
3  * @{
4  */
5 /*
6  ==============================================================================
7 
8  This file is part of the JUCE library.
9  Copyright (c) 2017 - ROLI Ltd.
10 
11  JUCE is an open source library subject to commercial or open-source
12  licensing.
13 
14  The code included in this file is provided under the terms of the ISC license
15  http://www.isc.org/downloads/software-support-policy/isc-license. Permission
16  To use, copy, modify, and/or distribute this software for any purpose with or
17  without fee is hereby granted provided that the above copyright notice and
18  this permission notice appear in all copies.
19 
20  JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
21  EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
22  DISCLAIMED.
23 
24  ==============================================================================
25 */
26 
27 namespace juce
28 {
29 
30 //==============================================================================
31 /**
32  A stream which uses zlib to compress the data written into it.
33 
34  Important note: When you call flush() on a GZIPCompressorOutputStream,
35  the gzip data is closed - this means that no more data can be written to
36  it, and any subsequent attempts to call write() will cause an assertion.
37 
38  @see GZIPDecompressorInputStream
39 
40  @tags{Core}
41 */
43 {
44 public:
45  //==============================================================================
46  /** Creates a compression stream.
47  @param destStream the stream into which the compressed data will be written
48  @param compressionLevel how much to compress the data, between 0 and 9, where
49  0 is non-compressed storage, 1 is the fastest/lowest compression,
50  and 9 is the slowest/highest compression. Any value outside this range
51  indicates that a default compression level should be used.
52  @param windowBits this is used internally to change the window size used
53  by zlib - leave it as 0 unless you specifically need to set
54  its value for some reason
55  */
57  int compressionLevel = -1,
58  int windowBits = 0);
59 
60  /** Creates a compression stream.
61  @param destStream the stream into which the compressed data will be written.
62  Ownership of this object depends on the value of deleteDestStreamWhenDestroyed
63  @param compressionLevel how much to compress the data, between 0 and 9, where
64  0 is non-compressed storage, 1 is the fastest/lowest compression,
65  and 9 is the slowest/highest compression. Any value outside this range
66  indicates that a default compression level should be used.
67  @param deleteDestStreamWhenDestroyed whether or not the GZIPCompressorOutputStream will delete the
68  destStream object when it is destroyed
69  @param windowBits this is used internally to change the window size used
70  by zlib - leave it as 0 unless you specifically need to set
71  its value for some reason
72  */
74  int compressionLevel = -1,
75  bool deleteDestStreamWhenDestroyed = false,
76  int windowBits = 0);
77 
78  /** Destructor. */
79  ~GZIPCompressorOutputStream() override;
80 
81  //==============================================================================
82  /** Flushes and closes the stream.
83  Note that unlike most streams, when you call flush() on a GZIPCompressorOutputStream,
84  the stream is closed - this means that no more data can be written to it, and any
85  subsequent attempts to call write() will cause an assertion.
86  */
87  void flush() override;
88 
89  int64 getPosition() override;
90  bool setPosition (int64) override;
91  bool write (const void*, size_t) override;
92 
93  /** These are preset values that can be used for the constructor's windowBits parameter.
94  For more info about this, see the zlib documentation for its windowBits parameter.
95  */
97  {
98  windowBitsRaw = -15,
99  windowBitsGZIP = 15 + 16
100  };
101 
102 private:
103  //==============================================================================
105 
106  class GZIPCompressorHelper;
107  std::unique_ptr<GZIPCompressorHelper> helper;
108 
109  JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (GZIPCompressorOutputStream)
110 };
111 
112 } // namespace juce
113 
114 /** @}*/
#define JUCE_API
This macro is added to all JUCE public class declarations.
A stream which uses zlib to compress the data written into it.
Holds a pointer to an object which can optionally be deleted when this pointer goes out of scope...
The base class for streams that write data to some kind of destination.
WindowBitsValues
These are preset values that can be used for the constructor&#39;s windowBits parameter.