[FFmpeg-devel] [PATCH] mpegtsenc: check for network write fail
Andrey Utkin
andrey.krieger.utkin at gmail.com
Mon Aug 13 13:20:24 CEST 2012
Before this patch, writing frames to mpegts muxer via failed network connection returned "OK".
--8<---
---
libavformat/mpegtsenc.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index d8e67c7..ae1861b 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -1159,6 +1159,8 @@ static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
ts_st2->payload_pts, ts_st2->payload_dts,
ts_st2->payload_flags & AV_PKT_FLAG_KEY);
ts_st2->payload_size = 0;
+ if (s->pb->error)
+ return s->pb->error;
}
}
}
@@ -1168,6 +1170,8 @@ static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
ts_st->payload_pts, ts_st->payload_dts,
ts_st->payload_flags & AV_PKT_FLAG_KEY);
ts_st->payload_size = 0;
+ if (s->pb->error)
+ return s->pb->error;
}
if (st->codec->codec_type != AVMEDIA_TYPE_AUDIO || size > ts->pes_payload_size) {
@@ -1175,7 +1179,7 @@ static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
// for video and subtitle, write a single pes packet
mpegts_write_pes(s, st, buf, size, pts, dts, pkt->flags & AV_PKT_FLAG_KEY);
av_free(data);
- return 0;
+ return s->pb->error;
}
if (!ts_st->payload_size) {
--
1.7.8.6
More information about the ffmpeg-devel
mailing list