#include <string.h>
#include <stdlib.h>
#include "avformat.h"
+#include "rtsp.h"
+#include "rtp.h"
+#include "os_support.h"
#include <stdarg.h>
#include <unistd.h>
/* prepare header */
if (url_open_dyn_buf(&ctx->pb) >= 0) {
av_write_trailer(ctx);
- url_close_dyn_buf(&ctx->pb, &c->pb_buffer);
+ url_close_dyn_buf(ctx->pb, &c->pb_buffer);
}
}
}
char *p;
time_t ti;
int i, len;
- ByteIOContext pb1, *pb = &pb1;
+ ByteIOContext *pb;
- if (url_open_dyn_buf(pb) < 0) {
+ if (url_open_dyn_buf(&pb) < 0) {
/* XXX: return an error ? */
c->buffer_ptr = c->buffer;
c->buffer_end = c->buffer;
/* XXX: potential leak */
return -1;
}
- c->fmt_ctx.pb.is_streamed = 1;
+ c->fmt_ctx.pb->is_streamed = 1;
av_set_parameters(&c->fmt_ctx, NULL);
if (av_write_header(&c->fmt_ctx) < 0)
return -1;
- len = url_close_dyn_buf(&c->fmt_ctx.pb, &c->pb_buffer);
+ len = url_close_dyn_buf(c->fmt_ctx.pb, &c->pb_buffer);
c->buffer_ptr = c->pb_buffer;
c->buffer_end = c->pb_buffer + len;
if (av_write_frame(ctx, &pkt))
c->state = HTTPSTATE_SEND_DATA_TRAILER;
- len = url_close_dyn_buf(&ctx->pb, &c->pb_buffer);
+ len = url_close_dyn_buf(ctx->pb, &c->pb_buffer);
c->cur_frame_bytes = len;
c->buffer_ptr = c->pb_buffer;
c->buffer_end = c->pb_buffer + len;
return -1;
}
av_write_trailer(ctx);
- len = url_close_dyn_buf(&ctx->pb, &c->pb_buffer);
+ len = url_close_dyn_buf(ctx->pb, &c->pb_buffer);
c->buffer_ptr = c->pb_buffer;
c->buffer_end = c->pb_buffer + len;
if (c->rtp_protocol == RTSP_PROTOCOL_RTP_TCP) {
/* RTP packets are sent inside the RTSP TCP connection */
- ByteIOContext pb1, *pb = &pb1;
+ ByteIOContext *pb;
int interleaved_index, size;
uint8_t header[4];
HTTPContext *rtsp_c;
/* if already sending something, then wait. */
if (rtsp_c->state != RTSPSTATE_WAIT_REQUEST)
break;
- if (url_open_dyn_buf(pb) < 0)
+ if (url_open_dyn_buf(&pb) < 0)
goto fail1;
interleaved_index = c->packet_stream_index * 2;
/* RTCP packets are sent at odd indexes */
/* We have a header in our hands that contains useful data */
AVFormatContext s;
AVInputFormat *fmt_in;
- ByteIOContext *pb = &s.pb;
int i;
memset(&s, 0, sizeof(s));
- url_open_buf(pb, c->buffer, c->buffer_end - c->buffer, URL_RDONLY);
- pb->buf_end = c->buffer_end; /* ?? */
- pb->is_streamed = 1;
+ url_open_buf(&s.pb, c->buffer, c->buffer_end - c->buffer, URL_RDONLY);
+ s.pb->buf_end = c->buffer_end; /* ?? */
+ s.pb->is_streamed = 1;
/* use feed output format name to find corresponding input format */
fmt_in = av_find_input_format(feed->fmt->name);
char url[1024];
char protocol[32];
char line[1024];
- ByteIOContext pb1;
int len;
RTSPHeader header1, *header = &header1;
av_strlcpy(c->url, url, sizeof(c->url));
av_strlcpy(c->protocol, protocol, sizeof(c->protocol));
- c->pb = &pb1;
- if (url_open_dyn_buf(c->pb) < 0) {
+ if (url_open_dyn_buf(&c->pb) < 0) {
/* XXX: cannot do more */
c->pb = NULL; /* safety */
return -1;
av_free(ctx);
return -1;
}
- url_close_dyn_buf(&ctx->pb, &dummy_buf);
+ url_close_dyn_buf(ctx->pb, &dummy_buf);
av_free(dummy_buf);
c->rtp_ctx[stream_index] = ctx;
}
/* XXX: need better api */
av_freep(&s->priv_data);
- url_fclose(&s->pb);
+ url_fclose(s->pb);
}
/* get feed size and write index */
fd = open(feed->feed_filename, O_RDONLY);
static int opt_audio_codec(const char *arg)
{
- AVCodec *p;
+ AVCodec *p= avcodec_find_encoder_by_name(arg);
- p = first_avcodec;
- while (p) {
- if (!strcmp(p->name, arg) && p->type == CODEC_TYPE_AUDIO)
- break;
- p = p->next;
- }
- if (p == NULL)
+ if (p == NULL || p->type != CODEC_TYPE_AUDIO)
return CODEC_ID_NONE;
return p->id;
static int opt_video_codec(const char *arg)
{
- AVCodec *p;
+ AVCodec *p= avcodec_find_encoder_by_name(arg);
- p = first_avcodec;
- while (p) {
- if (!strcmp(p->name, arg) && p->type == CODEC_TYPE_VIDEO)
- break;
- p = p->next;
- }
- if (p == NULL)
+ if (p == NULL || p->type != CODEC_TYPE_VIDEO)
return CODEC_ID_NONE;
return p->id;
if (feed) {
int i;
- feed->child_argv = (char **) av_mallocz(64 * sizeof(char *));
+ feed->child_argv = av_mallocz(64 * sizeof(char *));
for (i = 0; i < 62; i++) {
get_arg(arg, sizeof(arg), &p);
}
if (!errors) {
- IPAddressACL *nacl = (IPAddressACL *) av_mallocz(sizeof(*nacl));
+ IPAddressACL *nacl = av_mallocz(sizeof(*nacl));
IPAddressACL **naclp = 0;
acl.next = 0;
static void show_help(void)
{
- show_banner(program_name, program_birth_year);
printf("usage: ffserver [-L] [-h] [-f configfile]\n"
"Hyper fast multi format Audio/Video streaming server\n"
"\n"
av_register_all();
+ show_banner(program_name, program_birth_year);
+
config_filename = "/etc/ffserver.conf";
my_program_name = argv[0];
break;
switch(c) {
case 'L':
- show_banner(program_name, program_birth_year);
show_license();
exit(0);
case '?':