00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "avformat.h"
00023 #include "metadata.h"
00024 #include "vorbiscomment.h"
00025 #include "libavcodec/bytestream.h"
00026
00032 const AVMetadataConv ff_vorbiscomment_metadata_conv[] = {
00033 { "ALBUMARTIST", "album_artist"},
00034 { "TRACKNUMBER", "track" },
00035 { 0 }
00036 };
00037
00038 int ff_vorbiscomment_length(AVMetadata *m, const char *vendor_string,
00039 unsigned *count)
00040 {
00041 int len = 8;
00042 len += strlen(vendor_string);
00043 *count = 0;
00044 if (m) {
00045 AVMetadataTag *tag = NULL;
00046 while ( (tag = av_metadata_get(m, "", tag, AV_METADATA_IGNORE_SUFFIX) ) ) {
00047 len += 4 +strlen(tag->key) + 1 + strlen(tag->value);
00048 (*count)++;
00049 }
00050 }
00051 return len;
00052 }
00053
00054 int ff_vorbiscomment_write(uint8_t **p, AVMetadata *m,
00055 const char *vendor_string, const unsigned count)
00056 {
00057 bytestream_put_le32(p, strlen(vendor_string));
00058 bytestream_put_buffer(p, vendor_string, strlen(vendor_string));
00059 if (m) {
00060 AVMetadataTag *tag = NULL;
00061 bytestream_put_le32(p, count);
00062 while ( (tag = av_metadata_get(m, "", tag, AV_METADATA_IGNORE_SUFFIX) ) ) {
00063 unsigned int len1 = strlen(tag->key);
00064 unsigned int len2 = strlen(tag->value);
00065 bytestream_put_le32(p, len1+1+len2);
00066 bytestream_put_buffer(p, tag->key, len1);
00067 bytestream_put_byte(p, '=');
00068 bytestream_put_buffer(p, tag->value, len2);
00069 }
00070 } else
00071 bytestream_put_le32(p, 0);
00072 return 0;
00073 }