Skip to content

Commit

Permalink
Some clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
KMojek committed Dec 7, 2020
1 parent b4eec04 commit 2637194
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 34 deletions.
12 changes: 4 additions & 8 deletions include/mp4v2/file.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,12 @@ bool MP4Optimize(
* the library.
* On error, #MP4_INVALID_FILE_HANDLE.
*/
typedef bool( *ShouldParseAtomCallback )( uint32_t );

MP4V2_EXPORT
MP4FileHandle MP4Read(
const char* fileName );
const char* fileName,
ShouldParseAtomCallback cb = nullptr );

/** Read an existing mp4 file.
*
Expand Down Expand Up @@ -358,13 +361,6 @@ MP4FileHandle MP4ReadProvider(
const char* fileName,
const MP4FileProvider* fileProvider DEFAULT(NULL) );

typedef bool( *ShouldParseAtomCallback )( uint32_t );
MP4V2_EXPORT
void MP4SetShouldParseAtomCallback(
MP4FileHandle hFile,
ShouldParseAtomCallback f
);

/** @} ***********************************************************************/

#endif /* MP4V2_FILE_H */
30 changes: 5 additions & 25 deletions src/mp4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const char* MP4GetFilename( MP4FileHandle hFile )

///////////////////////////////////////////////////////////////////////////////

MP4FileHandle MP4Read( const char* fileName )
MP4FileHandle MP4Read( const char* fileName, ShouldParseAtomCallback cb/*=nullptr*/ )
{
if (!fileName)
return MP4_INVALID_FILE_HANDLE;
Expand All @@ -99,6 +99,10 @@ MP4FileHandle MP4Read( const char* fileName )
try
{
ASSERT(pFile);

if ( cb != nullptr )
pFile->SetShouldParseAtomCallback( cb );

pFile->Read( fileName, NULL );
return (MP4FileHandle)pFile;
}
Expand Down Expand Up @@ -143,30 +147,6 @@ MP4FileHandle MP4ReadProvider( const char* fileName, const MP4FileProvider* file
return MP4_INVALID_FILE_HANDLE;
}

///////////////////////////////////////////////////////////////////////////////

void MP4SetShouldParseAtomCallback( MP4FileHandle hFile, ShouldParseAtomCallback cb )
{
if (!MP4_IS_VALID_FILE_HANDLE(hFile))
return;
try
{
ASSERT(hFile);
MP4File& file = *static_cast<MP4File*>(hFile);
file.SetShouldParseAtomCallback( cb );
}
catch( Exception* x ) {
mp4v2::impl::log.errorf(*x);
delete x;
}
catch( ... ) {
mp4v2::impl::log.errorf("%s: unknown exception accessing MP4File "
"filename", __FUNCTION__ );
}

// g_parseCallback = cb;
}

///////////////////////////////////////////////////////////////////////////////

MP4FileHandle MP4Create (const char* fileName,
Expand Down
2 changes: 1 addition & 1 deletion src/mp4atom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ void MP4Atom::Read()

// skip parsing of certain atoms
ShouldParseAtomCallback cb = m_File.GetShouldParseAtomCallback();
if ( cb == nullptr || ( cb != nullptr && cb( ATOMID(m_type) ) ) )
if ( cb == nullptr || cb( ATOMID(m_type) ) )
{
ReadProperties();

Expand Down

0 comments on commit 2637194

Please sign in to comment.