<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple style='word-wrap:break-word'><div class=WordSection1><p class=MsoNormal>You may need a modified version of av_read_frame(). See this:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><a href="https://gist.github.com/bsenftner/ba3d493fa36b0b201ffd995e8c2c60a2">https://gist.github.com/bsenftner/ba3d493fa36b0b201ffd995e8c2c60a2</a><o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>That’s for an earlier version of the libs, but you can see at line 31, the modification is simply providing a hook for the interrupt callback.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>-Blake<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b>From:</b> Libav-user <libav-user-bounces@ffmpeg.org> <b>On Behalf Of </b>Yurii Monakov<br><b>Sent:</b> Thursday, November 11, 2021 12:57 PM<br><b>To:</b> This list is about using libavcodec, libavformat, libavutil, libavdevice and libavfilter. <libav-user@ffmpeg.org><br><b>Subject:</b> Re: [Libav-user] AVIOInterruptCB and how to use it<o:p></o:p></p></div><p class=MsoNormal><o:p> </o:p></p><div><div><p class=MsoNormal>Hi,<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Initial value of interrupt_callback can be cached internally somewhere inside avformat_find_stream_info.<o:p></o:p></p></div><div><p class=MsoNormal>My code performs assignment just right after context allocation. <o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Regards,<o:p></o:p></p></div><div><p class=MsoNormal>Yurii<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div></div><p class=MsoNormal><o:p> </o:p></p><div><div><p class=MsoNormal>вт, 9 нояб. 2021 г. в 18:23, Simon Brown <<a href="mailto:simon.k.brown@gmail.com">simon.k.brown@gmail.com</a>>:<o:p></o:p></p></div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in'><div><p class=MsoNormal>Hi,<o:p></o:p></p><div><p class=MsoNormal>I'm trying to stop av_read_frame from blocking when the stream is stopped (stream over TCP, and the sender pauses sending).  Reading various forum posts, it would appear that I need to use the AVIOInterruptCB structure and assign it to my format context.  So I do this:<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'>    /* retrieve stream information */<br>    if (avformat_find_stream_info(fmt_ctx, NULL) < 0) {<br>        fprintf(stderr, "Could not find stream information\n");<br>        exit(1);<br>    }<br>    static const AVIOInterruptCB int_cb = {interrupt_cb, &int_cb_ctx};<br>    fmt_ctx->interrupt_callback = int_cb;</span><o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal><span style='font-family:"Arial",sans-serif'>where interrupt_cb and int_cb_ctx are defined as:</span><o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal style='margin-bottom:12.0pt'><span style='font-family:"Courier New"'>static int interrupt_cb(void *ctx)<br>{<br>int *p = (int *)ctx;<br>*p = 53;<br>return 1;<br>}<br><br>int int_cb_ctx = 0;</span><o:p></o:p></p></div><div><p class=MsoNormal>The only problem now is that av_read_frame still blocks, there's no evidence that interrupt_cb is being called, and I cannot restart my stream because my decoder gets stuck in av_read_frame.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Is there anything I am doing wrong?  Or is this a feature that has been deprecated?  Is there a better way of getting out of av_read_frame blocking?<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Cheers,<o:p></o:p></p></div><div><p class=MsoNormal>Simon<o:p></o:p></p></div></div><p class=MsoNormal>_______________________________________________<br>Libav-user mailing list<br><a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br><a href="https://ffmpeg.org/mailman/listinfo/libav-user" target="_blank">https://ffmpeg.org/mailman/listinfo/libav-user</a><br><br>To unsubscribe, visit link above, or email<br><a href="mailto:libav-user-request@ffmpeg.org" target="_blank">libav-user-request@ffmpeg.org</a> with subject "unsubscribe".<o:p></o:p></p></blockquote></div></div></body></html>