Mercurial > audlegacy
annotate Plugins/Input/wma/libffwma/aviobuf.c @ 210:12004b385a96 trunk
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
author | chainsaw |
---|---|
date | Sat, 19 Nov 2005 14:42:28 -0800 |
parents | b8d4c1faa6d7 |
children | 0bea7509d6ba |
rev | line source |
---|---|
137 | 1 /* |
2 * Buffered I/O for ffmpeg system | |
3 * Copyright (c) 2000,2001 Fabrice Bellard | |
4 * | |
5 * This library is free software; you can redistribute it and/or | |
6 * modify it under the terms of the GNU Lesser General Public | |
7 * License as published by the Free Software Foundation; either | |
8 * version 2 of the License, or (at your option) any later version. | |
9 * | |
10 * This library is distributed in the hope that it will be useful, | |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 * Lesser General Public License for more details. | |
14 * | |
15 * You should have received a copy of the GNU Lesser General Public | |
16 * License along with this library; if not, write to the Free Software | |
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 */ | |
19 #include "avformat.h" | |
20 #include "avio.h" | |
210
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
21 #include "avcodec.h" |
137 | 22 #include <stdarg.h> |
23 | |
24 #define IO_BUFFER_SIZE 32768 | |
25 | |
26 int init_put_byte(ByteIOContext *s, | |
27 unsigned char *buffer, | |
28 int buffer_size, | |
29 int write_flag, | |
30 void *opaque, | |
31 int (*read_packet)(void *opaque, uint8_t *buf, int buf_size), | |
32 void (*write_packet)(void *opaque, uint8_t *buf, int buf_size), | |
33 int (*seek)(void *opaque, offset_t offset, int whence)) | |
34 { | |
35 s->buffer = buffer; | |
36 s->buffer_size = buffer_size; | |
37 s->buf_ptr = buffer; | |
38 s->write_flag = write_flag; | |
39 if (!s->write_flag) | |
40 s->buf_end = buffer; | |
41 else | |
42 s->buf_end = buffer + buffer_size; | |
43 s->opaque = opaque; | |
44 s->write_packet = write_packet; | |
45 s->read_packet = read_packet; | |
46 s->seek = seek; | |
47 s->pos = 0; | |
48 s->must_flush = 0; | |
49 s->eof_reached = 0; | |
50 s->is_streamed = 0; | |
51 s->max_packet_size = 0; | |
52 return 0; | |
53 } | |
54 | |
210
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
55 |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
56 #ifdef CONFIG_ENCODERS |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
57 static void flush_buffer(ByteIOContext *s) |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
58 { |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
59 if (s->buf_ptr > s->buffer) { |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
60 if (s->write_packet) |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
61 s->write_packet(s->opaque, s->buffer, s->buf_ptr - s->buffer); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
62 s->pos += s->buf_ptr - s->buffer; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
63 } |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
64 s->buf_ptr = s->buffer; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
65 } |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
66 |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
67 void put_byte(ByteIOContext *s, int b) |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
68 { |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
69 *(s->buf_ptr)++ = b; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
70 if (s->buf_ptr >= s->buf_end) |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
71 flush_buffer(s); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
72 } |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
73 |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
74 void put_buffer(ByteIOContext *s, const unsigned char *buf, int size) |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
75 { |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
76 int len; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
77 |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
78 while (size > 0) { |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
79 len = (s->buf_end - s->buf_ptr); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
80 if (len > size) |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
81 len = size; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
82 memcpy(s->buf_ptr, buf, len); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
83 s->buf_ptr += len; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
84 |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
85 if (s->buf_ptr >= s->buf_end) |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
86 flush_buffer(s); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
87 |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
88 buf += len; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
89 size -= len; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
90 } |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
91 } |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
92 |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
93 void put_flush_packet(ByteIOContext *s) |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
94 { |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
95 flush_buffer(s); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
96 s->must_flush = 0; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
97 } |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
98 #endif //CONFIG_ENCODERS |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
99 |
137 | 100 offset_t url_fseek(ByteIOContext *s, offset_t offset, int whence) |
101 { | |
102 offset_t offset1; | |
103 | |
104 if (whence != SEEK_CUR && whence != SEEK_SET) | |
105 return -EINVAL; | |
210
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
106 |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
107 #ifdef CONFIG_ENCODERS |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
108 if (s->write_flag) { |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
109 if (whence == SEEK_CUR) { |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
110 offset1 = s->pos + (s->buf_ptr - s->buffer); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
111 if (offset == 0) |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
112 return offset1; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
113 offset += offset1; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
114 } |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
115 offset1 = offset - s->pos; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
116 if (!s->must_flush && |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
117 offset1 >= 0 && offset1 < (s->buf_end - s->buffer)) { |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
118 /* can do the seek inside the buffer */ |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
119 s->buf_ptr = s->buffer + offset1; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
120 } else { |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
121 if (!s->seek) |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
122 return -EPIPE; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
123 flush_buffer(s); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
124 s->must_flush = 1; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
125 s->buf_ptr = s->buffer; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
126 s->seek(s->opaque, offset, SEEK_SET); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
127 s->pos = offset; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
128 } |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
129 } else |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
130 #endif //CONFIG_ENCODERS |
137 | 131 { |
132 if (whence == SEEK_CUR) { | |
133 offset1 = s->pos - (s->buf_end - s->buffer) + (s->buf_ptr - s->buffer); | |
134 if (offset == 0) | |
135 return offset1; | |
136 offset += offset1; | |
137 } | |
138 offset1 = offset - (s->pos - (s->buf_end - s->buffer)); | |
139 if (offset1 >= 0 && offset1 <= (s->buf_end - s->buffer)) { | |
140 /* can do the seek inside the buffer */ | |
141 s->buf_ptr = s->buffer + offset1; | |
142 } else { | |
143 if (!s->seek) | |
144 return -EPIPE; | |
145 s->buf_ptr = s->buffer; | |
146 s->buf_end = s->buffer; | |
147 s->seek(s->opaque, offset, SEEK_SET); | |
148 s->pos = offset; | |
149 } | |
150 s->eof_reached = 0; | |
151 } | |
152 return offset; | |
153 } | |
154 | |
155 void url_fskip(ByteIOContext *s, offset_t offset) | |
156 { | |
157 url_fseek(s, offset, SEEK_CUR); | |
158 } | |
159 | |
160 offset_t url_ftell(ByteIOContext *s) | |
161 { | |
162 return url_fseek(s, 0, SEEK_CUR); | |
163 } | |
164 | |
165 int url_feof(ByteIOContext *s) | |
166 { | |
167 return s->eof_reached; | |
168 } | |
169 | |
210
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
170 #ifdef CONFIG_ENCODERS |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
171 void put_le32(ByteIOContext *s, unsigned int val) |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
172 { |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
173 put_byte(s, val); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
174 put_byte(s, val >> 8); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
175 put_byte(s, val >> 16); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
176 put_byte(s, val >> 24); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
177 } |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
178 |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
179 void put_be32(ByteIOContext *s, unsigned int val) |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
180 { |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
181 put_byte(s, val >> 24); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
182 put_byte(s, val >> 16); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
183 put_byte(s, val >> 8); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
184 put_byte(s, val); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
185 } |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
186 |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
187 /* IEEE format is assumed */ |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
188 void put_be64_double(ByteIOContext *s, double val) |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
189 { |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
190 union { |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
191 double d; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
192 uint64_t ull; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
193 } u; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
194 u.d = val; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
195 put_be64(s, u.ull); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
196 } |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
197 |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
198 void put_strz(ByteIOContext *s, const char *str) |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
199 { |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
200 if (str) |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
201 put_buffer(s, (const unsigned char *) str, strlen(str) + 1); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
202 else |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
203 put_byte(s, 0); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
204 } |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
205 |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
206 void put_le64(ByteIOContext *s, uint64_t val) |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
207 { |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
208 put_le32(s, (uint32_t)(val & 0xffffffff)); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
209 put_le32(s, (uint32_t)(val >> 32)); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
210 } |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
211 |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
212 void put_be64(ByteIOContext *s, uint64_t val) |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
213 { |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
214 put_be32(s, (uint32_t)(val >> 32)); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
215 put_be32(s, (uint32_t)(val & 0xffffffff)); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
216 } |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
217 |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
218 void put_le16(ByteIOContext *s, unsigned int val) |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
219 { |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
220 put_byte(s, val); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
221 put_byte(s, val >> 8); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
222 } |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
223 |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
224 void put_be16(ByteIOContext *s, unsigned int val) |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
225 { |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
226 put_byte(s, val >> 8); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
227 put_byte(s, val); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
228 } |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
229 |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
230 void put_tag(ByteIOContext *s, const char *tag) |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
231 { |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
232 while (*tag) { |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
233 put_byte(s, *tag++); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
234 } |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
235 } |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
236 #endif //CONFIG_ENCODERS |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
237 |
137 | 238 /* Input stream */ |
239 | |
240 static void fill_buffer(ByteIOContext *s) | |
241 { | |
242 int len; | |
243 | |
244 /* no need to do anything if EOF already reached */ | |
245 if (s->eof_reached) | |
246 return; | |
247 len = s->read_packet(s->opaque, s->buffer, s->buffer_size); | |
248 if (len <= 0) { | |
249 /* do not modify buffer if EOF reached so that a seek back can | |
250 be done without rereading data */ | |
251 s->eof_reached = 1; | |
252 } else { | |
253 s->pos += len; | |
254 s->buf_ptr = s->buffer; | |
255 s->buf_end = s->buffer + len; | |
256 } | |
257 } | |
258 | |
259 /* NOTE: return 0 if EOF, so you cannot use it if EOF handling is | |
260 necessary */ | |
261 /* XXX: put an inline version */ | |
262 int get_byte(ByteIOContext *s) | |
263 { | |
264 if (s->buf_ptr < s->buf_end) { | |
265 return *s->buf_ptr++; | |
266 } else { | |
267 fill_buffer(s); | |
268 if (s->buf_ptr < s->buf_end) | |
269 return *s->buf_ptr++; | |
270 else | |
271 return 0; | |
272 } | |
273 } | |
274 | |
275 /* NOTE: return URL_EOF (-1) if EOF */ | |
276 int url_fgetc(ByteIOContext *s) | |
277 { | |
278 if (s->buf_ptr < s->buf_end) { | |
279 return *s->buf_ptr++; | |
280 } else { | |
281 fill_buffer(s); | |
282 if (s->buf_ptr < s->buf_end) | |
283 return *s->buf_ptr++; | |
284 else | |
285 return URL_EOF; | |
286 } | |
287 } | |
288 | |
289 int get_buffer(ByteIOContext *s, unsigned char *buf, int size) | |
290 { | |
291 int len, size1; | |
292 | |
293 size1 = size; | |
294 while (size > 0) { | |
295 len = s->buf_end - s->buf_ptr; | |
296 if (len > size) | |
297 len = size; | |
298 if (len == 0) { | |
299 fill_buffer(s); | |
300 len = s->buf_end - s->buf_ptr; | |
301 if (len == 0) | |
302 break; | |
303 } else { | |
304 memcpy(buf, s->buf_ptr, len); | |
305 buf += len; | |
306 s->buf_ptr += len; | |
307 size -= len; | |
308 } | |
309 } | |
310 return size1 - size; | |
311 } | |
312 | |
313 unsigned int get_le16(ByteIOContext *s) | |
314 { | |
315 unsigned int val; | |
316 val = get_byte(s); | |
317 val |= get_byte(s) << 8; | |
318 return val; | |
319 } | |
320 | |
321 unsigned int get_le32(ByteIOContext *s) | |
322 { | |
323 unsigned int val; | |
324 val = get_byte(s); | |
325 val |= get_byte(s) << 8; | |
326 val |= get_byte(s) << 16; | |
327 val |= get_byte(s) << 24; | |
328 return val; | |
329 } | |
330 | |
331 uint64_t get_le64(ByteIOContext *s) | |
332 { | |
333 uint64_t val; | |
334 val = (uint64_t)get_le32(s); | |
335 val |= (uint64_t)get_le32(s) << 32; | |
336 return val; | |
337 } | |
338 | |
339 unsigned int get_be16(ByteIOContext *s) | |
340 { | |
341 unsigned int val; | |
342 val = get_byte(s) << 8; | |
343 val |= get_byte(s); | |
344 return val; | |
345 } | |
346 | |
347 unsigned int get_be32(ByteIOContext *s) | |
348 { | |
349 unsigned int val; | |
350 val = get_byte(s) << 24; | |
351 val |= get_byte(s) << 16; | |
352 val |= get_byte(s) << 8; | |
353 val |= get_byte(s); | |
354 return val; | |
355 } | |
356 | |
357 double get_be64_double(ByteIOContext *s) | |
358 { | |
359 union { | |
360 double d; | |
361 uint64_t ull; | |
362 } u; | |
363 | |
364 u.ull = get_be64(s); | |
365 return u.d; | |
366 } | |
367 | |
368 char *get_strz(ByteIOContext *s, char *buf, int maxlen) | |
369 { | |
370 int i = 0; | |
371 char c; | |
372 | |
373 while ((c = get_byte(s))) { | |
374 if (i < maxlen-1) | |
375 buf[i++] = c; | |
376 } | |
377 | |
378 buf[i] = 0; /* Ensure null terminated, but may be truncated */ | |
379 | |
380 return buf; | |
381 } | |
382 | |
383 uint64_t get_be64(ByteIOContext *s) | |
384 { | |
385 uint64_t val; | |
386 val = (uint64_t)get_be32(s) << 32; | |
387 val |= (uint64_t)get_be32(s); | |
388 return val; | |
389 } | |
390 | |
391 /* link with avio functions */ | |
392 | |
210
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
393 #ifdef CONFIG_ENCODERS |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
394 static void url_write_packet(void *opaque, uint8_t *buf, int buf_size) |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
395 { |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
396 URLContext *h = opaque; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
397 url_write(h, buf, buf_size); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
398 } |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
399 #else |
137 | 400 #define url_write_packet NULL |
210
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
401 #endif //CONFIG_ENCODERS |
137 | 402 |
403 static int url_read_packet(void *opaque, uint8_t *buf, int buf_size) | |
404 { | |
405 URLContext *h = opaque; | |
406 return url_read(h, buf, buf_size); | |
407 } | |
408 | |
409 static int url_seek_packet(void *opaque, int64_t offset, int whence) | |
410 { | |
411 URLContext *h = opaque; | |
412 url_seek(h, offset, whence); | |
413 return 0; | |
414 } | |
415 | |
416 int url_fdopen(ByteIOContext *s, URLContext *h) | |
417 { | |
418 uint8_t *buffer; | |
419 int buffer_size, max_packet_size; | |
420 | |
421 | |
422 max_packet_size = url_get_max_packet_size(h); | |
423 if (max_packet_size) { | |
424 buffer_size = max_packet_size; /* no need to bufferize more than one packet */ | |
425 } else { | |
426 buffer_size = IO_BUFFER_SIZE; | |
427 } | |
210
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
428 buffer = av_malloc(buffer_size); |
137 | 429 if (!buffer) |
430 return -ENOMEM; | |
431 | |
432 if (init_put_byte(s, buffer, buffer_size, | |
433 (h->flags & URL_WRONLY) != 0, h, | |
434 url_read_packet, url_write_packet, url_seek_packet) < 0) { | |
210
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
435 av_free(buffer); |
137 | 436 return -EIO; |
437 } | |
438 s->is_streamed = h->is_streamed; | |
439 s->max_packet_size = max_packet_size; | |
440 return 0; | |
441 } | |
442 | |
443 /* XXX: must be called before any I/O */ | |
444 int url_setbufsize(ByteIOContext *s, int buf_size) | |
445 { | |
446 uint8_t *buffer; | |
210
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
447 buffer = av_malloc(buf_size); |
137 | 448 if (!buffer) |
449 return -ENOMEM; | |
450 | |
210
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
451 av_free(s->buffer); |
137 | 452 s->buffer = buffer; |
453 s->buffer_size = buf_size; | |
454 s->buf_ptr = buffer; | |
455 if (!s->write_flag) | |
456 s->buf_end = buffer; | |
457 else | |
458 s->buf_end = buffer + buf_size; | |
459 return 0; | |
460 } | |
461 | |
462 /* NOTE: when opened as read/write, the buffers are only used for | |
463 reading */ | |
464 int url_fopen(ByteIOContext *s, const char *filename, int flags) | |
465 { | |
466 URLContext *h; | |
467 int err; | |
468 | |
469 err = url_open(&h, filename, flags); | |
470 if (err < 0) | |
471 return err; | |
472 err = url_fdopen(s, h); | |
473 if (err < 0) { | |
474 url_close(h); | |
475 return err; | |
476 } | |
477 return 0; | |
478 } | |
479 | |
480 int url_fclose(ByteIOContext *s) | |
481 { | |
482 URLContext *h = s->opaque; | |
483 | |
210
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
484 av_free(s->buffer); |
137 | 485 memset(s, 0, sizeof(ByteIOContext)); |
486 return url_close(h); | |
487 } | |
488 | |
489 URLContext *url_fileno(ByteIOContext *s) | |
490 { | |
491 return s->opaque; | |
492 } | |
493 | |
210
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
494 #ifdef CONFIG_ENCODERS |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
495 /* XXX: currently size is limited */ |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
496 int url_fprintf(ByteIOContext *s, const char *fmt, ...) |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
497 { |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
498 va_list ap; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
499 char buf[4096]; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
500 int ret; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
501 |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
502 va_start(ap, fmt); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
503 ret = vsnprintf(buf, sizeof(buf), fmt, ap); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
504 va_end(ap); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
505 put_buffer(s, buf, strlen(buf)); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
506 return ret; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
507 } |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
508 #endif //CONFIG_ENCODERS |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
509 |
137 | 510 /* note: unlike fgets, the EOL character is not returned and a whole |
511 line is parsed. return NULL if first char read was EOF */ | |
512 char *url_fgets(ByteIOContext *s, char *buf, int buf_size) | |
513 { | |
514 int c; | |
515 char *q; | |
516 | |
517 c = url_fgetc(s); | |
518 if (c == EOF) | |
519 return NULL; | |
520 q = buf; | |
521 for(;;) { | |
522 if (c == EOF || c == '\n') | |
523 break; | |
524 if ((q - buf) < buf_size - 1) | |
525 *q++ = c; | |
526 c = url_fgetc(s); | |
527 } | |
528 if (buf_size > 0) | |
529 *q = '\0'; | |
530 return buf; | |
531 } | |
532 | |
533 /* | |
534 * Return the maximum packet size associated to packetized buffered file | |
535 * handle. If the file is not packetized (stream like http or file on | |
536 * disk), then 0 is returned. | |
537 * | |
538 * @param h buffered file handle | |
539 * @return maximum packet size in bytes | |
540 */ | |
541 int url_fget_max_packet_size(ByteIOContext *s) | |
542 { | |
543 return s->max_packet_size; | |
544 } | |
545 | |
210
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
546 #ifdef CONFIG_ENCODERS |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
547 /* buffer handling */ |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
548 int url_open_buf(ByteIOContext *s, uint8_t *buf, int buf_size, int flags) |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
549 { |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
550 return init_put_byte(s, buf, buf_size, |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
551 (flags & URL_WRONLY) != 0, NULL, NULL, NULL, NULL); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
552 } |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
553 |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
554 /* return the written or read size */ |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
555 int url_close_buf(ByteIOContext *s) |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
556 { |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
557 put_flush_packet(s); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
558 return s->buf_ptr - s->buffer; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
559 } |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
560 |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
561 /* output in a dynamic buffer */ |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
562 |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
563 typedef struct DynBuffer { |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
564 int pos, size, allocated_size; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
565 uint8_t *buffer; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
566 int io_buffer_size; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
567 uint8_t io_buffer[1]; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
568 } DynBuffer; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
569 |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
570 static void dyn_buf_write(void *opaque, uint8_t *buf, int buf_size) |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
571 { |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
572 DynBuffer *d = opaque; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
573 int new_size, new_allocated_size; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
574 |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
575 /* reallocate buffer if needed */ |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
576 new_size = d->pos + buf_size; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
577 new_allocated_size = d->allocated_size; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
578 while (new_size > new_allocated_size) { |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
579 if (!new_allocated_size) |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
580 new_allocated_size = new_size; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
581 else |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
582 new_allocated_size = (new_allocated_size * 3) / 2 + 1; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
583 } |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
584 |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
585 if (new_allocated_size > d->allocated_size) { |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
586 d->buffer = av_realloc(d->buffer, new_allocated_size); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
587 if(d->buffer == NULL) |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
588 return ; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
589 d->allocated_size = new_allocated_size; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
590 } |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
591 memcpy(d->buffer + d->pos, buf, buf_size); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
592 d->pos = new_size; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
593 if (d->pos > d->size) |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
594 d->size = d->pos; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
595 } |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
596 |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
597 static void dyn_packet_buf_write(void *opaque, uint8_t *buf, int buf_size) |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
598 { |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
599 unsigned char buf1[4]; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
600 |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
601 /* packetized write: output the header */ |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
602 buf1[0] = (buf_size >> 24); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
603 buf1[1] = (buf_size >> 16); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
604 buf1[2] = (buf_size >> 8); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
605 buf1[3] = (buf_size); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
606 dyn_buf_write(opaque, buf1, 4); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
607 |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
608 /* then the data */ |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
609 dyn_buf_write(opaque, buf, buf_size); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
610 } |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
611 |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
612 static int dyn_buf_seek(void *opaque, offset_t offset, int whence) |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
613 { |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
614 DynBuffer *d = opaque; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
615 |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
616 if (whence == SEEK_CUR) |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
617 offset += d->pos; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
618 else if (whence == SEEK_END) |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
619 offset += d->size; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
620 if (offset < 0 || offset > 0x7fffffffLL) |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
621 return -1; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
622 d->pos = offset; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
623 return 0; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
624 } |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
625 |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
626 static int url_open_dyn_buf_internal(ByteIOContext *s, int max_packet_size) |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
627 { |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
628 DynBuffer *d; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
629 int io_buffer_size, ret; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
630 |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
631 if (max_packet_size) |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
632 io_buffer_size = max_packet_size; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
633 else |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
634 io_buffer_size = 1024; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
635 |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
636 d = av_malloc(sizeof(DynBuffer) + io_buffer_size); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
637 if (!d) |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
638 return -1; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
639 d->io_buffer_size = io_buffer_size; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
640 d->buffer = NULL; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
641 d->pos = 0; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
642 d->size = 0; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
643 d->allocated_size = 0; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
644 ret = init_put_byte(s, d->io_buffer, io_buffer_size, |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
645 1, d, NULL, |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
646 max_packet_size ? dyn_packet_buf_write : dyn_buf_write, |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
647 max_packet_size ? NULL : dyn_buf_seek); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
648 if (ret == 0) { |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
649 s->max_packet_size = max_packet_size; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
650 } |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
651 return ret; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
652 } |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
653 |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
654 /* |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
655 * Open a write only memory stream. |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
656 * |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
657 * @param s new IO context |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
658 * @return zero if no error. |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
659 */ |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
660 int url_open_dyn_buf(ByteIOContext *s) |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
661 { |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
662 return url_open_dyn_buf_internal(s, 0); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
663 } |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
664 |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
665 /* |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
666 * Open a write only packetized memory stream with a maximum packet |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
667 * size of 'max_packet_size'. The stream is stored in a memory buffer |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
668 * with a big endian 4 byte header giving the packet size in bytes. |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
669 * |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
670 * @param s new IO context |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
671 * @param max_packet_size maximum packet size (must be > 0) |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
672 * @return zero if no error. |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
673 */ |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
674 int url_open_dyn_packet_buf(ByteIOContext *s, int max_packet_size) |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
675 { |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
676 if (max_packet_size <= 0) |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
677 return -1; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
678 return url_open_dyn_buf_internal(s, max_packet_size); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
679 } |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
680 |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
681 /* |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
682 * Return the written size and a pointer to the buffer. The buffer |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
683 * must be freed with av_free(). |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
684 * @param s IO context |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
685 * @param pointer to a byte buffer |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
686 * @return the length of the byte buffer |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
687 */ |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
688 int url_close_dyn_buf(ByteIOContext *s, uint8_t **pbuffer) |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
689 { |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
690 DynBuffer *d = s->opaque; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
691 int size; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
692 |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
693 put_flush_packet(s); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
694 |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
695 *pbuffer = d->buffer; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
696 size = d->size; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
697 av_free(d); |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
698 return size; |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
699 } |
12004b385a96
[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents:
137
diff
changeset
|
700 #endif //CONFIG_ENCODERS |