[Freeswitch-svn] [commit] r12811 - freeswitch/trunk/src/mod/endpoints/mod_opal

FreeSWITCH SVN anthm at freeswitch.org
Fri Mar 27 12:54:45 PDT 2009


Author: anthm
Date: Fri Mar 27 14:54:45 2009
New Revision: 12811

Log:
allocate frame from session pool so it will not go out of scope

Modified:
   freeswitch/trunk/src/mod/endpoints/mod_opal/mod_opal.cpp
   freeswitch/trunk/src/mod/endpoints/mod_opal/mod_opal.h

Modified: freeswitch/trunk/src/mod/endpoints/mod_opal/mod_opal.cpp
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_opal/mod_opal.cpp	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_opal/mod_opal.cpp	Fri Mar 27 14:54:45 2009
@@ -1057,9 +1057,11 @@
     , m_readRTP(0, 512)
     , m_callOnStart(true)
 {
-    memset(&m_readFrame, 0, sizeof(m_readFrame));
-    m_readFrame.codec = m_switchCodec;
-    m_readFrame.flags = SFF_RAW_RTP;
+
+    m_readFrame = (switch_frame_t *) switch_core_session_alloc(m_fsSession, sizeof(*m_readFrame));
+
+    m_readFrame->codec = m_switchCodec;
+    m_readFrame->flags = SFF_RAW_RTP;
 }
 
 
@@ -1116,7 +1118,7 @@
            << mediaFormat.GetMediaType() << " codec " << mediaFormat << " for connection " << *this);
 
     if (IsSink()) {
-        m_readFrame.rate = mediaFormat.GetClockRate();
+        m_readFrame->rate = mediaFormat.GetClockRate();
 
         if (isAudio) {
             switch_core_session_set_read_codec(m_fsSession, m_switchCodec);
@@ -1195,7 +1197,7 @@
         m_callOnStart = false;
     }
 
-    m_readFrame.flags = 0;
+    m_readFrame->flags = 0;
 
     /*
     while (switch_channel_ready(m_fsChannel)) {
@@ -1222,7 +1224,7 @@
                 return SWITCH_STATUS_FALSE;
             }
             if (!m_readRTP.GetPayloadSize()) {
-                m_readFrame.flags = SFF_CNG;
+                m_readFrame->flags = SFF_CNG;
                 break;
             }
         }
@@ -1234,8 +1236,8 @@
     
         switch_core_timer_next(m_switchTimer);
     
-        if (!(m_readFrame.datalen = m_readRTP.GetPayloadSize())) {
-            m_readFrame.flags = SFF_CNG;
+        if (!(m_readFrame->datalen = m_readRTP.GetPayloadSize())) {
+            m_readFrame->flags = SFF_CNG;
         }
     }
 
@@ -1245,17 +1247,17 @@
 
     //switch_core_timer_step(&m_switchTimer);
 
-    m_readFrame.buflen = m_readRTP.GetSize();
-    m_readFrame.data = m_readRTP.GetPayloadPtr();
-    m_readFrame.packet = m_readRTP.GetPointer();
-    m_readFrame.packetlen = m_readRTP.GetHeaderSize() + m_readFrame.datalen;
-    m_readFrame.payload = (switch_payload_t) m_readRTP.GetPayloadType();
-    m_readFrame.timestamp = m_readRTP.GetTimestamp();
-    m_readFrame.m = (switch_bool_t) m_readRTP.GetMarker();
-    m_readFrame.seq = m_readRTP.GetSequenceNumber();
-    m_readFrame.ssrc = m_readRTP.GetSyncSource();
-    m_readFrame.codec = m_switchCodec;
-    *frame = &m_readFrame;
+    m_readFrame->buflen = m_readRTP.GetSize();
+    m_readFrame->data = m_readRTP.GetPayloadPtr();
+    m_readFrame->packet = m_readRTP.GetPointer();
+    m_readFrame->packetlen = m_readRTP.GetHeaderSize() + m_readFrame->datalen;
+    m_readFrame->payload = (switch_payload_t) m_readRTP.GetPayloadType();
+    m_readFrame->timestamp = m_readRTP.GetTimestamp();
+    m_readFrame->m = (switch_bool_t) m_readRTP.GetMarker();
+    m_readFrame->seq = m_readRTP.GetSequenceNumber();
+    m_readFrame->ssrc = m_readRTP.GetSyncSource();
+    m_readFrame->codec = m_switchCodec;
+    *frame = m_readFrame;
 
     return SWITCH_STATUS_SUCCESS;
 }

Modified: freeswitch/trunk/src/mod/endpoints/mod_opal/mod_opal.h
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_opal/mod_opal.h	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_opal/mod_opal.h	Fri Mar 27 14:54:45 2009
@@ -234,7 +234,7 @@
     switch_channel_t *m_fsChannel;
     switch_timer_t *m_switchTimer;
     switch_codec_t *m_switchCodec;
-    switch_frame_t m_readFrame;
+    switch_frame_t *m_readFrame;
     RTP_DataFrame m_readRTP;
     bool m_callOnStart;
     uint32_t m_timeStamp;



More information about the Freeswitch-svn mailing list