From 7f410fa3fcd1103c3e93f7a846d70553456bf8fd Mon Sep 17 00:00:00 2001 From: John Stebbins Date: Mon, 12 Jan 2009 09:41:33 -0800 Subject: [PATCH] Add binary tag support --- include/libmkv.h | 2 ++ src/tags.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/include/libmkv.h b/include/libmkv.h index 5fd06cb..89f60ce 100644 --- a/include/libmkv.h +++ b/include/libmkv.h @@ -233,6 +233,8 @@ char *mk_laceXiph(uint64_t *sizes, uint8_t num_frames, uint64_t *output_size); int mk_createTagSimple(mk_Writer *w, char *tag_id, char *value); +int mk_createTagSimpleBin(mk_Writer *w, char *tag_id, const void *data, + unsigned size); int mk_writeTags(mk_Writer *w); #ifdef __cplusplus diff --git a/src/tags.c b/src/tags.c index 2907610..c3502f3 100644 --- a/src/tags.c +++ b/src/tags.c @@ -52,6 +52,37 @@ int mk_createTagSimple(mk_Writer * w, char *tag_id, char *value) return 0; } +int mk_createTagSimpleBin(mk_Writer * w, char *tag_id, const void *data, unsigned size) +{ + mk_Context *simple, *targets; + + if (w->tags == NULL) { + /* Tags */ + if ((w->tags = mk_createContext(w, w->root, MATROSKA_ID_TAGS)) == NULL) + return -1; + /* Tag */ + if ((w->tag = mk_createContext(w, w->tags, MATROSKA_ID_TAG)) == NULL) + return -1; + /* Targets */ + if ((targets = mk_createContext(w, w->tag, MATROSKA_ID_TARGETS)) == NULL) + return -1; + /* TargetTypeValue */ + CHECK(mk_writeUInt(targets, MATROSKA_ID_TARGETTYPEVALUE, MK_TARGETTYPE_MOVIE)); /* Album/Movie/Episode */ + CHECK(mk_closeContext(targets, 0)); + } + /* SimpleTag */ + if ((simple = mk_createContext(w, w->tag, MATROSKA_ID_SIMPLETAG)) == NULL) + return -1; + + /* TagName */ + CHECK(mk_writeStr(simple, MATROSKA_ID_TAGNAME, tag_id)); + /* TagBinary */ + CHECK(mk_writeBin(simple, MATROSKA_ID_TAGBINARY, data, size)); + CHECK(mk_closeContext(simple, 0)); + + return 0; +} + int mk_writeTags(mk_Writer * w) { if ((w->tags == NULL) || (w->tag == NULL)) -- 2.11.4.GIT