summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago Santos <ts.santos@sisa.samsung.com>2014-04-29 18:15:05 -0300
committerThiago Santos <ts.santos@sisa.samsung.com>2014-04-29 18:49:15 -0300
commit940576244cbb8857fcceace1d92934018e20a8d4 (patch)
tree115c57d372c7724bb41ea84a14461ebfc8b33fa9
parentbb8887baa79cfb74eec435ba2ef0bdc07a847947 (diff)
hlsdemux: Do not push last buffer after error
In decryption scenario, a buffer is always stored to be sent later to wait for more data or EOS to be able to strip the final bytes if requested. In case an error hapenned this buffer can be ignored and not pushed downstream.
-rw-r--r--ext/hls/gsthlsdemux.c39
1 files changed, 22 insertions, 17 deletions
diff --git a/ext/hls/gsthlsdemux.c b/ext/hls/gsthlsdemux.c
index b7ef8ac92..080a39baa 100644
--- a/ext/hls/gsthlsdemux.c
+++ b/ext/hls/gsthlsdemux.c
@@ -951,23 +951,28 @@ _src_event (GstPad * pad, GstObject * parent, GstEvent * event)
gst_adapter_clear (demux->adapter);
/* pending buffer is only used for encrypted streams */
- if (demux->pending_buffer) {
- GstMapInfo info;
- gsize unpadded_size;
-
- /* Handle pkcs7 unpadding here */
- gst_buffer_map (demux->pending_buffer, &info, GST_MAP_READ);
- unpadded_size = info.size - info.data[info.size - 1];
- gst_buffer_unmap (demux->pending_buffer, &info);
-
- gst_buffer_resize (demux->pending_buffer, 0, unpadded_size);
-
- /* TODO check return */
- demux->download_total_time +=
- g_get_monotonic_time () - demux->download_start_time;
- demux->download_total_bytes +=
- gst_buffer_get_size (demux->pending_buffer);
- gst_pad_push (demux->srcpad, demux->pending_buffer);
+ if (demux->last_ret == GST_FLOW_OK) {
+ if (demux->pending_buffer) {
+ GstMapInfo info;
+ gsize unpadded_size;
+
+ /* Handle pkcs7 unpadding here */
+ gst_buffer_map (demux->pending_buffer, &info, GST_MAP_READ);
+ unpadded_size = info.size - info.data[info.size - 1];
+ gst_buffer_unmap (demux->pending_buffer, &info);
+
+ gst_buffer_resize (demux->pending_buffer, 0, unpadded_size);
+
+ demux->download_total_time +=
+ g_get_monotonic_time () - demux->download_start_time;
+ demux->download_total_bytes +=
+ gst_buffer_get_size (demux->pending_buffer);
+ demux->last_ret = gst_pad_push (demux->srcpad, demux->pending_buffer);
+
+ demux->pending_buffer = NULL;
+ }
+ } else {
+ gst_buffer_unref (demux->pending_buffer);
demux->pending_buffer = NULL;
}