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 { "DISCNUMBER", "disc" },
00036 { 0 }
00037 };
00038
00039 int ff_vorbiscomment_length(AVMetadata *m, const char *vendor_string,
00040 unsigned *count)
00041 {
00042 int len = 8;
00043 len += strlen(vendor_string);
00044 *count = 0;
00045 if (m) {
00046 AVMetadataTag *tag = NULL;
00047 while ((tag = av_metadata_get(m, "", tag, AV_METADATA_IGNORE_SUFFIX))) {
00048 len += 4 +strlen(tag->key) + 1 + strlen(tag->value);
00049 (*count)++;
00050 }
00051 }
00052 return len;
00053 }
00054
00055 int ff_vorbiscomment_write(uint8_t **p, AVMetadata **m,
00056 const char *vendor_string, const unsigned count)
00057 {
00058 bytestream_put_le32(p, strlen(vendor_string));
00059 bytestream_put_buffer(p, vendor_string, strlen(vendor_string));
00060 if (*m) {
00061 AVMetadataTag *tag = NULL;
00062 bytestream_put_le32(p, count);
00063 while ((tag = av_metadata_get(*m, "", tag, AV_METADATA_IGNORE_SUFFIX))) {
00064 unsigned int len1 = strlen(tag->key);
00065 unsigned int len2 = strlen(tag->value);
00066 bytestream_put_le32(p, len1+1+len2);
00067 bytestream_put_buffer(p, tag->key, len1);
00068 bytestream_put_byte(p, '=');
00069 bytestream_put_buffer(p, tag->value, len2);
00070 }
00071 } else
00072 bytestream_put_le32(p, 0);
00073 return 0;
00074 }