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

List:       freeswitch-dev
Subject:    Re: [Freeswitch-dev] two rtp questions - rtp debug and non block rtp read
From:       cmrienzo () gmail ! com
Date:       2013-08-05 12:54:28
Message-ID: 76E99CD7-6497-4B5C-BFF8-135D2F976C89 () gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


For question 1, you can use SWITCH_CHANNEL_SESSION_LOG if you have a NULL session \
pointer.

Chris


On Aug 4, 2013, at 8:54 PM, Seven Du <dujinfang@gmail.com> wrote:

> Hi,
> 
> 1) when use switch_rtp without a session SWITCH_RTP_FLAG_DEBUG_RTP_READ complaining \
> no session attached because it use SWITCH_CHANNEL_SESSION_LOG. 
> Suggested fix:
> 
> use SWITCH_CHANNEL_SESSION_LOG where possible and SWITCH_CHANNEL_LOG when no \
> session. 
> also, I think the following code is wrong because there's no rtp_session->session:
> 
> if (!rtp_session->session) {
> 	rtp_session->flags[SWITCH_RTP_FLAG_DEBUG_RTP_READ] = 0;
> 	switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), \
> SWITCH_LOG_CRIT, "RTP HAS NO SESSION!\n");  } else {
> 	...
> 
> I can fix and push if confirmed.
> 
> 2) switch_rtp_zerocopy_read_frame() blocks forever if no RTP comes. Anyway to make \
> it non block? I tried the following code  it blocks even with \
> SWITCH_IO_FLAG_NOBLOCK. 
> I tried the following code in mod_skel, I can make a diff if necessary.
> 
> 
> 	rtp_flag[SWITCH_RTP_FLAG_IO] = 1;
> 	rtp_flag[SWITCH_RTP_FLAG_AUTOADJ] = 1;
> 	rtp_flag[SWITCH_RTP_FLAG_DATAWAIT] = 0;
> 	rtp_flag[SWITCH_RTP_FLAG_VIDEO] = 1;
> 	rtp_flag[SWITCH_RTP_FLAG_NOBLOCK] = 1;
> 	rtp_flag[SWITCH_RTP_FLAG_AUTO_CNG] = 1;
> 	// rtp_flag[SWITCH_RTP_FLAG_DEBUG_RTP_READ] = 1;
> 	// rtp_flag[SWITCH_RTP_FLAG_DEBUG_RTP_WRITE] = 1;
> 
> 	rtp_session = switch_rtp_new(IP, //local
> 		50002, //recv port
> 		IP,
> 		42000, //remote, doesn't matter for us, but can't be 0
> 		96, // payload_type
> 		1,
> 		90000,
> 		rtp_flag,
> 		NULL, &err, pool);
> 
> 	if (!rtp_session) {
> 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "RTP Error: %s\n", err);
> 		goto done;
> 	}
> 
> 	while(!done) {
> 		// status = switch_rtp_zerocopy_read_frame(rtp_session, &read_frame, \
> SWITCH_IO_FLAG_NOBLOCK);  status = switch_rtp_zerocopy_read_frame(rtp_session, \
> &read_frame, SWITCH_IO_FLAG_NONE);  switch_log_printf(SWITCH_CHANNEL_LOG, \
> SWITCH_LOG_INFO, "read %d\n", read_frame.packetlen);  switch_yield(100000);
> 	}
> 
> Thanks for help.
> 
> 
> -- 
> Seven Du
> http://www.freeswitch.org.cn
> http://about.me/dujinfang
> http://www.dujinfang.com
> 
> Sent with Sparrow
> 
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting@freeswitch.org
> http://www.freeswitchsolutions.com
> 
> FreeSWITCH-powered IP PBX: The CudaTel Communication Server
> http://www.cudatel.com
> 
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://wiki.freeswitch.org
> http://www.cluecon.com
> 
> FreeSWITCH-dev mailing list
> FreeSWITCH-dev@lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev
> http://www.freeswitch.org


[Attachment #5 (text/html)]

<html><head><meta http-equiv="content-type" content="text/html; \
charset=utf-8"></head><body dir="auto"><div>For question 1, you can use \
SWITCH_CHANNEL_SESSION_LOG if you have a NULL session \
pointer.</div><div><br></div><div>Chris</div><div><br></div><div><br>On Aug 4, 2013, \
at 8:54 PM, Seven Du &lt;<a \
href="mailto:dujinfang@gmail.com">dujinfang@gmail.com</a>&gt; \
wrote:<br><br></div><blockquote type="cite"><div>  <div>
                    Hi,
                </div><div><br></div><div>1) when use switch_rtp without a \
session&nbsp;SWITCH_RTP_FLAG_DEBUG_RTP_READ complaining no session attached because \
it use&nbsp;SWITCH_CHANNEL_SESSION_LOG.</div><div><br></div><div>Suggested \
fix:</div><div><br></div><div>use&nbsp;SWITCH_CHANNEL_SESSION_LOG where possible \
and&nbsp;SWITCH_CHANNEL_LOG when no session.</div><div><br></div><div>also, I think \
the following code is wrong because there's no \
rtp_session-&gt;session:</div><div><br></div><div>if (!rtp_session-&gt;session) \
{</div><div><div><span \
style="white-space:pre">	</span>rtp_session-&gt;flags[SWITCH_RTP_FLAG_DEBUG_RTP_READ] \
= 0;</div><div><span \
style="white-space:pre">	</span>switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session-&gt;session), \
SWITCH_LOG_CRIT, "RTP HAS NO SESSION!\n");</div><div><span \
style="white-space:pre">	</span>} else {</div></div><div><span \
style="white-space:pre">	</span>...</div><div><br></div><div>I can fix and push if \
confirmed.</div><div><br></div><div>2)&nbsp;switch_rtp_zerocopy_read_frame() blocks \
forever if no RTP comes. Anyway to make it non block? I tried the following code \
&nbsp;it blocks even with&nbsp;SWITCH_IO_FLAG_NOBLOCK.</div><div><br></div><div>I \
tried the following code in mod_skel, I can make a diff if \
necessary.</div><div><br></div><div><br></div><div><div><span \
style="white-space:pre">	</span>rtp_flag[SWITCH_RTP_FLAG_IO] = 1;</div><div><span \
style="white-space:pre">	</span>rtp_flag[SWITCH_RTP_FLAG_AUTOADJ] = \
1;</div><div><span style="white-space:pre">	</span>rtp_flag[SWITCH_RTP_FLAG_DATAWAIT] \
= 0;</div><div><span style="white-space:pre">	</span>rtp_flag[SWITCH_RTP_FLAG_VIDEO] \
= 1;</div><div><span \
style="white-space:pre">	</span>rtp_flag[SWITCH_RTP_FLAG_NOBLOCK] = \
1;</div><div><span style="white-space:pre">	</span>rtp_flag[SWITCH_RTP_FLAG_AUTO_CNG] \
= 1;</div><div><span style="white-space:pre">	</span>// \
rtp_flag[SWITCH_RTP_FLAG_DEBUG_RTP_READ] = 1;</div><div><span \
style="white-space:pre">	</span>// rtp_flag[SWITCH_RTP_FLAG_DEBUG_RTP_WRITE] = \
1;</div><div><br></div><div><span style="white-space:pre">	</span>rtp_session = \
switch_rtp_new(IP, //local</div><div><span style="white-space:pre">		</span>50002, \
//recv port</div><div><span style="white-space:pre">		</span>IP,</div><div><span \
style="white-space:pre">		</span>42000, //remote, doesn't matter for us, but can't be \
0</div><div><span style="white-space:pre">		</span>96, // \
payload_type</div><div><span style="white-space:pre">		</span>1,</div><div><span \
style="white-space:pre">		</span>90000,</div><div><span \
style="white-space:pre">		</span>rtp_flag,</div><div><span \
style="white-space:pre">		</span>NULL, &amp;err, \
pool);</div><div><br></div><div><span style="white-space:pre">	</span>if \
(!rtp_session) {</div><div><span \
style="white-space:pre">		</span>switch_log_printf(SWITCH_CHANNEL_LOG, \
SWITCH_LOG_ERROR, "RTP Error: %s\n", err);</div><div><span \
style="white-space:pre">		</span>goto done;</div><div><span \
style="white-space:pre">	</span>}</div><div><br></div><div><span \
style="white-space:pre">	</span>while(!done) {</div><div><span \
style="white-space:pre">		</span>// status = \
switch_rtp_zerocopy_read_frame(rtp_session, &amp;read_frame, \
SWITCH_IO_FLAG_NOBLOCK);</div><div><span style="white-space:pre">		</span>status = \
switch_rtp_zerocopy_read_frame(rtp_session, &amp;read_frame, \
SWITCH_IO_FLAG_NONE);</div><div><span \
style="white-space:pre">		</span>switch_log_printf(SWITCH_CHANNEL_LOG, \
SWITCH_LOG_INFO, "read %d\n", read_frame.packetlen);</div><div><span \
style="white-space:pre">		</span>switch_yield(100000);</div><div><span \
style="white-space:pre">	</span>}</div></div><div><br></div>  <div><div>Thanks for \
help.</div><div><br></div><div><br></div><div>--&nbsp;</div><div>Seven \
Du</div><div><span style="font-size: 10pt; "><a \
href="http://www.freeswitch.org.cn">http://www.freeswitch.org.cn</a></span></div><div><a \
href="http://about.me/dujinfang">http://about.me/dujinfang</a></div><div><div><a \
href="http://www.dujinfang.com">http://www.dujinfang.com</a></div></div><div><br></div><div>Sent \
with <a href="http://www.sparrowmailapp.com/?sig">Sparrow</a></div><div><br></div></div>
  </div></blockquote><blockquote \
type="cite"><div><span>_________________________________________________________________________</span><br><span>Professional \
FreeSWITCH Consulting Services:</span><br><span><a \
href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</a></span><br><span><a \
href="http://www.freeswitchsolutions.com">http://www.freeswitchsolutions.com</a></span><br><span></span><br><span>FreeSWITCH-powered \
IP PBX: The CudaTel Communication Server</span><br><span><a \
href="http://www.cudatel.com">http://www.cudatel.com</a></span><br><span></span><br><span>Official \
FreeSWITCH Sites</span><br><span><a \
href="http://www.freeswitch.org">http://www.freeswitch.org</a></span><br><span><a \
href="http://wiki.freeswitch.org">http://wiki.freeswitch.org</a></span><br><span><a \
href="http://www.cluecon.com">http://www.cluecon.com</a></span><br><span></span><br><span>FreeSWITCH-dev \
mailing list</span><br><span><a \
href="mailto:FreeSWITCH-dev@lists.freeswitch.org">FreeSWITCH-dev@lists.freeswitch.org</a></span><br><span><a \
href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev">http://lists.freesw \
itch.org/mailman/listinfo/freeswitch-dev</a></span><br><span>UNSUBSCRIBE:http://<a \
href="http://lists.freeswitch.org/mailman/options/freeswitch-dev">lists.freeswitch.org/mailman/options/freeswitch-dev</a></span><br><span><a \
href="http://www.freeswitch.org">http://www.freeswitch.org</a></span><br></div></blockquote></body></html>




_________________________________________________________________________
Professional FreeSWITCH Consulting Services:
consulting@freeswitch.org
http://www.freeswitchsolutions.com

FreeSWITCH-powered IP PBX: The CudaTel Communication Server
http://www.cudatel.com

Official FreeSWITCH Sites
http://www.freeswitch.org
http://wiki.freeswitch.org
http://www.cluecon.com

FreeSWITCH-dev mailing list
FreeSWITCH-dev@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev
http://www.freeswitch.org


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

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