Fresh pull from upstream (stable) package feed
[librecmc/package-feed.git] / multimedia / icecast / patches / 001-icecast-2.4.0-tremor.patch
1 --- a/src/format_vorbis.c
2 +++ b/src/format_vorbis.c
3 @@ -19,7 +19,7 @@
4  
5  #include <stdlib.h>
6  #include <ogg/ogg.h>
7 -#include <vorbis/codec.h>
8 +#include <tremor/ivorbiscodec.h>
9  #include <memory.h>
10  #include <string.h>
11  
12 @@ -34,6 +34,7 @@
13  #define CATMODULE "format-vorbis"
14  #include "logging.h"
15  
16 +int vorbis_commentheader_out(vorbis_comment *vc, ogg_packet *op);
17  
18  typedef struct vorbis_codec_tag
19  {
20 @@ -583,3 +584,91 @@ static refbuf_t *process_vorbis_page (og
21      return NULL;
22  }
23  
24 +/* Some additional functions from vorbis missing from tremor */
25 +
26 +static void _v_writestring(oggpack_buffer *o,char *s, int bytes)
27 +{
28 +
29 +  while(bytes--){
30 +    oggpack_write(o,*s++,8);
31 +  }
32 +}
33 +
34 +static int _vorbis_pack_comment(oggpack_buffer *opb,vorbis_comment *vc)
35 +{
36 +  char temp[]="Xiph.Org libVorbis I 20150104";
37 +  int bytes = strlen(temp);
38 +
39 +  /* preamble */
40 +  oggpack_write(opb,0x03,8);
41 +  _v_writestring(opb,"vorbis", 6);
42 +
43 +  /* vendor */
44 +  oggpack_write(opb,bytes,32);
45 +  _v_writestring(opb,temp, bytes);
46 +
47 +  /* comments */
48 +
49 +  oggpack_write(opb,vc->comments,32);
50 +  if(vc->comments){
51 +    int i;
52 +    for(i=0;i<vc->comments;i++){
53 +      if(vc->user_comments[i]){
54 +       oggpack_write(opb,vc->comment_lengths[i],32);
55 +       _v_writestring(opb,vc->user_comments[i], vc->comment_lengths[i]);
56 +      }else{
57 +       oggpack_write(opb,0,32);
58 +      }
59 +    }
60 +  }
61 +  oggpack_write(opb,1,1);
62 +
63 +  return(0);
64 +}
65 +
66 +void vorbis_comment_add(vorbis_comment *vc,char *comment)
67 +{
68 +  vc->user_comments=_ogg_realloc(vc->user_comments,
69 +                           (vc->comments+2)*sizeof(*vc->user_comments));
70 +  vc->comment_lengths=_ogg_realloc(vc->comment_lengths,
71 +                           (vc->comments+2)*sizeof(*vc->comment_lengths));
72 +  vc->comment_lengths[vc->comments]=strlen(comment);
73 +  vc->user_comments[vc->comments]=_ogg_malloc(vc->comment_lengths[vc->comments]+1);
74 +  strcpy(vc->user_comments[vc->comments], comment);
75 +  vc->comments++;
76 +  vc->user_comments[vc->comments]=NULL;
77 +}
78 +
79 +void vorbis_comment_add_tag(vorbis_comment *vc, char *tag, char *contents)
80 +{
81 +  char *comment=alloca(strlen(tag)+strlen(contents)+2); /* +2 for = and \0 */
82 +  strcpy(comment, tag);
83 +  strcat(comment, "=");
84 +  strcat(comment, contents);
85 +  vorbis_comment_add(vc, comment);
86 +
87 +  return;
88 +}
89 +
90 +int vorbis_commentheader_out(vorbis_comment *vc, ogg_packet *op)
91 +{
92 +  oggpack_buffer opb;
93 +
94 +  oggpack_writeinit(&opb);
95 +  if(_vorbis_pack_comment(&opb,vc)){
96 +    oggpack_writeclear(&opb);
97 +    return OV_EIMPL;
98 +  }
99 +
100 +  op->packet = _ogg_malloc(oggpack_bytes(&opb));
101 +  memcpy(op->packet, opb.buffer, oggpack_bytes(&opb));
102 +
103 +  op->bytes=oggpack_bytes(&opb);
104 +  op->b_o_s=0;
105 +  op->e_o_s=0;
106 +  op->granulepos=0;
107 +  op->packetno=1;
108 +
109 +  oggpack_writeclear(&opb);
110 +  return 0;
111 +}
112 --- a/m4/vorbis.m4
113 +++ b/m4/vorbis.m4
114 @@ -38,9 +38,9 @@ if test "x$vorbis_prefix" != "x$ogg_pref
115              ])
116  fi
117  
118 -VORBIS_LIBS="-lvorbis"
119 -VORBISFILE_LIBS="-lvorbisfile"
120 -VORBISENC_LIBS="-lvorbisenc"
121 +VORBIS_LIBS="-lvorbisidec"
122 +VORBISFILE_LIBS="-lvorbisidec"
123 +VORBISENC_LIBS="-lvorbisidec"
124  
125  xt_save_LIBS="$LIBS"
126  xt_save_LDFLAGS="$LDFLAGS"
127 @@ -58,18 +58,6 @@ AC_TRY_LINK_FUNC(ogg_stream_init, [xt_li
128              )
129          ])
130  
131 -if test "x$xt_lib_vorbis" = "xok"; then
132 -#
133 -# Now check if the installed Vorbis is sufficiently new.
134 -#
135 -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
136 -#include <vorbis/codec.h>
137 -#include <vorbis/vorbisenc.h>
138 -        ], [
139 -struct ovectl_ratemanage_arg a;
140 -])],,[xt_lib_vorbis="old version found"])
141 -AC_MSG_RESULT([$xt_lib_vorbis])
142 -fi
143  CPPFLAGS="$xt_save_CPPFLAGS"
144  LIBS="$xt_save_LIBS"
145  LDFLAGS="$xt_save_LDFLAGS"
146 --- a/m4/ogg.m4
147 +++ b/m4/ogg.m4
148 @@ -29,7 +29,7 @@ XIPH_GCC_WARNING([-I$ogg_prefix/include]
149        ])
150  AC_CACHE_CHECK([for libogg], xt_cv_lib_ogg,
151  [dnl
152 -OGG_LIBS="-logg"
153 +OGG_LIBS="-lvorbisidec"
154  
155  #
156  # check if the installed Ogg is sufficiently new.