2 Copyright (c) 2007, 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 AS_DCP_TimedText.cpp
29 \brief AS-DCP library, PCM essence reader and writer implementation
33 #include "AS_DCP_internal.h"
34 #include "AS_DCP_TimedText.h"
38 using namespace ASDCP;
40 //------------------------------------------------------------------------------------------
42 class ASDCP::TimedText::DCSubtitleParser::h__DCSubtitleParser
44 ui32_t m_FileReadCount;
46 ASDCP_NO_COPY_CONSTRUCT(h__DCSubtitleParser);
49 TimedTextDescriptor m_TDesc;
51 h__DCSubtitleParser() : m_FileReadCount(0)
53 memset(&m_TDesc, 0, sizeof(m_TDesc));
56 ~h__DCSubtitleParser()
61 Result_t OpenRead(const char* filename);
70 Result_t ReadFrame(FrameBuffer&);
73 //------------------------------------------------------------------------------------------
75 ASDCP::TimedText::DCSubtitleParser::DCSubtitleParser()
79 ASDCP::TimedText::DCSubtitleParser::~DCSubtitleParser()
83 // Opens the stream for reading, parses enough data to provide a complete
84 // set of stream metadata for the MXFWriter below.
86 ASDCP::TimedText::DCSubtitleParser::OpenRead(const char* filename) const
88 const_cast<ASDCP::TimedText::DCSubtitleParser*>(this)->m_Parser = new h__DCSubtitleParser;
90 Result_t result = m_Parser->OpenRead(filename);
92 if ( ASDCP_FAILURE(result) )
93 const_cast<ASDCP::TimedText::DCSubtitleParser*>(this)->m_Parser.release();
98 // Rewinds the stream to the beginning.
100 ASDCP::TimedText::DCSubtitleParser::Reset() const
102 if ( m_Parser.empty() )
105 return m_Parser->Reset();
108 // Places a frame of data in the frame buffer. Fails if the buffer is too small
109 // or the stream is empty.
111 ASDCP::TimedText::DCSubtitleParser::ReadFrame(FrameBuffer& FB) const
113 if ( m_Parser.empty() )
116 return m_Parser->ReadFrame(FB);
120 ASDCP::TimedText::DCSubtitleParser::FillDescriptor(TimedTextDescriptor& PDesc) const
122 if ( m_Parser.empty() )
125 PDesc = m_Parser->m_TDesc;
130 // end AS_DCP_timedText.cpp