OpenShot Library | libopenshot-audio  0.2.0
juce_SubregionStream.h
1 
2 /** @weakgroup juce_core-streams
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 /** Wraps another input stream, and reads from a specific part of it.
32 
33  This lets you take a subsection of a stream and present it as an entire
34  stream in its own right.
35 
36  @tags{Core}
37 */
39 {
40 public:
41  //==============================================================================
42  /** Creates a SubregionStream from an input source.
43 
44  @param sourceStream the source stream to read from
45  @param startPositionInSourceStream this is the position in the source stream that
46  corresponds to position 0 in this stream
47  @param lengthOfSourceStream this specifies the maximum number of bytes
48  from the source stream that will be passed through
49  by this stream. When the position of this stream
50  exceeds lengthOfSourceStream, it will cause an end-of-stream.
51  If the length passed in here is greater than the length
52  of the source stream (as returned by getTotalLength()),
53  then the smaller value will be used.
54  Passing a negative value for this parameter means it
55  will keep reading until the source's end-of-stream.
56  @param deleteSourceWhenDestroyed whether the sourceStream that is passed in should be
57  deleted by this object when it is itself deleted.
58  */
59  SubregionStream (InputStream* sourceStream,
60  int64 startPositionInSourceStream,
61  int64 lengthOfSourceStream,
62  bool deleteSourceWhenDestroyed);
63 
64  /** Destructor.
65 
66  This may also delete the source stream, if that option was chosen when the
67  buffered stream was created.
68  */
69  ~SubregionStream() override;
70 
71 
72  //==============================================================================
73  int64 getTotalLength() override;
74  int64 getPosition() override;
75  bool setPosition (int64 newPosition) override;
76  int read (void* destBuffer, int maxBytesToRead) override;
77  bool isExhausted() override;
78 
79 private:
80  //==============================================================================
82  const int64 startPositionInSourceStream, lengthOfSourceStream;
83 
84  JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SubregionStream)
85 };
86 
87 } // namespace juce
88 
89 /** @}*/
juce::InputStream
The base class for streams that read data.
Definition: juce_InputStream.h:40
JUCE_API
#define JUCE_API
This macro is added to all JUCE public class declarations.
Definition: juce_StandardHeader.h:143
juce::OptionalScopedPointer
Holds a pointer to an object which can optionally be deleted when this pointer goes out of scope.
Definition: juce_OptionalScopedPointer.h:43
juce::SubregionStream
Wraps another input stream, and reads from a specific part of it.
Definition: juce_SubregionStream.h:38