/* close connection if trailer sent */
if (c->state == HTTPSTATE_SEND_DATA_TRAILER)
return -1;
+ /* Check if it is a single jpeg frame 123 */
+ if (c->stream->single_frame && c->data_count > c->cur_frame_bytes && c->cur_frame_bytes > 0) {
+ close_connection(c);
+ }
break;
case HTTPSTATE_RECEIVE_DATA:
/* no need to read if no events */
}
acl = av_mallocz(sizeof(FFServerIPAddressACL));
+ if (!acl) {
+ fclose(f);
+ return NULL;
+ }
/* Build ACL */
while (fgets(line, sizeof(line), f)) {
}
/* set buffer size */
- if (buf_size > 0) ffio_set_buf_size(s->pb, buf_size);
+ if (buf_size > 0) {
+ ret = ffio_set_buf_size(s->pb, buf_size);
+ if (ret < 0) {
+ http_log("Failed to set buffer size\n");
+ return ret;
+ }
+ }
s->flags |= AVFMT_FLAG_GENPTS;
c->fmt_in = s;
switch(c->state) {
case HTTPSTATE_SEND_DATA_HEADER:
ctx = avformat_alloc_context();
+ if (!ctx)
+ return AVERROR(ENOMEM);
c->fmt_ctx = *ctx;
av_freep(&ctx);
av_dict_copy(&(c->fmt_ctx.metadata), c->stream->metadata, 0);
c->fmt_ctx.streams = av_mallocz_array(c->stream->nb_streams,
sizeof(AVStream *));
+ if (!c->fmt_ctx.streams)
+ return AVERROR(ENOMEM);
for(i=0;i<c->stream->nb_streams;i++) {
AVStream *src;
c->fmt_ctx.streams[i] = av_mallocz(sizeof(AVStream));
+
/* if file or feed, then just take streams from FFServerStream struct */
if (!c->stream->feed ||
c->stream->feed == c->stream)
pb = avio_alloc_context(c->buffer, c->buffer_end - c->buffer,
0, NULL, NULL, NULL, NULL);
+ if (!pb)
+ goto fail;
+
pb->seekable = 0;
s->pb = pb;
avc->streams[i]->codec = stream->streams[i]->codec;
}
*pbuffer = av_mallocz(2048);
+ if (!*pbuffer)
+ goto sdp_done;
av_sdp_create(&avc, 1, *pbuffer, 2048);
sdp_done:
return NULL;
if (copy) {
fst->codec = avcodec_alloc_context3(codec->codec);
+ if (!fst->codec) {
+ av_free(fst);
+ return NULL;
+ }
avcodec_copy_context(fst->codec, codec);
} else {
/* live streams must use the actual feed's codec since it may be
if (avformat_open_input(&s, feed->feed_filename, NULL, NULL) >= 0) {
/* set buffer size */
- ffio_set_buf_size(s->pb, FFM_PACKET_SIZE);
+ int ret = ffio_set_buf_size(s->pb, FFM_PACKET_SIZE);
+ if (ret < 0) {
+ http_log("Failed to set buffer size\n");
+ exit(1);
+ }
+
/* Now see if it matches */
if (s->nb_streams == feed->nb_streams) {
matches = 1;
if (avio_check(feed->feed_filename, AVIO_FLAG_WRITE) <= 0) {
AVFormatContext *s = avformat_alloc_context();
+ if (!s) {
+ http_log("Failed to allocate context\n");
+ exit(1);
+ }
+
if (feed->readonly) {
http_log("Unable to create feed file '%s' as it is marked readonly\n",
feed->feed_filename);