[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gstreamer-devel
Subject:    Re: SrtpDec: request-key-callback results in app crash
From:       Jochen Jung <jochenmajjung () gmail ! com>
Date:       2020-11-24 1:20:18
Message-ID: CALv4NJHwY_d9S-Y9bn3Qy9TYy2XS6YxwL4AOiuAD7ybaYW=e_Q () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hello,


You are completely right. The signature was at fault. Changing the return
value to GspCaps* and the callback parameter to GstElement* works out of
the box!

The documentation says otherwise though (GstSrtpDec
<https://gstreamer.freedesktop.org/documentation/srtp/srtpdec.html?gi-language=c#srtpdec::request-key>)
 and should be adjusted.


Thanks for clarifying this!
Regards,


Jochen Jung


On Tue, Nov 24, 2020 at 1:22 AM Matthew Waters <ystreet00@gmail.com> wrote:

> Hi,
> 
> You have a number of memory errors in your callback as outlined below.
> You should probably use something like valgrind to have a look at where
> there may be other memory errors.
> 
> On 23/11/20 12:37 pm, Jochen Jung wrote:
> 
> Hello,
> 
> 
> I have a similar problem to Need Help Regarding SRTPDEC
> request_key_callback
> <https://lists.freedesktop.org/archives/gstreamer-devel/2020-April/074627.html>,
> which was eventually not resolved.
> 
> The following callback is used:
> 
> GstCaps StreamDecrypt::keyRequested([[maybe_unused]] GstElement element, guint \
> ssrc, gpointer data)
> > 
> > 
> This is wrong and needs to have the argument 'GstElement * element'
> 
> {
> > 
> > 	GstCaps * caps = (GstCaps *)data;
> > 
> > 	GValue val_ssrc = G_VALUE_INIT;
> > 
> > 	g_value_init(&val_ssrc, G_TYPE_UINT);
> > 
> > 	g_value_set_uint(&val_ssrc, ssrc);
> > 
> > 	gst_caps_set_value(caps, "ssrc", &val_ssrc);
> > 
> > 	dump(caps); // print GstCaps
> > 
> > 	return *caps;
> > 
> > 
> This is wrong, you should not be dereferencing the pointer.
> 
> }
> > 
> > 
> This is how the request-key signal is connected:
> 
> g_signal_connect(decrypt->getGstElement(), "request-key", \
> G_CALLBACK(StreamDecrypt::keyRequested), decrypt->getCapsSrtp());
> > 
> > // decrypt->getGstElement() returns the GstElement* of the GstSrtpDec.
> > 
> // decrypt->getCapsSrtp() returns the GstCaps*.
> > 
> 
> I confirmed that the GstCaps are set correctly, which are:
> 
> application/x-srtp,
> > srtp-key=(buffer)c99a66320db73158a35a255d051758e95ed4abb2cdc69bb454110e827441,
> > srtp-cipher=(string)aes-128-icm, srtp-auth=(string)hmac-sha1-80,
> > srtcp-cipher=(string)aes-128-icm, srtcp-auth=(string)hmac-sha1-80,
> > media=(string)audio, clock-rate=(int)8000, encoding-name=(string)PCMU,
> > payload=(int)0, ssrc=(uint)112235;
> > 
> 
> During runtime i get the following error:
> 
> (AudioStream:9995): GLib-GObject-CRITICAL **: 02:12:00.065:
> > g_object_unref: assertion 'G_IS_OBJECT (object)' failed
> > 
> > ** (AudioStream:9995): CRITICAL **: 02:12:00.065:
> > update_session_stream_from_caps: assertion 'GST_IS_SRTP_DEC (filter)' failed
> > 
> 
> I traced this error back to a function in GstPad. The function
> ACQUIRE_PARENT(pad, parent, label) returns an invliad GstSrtpDev object.
> This invalid GstSrtpDec results in the above mentioned errors in
> GstSrtpDec::update_session_stream_from_caps. The app crash occurs in
> GstCaps::gst_caps_to_string.
> 
> Can anyone please tell me what i am doing wrong here? If everything is set
> up correctly i have to assume this is a bug in the plugin.
> 
> 
> Thanks in advance and regards,
> Jochen Jung
> 
> 
> _______________________________________________
> gstreamer-devel mailing \
> listgstreamer-devel@lists.freedesktop.orghttps://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>  
> 
> 


[Attachment #5 (text/html)]

<div dir="ltr"><div>Hello,</div><div><br></div><div><br></div><div>You are completely \
right. The signature was at fault. Changing the return value to GspCaps* and the \
callback parameter to GstElement* works out of the box!</div><div><br></div><div>The \
documentation says otherwise though (<a \
href="https://gstreamer.freedesktop.org/documentation/srtp/srtpdec.html?gi-language=c#srtpdec::request-key">GstSrtpDec</a>) \
and should be adjusted.</div><div><br></div><div><br></div><div>Thanks for clarifying \
this!</div><div>Regards,</div><div><br></div><div><br></div><div>Jochen \
Jung</div><div><br></div><div><br></div><div class="gmail_quote"><div dir="ltr" \
class="gmail_attr">On Tue, Nov 24, 2020 at 1:22 AM Matthew Waters &lt;<a \
href="mailto:ystreet00@gmail.com">ystreet00@gmail.com</a>&gt; \
wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">  
    
  
  <div>
    Hi,<br>
    <br>
    You have a number of memory errors in your callback as outlined
    below.   You should probably use something like valgrind to have a
    look at where there may be other memory errors.<br>
    <br>
    <div>On 23/11/20 12:37 pm, Jochen Jung
      wrote:<br>
    </div>
    <blockquote type="cite">
      
      <div dir="ltr">
        <div><span style="background-color:rgb(147,196,125)"><span></span></span>Hello,</div>
  <div><br>
        </div>
        <div><br>
        </div>
        <div>I have a similar problem to <a \
href="https://lists.freedesktop.org/archives/gstreamer-devel/2020-April/074627.html" \
                target="_blank">Need Help Regarding SRTPDEC
            request_key_callback</a>, which was eventually not resolved.</div>
        <div><br>
        </div>
        <div>The following callback is used:</div>
        <div><br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">  <div>
            <pre style="margin:0px;text-indent:0px">GstCaps<span \
style="color:rgb(192,192,192)"> \
</span>StreamDecrypt::keyRequested([[maybe_unused]]<span \
style="color:rgb(192,192,192)"> </span><span \
style="color:rgb(128,0,128)">GstElement</span><span style="color:rgb(192,192,192)"> \
</span>element,<span style="color:rgb(192,192,192)"> </span><span \
style="color:rgb(128,0,128)">guint</span><span style="color:rgb(192,192,192)"> \
</span>ssrc,<span style="color:rgb(192,192,192)"> </span>gpointer<span \
style="color:rgb(192,192,192)"> </span>data)</pre>  </div>
        </blockquote>
      </div>
    </blockquote>
    <br>
    This is wrong and needs to have the argument &#39;GstElement * element&#39;<br>
    <br>
    <blockquote type="cite">
      <div dir="ltr">
        <blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">  <div>
            <pre style="margin:0px;text-indent:0px">{</pre>
            <pre style="margin:0px;text-indent:0px"><span \
style="color:rgb(192,192,192)">	</span><span \
style="color:rgb(128,0,128)">GstCaps</span><span style="color:rgb(192,192,192)"> \
</span>*<span style="color:rgb(192,192,192)"> </span>caps<span \
style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> \
</span>(<span style="color:rgb(128,0,128)">GstCaps</span><span \
style="color:rgb(192,192,192)"> </span>*)data;</pre>  <pre \
style="margin:0px;text-indent:0px"></pre>  <pre \
style="margin:0px;text-indent:0px"><span style="color:rgb(192,192,192)">	</span><span \
style="color:rgb(128,0,128)">GValue</span><span style="color:rgb(192,192,192)"> \
</span>val_ssrc<span style="color:rgb(192,192,192)"> </span>=<span \
style="color:rgb(192,192,192)"> </span><span \
style="color:rgb(0,0,128)">G_VALUE_INIT</span>;</pre>  <pre \
style="margin:0px;text-indent:0px"><span \
style="color:rgb(192,192,192)">	</span>g_value_init(&amp;val_ssrc,<span \
style="color:rgb(192,192,192)"> </span><span \
style="color:rgb(0,0,128)">G_TYPE_UINT</span>);</pre>  <pre \
style="margin:0px;text-indent:0px"><span \
style="color:rgb(192,192,192)">	</span>g_value_set_uint(&amp;val_ssrc,<span \
style="color:rgb(192,192,192)"> </span>ssrc);</pre>  <pre \
style="margin:0px;text-indent:0px"></pre>  <pre \
style="margin:0px;text-indent:0px"><span \
style="color:rgb(192,192,192)">	</span>gst_caps_set_value(caps,<span \
style="color:rgb(192,192,192)"> </span><span \
style="color:rgb(0,128,0)">&quot;ssrc&quot;</span>,<span \
style="color:rgb(192,192,192)"> </span>&amp;val_ssrc);</pre>  <pre \
style="margin:0px;text-indent:0px"><span \
style="color:rgb(192,192,192)">	</span>dump(caps); <span \
style="color:rgb(56,118,29)">// print GstCaps</span></pre>  <pre \
style="margin:0px;text-indent:0px"></pre>  <pre \
style="margin:0px;text-indent:0px"><span style="color:rgb(192,192,192)">	</span><span \
style="color:rgb(128,128,0)">return</span><span style="color:rgb(192,192,192)"> \
</span>*caps;</pre>  </div>
        </blockquote>
      </div>
    </blockquote>
    <br>
    This is wrong, you should not be dereferencing the pointer.<br>
    <br>
    <blockquote type="cite">
      <div dir="ltr">
        <blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">  <div>
            <pre style="margin:0px;text-indent:0px">}</pre>
          </div>
        </blockquote>
        <div><br>
        </div>
        <div>This is how the request-key signal is connected:</div>
        <div><br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">  <div>
            <pre style="margin:0px;text-indent:0px"><span \
style="color:rgb(192,192,192)">g_signal_connect</span>(<span \
style="color:rgb(128,0,0)">decrypt</span>-&gt;<span \
style="color:rgb(61,133,198)">getGstElement()</span>,<span \
style="color:rgb(192,192,192)"> </span><span \
style="color:rgb(0,128,0)">&quot;request-key&quot;</span>,<span \
style="color:rgb(192,192,192)"> </span><span \
style="color:rgb(0,0,128)">G_CALLBACK</span>(<span \
style="color:rgb(128,0,128)">StreamDecrypt</span>::<span \
style="color:rgb(128,0,0)">keyRequested</span>),<span style="color:rgb(192,192,192)"> \
</span><span style="color:rgb(128,0,0)">decrypt</span>-&gt;<span \
style="color:rgb(0,103,124)">getCapsSrtp</span>());</pre>  </div>
        </blockquote>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">  <div><span \
style="color:rgb(56,118,29)">//  decrypt-&gt;getGstElement() returns the GstElement* \
of the  GstSrtpDec.<br>
            </span></div>
        </blockquote>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px \
                0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
          <div><span style="color:rgb(106,168,79)"><span \
                style="color:rgb(56,118,29)">//
                decrypt-&gt;getCapsSrtp() returns the GstCaps*.</span> </span><br>
          </div>
        </blockquote>
        <div><br>
        </div>
        <div>
          <div>I confirmed that the GstCaps are set correctly, which
            are:</div>
          <div><br>
          </div>
          <blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">  \
<div>application/x-srtp, \
srtp-key=(buffer)c99a66320db73158a35a255d051758e95ed4abb2cdc69bb454110e827441,  \
srtp-cipher=(string)aes-128-icm,  srtp-auth=(string)hmac-sha1-80,
              srtcp-cipher=(string)aes-128-icm,
              srtcp-auth=(string)hmac-sha1-80, media=(string)audio,
              clock-rate=(int)8000, encoding-name=(string)PCMU,
              payload=(int)0, ssrc=(uint)112235;</div>
          </blockquote>
        </div>
        <div><br>
        </div>
        <div>During runtime i get the following error:</div>
        <div><br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">  \
<div>(AudioStream:9995): GLib-GObject-CRITICAL **:  02:12:00.065: g_object_unref: \
assertion &#39;G_IS_OBJECT  (object)&#39; failed<br>
            <br>
            ** (AudioStream:9995): CRITICAL **: 02:12:00.065:
            update_session_stream_from_caps: assertion &#39;GST_IS_SRTP_DEC
            (filter)&#39; failed</div>
        </blockquote>
        <div><br>
        </div>
        <div>I traced this error back to a function in GstPad. The
          function ACQUIRE_PARENT(pad, parent, label) returns an invliad
          GstSrtpDev object. This invalid GstSrtpDec<span style="color:rgb(0,0,128)"> \
results in the above mentioned </span>errors  in \
GstSrtpDec::update_session_stream_from_caps. The app crash  occurs in \
GstCaps::gst_caps_to_string.</div>  <div><br>
        </div>
        <div>Can anyone please tell me what i am doing wrong here? If
          everything is set up correctly i have to assume this is a bug
          in the plugin.<br>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div>Thanks in advance and regards,</div>
        <div>Jochen Jung<br>
        </div>
        <div>  </div>
      </div>
      <br>
      <fieldset></fieldset>
      <pre>_______________________________________________
gstreamer-devel mailing list
<a href="mailto:gstreamer-devel@lists.freedesktop.org" \
target="_blank">gstreamer-devel@lists.freedesktop.org</a> <a \
href="https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" \
target="_blank">https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a> \
</pre>  </blockquote>
    <br>
  </div>

</blockquote></div></div>



_______________________________________________
gstreamer-devel mailing list
gstreamer-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic