Changeset 4161
- Timestamp:
- Jun 7, 2012 9:28:48 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/conference.c
r3664 r4161 1798 1798 pj_mutex_lock(conf->mutex); 1799 1799 1800 /* Reset port source count. We will only reset port's mix1801 * buffer when we have someone transmitting to it.1802 */ 1803 for (i=0, ci=0; i <conf->max_ports && ci < conf->port_cnt; ++i) {1800 /* Get frames from all ports, and "mix" the signal 1801 * to mix_buf of all listeners of the port. 1802 */ 1803 for (i=0, ci=0; i < conf->max_ports && ci < conf->port_cnt; ++i) { 1804 1804 struct conf_port *conf_port = conf->ports[i]; 1805 1806 /* Skip empty slot. */ 1805 pj_int32_t level = 0; 1806 1807 /* Skip empty port. */ 1807 1808 if (!conf_port) 1808 1809 continue; 1809 1810 1811 /* Var "ci" is to count how many ports have been visited so far. */ 1810 1812 ++ci; 1811 1813 1812 /* Reset buffer & auto adjustment level for mixed signal */ 1814 /* Reset buffer (only necessary if more than one transmitter) & 1815 * reset auto adjustment level for mixed signal */ 1813 1816 conf_port->mix_adj = NORMAL_LEVEL; 1814 if (conf_port->transmitter_cnt ) {1817 if (conf_port->transmitter_cnt > 1) { 1815 1818 pj_bzero(conf_port->mix_buf, 1816 1819 conf->samples_per_frame*sizeof(conf_port->mix_buf[0])); 1817 1820 } 1818 }1819 1820 /* Get frames from all ports, and "mix" the signal1821 * to mix_buf of all listeners of the port.1822 */1823 for (i=0, ci=0; i<conf->max_ports && ci<conf->port_cnt; ++i) {1824 struct conf_port *conf_port = conf->ports[i];1825 pj_int32_t level = 0;1826 1827 /* Skip empty port. */1828 if (!conf_port)1829 continue;1830 1831 /* Var "ci" is to count how many ports have been visited so far. */1832 ++ci;1833 1821 1834 1822 /* Skip if we're not allowed to receive from this port. */ … … 1949 1937 mix_buf = listener->mix_buf; 1950 1938 1951 /* Mixing signals, 1952 * and calculate appropriate level adjustment if there is 1953 * any overflowed level in the mixed signal. 1954 */ 1955 for (k=0; k<conf->samples_per_frame; ++k) { 1956 mix_buf[k] += p_in[k]; 1957 /* Check if normalization adjustment needed. */ 1958 if (IS_OVERFLOW(mix_buf[k])) { 1959 /* NORMAL_LEVEL * MAX_LEVEL / mix_buf[k]; */ 1960 int tmp_adj = (MAX_LEVEL<<7) / mix_buf[k]; 1961 if (tmp_adj<0) tmp_adj = -tmp_adj; 1962 1963 if (tmp_adj<listener->mix_adj) 1964 listener->mix_adj = tmp_adj; 1965 1966 } /* if any overflow in the mixed signals */ 1967 } /* loop mixing signals */ 1939 if (listener->transmitter_cnt > 1) { 1940 /* Mixing signals, 1941 * and calculate appropriate level adjustment if there is 1942 * any overflowed level in the mixed signal. 1943 */ 1944 for (k=0; k < conf->samples_per_frame; ++k) { 1945 mix_buf[k] += p_in[k]; 1946 /* Check if normalization adjustment needed. */ 1947 if (IS_OVERFLOW(mix_buf[k])) { 1948 /* NORMAL_LEVEL * MAX_LEVEL / mix_buf[k]; */ 1949 int tmp_adj = (MAX_LEVEL<<7) / mix_buf[k]; 1950 if (tmp_adj<0) tmp_adj = -tmp_adj; 1951 1952 if (tmp_adj<listener->mix_adj) 1953 listener->mix_adj = tmp_adj; 1954 1955 } /* if any overflow in the mixed signals */ 1956 } /* loop mixing signals */ 1957 } else { 1958 /* Only 1 transmitter: 1959 * just copy the samples to the mix buffer 1960 * no mixing and level adjustment needed 1961 */ 1962 for (k=0; k<conf->samples_per_frame; ++k) { 1963 mix_buf[k] = p_in[k]; 1964 } 1965 } 1968 1966 } /* loop the listeners of conf port */ 1969 1967 } /* loop of all conf ports */
Note: See TracChangeset
for help on using the changeset viewer.