Mercurial > libavformat.hg
annotate vorbiscomment.c @ 6479:3e7384f85f1d libavformat
tcp: Check both wfds and efds when waiting for the result from connect
On windows, a connection failure doesn't trigger wfds as it does on unix.
This fixes issue 2237, based on code by yeyingxian.
| author | mstorsjo |
|---|---|
| date | Tue, 21 Sep 2010 20:17:34 +0000 |
| parents | a8abcc0f32cf |
| children |
| rev | line source |
|---|---|
| 5857 | 1 /* |
| 2 * VorbisComment writer | |
| 3 * Copyright (c) 2009 James Darnley | |
| 4 * | |
| 5 * This file is part of FFmpeg. | |
| 6 * | |
| 7 * FFmpeg is free software; you can redistribute it and/or | |
| 8 * modify it under the terms of the GNU Lesser General Public | |
| 9 * License as published by the Free Software Foundation; either | |
| 10 * version 2.1 of the License, or (at your option) any later version. | |
| 11 * | |
| 12 * FFmpeg is distributed in the hope that it will be useful, | |
| 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 15 * Lesser General Public License for more details. | |
| 16 * | |
| 17 * You should have received a copy of the GNU Lesser General Public | |
| 18 * License along with FFmpeg; if not, write to the Free Software | |
| 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
| 20 */ | |
| 21 | |
| 22 #include "avformat.h" | |
| 23 #include "metadata.h" | |
| 24 #include "vorbiscomment.h" | |
| 25 #include "libavcodec/bytestream.h" | |
| 26 | |
| 27 /** | |
| 28 * VorbisComment metadata conversion mapping. | |
| 29 * from Ogg Vorbis I format specification: comment field and header specification | |
| 30 * http://xiph.org/vorbis/doc/v-comment.html | |
| 31 */ | |
| 32 const AVMetadataConv ff_vorbiscomment_metadata_conv[] = { | |
| 33 { "ALBUMARTIST", "album_artist"}, | |
| 34 { "TRACKNUMBER", "track" }, | |
| 35 { 0 } | |
| 36 }; | |
| 37 | |
| 38 int ff_vorbiscomment_length(AVMetadata *m, const char *vendor_string, | |
| 39 unsigned *count) | |
| 40 { | |
| 41 int len = 8; | |
| 42 len += strlen(vendor_string); | |
| 43 *count = 0; | |
| 44 if (m) { | |
| 45 AVMetadataTag *tag = NULL; | |
|
6451
a8abcc0f32cf
cosmetics: spaces between and after parentheses
bcoudurier
parents:
5857
diff
changeset
|
46 while ((tag = av_metadata_get(m, "", tag, AV_METADATA_IGNORE_SUFFIX))) { |
| 5857 | 47 len += 4 +strlen(tag->key) + 1 + strlen(tag->value); |
| 48 (*count)++; | |
| 49 } | |
| 50 } | |
| 51 return len; | |
| 52 } | |
| 53 | |
| 54 int ff_vorbiscomment_write(uint8_t **p, AVMetadata *m, | |
| 55 const char *vendor_string, const unsigned count) | |
| 56 { | |
| 57 bytestream_put_le32(p, strlen(vendor_string)); | |
| 58 bytestream_put_buffer(p, vendor_string, strlen(vendor_string)); | |
| 59 if (m) { | |
| 60 AVMetadataTag *tag = NULL; | |
| 61 bytestream_put_le32(p, count); | |
|
6451
a8abcc0f32cf
cosmetics: spaces between and after parentheses
bcoudurier
parents:
5857
diff
changeset
|
62 while ((tag = av_metadata_get(m, "", tag, AV_METADATA_IGNORE_SUFFIX))) { |
| 5857 | 63 unsigned int len1 = strlen(tag->key); |
| 64 unsigned int len2 = strlen(tag->value); | |
| 65 bytestream_put_le32(p, len1+1+len2); | |
| 66 bytestream_put_buffer(p, tag->key, len1); | |
| 67 bytestream_put_byte(p, '='); | |
| 68 bytestream_put_buffer(p, tag->value, len2); | |
| 69 } | |
| 70 } else | |
| 71 bytestream_put_le32(p, 0); | |
| 72 return 0; | |
| 73 } |
