enum StreamType stream_type;
char filename[1024]; /* stream filename */
struct FFStream *feed;
- AVFormat *fmt;
+ AVOutputFormat *fmt;
int nb_streams;
int prebuffer; /* Number of millseconds early to start */
int send_on_key;
}
*q = '\0';
- strlcpy(c->method, cmd, sizeof(c->method));
+ pstrcpy(c->method, sizeof(c->method), cmd);
if (!strcmp(cmd, "GET"))
post = 0;
}
*q = '\0';
- strlcpy(c->url, url, sizeof(c->url));
+ pstrcpy(c->url, sizeof(c->url), url);
while (isspace(*p)) p++;
q = protocol;
if (strcmp(protocol, "HTTP/1.0") && strcmp(protocol, "HTTP/1.1"))
return -1;
- strlcpy(c->protocol, protocol, sizeof(c->protocol));
+ pstrcpy(c->protocol, sizeof(c->protocol), protocol);
/* find the filename and the optional info string in the request */
p = url;
filename = p;
p = strchr(p, '?');
if (p) {
- strlcpy(info, p, sizeof(info));
+ pstrcpy(info, sizeof(info), p);
*p = '\0';
} else {
info[0] = '\0';
char *eosf;
if (stream->feed != stream) {
- strlcpy(sfilename, stream->filename, sizeof(sfilename) - 1);
+ pstrcpy(sfilename, sizeof(sfilename) - 1, stream->filename);
eosf = sfilename + strlen(sfilename);
if (eosf - sfilename >= 4) {
if (strcmp(eosf - 4, ".asf") == 0) {
return -1;
/* open stream */
- s = av_open_input_file(input_filename, NULL, buf_size, NULL);
- if (!s)
+ if (av_open_input_file(&s, input_filename, NULL, buf_size, NULL) < 0)
return -1;
c->fmt_in = s;
- if (c->fmt_in->format->read_seek) {
- c->fmt_in->format->read_seek(c->fmt_in, stream_pos);
+ if (c->fmt_in->iformat->read_seek) {
+ c->fmt_in->iformat->read_seek(c->fmt_in, stream_pos);
}
// printf("stream %s opened pos=%0.6f\n", input_filename, stream_pos / 1000000.0);
memset(&c->fmt_ctx, 0, sizeof(c->fmt_ctx));
if (c->stream->feed) {
/* open output stream by using specified codecs */
- c->fmt_ctx.format = c->stream->fmt;
+ c->fmt_ctx.oformat = c->stream->fmt;
c->fmt_ctx.nb_streams = c->stream->nb_streams;
for(i=0;i<c->fmt_ctx.nb_streams;i++) {
AVStream *st;
c->got_key_frame = 0;
} else {
/* open output stream by using codecs in specified file */
- c->fmt_ctx.format = c->stream->fmt;
+ c->fmt_ctx.oformat = c->stream->fmt;
c->fmt_ctx.nb_streams = c->fmt_in->nb_streams;
for(i=0;i<c->fmt_ctx.nb_streams;i++) {
AVStream *st;
1, c, NULL, http_write_packet, NULL);
c->fmt_ctx.pb.is_streamed = 1;
/* prepare header */
- c->fmt_ctx.format->write_header(&c->fmt_ctx);
+ av_write_header(&c->fmt_ctx);
c->state = HTTPSTATE_SEND_DATA;
c->last_packet_sent = 0;
break;
if (c->last_packet_sent)
return -1;
/* prepare header */
- c->fmt_ctx.format->write_trailer(&c->fmt_ctx);
+ av_write_trailer(&c->fmt_ctx);
c->last_packet_sent = 1;
break;
}
} else {
/* We have a header in our hands that contains useful data */
AVFormatContext s;
+ AVInputFormat *fmt_in;
ByteIOContext *pb = &s.pb;
int i;
pb->buf_end = c->buffer_end; /* ?? */
pb->is_streamed = 1;
- if (feed->fmt->read_header(&s, 0) < 0) {
+ /* use feed output format name to find corresponding input format */
+ fmt_in = av_find_input_format(feed->fmt->name);
+ if (!fmt_in)
+ goto fail;
+
+ if (fmt_in->read_header(&s, 0) < 0) {
goto fail;
}
goto fail;
}
for (i = 0; i < s.nb_streams; i++) {
- memcpy(&feed->streams[i]->codec, &s.streams[i]->codec, sizeof(AVCodecContext));
+ memcpy(&feed->streams[i]->codec,
+ &s.streams[i]->codec, sizeof(AVCodecContext));
}
}
c->buffer_ptr = c->buffer;
feed->feed_filename);
exit(1);
}
- s->format = feed->fmt;
+ s->oformat = feed->fmt;
s->nb_streams = feed->nb_streams;
for(i=0;i<s->nb_streams;i++) {
AVStream *st;
st = feed->streams[i];
s->streams[i] = st;
}
- s->format->write_header(s);
-
+ av_write_header(s);
+ /* XXX: need better api */
+ av_freep(&s->priv_data);
url_fclose(&s->pb);
}
/* get feed size and write index */