/** * \brief Writes data to a Wanpipe channel * \param ftdmchan Channel to write to * \param data Data buffer * \param datalen Size of data buffer * \return Success or failure */ static FIO_WRITE_FUNCTION(wanpipe_write) { int bsent; wp_tdm_api_tx_hdr_t hdrframe; /* Do we even need the headerframe here? on windows, we don't even pass it to the driver */ memset(&hdrframe, 0, sizeof(hdrframe)); if (*datalen == 0) { return FTDM_SUCCESS; } bsent = sangoma_writemsg_tdm(ftdmchan->sockfd, &hdrframe, (int)sizeof(hdrframe), data, (unsigned short)(*datalen),0); /* should we be checking if bsent == *datalen here? */ if (bsent > 0) { *datalen = bsent; return FTDM_SUCCESS; } return FTDM_FAIL; }
sbridge_bool_t sbridge_media_write(sbridge_chan_t *chan, sbridge_media_frame_t *f) { int32_t rc; if (chan->trace_raw_out) { int len = 0; len = fwrite(f->data.ptr, 1, f->datalen, chan->trace_raw_out); if (len != f->datalen) { sbridge_log(SBRIDGE_LOG_WARNING, "just wrote %d bytes of raw output when %d were requested\n", len, f->datalen); } fflush(chan->trace_raw_out); } rc = sangoma_writemsg_tdm(chan->sangoma_sock, &chan->hdrframe, sizeof(chan->hdrframe), (unsigned char *)f->data.ptr, f->datalen, 0); if (rc < 0) { sbridge_log(SBRIDGE_LOG_ERROR, "Failed to write to sangoma channel %d: %s\n", chan->channo, strerror(errno)); return SBRIDGE_FALSE; } if (rc == 0) { sbridge_log(SBRIDGE_LOG_ERROR, "Wow, wrote 0 bytes to sangoma channel %d: %s\n", chan->channo, strerror(errno)); return SBRIDGE_FALSE; } return SBRIDGE_TRUE; }