ref: 145c7352fe875420e31d3134ff3602fcf7025577
parent: 2da7ce40e73c98a5ab9040e41ab377e2a82e1811
author: Jean-Marc Valin <jmvalin@jmvalin.ca>
date: Wed May 10 14:24:07 EDT 2017
Making it possible to add a full comment string
--- a/include/opusenc.h
+++ b/include/opusenc.h
@@ -106,7 +106,7 @@
typedef struct OggOpusEnc OggOpusEnc;
/** Create a new comments object. */
-OPE_EXPORT OggOpusComments *ope_comments_create();
+OPE_EXPORT OggOpusComments *ope_comments_create(void);
/** Create a deep copy of a comments object. */
OPE_EXPORT OggOpusComments *ope_comments_copy(OggOpusComments *comments);
@@ -116,6 +116,9 @@
/** Add a comment. */
OPE_EXPORT int ope_comments_add(OggOpusComments *comments, const char *tag, const char *val);
+
+/** Add a comment. */
+OPE_EXPORT int ope_comments_add_string(OggOpusComments *comments, const char *tag_and_val);
/** Add a picture. */
OPE_EXPORT int ope_comments_add_picture(OggOpusComments *comments, const char *spec);
--- a/src/opusenc.c
+++ b/src/opusenc.c
@@ -119,7 +119,16 @@
/* Add a comment. */
int ope_comments_add(OggOpusComments *comments, const char *tag, const char *val) {
+ if (tag == NULL || val == NULL) return OPE_BAD_ARG;
+ if (strchr(tag, '=')) return OPE_BAD_ARG;
if (comment_add(&comments->comment, &comments->comment_length, tag, val)) return OPE_ALLOC_FAIL;
+ return OPE_OK;
+}
+
+/* Add a comment. */
+int ope_comments_add_string(OggOpusComments *comments, const char *tag_and_val) {
+ if (!strchr(tag_and_val, '=')) return OPE_BAD_ARG;
+ if (comment_add(&comments->comment, &comments->comment_length, tag_and_val, NULL)) return OPE_ALLOC_FAIL;
return OPE_OK;
}