Skip to content

Commit

Permalink
support for base64 embedded data
Browse files Browse the repository at this point in the history
  • Loading branch information
nem0 committed Oct 14, 2023
1 parent 0f53d04 commit 5d8175d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/ofbx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,12 @@ struct Allocator {
};




struct Video
{
DataView filename;
DataView content;
DataView media;
bool is_base_64;
};


Expand Down Expand Up @@ -1954,6 +1953,10 @@ struct Scene : IScene
return m_videos[index].content;
}

bool isEmbeddedBase64(int index) const override {
return m_videos[index].is_base_64;
}

DataView getEmbeddedFilename(int index) const override {
return m_videos[index].filename;
}
Expand Down Expand Up @@ -2248,17 +2251,32 @@ void parseVideo(Scene& scene, const Element& element, Allocator& allocator)

const Element* content_element = findChild(element, "Content");

bool is_base64 = false;
if (!content_element) return;
if (!content_element->first_property) return;
if (content_element->first_property->getType() != IElementProperty::BINARY) return;
const Property* content_property = content_element->first_property;
if (content_element->first_property->getType() != IElementProperty::BINARY) {
/*
if this happens in text format:
Content: ,
"iVBORw0KGgoA...
this is not a proper solution, but keep doing this until it become an issue
*/
if (content_element->first_property->getType() != IElementProperty::NONE) return;
if (!content_element->first_property->next) return;
if (content_element->first_property->next->getType() != IElementProperty::STRING) return;
content_property = content_element->first_property->next;
is_base64 = true;
}

const Element* filename_element = findChild(element, "Filename");
if (!filename_element) return;
if (!filename_element->first_property) return;
if (filename_element->first_property->getType() != IElementProperty::STRING) return;

Video video;
video.content = content_element->first_property->value;
video.is_base_64 = is_base64;
video.content = content_property->value;
video.filename = filename_element->first_property->value;
video.media = element.first_property->next->value;
scene.m_videos.push_back(video);
Expand Down
1 change: 1 addition & 0 deletions src/ofbx.h
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,7 @@ struct IScene
virtual int getEmbeddedDataCount() const = 0;
virtual DataView getEmbeddedData(int index) const = 0;
virtual DataView getEmbeddedFilename(int index) const = 0;
virtual bool isEmbeddedBase64(int index) const = 0;

// Scene Misc
virtual const TakeInfo* getTakeInfo(const char* name) const = 0;
Expand Down

0 comments on commit 5d8175d

Please sign in to comment.