Browse code

lavf: remove FF_API_OLD_METADATA cruft

Anton Khirnov authored on 2011/02/03 20:30:16
Showing 8 changed files
... ...
@@ -10,7 +10,6 @@ OBJS = allformats.o         \
10 10
        id3v1.o              \
11 11
        id3v2.o              \
12 12
        metadata.o           \
13
-       metadata_compat.o    \
14 13
        options.o            \
15 14
        os_support.o         \
16 15
        sdp.o                \
... ...
@@ -133,20 +133,6 @@ typedef struct AVMetadataConv AVMetadataConv;
133 133
 AVMetadataTag *
134 134
 av_metadata_get(AVMetadata *m, const char *key, const AVMetadataTag *prev, int flags);
135 135
 
136
-#if FF_API_OLD_METADATA
137
-/**
138
- * Set the given tag in *pm, overwriting an existing tag.
139
- *
140
- * @param pm pointer to a pointer to a metadata struct. If *pm is NULL
141
- * a metadata struct is allocated and put in *pm.
142
- * @param key tag key to add to *pm (will be av_strduped)
143
- * @param value tag value to add to *pm (will be av_strduped)
144
- * @return >= 0 on success otherwise an error code <0
145
- * @deprecated Use av_metadata_set2() instead.
146
- */
147
-attribute_deprecated int av_metadata_set(AVMetadata **pm, const char *key, const char *value);
148
-#endif
149
-
150 136
 /**
151 137
  * Set the given tag in *pm, overwriting an existing tag.
152 138
  *
... ...
@@ -544,10 +530,6 @@ typedef struct AVStream {
544 544
      */
545 545
     int64_t duration;
546 546
 
547
-#if FF_API_OLD_METADATA
548
-    attribute_deprecated char language[4]; /**< ISO 639-2/B 3-letter language code (empty string if undefined) */
549
-#endif
550
-
551 547
     /* av_read_frame() support */
552 548
     enum AVStreamParseType need_parsing;
553 549
     struct AVCodecParserContext *parser;
... ...
@@ -567,10 +549,6 @@ typedef struct AVStream {
567 567
     attribute_deprecated int64_t unused[4+1];
568 568
 #endif
569 569
 
570
-#if FF_API_OLD_METADATA
571
-    attribute_deprecated char *filename; /**< source filename of the stream */
572
-#endif
573
-
574 570
     int disposition; /**< AV_DISPOSITION_* bit field */
575 571
 
576 572
     AVProbeData probe_data;
... ...
@@ -648,10 +626,6 @@ typedef struct AVStream {
648 648
  */
649 649
 typedef struct AVProgram {
650 650
     int            id;
651
-#if FF_API_OLD_METADATA
652
-    attribute_deprecated char           *provider_name; ///< network name for DVB streams
653
-    attribute_deprecated char           *name;          ///< service name for DVB streams
654
-#endif
655 651
     int            flags;
656 652
     enum AVDiscard discard;        ///< selects which program to discard and which to feed to the caller
657 653
     unsigned int   *stream_index;
... ...
@@ -666,9 +640,6 @@ typedef struct AVChapter {
666 666
     int id;                 ///< unique ID to identify the chapter
667 667
     AVRational time_base;   ///< time base in which the start/end timestamps are specified
668 668
     int64_t start, end;     ///< chapter start/end time in time_base units
669
-#if FF_API_OLD_METADATA
670
-    attribute_deprecated char *title;            ///< chapter title
671
-#endif
672 669
     AVMetadata *metadata;
673 670
 } AVChapter;
674 671
 
... ...
@@ -691,16 +662,6 @@ typedef struct AVFormatContext {
691 691
     char filename[1024]; /**< input or output filename */
692 692
     /* stream info */
693 693
     int64_t timestamp;
694
-#if FF_API_OLD_METADATA
695
-    attribute_deprecated char title[512];
696
-    attribute_deprecated char author[512];
697
-    attribute_deprecated char copyright[512];
698
-    attribute_deprecated char comment[512];
699
-    attribute_deprecated char album[512];
700
-    attribute_deprecated int year;  /**< ID3 year, 0 if none */
701
-    attribute_deprecated int track; /**< track number, 0 if none */
702
-    attribute_deprecated char genre[32]; /**< ID3 genre */
703
-#endif
704 694
 
705 695
     int ctx_flags; /**< Format-specific flags, see AVFMTCTX_xx */
706 696
     /* private data for pts handling (do not modify directly). */
... ...
@@ -86,13 +86,6 @@ int av_metadata_set2(AVMetadata **pm, const char *key, const char *value, int fl
86 86
     return 0;
87 87
 }
88 88
 
89
-#if FF_API_OLD_METADATA
90
-int av_metadata_set(AVMetadata **pm, const char *key, const char *value)
91
-{
92
-    return av_metadata_set2(pm, key, value, 0);
93
-}
94
-#endif
95
-
96 89
 #if FF_API_OLD_METADATA2
97 90
 void av_metadata_conv(AVFormatContext *ctx, const AVMetadataConv *d_conv,
98 91
                                             const AVMetadataConv *s_conv)
... ...
@@ -43,11 +43,6 @@ struct AVMetadataConv{
43 43
 typedef struct AVMetadataConv AVMetadataConv;
44 44
 #endif
45 45
 
46
-#if FF_API_OLD_METADATA
47
-void ff_metadata_demux_compat(AVFormatContext *s);
48
-void ff_metadata_mux_compat(AVFormatContext *s);
49
-#endif
50
-
51 46
 void ff_metadata_conv(AVMetadata **pm, const AVMetadataConv *d_conv,
52 47
                                        const AVMetadataConv *s_conv);
53 48
 void ff_metadata_conv_ctx(AVFormatContext *ctx, const AVMetadataConv *d_conv,
54 49
deleted file mode 100644
... ...
@@ -1,148 +0,0 @@
1
-/*
2
- * Copyright (c) 2009  Aurelien Jacobs <aurel@gnuage.org>
3
- *
4
- * This file is part of Libav.
5
- *
6
- * Libav is free software; you can redistribute it and/or
7
- * modify it under the terms of the GNU Lesser General Public
8
- * License as published by the Free Software Foundation; either
9
- * version 2.1 of the License, or (at your option) any later version.
10
- *
11
- * Libav is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
- * Lesser General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU Lesser General Public
17
- * License along with Libav; if not, write to the Free Software
18
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
- */
20
-
21
-#include <strings.h>
22
-#include "avformat.h"
23
-#include "metadata.h"
24
-#include "libavutil/avstring.h"
25
-
26
-#if FF_API_OLD_METADATA
27
-
28
-#define SIZE_OFFSET(x) sizeof(((AVFormatContext*)0)->x),offsetof(AVFormatContext,x)
29
-
30
-static const struct {
31
-    const char name[16];
32
-    int   size;
33
-    int   offset;
34
-} compat_tab[] = {
35
-    { "title",           SIZE_OFFSET(title)     },
36
-    { "author",          SIZE_OFFSET(author)    },
37
-    { "copyright",       SIZE_OFFSET(copyright) },
38
-    { "comment",         SIZE_OFFSET(comment)   },
39
-    { "album",           SIZE_OFFSET(album)     },
40
-    { "year",            SIZE_OFFSET(year)      },
41
-    { "track",           SIZE_OFFSET(track)     },
42
-    { "genre",           SIZE_OFFSET(genre)     },
43
-
44
-    { "artist",          SIZE_OFFSET(author)    },
45
-    { "creator",         SIZE_OFFSET(author)    },
46
-    { "written_by",      SIZE_OFFSET(author)    },
47
-    { "lead_performer",  SIZE_OFFSET(author)    },
48
-    { "composer",        SIZE_OFFSET(author)    },
49
-    { "performer",       SIZE_OFFSET(author)    },
50
-    { "description",     SIZE_OFFSET(comment)   },
51
-    { "albumtitle",      SIZE_OFFSET(album)     },
52
-    { "date",            SIZE_OFFSET(year)      },
53
-    { "date_written",    SIZE_OFFSET(year)      },
54
-    { "date_released",   SIZE_OFFSET(year)      },
55
-    { "tracknumber",     SIZE_OFFSET(track)     },
56
-    { "part_number",     SIZE_OFFSET(track)     },
57
-};
58
-
59
-void ff_metadata_demux_compat(AVFormatContext *ctx)
60
-{
61
-    AVMetadata *m;
62
-    int i, j;
63
-
64
-    if ((m = ctx->metadata))
65
-        for (j=0; j<m->count; j++)
66
-            for (i=0; i<FF_ARRAY_ELEMS(compat_tab); i++)
67
-                if (!strcasecmp(m->elems[j].key, compat_tab[i].name)) {
68
-                    int *ptr = (int *)((char *)ctx+compat_tab[i].offset);
69
-                    if (*ptr)  continue;
70
-                    if (compat_tab[i].size > sizeof(int))
71
-                        av_strlcpy((char *)ptr, m->elems[j].value, compat_tab[i].size);
72
-                    else
73
-                        *ptr = atoi(m->elems[j].value);
74
-                }
75
-
76
-    for (i=0; i<ctx->nb_chapters; i++)
77
-        if ((m = ctx->chapters[i]->metadata))
78
-            for (j=0; j<m->count; j++)
79
-                if (!strcasecmp(m->elems[j].key, "title")) {
80
-                    av_free(ctx->chapters[i]->title);
81
-                    ctx->chapters[i]->title = av_strdup(m->elems[j].value);
82
-                }
83
-
84
-    for (i=0; i<ctx->nb_programs; i++)
85
-        if ((m = ctx->programs[i]->metadata))
86
-            for (j=0; j<m->count; j++) {
87
-                if (!strcasecmp(m->elems[j].key, "name")) {
88
-                    av_free(ctx->programs[i]->name);
89
-                    ctx->programs[i]->name = av_strdup(m->elems[j].value);
90
-                }
91
-                if (!strcasecmp(m->elems[j].key, "provider_name")) {
92
-                    av_free(ctx->programs[i]->provider_name);
93
-                    ctx->programs[i]->provider_name = av_strdup(m->elems[j].value);
94
-                }
95
-            }
96
-
97
-    for (i=0; i<ctx->nb_streams; i++)
98
-        if ((m = ctx->streams[i]->metadata))
99
-            for (j=0; j<m->count; j++) {
100
-                if (!strcasecmp(m->elems[j].key, "language"))
101
-                    av_strlcpy(ctx->streams[i]->language, m->elems[j].value, 4);
102
-                if (!strcasecmp(m->elems[j].key, "filename")) {
103
-                    av_free(ctx->streams[i]->filename);
104
-                    ctx->streams[i]->filename= av_strdup(m->elems[j].value);
105
-                }
106
-            }
107
-}
108
-
109
-
110
-#define FILL_METADATA(s, key, value) {                                        \
111
-    if (!av_metadata_get(s->metadata, #key, NULL, 0))                         \
112
-        av_metadata_set2(&s->metadata, #key, value, 0);                       \
113
-    }
114
-#define FILL_METADATA_STR(s, key) {                                           \
115
-    if (s->key && *s->key)  FILL_METADATA(s, key, s->key); }
116
-#define FILL_METADATA_INT(s, key) {                                           \
117
-    char number[10];                                                          \
118
-    snprintf(number, sizeof(number), "%d", s->key);                           \
119
-    if(s->key)  FILL_METADATA(s, key, number) }
120
-
121
-void ff_metadata_mux_compat(AVFormatContext *ctx)
122
-{
123
-    int i;
124
-
125
-    if (ctx->metadata && ctx->metadata->count > 0)
126
-        return;
127
-
128
-    FILL_METADATA_STR(ctx, title);
129
-    FILL_METADATA_STR(ctx, author);
130
-    FILL_METADATA_STR(ctx, copyright);
131
-    FILL_METADATA_STR(ctx, comment);
132
-    FILL_METADATA_STR(ctx, album);
133
-    FILL_METADATA_INT(ctx, year);
134
-    FILL_METADATA_INT(ctx, track);
135
-    FILL_METADATA_STR(ctx, genre);
136
-    for (i=0; i<ctx->nb_chapters; i++)
137
-        FILL_METADATA_STR(ctx->chapters[i], title);
138
-    for (i=0; i<ctx->nb_programs; i++) {
139
-        FILL_METADATA_STR(ctx->programs[i], name);
140
-        FILL_METADATA_STR(ctx->programs[i], provider_name);
141
-    }
142
-    for (i=0; i<ctx->nb_streams; i++) {
143
-        FILL_METADATA_STR(ctx->streams[i], language);
144
-        FILL_METADATA_STR(ctx->streams[i], filename);
145
-    }
146
-}
147
-
148
-#endif /* FF_API_OLD_METADATA */
... ...
@@ -50,10 +50,6 @@ static const AVOption options[]={
50 50
 {"noparse", "disable AVParsers, this needs nofillin too", 0, FF_OPT_TYPE_CONST, AVFMT_FLAG_NOPARSE, INT_MIN, INT_MAX, D, "fflags"},
51 51
 {"igndts", "ignore dts", 0, FF_OPT_TYPE_CONST, AVFMT_FLAG_IGNDTS, INT_MIN, INT_MAX, D, "fflags"},
52 52
 {"rtphint", "add rtp hinting", 0, FF_OPT_TYPE_CONST, AVFMT_FLAG_RTP_HINT, INT_MIN, INT_MAX, E, "fflags"},
53
-#if FF_API_OLD_METADATA
54
-{"track", " set the track number", OFFSET(track), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, E},
55
-{"year", "set the year", OFFSET(year), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, E},
56
-#endif
57 53
 {"analyzeduration", "how many microseconds are analyzed to estimate duration", OFFSET(max_analyze_duration), FF_OPT_TYPE_INT, 5*AV_TIME_BASE, 0, INT_MAX, D},
58 54
 {"cryptokey", "decryption key", OFFSET(key), FF_OPT_TYPE_BINARY, 0, 0, 0, D},
59 55
 {"indexmem", "max memory used for timestamp index (per stream)", OFFSET(max_index_size), FF_OPT_TYPE_INT, 1<<20, 0, INT_MAX, D},
... ...
@@ -508,10 +508,6 @@ int av_open_input_stream(AVFormatContext **ic_ptr,
508 508
     if (pb && !ic->data_offset)
509 509
         ic->data_offset = avio_tell(ic->pb);
510 510
 
511
-#if FF_API_OLD_METADATA
512
-    ff_metadata_demux_compat(ic);
513
-#endif
514
-
515 511
     ic->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE;
516 512
 
517 513
     *ic_ptr = ic;
... ...
@@ -2617,18 +2613,11 @@ void avformat_free_context(AVFormatContext *s)
2617 2617
         av_free(st->codec->extradata);
2618 2618
         av_free(st->codec->subtitle_header);
2619 2619
         av_free(st->codec);
2620
-#if FF_API_OLD_METADATA
2621
-        av_free(st->filename);
2622
-#endif
2623 2620
         av_free(st->priv_data);
2624 2621
         av_free(st->info);
2625 2622
         av_free(st);
2626 2623
     }
2627 2624
     for(i=s->nb_programs-1; i>=0; i--) {
2628
-#if FF_API_OLD_METADATA
2629
-        av_freep(&s->programs[i]->provider_name);
2630
-        av_freep(&s->programs[i]->name);
2631
-#endif
2632 2625
         av_metadata_free(&s->programs[i]->metadata);
2633 2626
         av_freep(&s->programs[i]->stream_index);
2634 2627
         av_freep(&s->programs[i]);
... ...
@@ -2636,9 +2625,6 @@ void avformat_free_context(AVFormatContext *s)
2636 2636
     av_freep(&s->programs);
2637 2637
     av_freep(&s->priv_data);
2638 2638
     while(s->nb_chapters--) {
2639
-#if FF_API_OLD_METADATA
2640
-        av_free(s->chapters[s->nb_chapters]->title);
2641
-#endif
2642 2639
         av_metadata_free(&s->chapters[s->nb_chapters]->metadata);
2643 2640
         av_free(s->chapters[s->nb_chapters]);
2644 2641
     }
... ...
@@ -2747,9 +2733,6 @@ AVChapter *ff_new_chapter(AVFormatContext *s, int id, AVRational time_base, int6
2747 2747
             return NULL;
2748 2748
         dynarray_add(&s->chapters, &s->nb_chapters, chapter);
2749 2749
     }
2750
-#if FF_API_OLD_METADATA
2751
-    av_free(chapter->title);
2752
-#endif
2753 2750
     av_metadata_set2(&chapter->metadata, "title", title, 0);
2754 2751
     chapter->id    = id;
2755 2752
     chapter->time_base= time_base;
... ...
@@ -2887,10 +2870,6 @@ int av_write_header(AVFormatContext *s)
2887 2887
             return AVERROR(ENOMEM);
2888 2888
     }
2889 2889
 
2890
-#if FF_API_OLD_METADATA
2891
-    ff_metadata_mux_compat(s);
2892
-#endif
2893
-
2894 2890
     /* set muxer identification string */
2895 2891
     if (s->nb_streams && !(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT)) {
2896 2892
         av_metadata_set2(&s->metadata, "encoder", LIBAVFORMAT_IDENT, 0);
... ...
@@ -41,9 +41,6 @@
41 41
  * Those FF_API_* defines are not part of public API.
42 42
  * They may change, break or disappear at any time.
43 43
  */
44
-#ifndef FF_API_OLD_METADATA
45
-#define FF_API_OLD_METADATA            (LIBAVFORMAT_VERSION_MAJOR < 53)
46
-#endif
47 44
 #ifndef FF_API_OLD_METADATA2
48 45
 #define FF_API_OLD_METADATA2           (LIBAVFORMAT_VERSION_MAJOR < 54)
49 46
 #endif