<HTML><BODY><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</BODY></HTML>