• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

libavformat/vorbiscomment.c

Go to the documentation of this file.
00001 /*
00002  * VorbisComment writer
00003  * Copyright (c) 2009 James Darnley
00004  *
00005  * This file is part of FFmpeg.
00006  *
00007  * FFmpeg is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * FFmpeg is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with FFmpeg; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
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 }

Generated on Fri Sep 16 2011 17:17:51 for FFmpeg by  doxygen 1.7.1