}
}
for(i=0;i<c->stream->nb_streams;i++) {
- if (c->feed_streams[i] == pkt.stream_index) {
+ if (c->stream->feed_streams[i] == pkt.stream_index) {
AVStream *st = c->fmt_in->streams[source_index];
pkt.stream_index = i;
if (pkt.flags & AV_PKT_FLAG_KEY &&
if (c->is_packetized) {
/* compute send time and duration */
c->cur_pts = av_rescale_q(pkt.dts, ist->time_base, AV_TIME_BASE_Q);
- if (ist->start_time != AV_NOPTS_VALUE)
- c->cur_pts -= av_rescale_q(ist->start_time, ist->time_base, AV_TIME_BASE_Q);
+ c->cur_pts -= c->first_pts;
c->cur_frame_duration = av_rescale_q(pkt.duration, ist->time_base, AV_TIME_BASE_Q);
/* find RTP context */
c->packet_stream_index = pkt.stream_index;
if (*p == '\n')
p++;
while (*p != '\0') {
- p1 = strchr(p, '\n');
+ p1 = memchr(p, '\n', (char *)c->buffer_ptr - p);
if (!p1)
break;
p2 = p1;
return;
}
rtsp_reply_header(c, RTSP_STATUS_OK);
+ url_fprintf(c->pb, "Content-Base: %s/\r\n", url);
url_fprintf(c->pb, "Content-Type: application/sdp\r\n");
url_fprintf(c->pb, "Content-Length: %d\r\n", content_length);
url_fprintf(c->pb, "\r\n");
st = av_mallocz(sizeof(AVStream));
if (!st)
goto fail;
- st->codec= avcodec_alloc_context();
ctx->nb_streams = 1;
ctx->streams[0] = st;
/********************************************************************/
/* ffserver initialization */
-static AVStream *add_av_stream1(FFStream *stream, AVCodecContext *codec)
+static AVStream *add_av_stream1(FFStream *stream, AVCodecContext *codec, int copy)
{
AVStream *fst;
fst = av_mallocz(sizeof(AVStream));
if (!fst)
return NULL;
- fst->codec= avcodec_alloc_context();
+ if (copy) {
+ fst->codec= avcodec_alloc_context();
+ memcpy(fst->codec, codec, sizeof(AVCodecContext));
+ if (codec->extradata_size) {
+ fst->codec->extradata = av_malloc(codec->extradata_size);
+ memcpy(fst->codec->extradata, codec->extradata,
+ codec->extradata_size);
+ }
+ } else {
+ /* live streams must use the actual feed's codec since it may be
+ * updated later to carry extradata needed by the streams.
+ */
+ fst->codec = codec;
+ }
fst->priv_data = av_mallocz(sizeof(FeedData));
- memcpy(fst->codec, codec, sizeof(AVCodecContext));
fst->index = stream->nb_streams;
av_set_pts_info(fst, 33, 1, 90000);
stream->streams[stream->nb_streams++] = fst;
}
}
- fst = add_av_stream1(feed, av);
+ fst = add_av_stream1(feed, av, 0);
if (!fst)
return -1;
return feed->nb_streams - 1;
extract_mpeg4_header(infile);
for(i=0;i<infile->nb_streams;i++)
- add_av_stream1(stream, infile->streams[i]->codec);
+ add_av_stream1(stream, infile->streams[i]->codec, 1);
av_close_input_file(infile);
}
ccs = ss->codec;
#define CHECK_CODEC(x) (ccf->x != ccs->x)
- if (CHECK_CODEC(codec) || CHECK_CODEC(codec_type)) {
+ if (CHECK_CODEC(codec_id) || CHECK_CODEC(codec_type)) {
http_log("Codecs do not match for stream %d\n", i);
matches = 0;
} else if (CHECK_CODEC(bit_rate) || CHECK_CODEC(flags)) {
} else if (!strcasecmp(cmd, "AudioBitRate")) {
get_arg(arg, sizeof(arg), &p);
if (stream)
- audio_enc.bit_rate = atoi(arg) * 1000;
+ audio_enc.bit_rate = lrintf(atof(arg) * 1000);
} else if (!strcasecmp(cmd, "AudioChannels")) {
get_arg(arg, sizeof(arg), &p);
if (stream)