~ubuntu-branches/ubuntu/wily/mediatomb/wily

« back to all changes in this revision

Viewing changes to debian/patches/0006a_fix_libmp4v2_build.patch

  • Committer: Package Import Robot
  • Author(s): Steve Langasek
  • Date: 2015-08-12 15:51:30 UTC
  • mfrom: (4.1.15 sid)
  • Revision ID: package-import@ubuntu.com-20150812155130-54v3y5zta9oyuejg
Tags: 0.12.1-47-g7ab7616-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - debian/control:
    + Don't build-depend on libmozjs-dev.
  - debian/{mediatomb-daemon.mediatomb.upstart,rules}: Introduce upstart
    support to fix start-on-boot failure.
  - debian/rules: Disable JS support.
* Dropped changes:
  - drop OR depends on abrowser, which last existed in precise.
  - debian/mediatomb-daemon.postinst: no reason this needs an executable
    bit in the source package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Description: Fix build against libmp4v2.
 
2
Author: Peter Asplund
 
3
Forwarded: yes, http://sourceforge.net/p/mediatomb/patches/35/
 
4
Bug-Debian: http://bugs.debian.org/677958
 
5
 
 
6
--- a/src/metadata/libmp4v2_handler.cc
 
7
+++ b/src/metadata/libmp4v2_handler.cc
 
8
@@ -65,29 +65,28 @@
 
9
 static void addMetaField(metadata_fields_t field, MP4FileHandle mp4, Ref<CdsItem> item)
 
10
 {
 
11
     String value;
 
12
-    char*  mp4_retval = NULL;
 
13
-    u_int16_t track;
 
14
-    u_int16_t total_tracks;
 
15
 
16
     Ref<StringConverter> sc = StringConverter::i2i();
 
17
     
 
18
+    const MP4Tags* new_tags = MP4TagsAlloc();
 
19
+
 
20
+    if (!MP4TagsFetch(new_tags, mp4))
 
21
+        return;
 
22
+
 
23
     switch (field)
 
24
     {
 
25
         case M_TITLE:
 
26
-            MP4GetMetadataName(mp4, &mp4_retval);
 
27
+            value = new_tags->name;
 
28
             break;
 
29
         case M_ARTIST:
 
30
-            MP4GetMetadataArtist(mp4, &mp4_retval);
 
31
+            value = new_tags->artist;
 
32
             break;
 
33
         case M_ALBUM:
 
34
-            MP4GetMetadataAlbum(mp4, &mp4_retval);
 
35
+            value = new_tags->album;
 
36
             break;
 
37
         case M_DATE:
 
38
-            MP4GetMetadataYear(mp4, &mp4_retval);
 
39
-            if (mp4_retval)
 
40
+            value = new_tags->releaseDate;
 
41
+            if (value.length() > 0)
 
42
             {
 
43
-                value = mp4_retval;
 
44
-                free(mp4_retval);
 
45
                 if (string_ok(value))
 
46
                     value = value + "-01-01";
 
47
                 else
 
48
@@ -95,34 +94,31 @@
 
49
             }
 
50
             break;
 
51
         case M_GENRE:
 
52
-            MP4GetMetadataGenre(mp4, &mp4_retval);
 
53
+            value = new_tags->genre;
 
54
             break;
 
55
         case M_DESCRIPTION:
 
56
-            MP4GetMetadataComment(mp4, &mp4_retval);
 
57
+            value = new_tags->comments;
 
58
             break;
 
59
         case M_TRACKNUMBER:
 
60
-            MP4GetMetadataTrack(mp4, &track, &total_tracks);
 
61
-            if (track > 0)
 
62
+            if (new_tags->track)
 
63
             {
 
64
-                value = String::from(track);
 
65
-                item->setTrackNumber((int)track);
 
66
+                value = String::from(new_tags->track->index);
 
67
+                item->setTrackNumber((int)new_tags->track->index);
 
68
             }
 
69
             else
 
70
+                       {
 
71
+                           MP4TagsFree( new_tags );
 
72
                 return;
 
73
+            }
 
74
             break;
 
75
         default:
 
76
+                       MP4TagsFree( new_tags );
 
77
             return;
 
78
     }
 
79
 
 
80
-    if ((field != M_DATE) && (field != M_TRACKNUMBER) && 
 
81
-        (mp4_retval))
 
82
-    {
 
83
-        value = mp4_retval;
 
84
-        free(mp4_retval);
 
85
-    }
 
86
-    
 
87
+       MP4TagsFree( new_tags );
 
88
     value = trim_string(value);
 
89
-    
 
90
+
 
91
     if (string_ok(value))
 
92
     {
 
93
         item->setMetadata(MT_KEYS[field].upnp, sc->convert(value));
 
94
@@ -190,14 +186,19 @@
 
95
         }
 
96
 
 
97
 #if defined(HAVE_MAGIC)
 
98
-        u_int8_t *art_data;
 
99
-        u_int32_t art_data_len;
 
100
+        void *art_data = 0;
 
101
+        u_int32_t art_data_len = 0;
 
102
         String art_mimetype;
 
103
+
 
104
+        const MP4Tags* new_tags = MP4TagsAlloc();
 
105
+        MP4TagsFetch(new_tags, mp4);
 
106
+        if (new_tags->artworkCount)
 
107
+        {
 
108
+            art_data = new_tags->artwork->data;
 
109
+            art_data_len = new_tags->artwork->size;
 
110
+        }
 
111
 #ifdef HAVE_MP4_GET_METADATA_COVER_ART_COUNT
 
112
-        if (MP4GetMetadataCoverArtCount(mp4) && 
 
113
-            MP4GetMetadataCoverArt(mp4, &art_data, &art_data_len))
 
114
-#else
 
115
-            MP4GetMetadataCoverArt(mp4, &art_data, &art_data_len);
 
116
+        if (new_tags->artworkCount && art_data_len > 0) 
 
117
 #endif
 
118
         {
 
119
             if (art_data)
 
120
@@ -211,11 +212,10 @@
 
121
                 }
 
122
                 catch (Exception ex)
 
123
                 {
 
124
-                    free(art_data);
 
125
+                    MP4TagsFree(new_tags);
 
126
                     throw ex;
 
127
                 }
 
128
 
 
129
-                free(art_data);
 
130
                 if (art_mimetype != _(MIMETYPE_DEFAULT))
 
131
                 {
 
132
                     Ref<CdsResource> resource(new CdsResource(CH_MP4));
 
133
@@ -225,6 +225,7 @@
 
134
                 }
 
135
             }
 
136
         }
 
137
+        MP4TagsFree(new_tags);
 
138
 #endif
 
139
         MP4Close(mp4);
 
140
     }
 
141
@@ -249,26 +250,35 @@
 
142
 
 
143
     if (ctype != ID3_ALBUM_ART)
 
144
         throw _Exception(_("LibMP4V2Handler: got unknown content type: ") + ctype);
 
145
+
 
146
+    const MP4Tags* new_tags = MP4TagsAlloc();
 
147
+    if (MP4TagsFetch(new_tags, mp4))
 
148
+    {
 
149
 #ifdef HAVE_MP4_GET_METADATA_COVER_ART_COUNT
 
150
-    if (!MP4GetMetadataCoverArtCount(mp4))
 
151
-        throw _Exception(_("LibMP4V2Handler: resource has no album art information"));
 
152
+        if (!new_tags->artworkCount)
 
153
+            throw _Exception(_("LibMP4V2Handler: resource has no album art information"));
 
154
 #endif
 
155
-    u_int8_t *art_data;
 
156
-    u_int32_t art_data_len;
 
157
-    if (MP4GetMetadataCoverArt(mp4, &art_data, &art_data_len))
 
158
-    {
 
159
-        if (art_data)
 
160
+        void *art_data = 0;
 
161
+        u_int32_t art_data_len;
 
162
+
 
163
+        const MP4TagArtwork* art = new_tags->artwork;
 
164
+        art_data = art->data;
 
165
+        art_data_len = art->size;
 
166
+        if (art)
 
167
         {
 
168
-            *data_size = (off_t)art_data_len;
 
169
-            Ref<IOHandler> h(new MemIOHandler((void *)art_data, art_data_len));
 
170
-            free(art_data);
 
171
-            return h;
 
172
+            if (art_data)
 
173
+            {
 
174
+                *data_size = (off_t)art_data_len;
 
175
+                Ref<IOHandler> h(new MemIOHandler(art_data, art_data_len));
 
176
+                MP4TagsFree(new_tags);
 
177
+                return h;
 
178
+            }
 
179
         }
 
180
+        MP4TagsFree(new_tags);
 
181
     }
 
182
-        
 
183
     throw _Exception(_("LibMP4V2Handler: could not serve album art "
 
184
-                           "for file") + item->getLocation() + 
 
185
-                           " - embedded image not found");
 
186
+            "for file") + item->getLocation() + 
 
187
+        " - embedded image not found");
 
188
 }
 
189
 
 
190
 #endif // HAVE_LIBMP4V2