]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
write cng frames during sleep
authorAnthony Minessale <anthony.minessale@gmail.com>
Fri, 3 Oct 2008 18:15:04 +0000 (18:15 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Fri, 3 Oct 2008 18:15:04 +0000 (18:15 +0000)
git-svn-id: http://svn.openzap.org/svn/openzap/trunk@576 a93c3328-9c30-0410-af19-c9cd2b2d52af

libs/openzap/mod_openzap/mod_openzap.c

index 18064e648675beedeff48b061c02a35b1f7509c2..94c2ac78342b0a6cc8daa1ecf45ca58816aba2ef 100644 (file)
@@ -364,6 +364,8 @@ static switch_status_t channel_on_init(switch_core_session_t *session)
 
        zap_channel_init(tech_pvt->zchan);
 
+       switch_channel_set_flag(channel, CF_ACCEPT_CNG);
+
        return SWITCH_STATUS_SUCCESS;
 }
 
@@ -636,7 +638,8 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
        switch_channel_t *channel = NULL;
        private_t *tech_pvt = NULL;
        zap_size_t len;
-
+       unsigned char data[SWITCH_RECOMMENDED_BUFFER_SIZE] = {0};
+       
        channel = switch_core_session_get_channel(session);
        assert(channel != NULL);
 
@@ -653,6 +656,16 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
                goto fail;
        }
        
+       if (switch_test_flag(frame, SFF_CNG)) {
+               frame->data = data;
+               frame->buflen = sizeof(data);
+               if ((frame->datalen = tech_pvt->write_codec.implementation->encoded_bytes_per_frame) > frame->buflen) {
+                       goto fail;
+               }
+               memset(data, 255, frame->datalen);
+       }
+
+
        len = frame->datalen;
        if (zap_channel_write(tech_pvt->zchan, frame->data, frame->buflen, &len) != ZAP_SUCCESS) {
                if (++tech_pvt->wr_error > 10) {