<html><head></head><body><div class="gmail_quote">Le 1 juillet 2017 15:24:45 GMT+02:00, Thomas Guillem <thomas@gllm.fr> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">This allow to pass block flags to a demux inside a demux_chained. This works<br />only if the block size and the read size match. This is the case for ts via rtp<br />for example.<br />---<br /> src/input/stream.c | 42 +++++++++++++++++++++++++++++++++++-------<br /> 1 file changed, 35 insertions(+), 7 deletions(-)<br /><br />diff --git a/src/input/stream.c b/src/input/stream.c<br />index affc7b2c0d..5b3ddffc89 100644<br />--- a/src/input/stream.c<br />+++ b/src/input/stream.c<br />@@ -387,7 +387,8 @@ static ssize_t vlc_stream_CopyBlock(block_t **restrict pp,<br /> return likely(len > 0) ? (ssize_t)len : -1;<br /> }<br /> <br />-static ssize_t vlc_stream_ReadRaw(stream_t *s, void *buf, size_t len)<br />+static ssize_t vlc_stream_ReadRaw(stream_t *s, void *buf, size_t len,<br />+ uint32_t *block_flags)<br /> {<br /> stream_priv_t *priv = (stream_priv_t *)s;<br /> ssize_t ret;<br />@@ -424,14 +425,19 @@ static ssize_t vlc_stream_ReadRaw(stream_t *s, void *buf, size_t len)<br /> priv->block = s->pf_block(s, &eof);<br /> ret = vlc_stream_CopyBlock(&priv->block, buf, len);<br /> if (ret >= 0)<br />+ {<br />+ if (block_flags != NULL)<br />+ *block_flags = priv->block->i_flags;<br /> return ret;<br />+ }<br /> return eof ? 0 : -1;<br /> }<br /> <br /> return 0;<br /> }<br /> <br />-ssize_t vlc_stream_ReadPartial(stream_t *s, void *buf, size_t len)<br />+static ssize_t vlc_stream_ReadPartialInternal(stream_t *s, void *buf, size_t len,<br />+ uint32_t *block_flags)<br /> {<br /> stream_priv_t *priv = (stream_priv_t *)s;<br /> ssize_t ret;<br />@@ -444,7 +450,7 @@ ssize_t vlc_stream_ReadPartial(stream_t *s, void *buf, size_t len)<br /> return ret;<br /> }<br /> <br />- ret = vlc_stream_ReadRaw(s, buf, len);<br />+ ret = vlc_stream_ReadRaw(s, buf, len, block_flags);<br /> if (ret > 0)<br /> priv->offset += ret;<br /> if (ret == 0)<br />@@ -453,6 +459,11 @@ ssize_t vlc_stream_ReadPartial(stream_t *s, void *buf, size_t len)<br /> return ret;<br /> }<br /> <br />+ssize_t vlc_stream_ReadPartial(stream_t *s, void *buf, size_t len)<br />+{<br />+ return vlc_stream_ReadPartialInternal(s, buf, len, NULL);<br />+}<br />+<br /> ssize_t vlc_stream_Read(stream_t *s, void *buf, size_t len)<br /> {<br /> size_t copied = 0;<br />@@ -516,7 +527,7 @@ ssize_t vlc_stream_Peek(stream_t *s, const uint8_t **restrict bufp, size_t len)<br /> size_t avail = peek->i_buffer;<br /> ssize_t ret;<br /> <br />- ret = vlc_stream_ReadRaw(s, peek->p_buffer + avail, len - avail);<br />+ ret = vlc_stream_ReadRaw(s, peek->p_buffer + avail, len - avail, NULL);<br /> if (ret < 0)<br /> continue;<br /> <br />@@ -706,14 +717,31 @@ block_t *vlc_stream_Block( stream_t *s, size_t size )<br /> if( unlikely(block == NULL) )<br /> return NULL;<br /> <br />- ssize_t val = vlc_stream_Read( s, block->p_buffer, size );<br />- if( val <= 0 )<br />+ block->i_buffer = 0;<br />+ char *buf = (char *)block->p_buffer;<br />+ while (size > 0)<br />+ {<br />+ uint32_t block_flags = 0;<br />+ ssize_t ret = vlc_stream_ReadPartialInternal( s, buf, size, &block_flags );<br />+ if (ret < 0)<br />+ continue;<br />+ if (ret == 0)<br />+ break;<br />+<br />+ if( size == (size_t) ret && block->i_buffer == 0 )<br />+ block->i_flags = block_flags;<br />+<br />+ buf += ret;<br />+ size -= ret;<br />+ block->i_buffer += ret;<br />+ }<br />+<br />+ if( block->i_buffer == 0 )<br /> {<br /> block_Release( block );<br /> return NULL;<br /> }<br /> <br />- block->i_buffer = val;<br /> return block;<br /> }<br /> </pre></blockquote></div><br clear="all">This does not seem to make sense. The necessary assumptions can never be warranted.<br>
-- <br>
Rémi Denis-Courmont<br>
Typed on an inconvenient virtual keyboard</body></html>