Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 29 additions & 42 deletions src/mp4file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -742,10 +742,10 @@ bool MP4File::FindProperty(const char* name,
void MP4File::FindIntegerProperty(const char* name,
MP4Property** ppProperty, uint32_t* pIndex)
{
if ( !FindProperty( name, ppProperty, pIndex ) ) {
if (!FindProperty(name, ppProperty, pIndex)) {
ostringstream msg;
msg << "no such property - " << name;
throw new Exception( msg.str(), __FILE__, __LINE__, __FUNCTION__ );
throw new Exception(msg.str(), __FILE__, __LINE__, __FUNCTION__);
}

switch ((*ppProperty)->GetType()) {
Expand All @@ -764,12 +764,10 @@ void MP4File::FindIntegerProperty(const char* name,

uint64_t MP4File::GetIntegerProperty(const char* name)
{
MP4Property* pProperty = nullptr;
MP4Property* pProperty;
uint32_t index;

FindIntegerProperty(name, &pProperty, &index);
if ( pProperty == nullptr )
return 0ULL;

return ((MP4IntegerProperty*)pProperty)->GetValue(index);
}
Expand All @@ -778,13 +776,12 @@ void MP4File::SetIntegerProperty(const char* name, uint64_t value)
{
ProtectWriteOperation(__FILE__, __LINE__, __FUNCTION__);

MP4Property* pProperty = nullptr;
MP4Property* pProperty = NULL;
uint32_t index = 0;

FindIntegerProperty(name, &pProperty, &index);

if ( pProperty != nullptr )
((MP4IntegerProperty*)pProperty)->SetValue(value, index);
((MP4IntegerProperty*)pProperty)->SetValue(value, index);
}

void MP4File::FindFloatProperty(const char* name,
Expand All @@ -793,38 +790,35 @@ void MP4File::FindFloatProperty(const char* name,
if (!FindProperty(name, ppProperty, pIndex)) {
ostringstream msg;
msg << "no such property - " << name;
log.errorf( "MP4File::FindFloatProperty - %s", msg.str().c_str() );
return;
throw new Exception(msg.str(), __FILE__, __LINE__, __FUNCTION__);
}
if ((*ppProperty)->GetType() != Float32Property) {
ostringstream msg;
msg << "type mismatch - property " << name << " type " << (*ppProperty)->GetType();
log.errorf( "MP4File::FindFloatProperty - %s", msg.str().c_str() );
return;
throw new Exception(msg.str(), __FILE__, __LINE__, __FUNCTION__);
}
}

float MP4File::GetFloatProperty(const char* name)
{
MP4Property* pProperty = nullptr;
uint32_t index;
MP4Property* pProperty;
uint32_t index;

FindFloatProperty(name, &pProperty, &index);
FindFloatProperty(name, &pProperty, &index);

return ( pProperty != nullptr ) ? ( (MP4Float32Property*)pProperty )->GetValue( index ) : 0.f;
return ((MP4Float32Property*)pProperty)->GetValue(index);
}

void MP4File::SetFloatProperty(const char* name, float value)
{
ProtectWriteOperation(__FILE__, __LINE__, __FUNCTION__);

MP4Property* pProperty = nullptr;
MP4Property* pProperty;
uint32_t index;

FindFloatProperty(name, &pProperty, &index);

if ( pProperty != nullptr )
((MP4Float32Property*)pProperty)->SetValue(value, index);
((MP4Float32Property*)pProperty)->SetValue(value, index);
}

void MP4File::FindStringProperty(const char* name,
Expand All @@ -833,38 +827,35 @@ void MP4File::FindStringProperty(const char* name,
if (!FindProperty(name, ppProperty, pIndex)) {
ostringstream msg;
msg << "no such property - " << name;
log.errorf( "MP4File::FindStringProperty - %s", msg.str().c_str() );
return;
throw new Exception(msg.str(), __FILE__, __LINE__, __FUNCTION__);
}
if ((*ppProperty)->GetType() != StringProperty) {
ostringstream msg;
msg << "type mismatch - property " << name << " type " << (*ppProperty)->GetType();
log.errorf( "MP4File::FindStringProperty - %s", msg.str().c_str() );
return;
throw new Exception(msg.str(), __FILE__, __LINE__, __FUNCTION__);
}
}

const char* MP4File::GetStringProperty(const char* name)
{
MP4Property* pProperty = nullptr;
uint32_t index;
MP4Property* pProperty;
uint32_t index;

FindStringProperty(name, &pProperty, &index);
FindStringProperty(name, &pProperty, &index);

return ( pProperty != nullptr ) ? ( (MP4StringProperty*)pProperty )->GetValue( index ) : "";
return ((MP4StringProperty*)pProperty)->GetValue(index);
}

void MP4File::SetStringProperty(const char* name, const char* value)
{
ProtectWriteOperation(__FILE__, __LINE__, __FUNCTION__);

MP4Property* pProperty = nullptr;
MP4Property* pProperty;
uint32_t index;

FindStringProperty(name, &pProperty, &index);

if ( pProperty != nullptr )
((MP4StringProperty*)pProperty)->SetValue(value, index);
((MP4StringProperty*)pProperty)->SetValue(value, index);
}

void MP4File::FindBytesProperty(const char* name,
Expand All @@ -873,41 +864,37 @@ void MP4File::FindBytesProperty(const char* name,
if (!FindProperty(name, ppProperty, pIndex)) {
ostringstream msg;
msg << "no such property " << name;
log.errorf( "MP4File::FindBytesProperty - %s", msg.str().c_str() );
return;
throw new Exception(msg.str(), __FILE__, __LINE__, __FUNCTION__);
}
if ((*ppProperty)->GetType() != BytesProperty) {
ostringstream msg;
msg << "type mismatch - property " << name << " - type " << (*ppProperty)->GetType();
log.errorf( "MP4File::FindBytesProperty - %s", msg.str().c_str() );
return;
throw new Exception(msg.str(), __FILE__, __LINE__, __FUNCTION__);
}
}

void MP4File::GetBytesProperty(const char* name,
uint8_t** ppValue, uint32_t* pValueSize)
{
MP4Property* pProperty = nullptr;
uint32_t index;
MP4Property* pProperty;
uint32_t index;

FindBytesProperty(name, &pProperty, &index);
FindBytesProperty(name, &pProperty, &index);

if ( pProperty != nullptr )
((MP4BytesProperty*)pProperty)->GetValue(ppValue, pValueSize, index);
((MP4BytesProperty*)pProperty)->GetValue(ppValue, pValueSize, index);
}

void MP4File::SetBytesProperty(const char* name,
const uint8_t* pValue, uint32_t valueSize)
{
ProtectWriteOperation(__FILE__, __LINE__, __FUNCTION__);

MP4Property* pProperty = nullptr;
MP4Property* pProperty;
uint32_t index;

FindBytesProperty(name, &pProperty, &index);

if ( pProperty != nullptr )
((MP4BytesProperty*)pProperty)->SetValue(pValue, valueSize, index);
((MP4BytesProperty*)pProperty)->SetValue(pValue, valueSize, index);
}


Expand Down