Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New VMF 3.0 API ideas #23

Closed
apavlenko opened this issue Jan 21, 2016 · 1 comment
Closed

New VMF 3.0 API ideas #23

apavlenko opened this issue Jan 21, 2016 · 1 comment
Assignees

Comments

@apavlenko
Copy link
Owner

1) MetadataSchema, MetadataDesc, Metadata

  • current code:
auto schema = make_shared<MetadataSchema>("schema-name", "author");
VMF_METADATA_BEGIN("channel-name");
    VMF_FIELD_STR("field1");
    VMF_FIELD_INT("field2");
VMF_METADATA_END(schema);
mdStream.addSchema(schema);
auto desc = schema->findMetadataDesc("channel-name");
auto md = std::make_shared<Metadata>(desc);
md->push_back(FieldValue("algo-id", "qqq"));
md->push_back(FieldValue("data", "qqq"));
mdStream.add(md);
  • proposed code:
mdStream.addSchema(
    MetadataSchema("schema-name", "author",
        MetadataDesc("channel-name",
            FieldDesc("field1", vmf_string),
            FieldDesc("field2", vmf_integer)
        ),
        MetadataDesc(
            ...
        )
    )
);

mdStream.add(
    Metadata("channel-name",
        FieldValue("field1", "qqq"),
        FieldValue("field2", 10)
    )
);

Less code, no shared_ptr => faster!

@apavlenko apavlenko self-assigned this Jan 21, 2016
@apavlenko
Copy link
Owner Author

IReader + IWriter => Format

class VMF_EXPORT Format
{
public:

    typedef std::map<std::string, std::string> AttribMap;
    /*!
    * \brief Export various metadata stream items to a string representation. Used in particular for "stream.serialize()" implementation.
    */
    virtual std::string store(
        const MetadataSet& set,
        const std::vector<std::shared_ptr<MetadataSchema>>& schemas = {},
        const std::vector<std::shared_ptr<MetadataStream::VideoSegment>>& segments = {},
        const std::vector<Stat>& stats = {},
        const AttribMap& attribs = {} // nextId, checksum, etc
        ) = 0;

    /*!
    * \brief Deserialize input string to stream metadata and related stuff. Used in particular for "stream.deserialize(text)" implementation.
    */
    virtual std::array<int, 5> parse(
        const std::string& text,
        std::vector<std::shared_ptr<MetadataInternal>>& metadata,
        std::vector<std::shared_ptr<MetadataSchema>>& schemas,
        std::vector<std::shared_ptr<MetadataStream::VideoSegment>>& segments,
        std::vector<Stat>& stats,
        AttribMap& attribs // nextId, checksum, etc
        ) = 0;
;

Simpler API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant