2 Copyright (c) 2013-2013, John Hurst
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions
8 1. Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer.
10 2. Redistributions in binary form must reproduce the above copyright
11 notice, this list of conditions and the following disclaimer in the
12 documentation and/or other materials provided with the distribution.
13 3. The name of the author may not be used to endorse or promote products
14 derived from this software without specific prior written permission.
16 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 /*! \file PCMDataProviders.h
29 \brief PCM sample data providers for WAV, AtmosSync and Silence.
32 #ifndef _PCMDATAPROVIDERS_H_
33 #define _PCMDATAPROVIDERS_H_
36 #include <AtmosSyncChannel_Generator.h>
41 // PCM Data Provider Interface
42 class PCMDataProviderInterface
44 ASDCP_NO_COPY_CONSTRUCT(PCMDataProviderInterface);
47 PCMDataProviderInterface() {};
48 virtual ~PCMDataProviderInterface() = 0;
49 virtual Result_t PutSample(const ui32_t numChannels, byte_t* buf, ui32_t* bytesWritten) = 0;
50 virtual Result_t ReadFrame() = 0;
51 virtual Result_t FillAudioDescriptor(PCM::AudioDescriptor& ADesc) const = 0;
52 virtual Result_t Reset() = 0;
55 // WAV file implementation of the PCM Data Provider Interface
56 class WAVDataProvider : public PCMDataProviderInterface
58 ASDCP_NO_COPY_CONSTRUCT(WAVDataProvider);
59 PCM::WAVParser m_Parser;
60 PCM::FrameBuffer m_FB;
61 PCM::AudioDescriptor m_ADesc;
67 virtual ~WAVDataProvider();
68 virtual Result_t PutSample(const ui32_t numChannels, byte_t* buf, ui32_t* bytesWritten);
69 virtual Result_t ReadFrame();
70 virtual Result_t FillAudioDescriptor(PCM::AudioDescriptor& ADesc) const;
71 virtual Result_t Reset();
72 Result_t OpenRead(const char* filename, const Rational& PictureRate);
76 // Atmos Sync Channel implementation of the PCM Data Provider Interface
77 class AtmosSyncDataProvider : public PCMDataProviderInterface
79 ASDCP_NO_COPY_CONSTRUCT(AtmosSyncDataProvider);
80 PCM::AtmosSyncChannelGenerator m_Generator;
81 PCM::FrameBuffer m_FB;
82 PCM::AudioDescriptor m_ADesc;
87 AtmosSyncDataProvider(const ui16_t bitsPerSample, const ui32_t sampleRate,
88 const ASDCP::Rational& PictureRate, const byte_t* uuid);
89 virtual ~AtmosSyncDataProvider();
90 virtual Result_t PutSample(const ui32_t numChannels, byte_t* buf, ui32_t* bytesWritten);
91 virtual Result_t ReadFrame();
92 virtual Result_t FillAudioDescriptor(PCM::AudioDescriptor& ADesc) const;
93 virtual Result_t Reset();
96 // Silence Channel(s) implementation of the PCM Data Provider Interface
97 class SilenceDataProvider : public PCMDataProviderInterface
99 ASDCP_NO_COPY_CONSTRUCT(SilenceDataProvider);
100 PCM::AudioDescriptor m_ADesc;
104 SilenceDataProvider(const ui16_t numChannels, const ui16_t bitsPerSample,
105 const ui32_t sampleRate, const ASDCP::Rational& editRate);
106 virtual ~SilenceDataProvider();
107 virtual Result_t PutSample(const ui32_t numChannels, byte_t* buf, ui32_t* bytesWritten);
108 virtual Result_t ReadFrame();
109 virtual Result_t FillAudioDescriptor(PCM::AudioDescriptor& ADesc) const;
110 virtual Result_t Reset();
115 #endif // _PCMDATAPROVIDERS_H_
118 // end PCMDataProviders.h