• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • Examples
  • 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 Libav.
00006  *
00007  * Libav 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  * Libav 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 Libav; 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 #include "libavutil/dict.h"
00027 
00033 const AVMetadataConv ff_vorbiscomment_metadata_conv[] = {
00034     { "ALBUMARTIST", "album_artist"},
00035     { "TRACKNUMBER", "track"  },
00036     { "DISCNUMBER",  "disc"   },
00037     { 0 }
00038 };
00039 
00040 int ff_vorbiscomment_length(AVDictionary *m, const char *vendor_string,
00041                             unsigned *count)
00042 {
00043     int len = 8;
00044     len += strlen(vendor_string);
00045     *count = 0;
00046     if (m) {
00047         AVDictionaryEntry *tag = NULL;
00048         while ((tag = av_dict_get(m, "", tag, AV_DICT_IGNORE_SUFFIX))) {
00049             len += 4 +strlen(tag->key) + 1 + strlen(tag->value);
00050             (*count)++;
00051         }
00052     }
00053     return len;
00054 }
00055 
00056 int ff_vorbiscomment_write(uint8_t **p, AVDictionary **m,
00057                            const char *vendor_string, const unsigned count)
00058 {
00059     bytestream_put_le32(p, strlen(vendor_string));
00060     bytestream_put_buffer(p, vendor_string, strlen(vendor_string));
00061     if (*m) {
00062         AVDictionaryEntry *tag = NULL;
00063         bytestream_put_le32(p, count);
00064         while ((tag = av_dict_get(*m, "", tag, AV_DICT_IGNORE_SUFFIX))) {
00065             unsigned int len1 = strlen(tag->key);
00066             unsigned int len2 = strlen(tag->value);
00067             bytestream_put_le32(p, len1+1+len2);
00068             bytestream_put_buffer(p, tag->key, len1);
00069             bytestream_put_byte(p, '=');
00070             bytestream_put_buffer(p, tag->value, len2);
00071         }
00072     } else
00073         bytestream_put_le32(p, 0);
00074     return 0;
00075 }
Generated on Sat Mar 17 2012 12:57:55 for Libav by doxygen 1.7.1