<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hello,<br>
    <br>
    not using app_python, but from its readme file I understand that the
    script is loaded at startup, then you can execute methods
    (functions) from it at runtime.<br>
    <br>
    Is setflow() a function inside the setflow.py script?<br>
    <br>
    Cheers,<br>
    Daniel<br>
    <br>
    <br>
    <div class="moz-cite-prefix">On 05/11/14 14:21, Azamat Ailbayev
      wrote:<br>
    </div>
    <blockquote cite="mid:1415193666.500254128@f375.i.mail.ru"
      type="cite">
      <span style="color: #222222; font-family: arial; font-size:
        small;" data-mce-style="color: #222222; font-family: arial;
        font-size: small;">Dear All,</span>
      <div style="color: #222222; font-family: arial; font-size: small;"
        data-mce-style="color: #222222; font-family: arial; font-size:
        small;"> </div>
      <div style="color: #222222; font-family: arial; font-size: small;"
        data-mce-style="color: #222222; font-family: arial; font-size:
        small;">I am trying to execute python script from the kamailio.
        According to documentation I have initialized everything and it
        works. As soon as I run the Kamailio the python script is
        executed. </div>
      <div style="color: #222222; font-family: arial; font-size: small;"
        data-mce-style="color: #222222; font-family: arial; font-size:
        small;"> </div>
      <div style="color: #222222; font-family: arial; font-size: small;"
        data-mce-style="color: #222222; font-family: arial; font-size:
        small;">However, according to my task I need to execute the
        script based on session media type (WebRTC communication type)
        whether it is audio or video.</div>
      <div style="color: #222222; font-family: arial; font-size: small;"
        data-mce-style="color: #222222; font-family: arial; font-size:
        small;"> </div>
      <div style="color: #222222; font-family: arial; font-size: small;"
        data-mce-style="color: #222222; font-family: arial; font-size:
        small;">For that purpose there was used SDPOPS module with
        function sdp_with_media("video"). </div>
      <div style="color: #222222; font-family: arial; font-size: small;"
        data-mce-style="color: #222222; font-family: arial; font-size:
        small;"> </div>
      <div style="color: #222222; font-family: arial; font-size: small;"
        data-mce-style="color: #222222; font-family: arial; font-size:
        small;">So, in config file it looks like: </div>
      <div style="color: #222222; font-family: arial; font-size: small;"
        data-mce-style="color: #222222; font-family: arial; font-size:
        small;"> </div>
      <div style="color: #222222; font-family: arial; font-size: small;"
        data-mce-style="color: #222222; font-family: arial; font-size:
        small;">#!ifdef WITH_WEBSOCKETS</div>
      <div style="color: #222222; font-family: arial; font-size: small;"
        data-mce-style="color: #222222; font-family: arial; font-size:
        small;">loadmodule "xhttp.so"</div>
      <div style="color: #222222; font-family: arial; font-size: small;"
        data-mce-style="color: #222222; font-family: arial; font-size:
        small;">loadmodule "websocket.so"</div>
      <div style="color: #222222; font-family: arial; font-size: small;"
        data-mce-style="color: #222222; font-family: arial; font-size:
        small;">loadmodule "nathelper.so"</div>
      <div style="color: #222222; font-family: arial; font-size: small;"
        data-mce-style="color: #222222; font-family: arial; font-size:
        small;">loadmodule "sdpops.so"</div>
      <div style="color: #222222; font-family: arial; font-size: small;"
        data-mce-style="color: #222222; font-family: arial; font-size:
        small;">loadmodule "app_python.so"</div>
      <div style="color: #222222; font-family: arial; font-size: small;"
        data-mce-style="color: #222222; font-family: arial; font-size:
        small;">#!endif</div>
      <div style="color: #222222; font-family: arial; font-size: small;"
        data-mce-style="color: #222222; font-family: arial; font-size:
        small;">......</div>
      <div style="color: #222222; font-family: arial; font-size: small;"
        data-mce-style="color: #222222; font-family: arial; font-size:
        small;">modparam("app_python", "script_name",
        "/usr/local/etc/sip-router/setflow.py")</div>
      <div style="color: #222222; font-family: arial; font-size: small;"
        data-mce-style="color: #222222; font-family: arial; font-size:
        small;">modparam("app_python", "mod_init_function", "mod_init")</div>
      <div style="color: #222222; font-family: arial; font-size: small;"
        data-mce-style="color: #222222; font-family: arial; font-size:
        small;">modparam("app_python", "child_init_method",
        "child_init")</div>
      <div style="color: #222222; font-family: arial; font-size: small;"
        data-mce-style="color: #222222; font-family: arial; font-size:
        small;">......</div>
      <div style="color: #222222; font-family: arial; font-size: small;"
        data-mce-style="color: #222222; font-family: arial; font-size:
        small;">......</div>
      <div style="color: #222222; font-family: arial; font-size: small;"
        data-mce-style="color: #222222; font-family: arial; font-size:
        small;">request_route {</div>
      <div style="color: #222222; font-family: arial; font-size: small;"
        data-mce-style="color: #222222; font-family: arial; font-size:
        small;"> </div>
      <div style="color: #222222; font-family: arial; font-size: small;"
        data-mce-style="color: #222222; font-family: arial; font-size:
        small;"> </div>
      <div style="color: #222222; font-family: arial; font-size: small;"
        data-mce-style="color: #222222; font-family: arial; font-size:
        small;">if (sdp_with_media("video")){</div>
      <div style="color: #222222; font-family: arial; font-size: small;"
        data-mce-style="color: #222222; font-family: arial; font-size:
        small;">       python_exec("setflow");</div>
      <div style="color: #222222; font-family: arial; font-size: small;"
        data-mce-style="color: #222222; font-family: arial; font-size:
        small;">}</div>
      <div style="color: #222222; font-family: arial; font-size: small;"
        data-mce-style="color: #222222; font-family: arial; font-size:
        small;">..........</div>
      <div style="color: #222222; font-family: arial; font-size: small;"
        data-mce-style="color: #222222; font-family: arial; font-size:
        small;">..........</div>
      <div style="color: #222222; font-family: arial; font-size: small;"
        data-mce-style="color: #222222; font-family: arial; font-size:
        small;"> </div>
      <div style="color: #222222; font-family: arial; font-size: small;"
        data-mce-style="color: #222222; font-family: arial; font-size:
        small;">Basically, this python script should be executed if the
        media session is video. For that it should have analyzed SDP
        body during the session establishment. However, it is executed
        as soon as kamailio is running. There was no any session
        establishment procedure (no INVITE), three way handshake, etc.  </div>
      <div style="color: #222222; font-family: arial; font-size: small;"
        data-mce-style="color: #222222; font-family: arial; font-size:
        small;">How it is possible to solve this issue? Do I need to
        execute it under certain conditions or am I missing something?
        Why the script is executed even though it is in "if" statement?
        I thought that it would execute the script if condition is
        true. </div>
      <div style="color: #222222; font-family: arial; font-size: small;"
        data-mce-style="color: #222222; font-family: arial; font-size:
        small;"> </div>
      <div style="color: #222222; font-family: arial; font-size: small;"
        data-mce-style="color: #222222; font-family: arial; font-size:
        small;">Thank you in advance.</div>
      <div style="color: #222222; font-family: arial; font-size: small;"
        data-mce-style="color: #222222; font-family: arial; font-size:
        small;"> </div>
      <div style="color: #222222; font-family: arial; font-size: small;"
        data-mce-style="color: #222222; font-family: arial; font-size:
        small;">Cheers,</div>
      <div style="color: #222222; font-family: arial; font-size: small;"
        data-mce-style="color: #222222; font-family: arial; font-size:
        small;">Azat</div>
      <br>
      <br>
      Best Regards,<br>
      Azamat Ailbayev<br>
      Mob.: +49 (0) 15215023005
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
sr-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:sr-dev@lists.sip-router.org">sr-dev@lists.sip-router.org</a>
<a class="moz-txt-link-freetext" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev</a>
</pre>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla
<a class="moz-txt-link-freetext" href="http://twitter.com/#!/miconda">http://twitter.com/#!/miconda</a> - <a class="moz-txt-link-freetext" href="http://www.linkedin.com/in/miconda">http://www.linkedin.com/in/miconda</a>
Kamailio Advanced Training, Nov 24-27, Berlin - <a class="moz-txt-link-freetext" href="http://www.asipto.com">http://www.asipto.com</a></pre>
  </body>
</html>