Skip to content
This repository was archived by the owner on Jan 11, 2022. It is now read-only.

Commit e7beb72

Browse files
authored
Merge pull request #5 from TechSmith/AllowForStructuredStorageStreams
Allow for structured storage streams
2 parents 9967bb4 + 408c0be commit e7beb72

24 files changed

+283
-73
lines changed

avi20.autopkg

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ nuget
1010
nuspec
1111
{
1212
id = avi20;
13-
version: 1.3.0.0;
13+
version: 1.4.0;
1414
title: AVI20 Library;
1515
authors: { TechSmith Corporation };
1616
owners: { TechSmith Corporation };
@@ -20,7 +20,10 @@ nuget
2020
requireLicenseAcceptance: false;
2121
summary: AVI20 Library;
2222
releaseNotes: "Updated to Visual Studio 2017";
23-
description: @"Library for reading and writing AVI 2.0 files (which supports files larger than 4GB) ";
23+
description: @"Library for reading and writing AVI 2.0 files (which supports files larger than 4GB)";
24+
releaseNotes: "
25+
1.4.0.0 Allow for either std::istream or Windows-specific IStream implementations of file streams
26+
1.3.0.0 Updated to Visual Studio 2017";
2427
copyright: "Copyright (c) 2015-2018 TechSmith Corporation. All rights reserved.";
2528
tags: { native, tsc, vs2017, cpp, nomfc, techsmith, cross-platform };
2629
};

avi20.vcxproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,15 @@
157157
<ClInclude Include="include\AVI20\Read\ChunkHeader.h" />
158158
<ClInclude Include="include\AVI20\Read\FillAVIIndexInfo.h" />
159159
<ClInclude Include="include\AVI20\Read\FrameIndex.h" />
160+
<ClInclude Include="include\AVI20\Read\IStream.h" />
160161
<ClInclude Include="include\AVI20\Read\MediaStreamInfo.h" />
161162
<ClInclude Include="include\AVI20\Read\MediaStreamReader.h" />
162163
<ClInclude Include="include\AVI20\Read\MediaStreamReaderImpl.h" />
163164
<ClInclude Include="include\AVI20\Read\ParserBase.h" />
164165
<ClInclude Include="include\AVI20\Read\Reader.h" />
165166
<ClInclude Include="include\AVI20\Read\Stream.h" />
166167
<ClInclude Include="include\AVI20\Read\StreamPosRestorer.h" />
168+
<ClInclude Include="include\AVI20\Read\WindowsStream.h" />
167169
<ClInclude Include="include\AVI20\Tools\Tools.h" />
168170
<ClInclude Include="include\AVI20\Utl.h" />
169171
<ClInclude Include="include\AVI20\WaveFormatEx.h" />
@@ -188,6 +190,7 @@
188190
<ClCompile Include="src\Read\Reader.cpp" />
189191
<ClCompile Include="src\Read\Stream.cpp" />
190192
<ClCompile Include="src\Read\StreamPosRestorer.cpp" />
193+
<ClCompile Include="src\Read\WindowsStream.cpp" />
191194
<ClCompile Include="src\Tools\Tools.cpp" />
192195
<ClCompile Include="src\Utl.cpp" />
193196
<ClCompile Include="src\WaveFormatEx.cpp" />

avi20.vcxproj.filters

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@
9393
<ClInclude Include="include\AVI20\Write\Writer.h">
9494
<Filter>Header Files</Filter>
9595
</ClInclude>
96+
<ClInclude Include="include\AVI20\Read\IStream.h">
97+
<Filter>Header Files</Filter>
98+
</ClInclude>
99+
<ClInclude Include="include\AVI20\Read\WindowsStream.h">
100+
<Filter>Header Files</Filter>
101+
</ClInclude>
96102
</ItemGroup>
97103
<ItemGroup>
98104
<ClCompile Include="src\Buffer.cpp">
@@ -158,5 +164,8 @@
158164
<ClCompile Include="src\Write\Writer.cpp">
159165
<Filter>Source Files</Filter>
160166
</ClCompile>
167+
<ClCompile Include="src\Read\WindowsStream.cpp">
168+
<Filter>Source Files</Filter>
169+
</ClCompile>
161170
</ItemGroup>
162171
</Project>

include/AVI20/Read/ChunkHeader.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
NAMESPACE_AVI20_READ_BEGIN
99

10-
class Stream;
10+
class IStream;
1111

1212
struct ChunkHeader
1313
{
@@ -25,7 +25,7 @@ struct ChunkHeader
2525
bool IsValid() const { return fcc != 0; }
2626

2727
static bool IsList( uint32_t fcc ) { return fcc == FCC('RIFF') || fcc == FCC('LIST'); }
28-
static ChunkHeader Read( Stream& stream );
28+
static ChunkHeader Read( IStream& stream );
2929
static ChunkHeader Invalid();
3030
};
3131

include/AVI20/Read/FillAVIIndexInfo.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
NAMESPACE_AVI20_READ_BEGIN
1010

11+
class IStream;
12+
1113
struct Index
1214
{
1315
Index() {}
@@ -62,7 +64,7 @@ struct FillAVIIndexInfo
6264
std::vector<ChunkHeader> _AVIchs;
6365
std::vector<ChunkHeader> _MOVIchs;
6466

65-
void InitFrom( Stream& stream );
67+
void InitFrom( IStream& stream );
6668
void InitFrom( const std::string& filename );
6769
};
6870

include/AVI20/Read/FrameIndex.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ NAMESPACE_AVI20_END
1010

1111
NAMESPACE_AVI20_READ_BEGIN
1212

13-
class Stream;
13+
class IStream;
1414
struct Type2Index;
1515

1616
class FrameIndex
1717
{
1818
public:
19-
FrameIndex( Stream& stream, const ChunkHeader& indxChunk );
19+
FrameIndex( IStream& stream, const ChunkHeader& indxChunk );
2020
virtual ~FrameIndex();
2121

2222
uint32_t NumFrames() const;
@@ -41,7 +41,7 @@ class FrameIndex
4141
void Parse();
4242

4343
private:
44-
Stream& _Stream;
44+
IStream& _Stream;
4545
ChunkHeader _IndxChunk;
4646
Type2Index* _Type2Index;
4747
};

include/AVI20/Read/IStream.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#pragma once
2+
3+
#include <AVI20/AVI20Defs.h>
4+
#include <AVI20/Namespace.h>
5+
6+
#include <exception>
7+
8+
#include <stdint.h>
9+
10+
NAMESPACE_AVI20_READ_BEGIN
11+
12+
class IStream
13+
{
14+
public:
15+
virtual bool IsNULL() const = 0;
16+
17+
template<typename T> void Read( T& t ) { Read( (uint8_t *)&t, sizeof( T ) ); }
18+
virtual bool Read( uint8_t* dest, uint64_t size ) = 0;
19+
20+
virtual uint64_t Pos() = 0;
21+
virtual void SetPos( uint64_t pos ) = 0;
22+
virtual void SetPosToEnd() = 0;
23+
virtual uint64_t Size() = 0;
24+
virtual bool IsGood() const = 0;
25+
virtual void Rewind() = 0;
26+
27+
static void ThrowException() { throw std::exception(); }
28+
};
29+
30+
NAMESPACE_AVI20_READ_END

include/AVI20/Read/MediaStreamReaderImpl.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ NAMESPACE_AVI20_END
1010
NAMESPACE_AVI20_READ_BEGIN
1111

1212
struct MediaStreamInfo;
13-
class Stream;
13+
class IStream;
1414
class FrameIndex;
1515

1616
class MediaStreamReaderImpl
1717
{
1818
public:
19-
MediaStreamReaderImpl( Stream& stream, const MediaStreamInfo& indxChunk );
19+
MediaStreamReaderImpl( IStream& stream, const MediaStreamInfo& indxChunk );
2020
virtual ~MediaStreamReaderImpl();
2121
void ParseIndex();
2222

@@ -34,7 +34,7 @@ class MediaStreamReaderImpl
3434
double Duration() const;
3535

3636
private:
37-
Stream& _Stream;
37+
IStream& _Stream;
3838
MediaStreamInfo _StreamInfo;
3939
FrameIndex* _FrameIndex;
4040
};

include/AVI20/Read/ParserBase.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
NAMESPACE_AVI20_READ_BEGIN
99

1010
struct ChunkHeader;
11-
class Stream;
11+
class IStream;
1212

1313
class ParserBase
1414
{
1515
public:
1616
ParserBase();
17-
ParserBase( Stream& stream );
17+
ParserBase( IStream& stream );
1818
void Parse();
19-
void Parse( Stream& stream );
19+
void Parse( IStream& stream );
2020
void ParseChunk( int depth );
2121

2222
private:
@@ -38,7 +38,7 @@ class ParserBase
3838
virtual std::string DebugStr( int depth, const ChunkHeader& ch, bool skip );
3939

4040
protected:
41-
Stream* _Stream;
41+
IStream* _Stream;
4242

4343
protected:
4444
MainHeader _MainHeader;

include/AVI20/Read/Reader.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ NAMESPACE_AVI20_READ_BEGIN
77
struct MediaStreamInfo;
88
class ReaderImpl;
99
class MediaStreamReader;
10-
class Stream;
10+
class IStream;
1111

1212
class Reader
1313
{
1414
public:
1515
Reader();
16-
Reader( Stream& stream );
16+
Reader( IStream& stream );
1717
virtual ~Reader();
1818

1919
int NumStreams() const;

0 commit comments

Comments
 (0)