├── .gitignore ├── Makefile ├── README.md ├── base ├── Makefile ├── bytes.h ├── config.cpp ├── config.h ├── log.cpp ├── log.h ├── net.cpp ├── net.h ├── objpool.h ├── packet.cpp ├── packet.h ├── strings.h ├── tcplink.cpp ├── tcplink.h ├── udplink.cpp └── udplink.h ├── build.sh ├── build_library.mk ├── client ├── Makefile ├── client.h ├── voice_client.h ├── voice_client_impl.cpp └── voice_client_impl.h ├── deps ├── freetype.framework │ ├── Resources │ │ └── Info.plist │ ├── Versions │ │ ├── A │ │ │ ├── Resources │ │ │ │ └── Info.plist │ │ │ └── freetype │ │ └── Current │ │ │ ├── Resources │ │ │ └── Info.plist │ │ │ └── freetype │ └── freetype ├── opus-1.0.3 │ ├── AUTHORS │ ├── COPYING │ ├── ChangeLog │ ├── INSTALL │ ├── Makefile.am │ ├── Makefile.in │ ├── Makefile.unix │ ├── NEWS │ ├── README │ ├── aclocal.m4 │ ├── celt │ │ ├── _kiss_fft_guts.h │ │ ├── arch.h │ │ ├── bands.c │ │ ├── bands.h │ │ ├── celt.c │ │ ├── celt.h │ │ ├── celt.vcxproj │ │ ├── celt.vcxproj.filters │ │ ├── celt_lpc.c │ │ ├── celt_lpc.h │ │ ├── cwrs.c │ │ ├── cwrs.h │ │ ├── ecintrin.h │ │ ├── entcode.c │ │ ├── entcode.h │ │ ├── entdec.c │ │ ├── entdec.h │ │ ├── entenc.c │ │ ├── entenc.h │ │ ├── fixed_debug.h │ │ ├── fixed_generic.h │ │ ├── float_cast.h │ │ ├── kiss_fft.c │ │ ├── kiss_fft.h │ │ ├── laplace.c │ │ ├── laplace.h │ │ ├── mathops.c │ │ ├── mathops.h │ │ ├── mdct.c │ │ ├── mdct.h │ │ ├── mfrngcod.h │ │ ├── modes.c │ │ ├── modes.h │ │ ├── opus_custom_demo.c │ │ ├── os_support.h │ │ ├── pitch.c │ │ ├── pitch.h │ │ ├── quant_bands.c │ │ ├── quant_bands.h │ │ ├── rate.c │ │ ├── rate.h │ │ ├── stack_alloc.h │ │ ├── static_modes_fixed.h │ │ ├── static_modes_float.h │ │ ├── tests │ │ │ ├── test_unit_cwrs32.c │ │ │ ├── test_unit_dft.c │ │ │ ├── test_unit_entropy.c │ │ │ ├── test_unit_laplace.c │ │ │ ├── test_unit_mathops.c │ │ │ ├── test_unit_mdct.c │ │ │ ├── test_unit_rotation.c │ │ │ └── test_unit_types.c │ │ ├── vq.c │ │ └── vq.h │ ├── celt_headers.mk │ ├── celt_sources.mk │ ├── compile │ ├── config.guess │ ├── config.h.in │ ├── config.sub │ ├── configure │ ├── configure.ac │ ├── depcomp │ ├── doc │ │ ├── Doxyfile.in │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── customdoxygen.css │ │ ├── footer.html │ │ ├── header.html │ │ └── opus_logo.svg │ ├── include │ │ ├── opus.h │ │ ├── opus_custom.h │ │ ├── opus_defines.h │ │ ├── opus_multistream.h │ │ └── opus_types.h │ ├── install-sh │ ├── ltmain.sh │ ├── m4 │ │ ├── libtool.m4 │ │ ├── ltoptions.m4 │ │ ├── ltsugar.m4 │ │ ├── ltversion.m4 │ │ └── lt~obsolete.m4 │ ├── missing │ ├── opus-uninstalled.pc.in │ ├── opus.m4 │ ├── opus.pc.in │ ├── opus.sln │ ├── opus_headers.mk │ ├── opus_sources.mk │ ├── package_version │ ├── silk │ │ ├── A2NLSF.c │ │ ├── API.h │ │ ├── CNG.c │ │ ├── HP_variable_cutoff.c │ │ ├── Inlines.h │ │ ├── LPC_analysis_filter.c │ │ ├── LPC_inv_pred_gain.c │ │ ├── LP_variable_cutoff.c │ │ ├── MacroCount.h │ │ ├── MacroDebug.h │ │ ├── NLSF2A.c │ │ ├── NLSF_VQ.c │ │ ├── NLSF_VQ_weights_laroia.c │ │ ├── NLSF_decode.c │ │ ├── NLSF_del_dec_quant.c │ │ ├── NLSF_encode.c │ │ ├── NLSF_stabilize.c │ │ ├── NLSF_unpack.c │ │ ├── NSQ.c │ │ ├── NSQ_del_dec.c │ │ ├── PLC.c │ │ ├── PLC.h │ │ ├── SigProc_FIX.h │ │ ├── VAD.c │ │ ├── VQ_WMat_EC.c │ │ ├── ana_filt_bank_1.c │ │ ├── biquad_alt.c │ │ ├── bwexpander.c │ │ ├── bwexpander_32.c │ │ ├── check_control_input.c │ │ ├── code_signs.c │ │ ├── control.h │ │ ├── control_SNR.c │ │ ├── control_audio_bandwidth.c │ │ ├── control_codec.c │ │ ├── debug.c │ │ ├── debug.h │ │ ├── dec_API.c │ │ ├── decode_core.c │ │ ├── decode_frame.c │ │ ├── decode_indices.c │ │ ├── decode_parameters.c │ │ ├── decode_pitch.c │ │ ├── decode_pulses.c │ │ ├── decoder_set_fs.c │ │ ├── define.h │ │ ├── enc_API.c │ │ ├── encode_indices.c │ │ ├── encode_pulses.c │ │ ├── errors.h │ │ ├── fixed │ │ │ ├── LTP_analysis_filter_FIX.c │ │ │ ├── LTP_scale_ctrl_FIX.c │ │ │ ├── apply_sine_window_FIX.c │ │ │ ├── autocorr_FIX.c │ │ │ ├── burg_modified_FIX.c │ │ │ ├── corrMatrix_FIX.c │ │ │ ├── encode_frame_FIX.c │ │ │ ├── find_LPC_FIX.c │ │ │ ├── find_LTP_FIX.c │ │ │ ├── find_pitch_lags_FIX.c │ │ │ ├── find_pred_coefs_FIX.c │ │ │ ├── k2a_FIX.c │ │ │ ├── k2a_Q16_FIX.c │ │ │ ├── main_FIX.h │ │ │ ├── noise_shape_analysis_FIX.c │ │ │ ├── pitch_analysis_core_FIX.c │ │ │ ├── prefilter_FIX.c │ │ │ ├── process_gains_FIX.c │ │ │ ├── regularize_correlations_FIX.c │ │ │ ├── residual_energy16_FIX.c │ │ │ ├── residual_energy_FIX.c │ │ │ ├── schur64_FIX.c │ │ │ ├── schur_FIX.c │ │ │ ├── silk_fixed.vcxproj │ │ │ ├── silk_fixed.vcxproj.filters │ │ │ ├── solve_LS_FIX.c │ │ │ ├── structs_FIX.h │ │ │ ├── vector_ops_FIX.c │ │ │ └── warped_autocorrelation_FIX.c │ │ ├── float │ │ │ ├── LPC_analysis_filter_FLP.c │ │ │ ├── LPC_inv_pred_gain_FLP.c │ │ │ ├── LTP_analysis_filter_FLP.c │ │ │ ├── LTP_scale_ctrl_FLP.c │ │ │ ├── SigProc_FLP.h │ │ │ ├── apply_sine_window_FLP.c │ │ │ ├── autocorrelation_FLP.c │ │ │ ├── burg_modified_FLP.c │ │ │ ├── bwexpander_FLP.c │ │ │ ├── corrMatrix_FLP.c │ │ │ ├── encode_frame_FLP.c │ │ │ ├── energy_FLP.c │ │ │ ├── find_LPC_FLP.c │ │ │ ├── find_LTP_FLP.c │ │ │ ├── find_pitch_lags_FLP.c │ │ │ ├── find_pred_coefs_FLP.c │ │ │ ├── inner_product_FLP.c │ │ │ ├── k2a_FLP.c │ │ │ ├── levinsondurbin_FLP.c │ │ │ ├── main_FLP.h │ │ │ ├── noise_shape_analysis_FLP.c │ │ │ ├── pitch_analysis_core_FLP.c │ │ │ ├── prefilter_FLP.c │ │ │ ├── process_gains_FLP.c │ │ │ ├── regularize_correlations_FLP.c │ │ │ ├── residual_energy_FLP.c │ │ │ ├── scale_copy_vector_FLP.c │ │ │ ├── scale_vector_FLP.c │ │ │ ├── schur_FLP.c │ │ │ ├── silk_float.vcxproj │ │ │ ├── silk_float.vcxproj.filters │ │ │ ├── solve_LS_FLP.c │ │ │ ├── sort_FLP.c │ │ │ ├── structs_FLP.h │ │ │ ├── warped_autocorrelation_FLP.c │ │ │ └── wrappers_FLP.c │ │ ├── gain_quant.c │ │ ├── init_decoder.c │ │ ├── init_encoder.c │ │ ├── inner_prod_aligned.c │ │ ├── interpolate.c │ │ ├── lin2log.c │ │ ├── log2lin.c │ │ ├── macros.h │ │ ├── main.h │ │ ├── pitch_est_defines.h │ │ ├── pitch_est_tables.c │ │ ├── process_NLSFs.c │ │ ├── quant_LTP_gains.c │ │ ├── resampler.c │ │ ├── resampler_down2.c │ │ ├── resampler_down2_3.c │ │ ├── resampler_private.h │ │ ├── resampler_private_AR2.c │ │ ├── resampler_private_IIR_FIR.c │ │ ├── resampler_private_down_FIR.c │ │ ├── resampler_private_up2_HQ.c │ │ ├── resampler_rom.c │ │ ├── resampler_rom.h │ │ ├── resampler_structs.h │ │ ├── shell_coder.c │ │ ├── sigm_Q15.c │ │ ├── silk_common.vcxproj │ │ ├── silk_common.vcxproj.filters │ │ ├── sort.c │ │ ├── stereo_LR_to_MS.c │ │ ├── stereo_MS_to_LR.c │ │ ├── stereo_decode_pred.c │ │ ├── stereo_encode_pred.c │ │ ├── stereo_find_predictor.c │ │ ├── stereo_quant_pred.c │ │ ├── structs.h │ │ ├── sum_sqr_shift.c │ │ ├── table_LSF_cos.c │ │ ├── tables.h │ │ ├── tables_LTP.c │ │ ├── tables_NLSF_CB_NB_MB.c │ │ ├── tables_NLSF_CB_WB.c │ │ ├── tables_gain.c │ │ ├── tables_other.c │ │ ├── tables_pitch_lag.c │ │ ├── tables_pulses_per_block.c │ │ ├── tuning_parameters.h │ │ └── typedef.h │ ├── silk_headers.mk │ ├── silk_sources.mk │ ├── src │ │ ├── opus.c │ │ ├── opus.vcxproj │ │ ├── opus.vcxproj.filters │ │ ├── opus_compare.c │ │ ├── opus_decoder.c │ │ ├── opus_demo.c │ │ ├── opus_demo.vcxproj │ │ ├── opus_demo.vcxproj.filters │ │ ├── opus_encoder.c │ │ ├── opus_multistream.c │ │ ├── opus_private.h │ │ ├── repacketizer.c │ │ └── repacketizer_demo.c │ ├── tests │ │ ├── run_vectors.sh │ │ ├── test_opus_api.c │ │ ├── test_opus_api.vcxproj │ │ ├── test_opus_api.vcxproj.filters │ │ ├── test_opus_common.h │ │ ├── test_opus_decode.c │ │ ├── test_opus_decode.vcxproj │ │ ├── test_opus_decode.vcxproj.filters │ │ ├── test_opus_encode.c │ │ ├── test_opus_encode.vcxproj │ │ └── test_opus_encode.vcxproj.filters │ ├── version.mk │ └── win32 │ │ ├── config.h │ │ └── genversion.bat ├── sfml-2.0 │ ├── include │ │ └── SFML │ │ │ ├── Audio.hpp │ │ │ ├── Audio │ │ │ ├── Export.hpp │ │ │ ├── Listener.hpp │ │ │ ├── Music.hpp │ │ │ ├── Sound.hpp │ │ │ ├── SoundBuffer.hpp │ │ │ ├── SoundBufferRecorder.hpp │ │ │ ├── SoundRecorder.hpp │ │ │ ├── SoundSource.hpp │ │ │ └── SoundStream.hpp │ │ │ ├── Config.hpp │ │ │ ├── Graphics.hpp │ │ │ ├── Graphics │ │ │ ├── BlendMode.hpp │ │ │ ├── CircleShape.hpp │ │ │ ├── Color.hpp │ │ │ ├── ConvexShape.hpp │ │ │ ├── Drawable.hpp │ │ │ ├── Export.hpp │ │ │ ├── Font.hpp │ │ │ ├── Glyph.hpp │ │ │ ├── Image.hpp │ │ │ ├── PrimitiveType.hpp │ │ │ ├── Rect.hpp │ │ │ ├── Rect.inl │ │ │ ├── RectangleShape.hpp │ │ │ ├── RenderStates.hpp │ │ │ ├── RenderTarget.hpp │ │ │ ├── RenderTexture.hpp │ │ │ ├── RenderWindow.hpp │ │ │ ├── Shader.hpp │ │ │ ├── Shape.hpp │ │ │ ├── Sprite.hpp │ │ │ ├── Text.hpp │ │ │ ├── Texture.hpp │ │ │ ├── Transform.hpp │ │ │ ├── Transformable.hpp │ │ │ ├── Vertex.hpp │ │ │ ├── VertexArray.hpp │ │ │ └── View.hpp │ │ │ ├── Network.hpp │ │ │ ├── Network │ │ │ ├── Export.hpp │ │ │ ├── Ftp.hpp │ │ │ ├── Http.hpp │ │ │ ├── IpAddress.hpp │ │ │ ├── Packet.hpp │ │ │ ├── Socket.hpp │ │ │ ├── SocketHandle.hpp │ │ │ ├── SocketSelector.hpp │ │ │ ├── TcpListener.hpp │ │ │ ├── TcpSocket.hpp │ │ │ └── UdpSocket.hpp │ │ │ ├── OpenGL.hpp │ │ │ ├── System.hpp │ │ │ ├── System │ │ │ ├── Clock.hpp │ │ │ ├── Err.hpp │ │ │ ├── Export.hpp │ │ │ ├── InputStream.hpp │ │ │ ├── Lock.hpp │ │ │ ├── Mutex.hpp │ │ │ ├── NonCopyable.hpp │ │ │ ├── Sleep.hpp │ │ │ ├── String.hpp │ │ │ ├── Thread.hpp │ │ │ ├── Thread.inl │ │ │ ├── ThreadLocal.hpp │ │ │ ├── ThreadLocalPtr.hpp │ │ │ ├── ThreadLocalPtr.inl │ │ │ ├── Time.hpp │ │ │ ├── Utf.hpp │ │ │ ├── Utf.inl │ │ │ ├── Vector2.hpp │ │ │ ├── Vector2.inl │ │ │ ├── Vector3.hpp │ │ │ └── Vector3.inl │ │ │ ├── Window.hpp │ │ │ └── Window │ │ │ ├── Context.hpp │ │ │ ├── ContextSettings.hpp │ │ │ ├── Event.hpp │ │ │ ├── Export.hpp │ │ │ ├── GlResource.hpp │ │ │ ├── Joystick.hpp │ │ │ ├── Keyboard.hpp │ │ │ ├── Mouse.hpp │ │ │ ├── VideoMode.hpp │ │ │ ├── Window.hpp │ │ │ ├── WindowHandle.hpp │ │ │ └── WindowStyle.hpp │ ├── libsfml-audio.2.0.dylib │ ├── libsfml-audio.2.dylib │ ├── libsfml-audio.dylib │ ├── libsfml-graphics.2.0.dylib │ ├── libsfml-graphics.2.dylib │ ├── libsfml-graphics.dylib │ ├── libsfml-network.2.0.dylib │ ├── libsfml-network.2.dylib │ ├── libsfml-network.dylib │ ├── libsfml-system.2.0.dylib │ ├── libsfml-system.2.dylib │ ├── libsfml-system.dylib │ ├── libsfml-window.2.0.dylib │ ├── libsfml-window.2.dylib │ └── libsfml-window.dylib └── sndfile.framework │ ├── Resources │ └── Info.plist │ ├── Versions │ ├── A │ │ ├── Resources │ │ │ └── Info.plist │ │ └── sndfile │ └── Current │ │ ├── Resources │ │ └── Info.plist │ │ └── sndfile │ └── sndfile ├── docs ├── design.txt ├── protocol.md └── test.txt ├── multimedia ├── Makefile ├── audio │ ├── Makefile │ ├── audio_device.h │ ├── audio_device_impl.cpp │ ├── audio_device_impl.h │ └── chunk_buffer.h └── webrtc │ ├── common.h │ ├── common_audio │ ├── OWNERS │ ├── audio_util.cc │ ├── audio_util_unittest.cc │ ├── common_audio.gyp │ ├── include │ │ └── audio_util.h │ ├── resampler │ │ ├── Android.mk │ │ ├── Makefile │ │ ├── include │ │ │ ├── push_resampler.h │ │ │ └── resampler.h │ │ ├── push_resampler.cc │ │ ├── push_resampler_unittest.cc │ │ ├── push_sinc_resampler.cc │ │ ├── push_sinc_resampler.h │ │ ├── push_sinc_resampler_unittest.cc │ │ ├── resampler.cc │ │ ├── resampler_unittest.cc │ │ ├── sinc_resampler.cc │ │ ├── sinc_resampler.h │ │ ├── sinc_resampler_neon.cc │ │ ├── sinc_resampler_sse.cc │ │ ├── sinc_resampler_unittest.cc │ │ ├── sinusoidal_linear_chirp_source.cc │ │ └── sinusoidal_linear_chirp_source.h │ ├── signal_processing │ │ ├── Android.mk │ │ ├── Makefile │ │ ├── auto_corr_to_refl_coef.c │ │ ├── auto_correlation.c │ │ ├── complex_bit_reverse.c │ │ ├── complex_bit_reverse_mips.c │ │ ├── complex_fft.c │ │ ├── complex_fft_mips.c │ │ ├── complex_fft_tables.h │ │ ├── copy_set_operations.c │ │ ├── cross_correlation.c │ │ ├── division_operations.c │ │ ├── dot_product_with_scale.c │ │ ├── downsample_fast.c │ │ ├── downsample_fast_mips.c │ │ ├── energy.c │ │ ├── filter_ar.c │ │ ├── filter_ar_fast_q12.c │ │ ├── filter_ar_fast_q12_mips.c │ │ ├── filter_ma_fast_q12.c │ │ ├── get_hanning_window.c │ │ ├── get_scaling_square.c │ │ ├── ilbc_specific_functions.c │ │ ├── include │ │ │ ├── real_fft.h │ │ │ ├── signal_processing_library.h │ │ │ ├── spl_inl.h │ │ │ └── spl_inl_armv7.h │ │ ├── levinson_durbin.c │ │ ├── lpc_to_refl_coef.c │ │ ├── min_max_operations.c │ │ ├── min_max_operations_mips.c │ │ ├── randomization_functions.c │ │ ├── real_fft.c │ │ ├── real_fft_unittest.cc │ │ ├── refl_coef_to_lpc.c │ │ ├── resample.c │ │ ├── resample_48khz.c │ │ ├── resample_by_2.c │ │ ├── resample_by_2_internal.c │ │ ├── resample_by_2_internal.h │ │ ├── resample_by_2_mips.c │ │ ├── resample_fractional.c │ │ ├── signal_processing_unittest.cc │ │ ├── spl_init.c │ │ ├── spl_sqrt.c │ │ ├── spl_sqrt_floor.c │ │ ├── spl_version.c │ │ ├── splitting_filter.c │ │ ├── sqrt_of_one_minus_x_squared.c │ │ ├── vector_scaling_operations.c │ │ ├── webrtc_fft_t_1024_8.c │ │ └── webrtc_fft_t_rad.c │ └── vad │ │ ├── Android.mk │ │ ├── Makefile │ │ ├── include │ │ └── webrtc_vad.h │ │ ├── vad_core.c │ │ ├── vad_core.h │ │ ├── vad_core_unittest.cc │ │ ├── vad_filterbank.c │ │ ├── vad_filterbank.h │ │ ├── vad_filterbank_unittest.cc │ │ ├── vad_gmm.c │ │ ├── vad_gmm.h │ │ ├── vad_gmm_unittest.cc │ │ ├── vad_sp.c │ │ ├── vad_sp.h │ │ ├── vad_sp_unittest.cc │ │ ├── vad_unittest.cc │ │ ├── vad_unittest.h │ │ └── webrtc_vad.c │ ├── common_types.h │ ├── modules │ ├── audio_device │ │ ├── Android.mk │ │ ├── Makefile │ │ ├── OWNERS │ │ ├── android │ │ │ ├── OWNERS │ │ │ ├── audio_device_jni_android.cc │ │ │ ├── audio_device_jni_android.h │ │ │ ├── audio_device_opensles_android.cc │ │ │ ├── audio_device_opensles_android.h │ │ │ ├── audio_device_utility_android.cc │ │ │ ├── audio_device_utility_android.h │ │ │ └── java │ │ │ │ └── src │ │ │ │ └── org │ │ │ │ └── webrtc │ │ │ │ └── voiceengine │ │ │ │ └── WebRTCAudioDevice.java │ │ ├── audio_device.gypi │ │ ├── audio_device_buffer.cc │ │ ├── audio_device_buffer.h │ │ ├── audio_device_config.h │ │ ├── audio_device_generic.cc │ │ ├── audio_device_generic.h │ │ ├── audio_device_impl.cc │ │ ├── audio_device_impl.h │ │ ├── audio_device_utility.cc │ │ ├── audio_device_utility.h │ │ ├── dummy │ │ │ ├── audio_device_dummy.cc │ │ │ ├── audio_device_dummy.h │ │ │ ├── audio_device_utility_dummy.cc │ │ │ └── audio_device_utility_dummy.h │ │ ├── include │ │ │ ├── audio_device.h │ │ │ ├── audio_device_defines.h │ │ │ └── fake_audio_device.h │ │ ├── ios │ │ │ ├── audio_device_ios.cc │ │ │ ├── audio_device_ios.h │ │ │ ├── audio_device_utility_ios.cc │ │ │ └── audio_device_utility_ios.h │ │ ├── linux │ │ │ ├── alsasymboltable_linux.cc │ │ │ ├── alsasymboltable_linux.h │ │ │ ├── audio_device_alsa_linux.cc │ │ │ ├── audio_device_alsa_linux.h │ │ │ ├── audio_device_pulse_linux.cc │ │ │ ├── audio_device_pulse_linux.h │ │ │ ├── audio_device_utility_linux.cc │ │ │ ├── audio_device_utility_linux.h │ │ │ ├── audio_mixer_manager_alsa_linux.cc │ │ │ ├── audio_mixer_manager_alsa_linux.h │ │ │ ├── audio_mixer_manager_pulse_linux.cc │ │ │ ├── audio_mixer_manager_pulse_linux.h │ │ │ ├── latebindingsymboltable_linux.cc │ │ │ ├── latebindingsymboltable_linux.h │ │ │ ├── pulseaudiosymboltable_linux.cc │ │ │ └── pulseaudiosymboltable_linux.h │ │ ├── mac │ │ │ ├── audio_device_mac.cc │ │ │ ├── audio_device_mac.h │ │ │ ├── audio_device_utility_mac.cc │ │ │ ├── audio_device_utility_mac.h │ │ │ ├── audio_mixer_manager_mac.cc │ │ │ ├── audio_mixer_manager_mac.h │ │ │ └── portaudio │ │ │ │ ├── pa_memorybarrier.h │ │ │ │ ├── pa_ringbuffer.c │ │ │ │ └── pa_ringbuffer.h │ │ ├── main │ │ │ ├── interface │ │ │ │ └── audio_device.h │ │ │ └── source │ │ │ │ └── audio_device.gypi │ │ ├── test │ │ │ ├── README.txt │ │ │ ├── android │ │ │ │ └── audio_device_android_test │ │ │ │ │ ├── .classpath │ │ │ │ │ ├── .project │ │ │ │ │ ├── AndroidManifest.xml │ │ │ │ │ ├── default.properties │ │ │ │ │ ├── gen │ │ │ │ │ └── org │ │ │ │ │ │ └── webrtc │ │ │ │ │ │ └── voiceengine │ │ │ │ │ │ └── test │ │ │ │ │ │ └── R.java │ │ │ │ │ ├── jni │ │ │ │ │ ├── audio_device_android_test.cc │ │ │ │ │ └── org_webrtc_voiceengine_test_AudioDeviceAndroidTest.h │ │ │ │ │ ├── res │ │ │ │ │ ├── drawable │ │ │ │ │ │ └── icon.png │ │ │ │ │ ├── layout │ │ │ │ │ │ └── main.xml │ │ │ │ │ └── values │ │ │ │ │ │ └── strings.xml │ │ │ │ │ └── src │ │ │ │ │ └── org │ │ │ │ │ └── webrtc │ │ │ │ │ └── voiceengine │ │ │ │ │ ├── AudioDeviceAndroid.java │ │ │ │ │ └── test │ │ │ │ │ └── AudioDeviceAndroidTest.java │ │ │ ├── audio_device_test_api.cc │ │ │ ├── audio_device_test_defines.h │ │ │ ├── audio_device_test_func.cc │ │ │ ├── func_test_manager.cc │ │ │ └── func_test_manager.h │ │ └── win │ │ │ ├── audio_device_core_win.cc │ │ │ ├── audio_device_core_win.h │ │ │ ├── audio_device_utility_win.cc │ │ │ ├── audio_device_utility_win.h │ │ │ ├── audio_device_wave_win.cc │ │ │ ├── audio_device_wave_win.h │ │ │ ├── audio_mixer_manager_win.cc │ │ │ └── audio_mixer_manager_win.h │ ├── audio_processing │ │ ├── Android.mk │ │ ├── Makefile │ │ ├── aec │ │ │ ├── Android.mk │ │ │ ├── Makefile │ │ │ ├── aec_core.c │ │ │ ├── aec_core.h │ │ │ ├── aec_core_internal.h │ │ │ ├── aec_core_sse2.c │ │ │ ├── aec_rdft.c │ │ │ ├── aec_rdft.h │ │ │ ├── aec_rdft_sse2.c │ │ │ ├── aec_resampler.c │ │ │ ├── aec_resampler.h │ │ │ ├── echo_cancellation.c │ │ │ ├── echo_cancellation_internal.h │ │ │ ├── echo_cancellation_unittest.cc │ │ │ ├── include │ │ │ │ └── echo_cancellation.h │ │ │ └── system_delay_unittest.cc │ │ ├── aecm │ │ │ ├── Android.mk │ │ │ ├── Makefile │ │ │ ├── aecm_core.c │ │ │ ├── aecm_core.h │ │ │ ├── aecm_core_neon.S │ │ │ ├── aecm_core_neon.c │ │ │ ├── aecm_core_neon_offsets.c │ │ │ ├── aecm_defines.h │ │ │ ├── echo_control_mobile.c │ │ │ └── include │ │ │ │ └── echo_control_mobile.h │ │ ├── agc │ │ │ ├── Android.mk │ │ │ ├── Makefile │ │ │ ├── analog_agc.c │ │ │ ├── analog_agc.h │ │ │ ├── digital_agc.c │ │ │ ├── digital_agc.h │ │ │ └── include │ │ │ │ └── gain_control.h │ │ ├── audio_buffer.cc │ │ ├── audio_buffer.h │ │ ├── audio_processing.gypi │ │ ├── audio_processing_impl.cc │ │ ├── audio_processing_impl.h │ │ ├── audio_processing_tests.gypi │ │ ├── debug.proto │ │ ├── echo_cancellation_impl.cc │ │ ├── echo_cancellation_impl.h │ │ ├── echo_cancellation_impl_wrapper.h │ │ ├── echo_control_mobile_impl.cc │ │ ├── echo_control_mobile_impl.h │ │ ├── gain_control_impl.cc │ │ ├── gain_control_impl.h │ │ ├── high_pass_filter_impl.cc │ │ ├── high_pass_filter_impl.h │ │ ├── include │ │ │ ├── audio_processing.h │ │ │ └── mock_audio_processing.h │ │ ├── level_estimator_impl.cc │ │ ├── level_estimator_impl.h │ │ ├── noise_suppression_impl.cc │ │ ├── noise_suppression_impl.h │ │ ├── ns │ │ │ ├── Android.mk │ │ │ ├── Makefile │ │ │ ├── defines.h │ │ │ ├── include │ │ │ │ ├── noise_suppression.h │ │ │ │ └── noise_suppression_x.h │ │ │ ├── noise_suppression.c │ │ │ ├── noise_suppression_x.c │ │ │ ├── ns_core.c │ │ │ ├── ns_core.h │ │ │ ├── nsx_core.c │ │ │ ├── nsx_core.h │ │ │ ├── nsx_core_neon.S │ │ │ ├── nsx_core_neon.c │ │ │ ├── nsx_core_neon_offsets.c │ │ │ ├── nsx_defines.h │ │ │ └── windows_private.h │ │ ├── processing_component.cc │ │ ├── processing_component.h │ │ ├── splitting_filter.cc │ │ ├── splitting_filter.h │ │ ├── utility │ │ │ ├── Android.mk │ │ │ ├── Makefile │ │ │ ├── delay_estimator.c │ │ │ ├── delay_estimator.h │ │ │ ├── delay_estimator_internal.h │ │ │ ├── delay_estimator_unittest.cc │ │ │ ├── delay_estimator_wrapper.c │ │ │ ├── delay_estimator_wrapper.h │ │ │ ├── fft4g.c │ │ │ ├── fft4g.h │ │ │ ├── ring_buffer.c │ │ │ ├── ring_buffer.h │ │ │ └── ring_buffer_unittest.cc │ │ ├── voice_detection_impl.cc │ │ └── voice_detection_impl.h │ └── interface │ │ ├── module.h │ │ └── module_common_types.h │ ├── system_wrappers │ ├── OWNERS │ ├── interface │ │ ├── aligned_malloc.h │ │ ├── asm_defines.h │ │ ├── atomic32.h │ │ ├── clock.h │ │ ├── compile_assert.h │ │ ├── condition_variable_wrapper.h │ │ ├── constructor_magic.h │ │ ├── cpu_features_wrapper.h │ │ ├── cpu_info.h │ │ ├── critical_section_wrapper.h │ │ ├── data_log.h │ │ ├── data_log_c.h │ │ ├── data_log_impl.h │ │ ├── event_tracer.h │ │ ├── event_wrapper.h │ │ ├── file_wrapper.h │ │ ├── fix_interlocked_exchange_pointer_win.h │ │ ├── list_wrapper.h │ │ ├── logging.h │ │ ├── map_wrapper.h │ │ ├── ref_count.h │ │ ├── rw_lock_wrapper.h │ │ ├── scoped_ptr.h │ │ ├── scoped_refptr.h │ │ ├── sleep.h │ │ ├── sort.h │ │ ├── static_instance.h │ │ ├── stringize_macros.h │ │ ├── thread_wrapper.h │ │ ├── tick_util.h │ │ ├── trace.h │ │ └── trace_event.h │ ├── source │ │ ├── Android.mk │ │ ├── Makefile │ │ ├── aligned_malloc.cc │ │ ├── aligned_malloc_unittest.cc │ │ ├── android │ │ │ ├── cpu-features.c │ │ │ └── cpu-features.h │ │ ├── atomic32_mac.cc │ │ ├── atomic32_posix.cc │ │ ├── atomic32_win.cc │ │ ├── clock.cc │ │ ├── clock_unittest.cc │ │ ├── condition_variable.cc │ │ ├── condition_variable_event_win.cc │ │ ├── condition_variable_event_win.h │ │ ├── condition_variable_native_win.cc │ │ ├── condition_variable_native_win.h │ │ ├── condition_variable_posix.cc │ │ ├── condition_variable_posix.h │ │ ├── condition_variable_unittest.cc │ │ ├── cpu_features.cc │ │ ├── cpu_features_android.c │ │ ├── cpu_info.cc │ │ ├── critical_section.cc │ │ ├── critical_section_posix.cc │ │ ├── critical_section_posix.h │ │ ├── critical_section_unittest.cc │ │ ├── critical_section_win.cc │ │ ├── critical_section_win.h │ │ ├── data_log.cc │ │ ├── data_log_c.cc │ │ ├── data_log_c_helpers_unittest.c │ │ ├── data_log_c_helpers_unittest.h │ │ ├── data_log_helpers_unittest.cc │ │ ├── data_log_no_op.cc │ │ ├── data_log_unittest.cc │ │ ├── data_log_unittest_disabled.cc │ │ ├── event.cc │ │ ├── event_posix.cc │ │ ├── event_posix.h │ │ ├── event_tracer.cc │ │ ├── event_tracer_unittest.cc │ │ ├── event_win.cc │ │ ├── event_win.h │ │ ├── file_impl.cc │ │ ├── file_impl.h │ │ ├── list_no_stl.cc │ │ ├── list_no_stl.h │ │ ├── list_stl.cc │ │ ├── list_stl.h │ │ ├── list_unittest.cc │ │ ├── logging.cc │ │ ├── logging_no_op.cc │ │ ├── logging_unittest.cc │ │ ├── map.cc │ │ ├── map_no_stl.cc │ │ ├── map_no_stl.h │ │ ├── map_unittest.cc │ │ ├── rw_lock.cc │ │ ├── rw_lock_generic.cc │ │ ├── rw_lock_generic.h │ │ ├── rw_lock_posix.cc │ │ ├── rw_lock_posix.h │ │ ├── rw_lock_win.cc │ │ ├── rw_lock_win.h │ │ ├── set_thread_name_win.h │ │ ├── sleep.cc │ │ ├── sort.cc │ │ ├── spreadsortlib │ │ │ ├── constants.hpp │ │ │ └── spreadsort.hpp │ │ ├── stringize_macros_unittest.cc │ │ ├── system_wrappers.gyp │ │ ├── system_wrappers_tests.gyp │ │ ├── thread.cc │ │ ├── thread_posix.cc │ │ ├── thread_posix.h │ │ ├── thread_posix_unittest.cc │ │ ├── thread_unittest.cc │ │ ├── thread_win.cc │ │ ├── thread_win.h │ │ ├── tick_util.cc │ │ ├── trace_impl.cc │ │ ├── trace_impl.h │ │ ├── trace_impl_no_op.cc │ │ ├── trace_posix.cc │ │ ├── trace_posix.h │ │ ├── trace_win.cc │ │ ├── trace_win.h │ │ ├── unittest_utilities.h │ │ └── unittest_utilities_unittest.cc │ └── test │ │ ├── TestSort │ │ └── TestSort.cc │ │ ├── list │ │ └── list.cc │ │ └── map │ │ └── map.cc │ └── typedefs.h ├── server ├── Makefile ├── client.h ├── fde.cpp ├── fde.h ├── fde_epoll.cpp ├── fde_select.cpp ├── include.h ├── room.cpp ├── room.h ├── rtc.cpp ├── server.cpp ├── server.h ├── token.cpp ├── token.h └── voice │ ├── Makefile │ ├── channel.cpp │ ├── channel.h │ ├── frame.h │ ├── include.h │ ├── mixer.cpp │ └── mixer.h └── test ├── Makefile ├── av.cpp ├── common.h └── music_player.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.swp 3 | *.a 4 | *.la 5 | *.o 6 | *.so 7 | *.lo 8 | *.exe 9 | *.dSYM 10 | *.wav 11 | .libs 12 | ./server/rtc 13 | ./test/av 14 | config.mk 15 | dist 16 | deps/opus-1.0.3 17 | *.obj 18 | *.lib 19 | 20 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | $(shell sh build.sh > config.mk) 2 | include config.mk 3 | 4 | ROOT = $(shell pwd) 5 | 6 | .PHONY: * 7 | 8 | all: base mm client 9 | @echo 10 | 11 | server: 12 | cd server/voice; make ROOT=$(ROOT) 13 | cd server; make ROOT=$(ROOT) 14 | @echo 15 | 16 | base: 17 | cd base; make ROOT=$(ROOT) 18 | @echo 19 | 20 | mm: 21 | cd multimedia; make ROOT=$(ROOT) 22 | @echo 23 | 24 | client: 25 | cd client; make ROOT=$(ROOT) 26 | @echo 27 | 28 | test: 29 | cd test; make ROOT=$(ROOT) 30 | @echo 31 | 32 | clean: 33 | cd server; make clean 34 | rm -f $(DIST_LIB_DIR)/* $(DIST_INC_DIR)/* $(DIST_OBJ_DIR)/* 35 | @echo 36 | 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | rtc 2 | === 3 | 4 | Real-Time Communication Infracture 5 | -------------------------------------------------------------------------------- /base/Makefile: -------------------------------------------------------------------------------- 1 | include $(ROOT)/config.mk 2 | 3 | LOCAL_SRC_FILES = $(wildcard *.cpp) 4 | 5 | all: 6 | $(CC) -c $(filter-out fde_%.cpp, $(LOCAL_SRC_FILES)) $(CFLAGS) 7 | ar -cru $(DIST_LIB_DIR)/librtc-base.a *.o 8 | -------------------------------------------------------------------------------- /base/net.cpp: -------------------------------------------------------------------------------- 1 | #include "net.h" 2 | #include 3 | 4 | Address::Address(){ 5 | bzero(&sock_addr, sizeof(sock_addr)); 6 | } 7 | 8 | Address::~Address(){ 9 | } 10 | 11 | 12 | std::string Address::host() const{ 13 | char buf[INET_ADDRSTRLEN]; 14 | if(inet_ntop(AF_INET, &(sock_addr.sin_addr), buf, INET_ADDRSTRLEN) != NULL){ 15 | return buf; 16 | }else{ 17 | return ""; 18 | } 19 | } 20 | 21 | int Address::port() const{ 22 | return ntohs(sock_addr.sin_port);; 23 | } 24 | 25 | /* 26 | void Address::set(const std::string host, int port){ 27 | bzero(&sock_addr, sizeof(sock_addr)); 28 | sock_addr.sin_family = AF_INET; 29 | sock_addr.sin_port = htons((short)port); 30 | inet_pton(AF_INET, host.c_str(), &sock_addr.sin_addr); 31 | this->host = host; 32 | this->port = port; 33 | } 34 | 35 | void Address::set(const struct sockaddr_in *addr){ 36 | bzero(&sock_addr, sizeof(sock_addr)); 37 | this->sock_addr = *addr; 38 | 39 | char buf[INET_ADDRSTRLEN]; 40 | if(inet_ntop(AF_INET, &(sock_addr.sin_addr), buf, INET_ADDRSTRLEN) != NULL){ 41 | this->host = host; 42 | } 43 | this->port = ntohs(sock_addr.sin_port); 44 | } 45 | */ 46 | -------------------------------------------------------------------------------- /base/net.h: -------------------------------------------------------------------------------- 1 | #ifndef RTC_BASE_NET_H 2 | #define RTC_BASE_NET_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | class Address 13 | { 14 | public: 15 | struct sockaddr_in sock_addr; 16 | 17 | public: 18 | Address(); 19 | ~Address(); 20 | 21 | std::string host() const; 22 | int port() const; 23 | 24 | std::string repr() const{ 25 | char buf[16]; 26 | snprintf(buf, sizeof(buf), "%d", this->port()); 27 | std::string ret = this->host(); 28 | ret.append(":"); 29 | ret.append(buf); 30 | return ret; 31 | } 32 | }; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /base/objpool.h: -------------------------------------------------------------------------------- 1 | #ifndef RRoomC_BASE_OBJPOOL_H 2 | #define RRoomC_BASE_OBJPOOL_H 3 | 4 | #include 5 | #include 6 | 7 | class RoomSvc 8 | { 9 | private: 10 | std::map used; 11 | std::list pool; 12 | public: 13 | Room* get(int id){ 14 | std::map::iterator it = used.find(id); 15 | if(used.find(id) == used.end()){ 16 | return NULL; 17 | }else{ 18 | return *it; 19 | } 20 | } 21 | 22 | Room* alloc(){ 23 | Room *t = NULL; 24 | if(pool.size() > 0){ 25 | t = pool.front(); 26 | pool.pop_front(); 27 | used[t->id] = t; 28 | }else{ 29 | t = new Room(); 30 | t->id = used.size(); 31 | used[t->id] = t; 32 | } 33 | return t; 34 | } 35 | 36 | void free(int id){ 37 | std::map::iterator it = used.find(id); 38 | if(it == used.end()){ 39 | return; 40 | }else{ 41 | pool.push_back(*it); 42 | used.erase(it); 43 | } 44 | } 45 | }; 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /base/udplink.h: -------------------------------------------------------------------------------- 1 | #ifndef RTC_BASE_UDPLINK_H 2 | #define RTC_BASE_UDPLINK_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class Packet; 10 | class Address; 11 | 12 | class UdpLink 13 | { 14 | private: 15 | int sock; 16 | 17 | public: 18 | void *data; 19 | 20 | UdpLink(); 21 | ~UdpLink(); 22 | 23 | static UdpLink* create(); 24 | static UdpLink* server(const std::string &host, int port); 25 | static UdpLink* client(const std::string &host, int port); 26 | 27 | int fd() const{ 28 | return sock; 29 | } 30 | 31 | void close(){ 32 | if(sock >= 0){ 33 | ::close(sock); 34 | sock = -1; 35 | } 36 | } 37 | 38 | int bind(const std::string &host, int port); 39 | int connect(const std::string &host, int port); 40 | int connect(const Address &addr); 41 | 42 | int send(const Packet &packet, const Address *addr=NULL); 43 | int recv(Packet *packet, Address *addr=NULL); 44 | 45 | int send_buf(int size=-1); 46 | int recv_buf(int size=-1); 47 | }; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # used to generate config.mk 3 | DIR=`pwd` 4 | cd `dirname $0` 5 | BASE_DIR=`pwd` 6 | cd $DIR 7 | BASE_DIR=`echo $BASE_DIR | sed -e "s/^\/cygdrive\/\([a-z]\)/\1:/"` 8 | 9 | 10 | DIST_LIB_DIR=${BASE_DIR}/dist/lib 11 | DIST_OBJ_DIR=${BASE_DIR}/dist/obj 12 | DIST_INC_DIR=${BASE_DIR}/dist/include/rtc 13 | 14 | mkdir -p ${DIST_LIB_DIR} 15 | mkdir -p ${DIST_OBJ_DIR} 16 | mkdir -p ${DIST_INC_DIR} 17 | 18 | 19 | TARGET_OS=`uname -s` 20 | case "$TARGET_OS" in 21 | Darwin) 22 | OS=mac 23 | C=clang 24 | CC=clang++ 25 | AR="ar -cru " 26 | OBJ=o 27 | LIB=a 28 | ;; 29 | CYGWIN_*) 30 | OS=win 31 | C=cl 32 | CC=cl 33 | AR="lib /NOLOGO /OUT:" 34 | OBJ=obj 35 | LIB=lib 36 | ;; 37 | *) 38 | echo "Unknown platform!" >&2 39 | exit 1 40 | esac 41 | 42 | 43 | OS_UPPER=`echo $OS | tr '[:lower:]' '[:upper:]'` 44 | 45 | 46 | #### generate config.mk #### 47 | 48 | echo BASE_DIR := $BASE_DIR 49 | echo DIST_LIB_DIR := $DIST_LIB_DIR 50 | echo DIST_OBJ_DIR := $DIST_OBJ_DIR 51 | echo DIST_INC_DIR := $DIST_INC_DIR 52 | 53 | echo TARGET_ARCH=x86 54 | echo OS=$OS 55 | echo C=$C 56 | echo CC=$CC 57 | echo AR="$AR" 58 | echo OBJ=$OBJ 59 | echo LIB=$LIB 60 | 61 | 62 | echo CFLAGS := 63 | echo CFLAGS += -I $BASE_DIR -I $BASE_DIR/multimedia 64 | echo CFLAGS += -D WEBRTC_${OS_UPPER} -D WEBRTC_CLOCK_TYPE_REALTIME -DWEBRTC_NS_FIXED 65 | if [ "$OS" == "mac" ]; then 66 | echo CFLAGS += -Wall -Wno-sign-compare -g 67 | fi 68 | if [ "$OS" == "win" ]; then 69 | echo CFLAGS += /EHsc 70 | fi 71 | 72 | 73 | -------------------------------------------------------------------------------- /build_library.mk: -------------------------------------------------------------------------------- 1 | 2 | C_SRC_FILES = $(filter %.c, $(LOCAL_SRC_FILES)) 3 | CC_SRC_FILES = $(filter %.cc %.cpp, $(LOCAL_SRC_FILES)) 4 | 5 | build_c := 6 | build_cc := 7 | 8 | ifneq ($(C_SRC_FILES),) 9 | build_c = $(C) -c $(C_SRC_FILES) $(CFLAGS) 10 | endif 11 | ifneq ($(CC_SRC_FILES),) 12 | build_cc = $(CC) -c $(CC_SRC_FILES) $(CFLAGS) 13 | endif 14 | 15 | 16 | all: 17 | $(build_c) 18 | $(build_cc) 19 | $(AR)$(DIST_LIB_DIR)/$(LOCAL_MODULE).$(LIB) *.$(OBJ) 20 | cp *.$(OBJ) $(DIST_OBJ_DIR) 21 | @echo 22 | 23 | -------------------------------------------------------------------------------- /client/Makefile: -------------------------------------------------------------------------------- 1 | include $(ROOT)/config.mk 2 | 3 | CFLAGS += \ 4 | -I $(DIST_INC_DIR) 5 | LOCAL_SRC_FILES = $(wildcard *.cpp) 6 | 7 | all: 8 | $(CC) -o rtc_voice_client_impl.o -c voice_client_impl.cpp $(CFLAGS) 9 | cp *.o $(DIST_OBJ_DIR) 10 | cp voice_client.h $(DIST_INC_DIR) 11 | 12 | -------------------------------------------------------------------------------- /client/client.h: -------------------------------------------------------------------------------- 1 | #ifndef RTC_CLIENT_CLIENT_H 2 | #define RTC_CLIENT_CLIENT_H 3 | 4 | #include 5 | #include "base/packet.h" 6 | #include "base/udplink.h" 7 | 8 | namespace rtc{ 9 | 10 | class Client 11 | { 12 | public: 13 | Client(); 14 | ~Client(); 15 | 16 | UdpLink* link(); 17 | 18 | int connect(std::string host, int port); 19 | int join(int room_id, std::string token); 20 | int quit(); 21 | }; 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /client/voice_client.h: -------------------------------------------------------------------------------- 1 | #ifndef RTC_VOICE_CLIENT_H 2 | #define RTC_VOICE_CLIENT_H 3 | 4 | #include 5 | 6 | namespace rtc{ 7 | 8 | class VoiceClient 9 | { 10 | public: 11 | static VoiceClient* create(); 12 | 13 | virtual int init() = 0; 14 | 15 | virtual int connect(std::string host, int port) = 0; 16 | virtual int join_room(int room_id, std::string token) = 0; 17 | virtual int close() = 0; 18 | 19 | virtual int start_send() = 0; 20 | virtual int stop_send() = 0; 21 | virtual int start_recv() = 0; 22 | virtual int stop_recv() = 0; 23 | 24 | virtual int run() = 0; 25 | }; 26 | 27 | }; 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /client/voice_client_impl.h: -------------------------------------------------------------------------------- 1 | #ifndef RTC_VOICE_CLIENT_IMPL_H 2 | #define RTC_VOICE_CLIENT_IMPL_H 3 | 4 | #include "base/log.h" 5 | #include "base/net.h" 6 | #include "base/packet.h" 7 | #include "base/udplink.h" 8 | 9 | #include "audio_device.h" 10 | #include "voice_client.h" 11 | 12 | // TODO: multithread-lock 13 | 14 | namespace rtc{ 15 | 16 | class AudioCallbackImpl; 17 | 18 | class VoiceClientImpl : public VoiceClient 19 | { 20 | private: 21 | friend class VoiceClient; 22 | 23 | UdpLink *link; 24 | 25 | ave::AudioDevice *audio; 26 | AudioCallbackImpl *audio_callback; 27 | 28 | bool inited_; 29 | 30 | public: 31 | VoiceClientImpl(); 32 | ~VoiceClientImpl(); 33 | 34 | virtual int init(); 35 | 36 | virtual int connect(std::string host, int port); 37 | virtual int join_room(int room_id, std::string token); 38 | virtual int close(); 39 | 40 | virtual int start_send(); 41 | virtual int stop_send(); 42 | virtual int start_recv(); 43 | virtual int stop_recv(); 44 | 45 | virtual int run(); 46 | }; 47 | 48 | 49 | class AudioCallbackImpl : public ave::AudioDeviceCallback 50 | { 51 | private: 52 | uint16_t seq; 53 | UdpLink *link; 54 | public: 55 | AudioCallbackImpl(UdpLink *link){ 56 | seq = 0; 57 | this->link = link; 58 | } 59 | int input(const int16_t *samples, int size); 60 | }; 61 | 62 | }; 63 | #endif 64 | -------------------------------------------------------------------------------- /deps/freetype.framework/Resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | freetype 9 | CFBundleIdentifier 10 | org.sfml-dev.freetype 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | FMWK 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 1.0 19 | 20 | 21 | -------------------------------------------------------------------------------- /deps/freetype.framework/Versions/A/Resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | freetype 9 | CFBundleIdentifier 10 | org.sfml-dev.freetype 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | FMWK 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 1.0 19 | 20 | 21 | -------------------------------------------------------------------------------- /deps/freetype.framework/Versions/A/freetype: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ideawu/rtc/585868fd245accad618efde7b9198866c238220f/deps/freetype.framework/Versions/A/freetype -------------------------------------------------------------------------------- /deps/freetype.framework/Versions/Current/Resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | freetype 9 | CFBundleIdentifier 10 | org.sfml-dev.freetype 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | FMWK 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 1.0 19 | 20 | 21 | -------------------------------------------------------------------------------- /deps/freetype.framework/Versions/Current/freetype: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ideawu/rtc/585868fd245accad618efde7b9198866c238220f/deps/freetype.framework/Versions/Current/freetype -------------------------------------------------------------------------------- /deps/freetype.framework/freetype: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ideawu/rtc/585868fd245accad618efde7b9198866c238220f/deps/freetype.framework/freetype -------------------------------------------------------------------------------- /deps/opus-1.0.3/AUTHORS: -------------------------------------------------------------------------------- 1 | Jean-Marc Valin (jmvalin@jmvalin.ca) 2 | Koen Vos (koenvos74@gmail.com) 3 | Timothy Terriberry (tterribe@xiph.org) 4 | Karsten Vandborg Sorensen (karsten.vandborg.sorensen@skype.net) 5 | Soren Skak Jensen (ssjensen@gn.com) 6 | Gregory Maxwell (greg@xiph.org) 7 | -------------------------------------------------------------------------------- /deps/opus-1.0.3/ChangeLog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ideawu/rtc/585868fd245accad618efde7b9198866c238220f/deps/opus-1.0.3/ChangeLog -------------------------------------------------------------------------------- /deps/opus-1.0.3/INSTALL: -------------------------------------------------------------------------------- 1 | See README file for details 2 | -------------------------------------------------------------------------------- /deps/opus-1.0.3/NEWS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ideawu/rtc/585868fd245accad618efde7b9198866c238220f/deps/opus-1.0.3/NEWS -------------------------------------------------------------------------------- /deps/opus-1.0.3/celt_headers.mk: -------------------------------------------------------------------------------- 1 | CELT_HEAD = \ 2 | celt/arch.h \ 3 | celt/bands.h \ 4 | celt/celt.h \ 5 | include/opus_types.h \ 6 | include/opus_defines.h \ 7 | include/opus_custom.h \ 8 | celt/cwrs.h \ 9 | celt/ecintrin.h \ 10 | celt/entcode.h \ 11 | celt/entdec.h \ 12 | celt/entenc.h \ 13 | celt/fixed_debug.h \ 14 | celt/fixed_generic.h \ 15 | celt/float_cast.h \ 16 | celt/_kiss_fft_guts.h \ 17 | celt/kiss_fft.h \ 18 | celt/laplace.h \ 19 | celt/mathops.h \ 20 | celt/mdct.h \ 21 | celt/mfrngcod.h \ 22 | celt/modes.h \ 23 | celt/os_support.h \ 24 | celt/pitch.h \ 25 | celt/celt_lpc.h \ 26 | celt/quant_bands.h \ 27 | celt/rate.h \ 28 | celt/stack_alloc.h \ 29 | celt/vq.h \ 30 | celt/static_modes_float.h \ 31 | celt/static_modes_fixed.h 32 | -------------------------------------------------------------------------------- /deps/opus-1.0.3/celt_sources.mk: -------------------------------------------------------------------------------- 1 | CELT_SOURCES = celt/bands.c \ 2 | celt/celt.c \ 3 | celt/cwrs.c \ 4 | celt/entcode.c \ 5 | celt/entdec.c \ 6 | celt/entenc.c \ 7 | celt/kiss_fft.c \ 8 | celt/laplace.c \ 9 | celt/mathops.c \ 10 | celt/mdct.c \ 11 | celt/modes.c \ 12 | celt/pitch.c \ 13 | celt/celt_lpc.c \ 14 | celt/quant_bands.c \ 15 | celt/rate.c \ 16 | celt/vq.c 17 | -------------------------------------------------------------------------------- /deps/opus-1.0.3/doc/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | DOCINPUTS = $(top_srcdir)/include/opus.h \ 4 | $(top_srcdir)/include/opus_multistream.h \ 5 | $(top_srcdir)/include/opus_defines.h \ 6 | $(top_srcdir)/include/opus_types.h \ 7 | $(top_srcdir)/include/opus_custom.h \ 8 | $(top_srcdir)/doc/header.html \ 9 | $(top_srcdir)/doc/footer.html \ 10 | $(top_srcdir)/doc/customdoxygen.css 11 | 12 | EXTRA_DIST = customdoxygen.css Doxyfile.in footer.html header.html opus_logo.svg 13 | 14 | 15 | if HAVE_DOXYGEN 16 | 17 | all-local: doxygen-build.stamp 18 | 19 | doxygen-build.stamp: Doxyfile $(DOCINPUTS) 20 | doxygen 21 | touch $@ 22 | 23 | install-data-local: 24 | $(INSTALL) -d $(DESTDIR)$(docdir)/html/search 25 | for f in `find html -type f \! -name "installdox"`; do \ 26 | $(INSTALL_DATA) $$f $(DESTDIR)$(docdir)/$$f; \ 27 | done 28 | 29 | $(INSTALL) -d $(DESTDIR)$(mandir)/man3 30 | cd man && find man3 -type f -name opus_*.3 \ 31 | -exec $(INSTALL_DATA) \{} $(DESTDIR)$(mandir)/man3 \; 32 | 33 | clean-local: 34 | $(RM) -r html 35 | $(RM) -r latex 36 | $(RM) -r man 37 | $(RM) doxygen-build.stamp 38 | 39 | uninstall-local: 40 | $(RM) -r $(DESTDIR)$(docdir)/html 41 | $(RM) $(DESTDIR)$(mandir)/man3/opus_*.3 $(DESTDIR)$(mandir)/man3/opus.h.3 42 | 43 | endif 44 | -------------------------------------------------------------------------------- /deps/opus-1.0.3/doc/footer.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | For more information visit the Opus Website. 12 |
18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /deps/opus-1.0.3/m4/ltversion.m4: -------------------------------------------------------------------------------- 1 | # ltversion.m4 -- version numbers -*- Autoconf -*- 2 | # 3 | # Copyright (C) 2004 Free Software Foundation, Inc. 4 | # Written by Scott James Remnant, 2004 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # @configure_input@ 11 | 12 | # serial 3337 ltversion.m4 13 | # This file is part of GNU Libtool 14 | 15 | m4_define([LT_PACKAGE_VERSION], [2.4.2]) 16 | m4_define([LT_PACKAGE_REVISION], [1.3337]) 17 | 18 | AC_DEFUN([LTVERSION_VERSION], 19 | [macro_version='2.4.2' 20 | macro_revision='1.3337' 21 | _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) 22 | _LT_DECL(, macro_revision, 0) 23 | ]) 24 | -------------------------------------------------------------------------------- /deps/opus-1.0.3/opus-uninstalled.pc.in: -------------------------------------------------------------------------------- 1 | # Opus codec reference implementation uninstalled pkg-config file 2 | 3 | libdir=${pcfiledir}/.libs 4 | includedir=${pcfiledir} 5 | 6 | Name: opus uninstalled 7 | Description: Opus IETF audio codec (not installed, @PC_BUILD@) 8 | Version: @VERSION@ 9 | Requires: 10 | Conflicts: 11 | Libs: ${libdir}/libopus.a @PC_LIBM@ 12 | Cflags: -I${pcfiledir}/@top_srcdir@/include 13 | -------------------------------------------------------------------------------- /deps/opus-1.0.3/opus.pc.in: -------------------------------------------------------------------------------- 1 | # Opus codec reference implementation pkg-config file 2 | 3 | prefix=@prefix@ 4 | exec_prefix=@exec_prefix@ 5 | libdir=@libdir@ 6 | includedir=@includedir@ 7 | 8 | Name: Opus 9 | Description: Opus IETF audio codec (@PC_BUILD@ build) 10 | URL: http://opus-codec.org/ 11 | Version: @VERSION@ 12 | Requires: 13 | Conflicts: 14 | Libs: -L${libdir} -lopus 15 | Libs.private: @PC_LIBM@ 16 | Cflags: -I${includedir}/opus 17 | -------------------------------------------------------------------------------- /deps/opus-1.0.3/opus_headers.mk: -------------------------------------------------------------------------------- 1 | OPUS_HEAD = \ 2 | include/opus.h \ 3 | include/opus_multistream.h \ 4 | src/opus_private.h 5 | -------------------------------------------------------------------------------- /deps/opus-1.0.3/opus_sources.mk: -------------------------------------------------------------------------------- 1 | OPUS_SOURCES = src/opus.c \ 2 | src/opus_decoder.c \ 3 | src/opus_encoder.c \ 4 | src/opus_multistream.c \ 5 | src/repacketizer.c 6 | -------------------------------------------------------------------------------- /deps/opus-1.0.3/package_version: -------------------------------------------------------------------------------- 1 | PACKAGE_VERSION="1.0.3" 2 | -------------------------------------------------------------------------------- /deps/opus-1.0.3/silk_headers.mk: -------------------------------------------------------------------------------- 1 | SILK_HEAD = \ 2 | silk/debug.h \ 3 | silk/control.h \ 4 | silk/errors.h \ 5 | silk/API.h \ 6 | silk/typedef.h \ 7 | silk/define.h \ 8 | silk/main.h \ 9 | silk/PLC.h \ 10 | silk/structs.h \ 11 | silk/tables.h \ 12 | silk/tuning_parameters.h \ 13 | silk/Inlines.h \ 14 | silk/MacroCount.h \ 15 | silk/MacroDebug.h \ 16 | silk/macros.h \ 17 | silk/pitch_est_defines.h \ 18 | silk/resampler_private.h \ 19 | silk/resampler_rom.h \ 20 | silk/resampler_structs.h \ 21 | silk/SigProc_FIX.h \ 22 | silk/fixed/main_FIX.h \ 23 | silk/fixed/structs_FIX.h \ 24 | silk/float/main_FLP.h \ 25 | silk/float/structs_FLP.h \ 26 | silk/float/SigProc_FLP.h 27 | -------------------------------------------------------------------------------- /deps/opus-1.0.3/src/opus.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011 Xiph.Org Foundation, Skype Limited 2 | Written by Jean-Marc Valin and Koen Vos */ 3 | /* 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 19 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifdef HAVE_CONFIG_H 29 | #include "config.h" 30 | #endif 31 | 32 | #include "opus.h" 33 | #include "opus_private.h" 34 | 35 | int encode_size(int size, unsigned char *data) 36 | { 37 | if (size < 252) 38 | { 39 | data[0] = size; 40 | return 1; 41 | } else { 42 | data[0] = 252+(size&0x3); 43 | data[1] = (size-(int)data[0])>>2; 44 | return 2; 45 | } 46 | } 47 | 48 | -------------------------------------------------------------------------------- /deps/opus-1.0.3/tests/test_opus_api.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /deps/opus-1.0.3/tests/test_opus_decode.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4a0dd677-931f-4728-afe5-b761149fc7eb} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | 10 | 11 | Source Files 12 | 13 | 14 | -------------------------------------------------------------------------------- /deps/opus-1.0.3/tests/test_opus_encode.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {546c8d9a-103e-4f78-972b-b44e8d3c8aba} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | 10 | 11 | Source Files 12 | 13 | 14 | -------------------------------------------------------------------------------- /deps/opus-1.0.3/version.mk: -------------------------------------------------------------------------------- 1 | # static version string; update manually every release. 2 | OPUS_VERSION = "1.0.3" 3 | -------------------------------------------------------------------------------- /deps/opus-1.0.3/win32/genversion.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | setlocal enableextensions enabledelayedexpansion 4 | 5 | for /f %%v in ('git describe --tags --match "v*"') do set version=%%v 6 | 7 | if not "%version%"=="" goto :gotversion 8 | 9 | if exist "%~dp0..\version.mk" goto :getversion 10 | 11 | echo Git cannot be found, nor can version.mk. Generating unknown version. 12 | 13 | set version=unknown 14 | 15 | goto :gotversion 16 | 17 | :getversion 18 | 19 | for /f "delims== tokens=2" %%v in (%~dp0..\version.mk) do set version=%%v 20 | 21 | set version=!version:^"=! 22 | set version=!version: =! 23 | 24 | :gotversion 25 | 26 | set version_out=#define %2 "%version%" 27 | set version_mk=%2 = "%version%" 28 | 29 | echo %version_out%> %1_temp 30 | 31 | if %version%==unknown goto :skipgenerate 32 | 33 | echo # static version string; update manually every release.> "%~dp0..\version.mk" 34 | echo %version_mk%>> "%~dp0..\version.mk" 35 | 36 | :skipgenerate 37 | 38 | echo n | comp %1_temp %1 > NUL 2> NUL 39 | 40 | if not errorlevel 1 goto exit 41 | 42 | copy /y %1_temp %1 43 | 44 | :exit 45 | 46 | del %1_temp 47 | -------------------------------------------------------------------------------- /deps/sfml-2.0/include/SFML/Audio/Export.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_AUDIO_EXPORT_HPP 26 | #define SFML_AUDIO_EXPORT_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | 33 | 34 | //////////////////////////////////////////////////////////// 35 | // Define portable import / export macros 36 | //////////////////////////////////////////////////////////// 37 | #if defined(SFML_AUDIO_EXPORTS) 38 | 39 | #define SFML_AUDIO_API SFML_API_EXPORT 40 | 41 | #else 42 | 43 | #define SFML_AUDIO_API SFML_API_IMPORT 44 | 45 | #endif 46 | 47 | 48 | #endif // SFML_AUDIO_EXPORT_HPP 49 | -------------------------------------------------------------------------------- /deps/sfml-2.0/include/SFML/Graphics/BlendMode.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_BLENDMODE_HPP 26 | #define SFML_BLENDMODE_HPP 27 | 28 | namespace sf 29 | { 30 | //////////////////////////////////////////////////////////// 31 | /// \ingroup graphics 32 | /// \brief Available blending modes for drawing 33 | /// 34 | //////////////////////////////////////////////////////////// 35 | enum BlendMode 36 | { 37 | BlendAlpha, ///< Pixel = Source * Source.a + Dest * (1 - Source.a) 38 | BlendAdd, ///< Pixel = Source + Dest 39 | BlendMultiply, ///< Pixel = Source * Dest 40 | BlendNone ///< Pixel = Source 41 | }; 42 | 43 | } // namespace sf 44 | 45 | 46 | #endif // SFML_BLENDMODE_HPP 47 | -------------------------------------------------------------------------------- /deps/sfml-2.0/include/SFML/Graphics/Export.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_GRAPHICS_EXPORT_HPP 26 | #define SFML_GRAPHICS_EXPORT_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | 33 | 34 | //////////////////////////////////////////////////////////// 35 | // Define portable import / export macros 36 | //////////////////////////////////////////////////////////// 37 | #if defined(SFML_GRAPHICS_EXPORTS) 38 | 39 | #define SFML_GRAPHICS_API SFML_API_EXPORT 40 | 41 | #else 42 | 43 | #define SFML_GRAPHICS_API SFML_API_IMPORT 44 | 45 | #endif 46 | 47 | 48 | #endif // SFML_GRAPHICS_EXPORT_HPP 49 | -------------------------------------------------------------------------------- /deps/sfml-2.0/include/SFML/Network/Export.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_NETWORK_EXPORT_HPP 26 | #define SFML_NETWORK_EXPORT_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | 33 | 34 | //////////////////////////////////////////////////////////// 35 | // Define portable import / export macros 36 | //////////////////////////////////////////////////////////// 37 | #if defined(SFML_NETWORK_EXPORTS) 38 | 39 | #define SFML_NETWORK_API SFML_API_EXPORT 40 | 41 | #else 42 | 43 | #define SFML_NETWORK_API SFML_API_IMPORT 44 | 45 | #endif 46 | 47 | 48 | #endif // SFML_NETWORK_EXPORT_HPP 49 | -------------------------------------------------------------------------------- /deps/sfml-2.0/include/SFML/System/Export.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_SYSTEM_EXPORT_HPP 26 | #define SFML_SYSTEM_EXPORT_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | 33 | 34 | //////////////////////////////////////////////////////////// 35 | // Define portable import / export macros 36 | //////////////////////////////////////////////////////////// 37 | #if defined(SFML_SYSTEM_EXPORTS) 38 | 39 | #define SFML_SYSTEM_API SFML_API_EXPORT 40 | 41 | #else 42 | 43 | #define SFML_SYSTEM_API SFML_API_IMPORT 44 | 45 | #endif 46 | 47 | 48 | #endif // SFML_SYSTEM_EXPORT_HPP 49 | -------------------------------------------------------------------------------- /deps/sfml-2.0/include/SFML/Window/Export.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_WINDOW_EXPORT_HPP 26 | #define SFML_WINDOW_EXPORT_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | 33 | 34 | //////////////////////////////////////////////////////////// 35 | // Define portable import / export macros 36 | //////////////////////////////////////////////////////////// 37 | #if defined(SFML_WINDOW_EXPORTS) 38 | 39 | #define SFML_WINDOW_API SFML_API_EXPORT 40 | 41 | #else 42 | 43 | #define SFML_WINDOW_API SFML_API_IMPORT 44 | 45 | #endif 46 | 47 | 48 | #endif // SFML_WINDOW_EXPORT_HPP 49 | -------------------------------------------------------------------------------- /deps/sfml-2.0/libsfml-audio.2.0.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ideawu/rtc/585868fd245accad618efde7b9198866c238220f/deps/sfml-2.0/libsfml-audio.2.0.dylib -------------------------------------------------------------------------------- /deps/sfml-2.0/libsfml-audio.2.dylib: -------------------------------------------------------------------------------- 1 | libsfml-audio.2.0.dylib -------------------------------------------------------------------------------- /deps/sfml-2.0/libsfml-audio.dylib: -------------------------------------------------------------------------------- 1 | libsfml-audio.2.dylib -------------------------------------------------------------------------------- /deps/sfml-2.0/libsfml-graphics.2.0.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ideawu/rtc/585868fd245accad618efde7b9198866c238220f/deps/sfml-2.0/libsfml-graphics.2.0.dylib -------------------------------------------------------------------------------- /deps/sfml-2.0/libsfml-graphics.2.dylib: -------------------------------------------------------------------------------- 1 | libsfml-graphics.2.0.dylib -------------------------------------------------------------------------------- /deps/sfml-2.0/libsfml-graphics.dylib: -------------------------------------------------------------------------------- 1 | libsfml-graphics.2.dylib -------------------------------------------------------------------------------- /deps/sfml-2.0/libsfml-network.2.0.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ideawu/rtc/585868fd245accad618efde7b9198866c238220f/deps/sfml-2.0/libsfml-network.2.0.dylib -------------------------------------------------------------------------------- /deps/sfml-2.0/libsfml-network.2.dylib: -------------------------------------------------------------------------------- 1 | libsfml-network.2.0.dylib -------------------------------------------------------------------------------- /deps/sfml-2.0/libsfml-network.dylib: -------------------------------------------------------------------------------- 1 | libsfml-network.2.dylib -------------------------------------------------------------------------------- /deps/sfml-2.0/libsfml-system.2.0.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ideawu/rtc/585868fd245accad618efde7b9198866c238220f/deps/sfml-2.0/libsfml-system.2.0.dylib -------------------------------------------------------------------------------- /deps/sfml-2.0/libsfml-system.2.dylib: -------------------------------------------------------------------------------- 1 | libsfml-system.2.0.dylib -------------------------------------------------------------------------------- /deps/sfml-2.0/libsfml-system.dylib: -------------------------------------------------------------------------------- 1 | libsfml-system.2.dylib -------------------------------------------------------------------------------- /deps/sfml-2.0/libsfml-window.2.0.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ideawu/rtc/585868fd245accad618efde7b9198866c238220f/deps/sfml-2.0/libsfml-window.2.0.dylib -------------------------------------------------------------------------------- /deps/sfml-2.0/libsfml-window.2.dylib: -------------------------------------------------------------------------------- 1 | libsfml-window.2.0.dylib -------------------------------------------------------------------------------- /deps/sfml-2.0/libsfml-window.dylib: -------------------------------------------------------------------------------- 1 | libsfml-window.2.dylib -------------------------------------------------------------------------------- /deps/sndfile.framework/Resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | sndfile 9 | CFBundleIdentifier 10 | com.mega-nerd.sndfile 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | FMWK 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 1.0 19 | 20 | 21 | -------------------------------------------------------------------------------- /deps/sndfile.framework/Versions/A/Resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | sndfile 9 | CFBundleIdentifier 10 | com.mega-nerd.sndfile 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | FMWK 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 1.0 19 | 20 | 21 | -------------------------------------------------------------------------------- /deps/sndfile.framework/Versions/A/sndfile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ideawu/rtc/585868fd245accad618efde7b9198866c238220f/deps/sndfile.framework/Versions/A/sndfile -------------------------------------------------------------------------------- /deps/sndfile.framework/Versions/Current/Resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | sndfile 9 | CFBundleIdentifier 10 | com.mega-nerd.sndfile 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | FMWK 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 1.0 19 | 20 | 21 | -------------------------------------------------------------------------------- /deps/sndfile.framework/Versions/Current/sndfile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ideawu/rtc/585868fd245accad618efde7b9198866c238220f/deps/sndfile.framework/Versions/Current/sndfile -------------------------------------------------------------------------------- /deps/sndfile.framework/sndfile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ideawu/rtc/585868fd245accad618efde7b9198866c238220f/deps/sndfile.framework/sndfile -------------------------------------------------------------------------------- /docs/design.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | last_sent_ticks = BUF_TICKS; 4 | BATCH_SEND_TICKS = BUF_TICKS/2; 5 | 6 | while(1){ 7 | wait(last_sent_ticks); 8 | 9 | last_sent_ticks = 0; 10 | foreach(channels as channel){ 11 | sent_ticks = channel.read(BATCH_SEND_TICKS); 12 | if(sent_ticks < BATCH_SEND_TICKS){ 13 | if(channel.continued_drop_ticks > XXX){ 14 | channel.reset(); 15 | }else{ 16 | // if client doesn't have enough frames yet, 17 | // those frames must have been lost. 18 | // if those frames however come later, drop them. 19 | channel.simulate_lost_frames(BATCH_SEND_TICKS - sent_ticks); 20 | } 21 | } 22 | last_sent_ticks = max(last_sent_ticks, sent_ticks); 23 | } 24 | 25 | if(last_sent_ticks == 0){ 26 | last_sent_ticks = BATCH_SEND_TICKS; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /docs/protocol.md: -------------------------------------------------------------------------------- 1 | # Roles: 2 | 3 | * M: Manager 4 | * S: Server 5 | * C: Client 6 | 7 | # Data Structures 8 | 9 | class Packet{ 10 | type 11 | seq 12 | data 13 | }; 14 | 15 | # Interactions 16 | 17 | ## Basic Commands 18 | 19 | noop 20 | roles: * <-> * 21 | 22 | resp 23 | roles: * <-> * 24 | set seq as the sequence number this resp is to 25 | return ok|fail 26 | 27 | ## Room Management 28 | 29 | open 30 | roles: M -> S 31 | params: feed_queue_size 32 | return: ok|fail room_id 33 | 34 | close 35 | roles: M -> S 36 | params: room_id 37 | return: ok|fail 38 | 39 | sign 40 | roles: M -> S 41 | params: room_id 42 | return: ok|fail token 43 | 44 | join 45 | roles: C -> S 46 | params: room_id token 47 | return ok|fail 48 | 49 | quit 50 | roles: C -> S 51 | params: room_id 52 | return ok|fail 53 | 54 | ## Subscription 55 | 56 | sub 57 | roles: C -> S 58 | with_seq 59 | params: room_id 60 | return ok|fail 61 | 62 | unsub 63 | roles: C -> S 64 | params: room_id 65 | return ok|fail 66 | 67 | pub 68 | roles: C -> S 69 | with_seq 70 | params: room_id data 71 | return ok|fail 72 | 73 | data 74 | roles: S -> C 75 | with_seq 76 | params: room_id type data 77 | 78 | retrx 79 | roles: C <-> S 80 | params: room_id seq 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /docs/test.txt: -------------------------------------------------------------------------------- 1 | nc -u 127.0.0.1 10210 2 | jo..1 0 3 abc 3 | pu..1 0 1 0 2 ab 4 | 5 | -------------------------------------------------------------------------------- /multimedia/Makefile: -------------------------------------------------------------------------------- 1 | #$(shell sh build.sh > config.mk) 2 | include ../config.mk 3 | 4 | 5 | all: 6 | cd webrtc/system_wrappers/source; make ROOT=$(ROOT) 7 | cd webrtc/common_audio/signal_processing; make ROOT=$(ROOT) 8 | cd webrtc/common_audio/vad; make ROOT=$(ROOT) 9 | cd webrtc/common_audio/resampler; make ROOT=$(ROOT) 10 | cd webrtc/modules/audio_device; make ROOT=$(ROOT) 11 | cd webrtc/modules/audio_processing/utility; make ROOT=$(ROOT) 12 | cd webrtc/modules/audio_processing/aec; make ROOT=$(ROOT) 13 | cd webrtc/modules/audio_processing/agc; make ROOT=$(ROOT) 14 | cd webrtc/modules/audio_processing/ns; make ROOT=$(ROOT) 15 | cd audio; make ROOT=$(ROOT) 16 | cp audio/audio_device.h $(DIST_INC_DIR) 17 | $(AR) $(DIST_LIB_DIR)/librtc-multimedia.$(LIB) $(DIST_OBJ_DIR)/*.$(OBJ) 18 | 19 | a: 20 | 21 | -------------------------------------------------------------------------------- /multimedia/audio/Makefile: -------------------------------------------------------------------------------- 1 | include $(ROOT)/config.mk 2 | 3 | CFLAGS += \ 4 | -I ../../ 5 | 6 | all: 7 | $(CC) -o rtc_audio_device_impl.o -c audio_device_impl.cpp $(CFLAGS) 8 | cp *.o $(DIST_OBJ_DIR) 9 | -------------------------------------------------------------------------------- /multimedia/audio/audio_device.h: -------------------------------------------------------------------------------- 1 | #ifndef AVE_AUDIO_DEVICE_H 2 | #define AVE_AUDIO_DEVICE_H 3 | 4 | #include 5 | 6 | namespace ave{ 7 | 8 | class AudioDeviceCallback 9 | { 10 | public: 11 | // if Non-active Voice detected, size is set to zero 12 | virtual int input(const int16_t *samples, int size) = 0; 13 | }; 14 | 15 | 16 | class AudioDevice 17 | { 18 | public: 19 | // AudioDevice methods 20 | static AudioDevice* create(); 21 | 22 | virtual int set_callback(AudioDeviceCallback *callback) = 0; 23 | 24 | virtual int init_input_device(int id, int sample_rate_hz) = 0; 25 | virtual int init_output_device(int id, int sample_rate_hz, int channels) = 0; 26 | 27 | virtual int start_record() = 0; 28 | virtual int stop_record() = 0; 29 | 30 | virtual int start_playout() = 0; 31 | virtual int stop_playout() = 0; 32 | 33 | //playout automatically startup 34 | virtual int play(const int16_t *samples, int size) = 0; 35 | }; 36 | 37 | }; // namespace ave 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /multimedia/audio/chunk_buffer.h: -------------------------------------------------------------------------------- 1 | #ifndef AVE_CHUNK_BUFFER_H 2 | #define AVE_CHUNK_BUFFER_H 3 | 4 | #include 5 | 6 | namespace ave{ 7 | 8 | class ChunkBuffer 9 | { 10 | private: 11 | int chunk_count; 12 | int chunk_size; 13 | int size; 14 | int first; 15 | char *buf; 16 | 17 | public: 18 | ChunkBuffer(int chunk_count, int chunk_size){ 19 | this->chunk_count = chunk_count; 20 | this->chunk_size = chunk_size; 21 | buf = (char *)malloc(chunk_count * chunk_size); 22 | size = 0; 23 | first = 0; 24 | } 25 | 26 | ~ChunkBuffer(){ 27 | free(buf); 28 | } 29 | 30 | void* space(){ 31 | if(size >= chunk_count){ 32 | return NULL; 33 | } 34 | int index = (first + size) % chunk_count; 35 | return buf + index * chunk_size; 36 | } 37 | 38 | bool push_back(){ 39 | if(size >= chunk_count){ 40 | return false; 41 | } 42 | size ++; 43 | return true; 44 | } 45 | 46 | void* pop_front(){ 47 | if(size <= 0){ 48 | return NULL; 49 | } 50 | void *ret = buf + first * chunk_size; 51 | size --; 52 | first = ++first % chunk_count; 53 | return ret; 54 | } 55 | }; 56 | 57 | }; // namespace ave 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /multimedia/webrtc/common_audio/OWNERS: -------------------------------------------------------------------------------- 1 | bjornv@webrtc.org 2 | tina.legrand@webrtc.org 3 | jan.skoglund@webrtc.org 4 | andrew@webrtc.org 5 | -------------------------------------------------------------------------------- /multimedia/webrtc/common_audio/audio_util.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "webrtc/common_audio/include/audio_util.h" 12 | 13 | #include "webrtc/typedefs.h" 14 | 15 | namespace webrtc { 16 | 17 | void Deinterleave(const int16_t* interleaved, int samples_per_channel, 18 | int num_channels, int16_t** deinterleaved) { 19 | for (int i = 0; i < num_channels; i++) { 20 | int16_t* channel = deinterleaved[i]; 21 | int interleaved_idx = i; 22 | for (int j = 0; j < samples_per_channel; j++) { 23 | channel[j] = interleaved[interleaved_idx]; 24 | interleaved_idx += num_channels; 25 | } 26 | } 27 | } 28 | 29 | void Interleave(const int16_t* const* deinterleaved, int samples_per_channel, 30 | int num_channels, int16_t* interleaved) { 31 | for (int i = 0; i < num_channels; ++i) { 32 | const int16_t* channel = deinterleaved[i]; 33 | int interleaved_idx = i; 34 | for (int j = 0; j < samples_per_channel; j++) { 35 | interleaved[interleaved_idx] = channel[j]; 36 | interleaved_idx += num_channels; 37 | } 38 | } 39 | } 40 | 41 | } // namespace webrtc 42 | -------------------------------------------------------------------------------- /multimedia/webrtc/common_audio/include/audio_util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_COMMON_AUDIO_INCLUDE_AUDIO_UTIL_H_ 12 | #define WEBRTC_COMMON_AUDIO_INCLUDE_AUDIO_UTIL_H_ 13 | 14 | #include "webrtc/typedefs.h" 15 | 16 | namespace webrtc { 17 | 18 | // Deinterleave audio from |interleaved| to the channel buffers pointed to 19 | // by |deinterleaved|. There must be sufficient space allocated in the 20 | // |deinterleaved| buffers (|num_channel| buffers with |samples_per_channel| 21 | // per buffer). 22 | void Deinterleave(const int16_t* interleaved, int samples_per_channel, 23 | int num_channels, int16_t** deinterleaved); 24 | 25 | // Interleave audio from the channel buffers pointed to by |deinterleaved| to 26 | // |interleaved|. There must be sufficient space allocated in |interleaved| 27 | // (|samples_per_channel| * |num_channels|). 28 | void Interleave(const int16_t* const* deinterleaved, int samples_per_channel, 29 | int num_channels, int16_t* interleaved); 30 | 31 | } // namespace webrtc 32 | 33 | #endif // WEBRTC_COMMON_AUDIO_INCLUDE_AUDIO_UTIL_H_ 34 | -------------------------------------------------------------------------------- /multimedia/webrtc/common_audio/resampler/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 2 | # 3 | # Use of this source code is governed by a BSD-style license 4 | # that can be found in the LICENSE file in the root of the source 5 | # tree. An additional intellectual property rights grant can be found 6 | # in the file PATENTS. All contributing project authors may 7 | # be found in the AUTHORS file in the root of the source tree. 8 | 9 | LOCAL_PATH := $(call my-dir) 10 | 11 | include $(CLEAR_VARS) 12 | 13 | include $(LOCAL_PATH)/../../../android-webrtc.mk 14 | 15 | LOCAL_ARM_MODE := arm 16 | LOCAL_MODULE_CLASS := STATIC_LIBRARIES 17 | LOCAL_MODULE := libwebrtc_resampler 18 | LOCAL_MODULE_TAGS := optional 19 | LOCAL_CPP_EXTENSION := .cc 20 | LOCAL_SRC_FILES := resampler.cc 21 | 22 | # Flags passed to both C and C++ files. 23 | LOCAL_CFLAGS := \ 24 | $(MY_WEBRTC_COMMON_DEFS) 25 | 26 | LOCAL_C_INCLUDES := \ 27 | $(LOCAL_PATH)/include \ 28 | $(LOCAL_PATH)/../.. \ 29 | $(LOCAL_PATH)/../signal_processing/include 30 | 31 | LOCAL_SHARED_LIBRARIES := \ 32 | libcutils \ 33 | libdl \ 34 | libstlport 35 | 36 | ifeq ($(TARGET_OS)-$(TARGET_SIMULATOR),linux-true) 37 | LOCAL_LDLIBS += -ldl -lpthread 38 | endif 39 | 40 | ifneq ($(TARGET_SIMULATOR),true) 41 | LOCAL_SHARED_LIBRARIES += libdl 42 | endif 43 | 44 | ifndef NDK_ROOT 45 | include external/stlport/libstlport.mk 46 | endif 47 | include $(BUILD_STATIC_LIBRARY) 48 | -------------------------------------------------------------------------------- /multimedia/webrtc/common_audio/resampler/Makefile: -------------------------------------------------------------------------------- 1 | include $(ROOT)/config.mk 2 | 3 | LOCAL_MODULE := libwebrtc_resampler 4 | LOCAL_SRC_FILES := \ 5 | resampler.cc 6 | 7 | 8 | include $(ROOT)/build_library.mk 9 | 10 | -------------------------------------------------------------------------------- /multimedia/webrtc/common_audio/resampler/push_resampler_unittest.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "testing/gtest/include/gtest/gtest.h" 12 | #include "webrtc/common_audio/resampler/include/push_resampler.h" 13 | 14 | // Quality testing of PushResampler is handled through output_mixer_unittest.cc. 15 | 16 | namespace webrtc { 17 | 18 | TEST(PushResamplerTest, VerifiesInputParameters) { 19 | PushResampler resampler; 20 | EXPECT_EQ(-1, resampler.InitializeIfNeeded(-1, 16000, 1)); 21 | EXPECT_EQ(-1, resampler.InitializeIfNeeded(16000, -1, 1)); 22 | EXPECT_EQ(-1, resampler.InitializeIfNeeded(16000, 16000, 0)); 23 | EXPECT_EQ(-1, resampler.InitializeIfNeeded(16000, 16000, 3)); 24 | EXPECT_EQ(0, resampler.InitializeIfNeeded(16000, 16000, 1)); 25 | EXPECT_EQ(0, resampler.InitializeIfNeeded(16000, 16000, 2)); 26 | } 27 | 28 | } // namespace webrtc 29 | -------------------------------------------------------------------------------- /multimedia/webrtc/common_audio/resampler/sinc_resampler_neon.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | // Modified from the Chromium original: 12 | // src/media/base/sinc_resampler.cc 13 | 14 | #include "webrtc/common_audio/resampler/sinc_resampler.h" 15 | 16 | #include 17 | 18 | namespace webrtc { 19 | 20 | float SincResampler::Convolve_NEON(const float* input_ptr, const float* k1, 21 | const float* k2, 22 | double kernel_interpolation_factor) { 23 | float32x4_t m_input; 24 | float32x4_t m_sums1 = vmovq_n_f32(0); 25 | float32x4_t m_sums2 = vmovq_n_f32(0); 26 | 27 | const float* upper = input_ptr + kKernelSize; 28 | for (; input_ptr < upper; ) { 29 | m_input = vld1q_f32(input_ptr); 30 | input_ptr += 4; 31 | m_sums1 = vmlaq_f32(m_sums1, m_input, vld1q_f32(k1)); 32 | k1 += 4; 33 | m_sums2 = vmlaq_f32(m_sums2, m_input, vld1q_f32(k2)); 34 | k2 += 4; 35 | } 36 | 37 | // Linearly interpolate the two "convolutions". 38 | m_sums1 = vmlaq_f32( 39 | vmulq_f32(m_sums1, vmovq_n_f32(1.0 - kernel_interpolation_factor)), 40 | m_sums2, vmovq_n_f32(kernel_interpolation_factor)); 41 | 42 | // Sum components together. 43 | float32x2_t m_half = vadd_f32(vget_high_f32(m_sums1), vget_low_f32(m_sums1)); 44 | return vget_lane_f32(vpadd_f32(m_half, m_half), 0); 45 | } 46 | 47 | } // namespace webrtc 48 | -------------------------------------------------------------------------------- /multimedia/webrtc/common_audio/signal_processing/Makefile: -------------------------------------------------------------------------------- 1 | include $(ROOT)/config.mk 2 | 3 | LOCAL_MODULE := libwebrtc_spl 4 | LOCAL_SRC_FILES := \ 5 | auto_corr_to_refl_coef.c \ 6 | auto_correlation.c \ 7 | complex_fft.c \ 8 | copy_set_operations.c \ 9 | cross_correlation.c \ 10 | division_operations.c \ 11 | dot_product_with_scale.c \ 12 | downsample_fast.c \ 13 | energy.c \ 14 | filter_ar.c \ 15 | filter_ma_fast_q12.c \ 16 | get_hanning_window.c \ 17 | get_scaling_square.c \ 18 | ilbc_specific_functions.c \ 19 | levinson_durbin.c \ 20 | lpc_to_refl_coef.c \ 21 | min_max_operations.c \ 22 | randomization_functions.c \ 23 | real_fft.c \ 24 | refl_coef_to_lpc.c \ 25 | resample.c \ 26 | resample_48khz.c \ 27 | resample_by_2.c \ 28 | resample_by_2_internal.c \ 29 | resample_fractional.c \ 30 | spl_init.c \ 31 | spl_sqrt.c \ 32 | spl_version.c \ 33 | splitting_filter.c \ 34 | sqrt_of_one_minus_x_squared.c \ 35 | vector_scaling_operations.c 36 | 37 | 38 | ifeq ($(TARGET_ARCH), arm) 39 | LOCAL_SRC_FILES += \ 40 | complex_bit_reverse_arm.S \ 41 | spl_sqrt_floor_arm.S 42 | else 43 | LOCAL_SRC_FILES += \ 44 | complex_bit_reverse.c \ 45 | spl_sqrt_floor.c 46 | endif 47 | 48 | 49 | include $(ROOT)/build_library.mk 50 | 51 | -------------------------------------------------------------------------------- /multimedia/webrtc/common_audio/signal_processing/cross_correlation.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "webrtc/common_audio/signal_processing/include/signal_processing_library.h" 12 | 13 | /* C version of WebRtcSpl_CrossCorrelation() for generic platforms. */ 14 | void WebRtcSpl_CrossCorrelationC(int32_t* cross_correlation, 15 | const int16_t* seq1, 16 | const int16_t* seq2, 17 | int16_t dim_seq, 18 | int16_t dim_cross_correlation, 19 | int16_t right_shifts, 20 | int16_t step_seq2) { 21 | int i = 0, j = 0; 22 | 23 | for (i = 0; i < dim_cross_correlation; i++) { 24 | *cross_correlation = 0; 25 | /* Unrolling doesn't seem to improve performance. */ 26 | for (j = 0; j < dim_seq; j++) { 27 | *cross_correlation += (seq1[j] * seq2[step_seq2 * i + j]) >> right_shifts; 28 | } 29 | cross_correlation++; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /multimedia/webrtc/common_audio/signal_processing/dot_product_with_scale.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "webrtc/common_audio/signal_processing/include/signal_processing_library.h" 12 | 13 | int32_t WebRtcSpl_DotProductWithScale(const int16_t* vector1, 14 | const int16_t* vector2, 15 | int length, 16 | int scaling) { 17 | int32_t sum = 0; 18 | int i = 0; 19 | 20 | /* Unroll the loop to improve performance. */ 21 | for (i = 0; i < length - 3; i += 4) { 22 | sum += (vector1[i + 0] * vector2[i + 0]) >> scaling; 23 | sum += (vector1[i + 1] * vector2[i + 1]) >> scaling; 24 | sum += (vector1[i + 2] * vector2[i + 2]) >> scaling; 25 | sum += (vector1[i + 3] * vector2[i + 3]) >> scaling; 26 | } 27 | for (; i < length; i++) { 28 | sum += (vector1[i] * vector2[i]) >> scaling; 29 | } 30 | 31 | return sum; 32 | } 33 | -------------------------------------------------------------------------------- /multimedia/webrtc/common_audio/signal_processing/downsample_fast.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "webrtc/common_audio/signal_processing/include/signal_processing_library.h" 12 | 13 | // TODO(Bjornv): Change the function parameter order to WebRTC code style. 14 | // C version of WebRtcSpl_DownsampleFast() for generic platforms. 15 | int WebRtcSpl_DownsampleFastC(const int16_t* data_in, 16 | int data_in_length, 17 | int16_t* data_out, 18 | int data_out_length, 19 | const int16_t* __restrict coefficients, 20 | int coefficients_length, 21 | int factor, 22 | int delay) { 23 | int i = 0; 24 | int j = 0; 25 | int32_t out_s32 = 0; 26 | int endpos = delay + factor * (data_out_length - 1) + 1; 27 | 28 | // Return error if any of the running conditions doesn't meet. 29 | if (data_out_length <= 0 || coefficients_length <= 0 30 | || data_in_length < endpos) { 31 | return -1; 32 | } 33 | 34 | for (i = delay; i < endpos; i += factor) { 35 | out_s32 = 2048; // Round value, 0.5 in Q12. 36 | 37 | for (j = 0; j < coefficients_length; j++) { 38 | out_s32 += coefficients[j] * data_in[i - j]; // Q12. 39 | } 40 | 41 | out_s32 >>= 12; // Q0. 42 | 43 | // Saturate and store the output. 44 | *data_out++ = WebRtcSpl_SatW32ToW16(out_s32); 45 | } 46 | 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /multimedia/webrtc/common_audio/signal_processing/energy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file contains the function WebRtcSpl_Energy(). 14 | * The description header can be found in signal_processing_library.h 15 | * 16 | */ 17 | 18 | #include "webrtc/common_audio/signal_processing/include/signal_processing_library.h" 19 | 20 | int32_t WebRtcSpl_Energy(int16_t* vector, int vector_length, int* scale_factor) 21 | { 22 | int32_t en = 0; 23 | int i; 24 | int scaling = WebRtcSpl_GetScalingSquare(vector, vector_length, vector_length); 25 | int looptimes = vector_length; 26 | int16_t *vectorptr = vector; 27 | 28 | for (i = 0; i < looptimes; i++) 29 | { 30 | en += WEBRTC_SPL_MUL_16_16_RSFT(*vectorptr, *vectorptr, scaling); 31 | vectorptr++; 32 | } 33 | *scale_factor = scaling; 34 | 35 | return en; 36 | } 37 | -------------------------------------------------------------------------------- /multimedia/webrtc/common_audio/signal_processing/filter_ar_fast_q12.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | #include 11 | 12 | #include "webrtc/common_audio/signal_processing/include/signal_processing_library.h" 13 | 14 | // TODO(bjornv): Change the return type to report errors. 15 | 16 | void WebRtcSpl_FilterARFastQ12(const int16_t* data_in, 17 | int16_t* data_out, 18 | const int16_t* __restrict coefficients, 19 | int coefficients_length, 20 | int data_length) { 21 | int i = 0; 22 | int j = 0; 23 | 24 | assert(data_length > 0); 25 | assert(coefficients_length > 1); 26 | 27 | for (i = 0; i < data_length; i++) { 28 | int32_t output = 0; 29 | int32_t sum = 0; 30 | 31 | for (j = coefficients_length - 1; j > 0; j--) { 32 | sum += coefficients[j] * data_out[i - j]; 33 | } 34 | 35 | output = coefficients[0] * data_in[i]; 36 | output -= sum; 37 | 38 | // Saturate and store the output. 39 | output = WEBRTC_SPL_SAT(134215679, output, -134217728); 40 | data_out[i] = (int16_t)((output + 2048) >> 12); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /multimedia/webrtc/common_audio/signal_processing/filter_ma_fast_q12.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file contains the function WebRtcSpl_FilterMAFastQ12(). 14 | * The description header can be found in signal_processing_library.h 15 | * 16 | */ 17 | 18 | #include "webrtc/common_audio/signal_processing/include/signal_processing_library.h" 19 | 20 | void WebRtcSpl_FilterMAFastQ12(int16_t* in_ptr, 21 | int16_t* out_ptr, 22 | int16_t* B, 23 | int16_t B_length, 24 | int16_t length) 25 | { 26 | int32_t o; 27 | int i, j; 28 | for (i = 0; i < length; i++) 29 | { 30 | const int16_t* b_ptr = &B[0]; 31 | const int16_t* x_ptr = &in_ptr[i]; 32 | 33 | o = (int32_t)0; 34 | 35 | for (j = 0; j < B_length; j++) 36 | { 37 | o += WEBRTC_SPL_MUL_16_16(*b_ptr++, *x_ptr--); 38 | } 39 | 40 | // If output is higher than 32768, saturate it. Same with negative side 41 | // 2^27 = 134217728, which corresponds to 32768 in Q12 42 | 43 | // Saturate the output 44 | o = WEBRTC_SPL_SAT((int32_t)134215679, o, (int32_t)-134217728); 45 | 46 | *out_ptr++ = (int16_t)((o + (int32_t)2048) >> 12); 47 | } 48 | return; 49 | } 50 | -------------------------------------------------------------------------------- /multimedia/webrtc/common_audio/signal_processing/get_scaling_square.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file contains the function WebRtcSpl_GetScalingSquare(). 14 | * The description header can be found in signal_processing_library.h 15 | * 16 | */ 17 | 18 | #include "webrtc/common_audio/signal_processing/include/signal_processing_library.h" 19 | 20 | int WebRtcSpl_GetScalingSquare(int16_t *in_vector, int in_vector_length, int times) 21 | { 22 | int nbits = WebRtcSpl_GetSizeInBits(times); 23 | int i; 24 | int16_t smax = -1; 25 | int16_t sabs; 26 | int16_t *sptr = in_vector; 27 | int t; 28 | int looptimes = in_vector_length; 29 | 30 | for (i = looptimes; i > 0; i--) 31 | { 32 | sabs = (*sptr > 0 ? *sptr++ : -*sptr++); 33 | smax = (sabs > smax ? sabs : smax); 34 | } 35 | t = WebRtcSpl_NormW32(WEBRTC_SPL_MUL(smax, smax)); 36 | 37 | if (smax == 0) 38 | { 39 | return 0; // Since norm(0) returns 0 40 | } else 41 | { 42 | return (t > nbits) ? 0 : nbits - t; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /multimedia/webrtc/common_audio/signal_processing/refl_coef_to_lpc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file contains the function WebRtcSpl_ReflCoefToLpc(). 14 | * The description header can be found in signal_processing_library.h 15 | * 16 | */ 17 | 18 | #include "webrtc/common_audio/signal_processing/include/signal_processing_library.h" 19 | 20 | void WebRtcSpl_ReflCoefToLpc(const int16_t *k, int use_order, int16_t *a) 21 | { 22 | int16_t any[WEBRTC_SPL_MAX_LPC_ORDER + 1]; 23 | int16_t *aptr, *aptr2, *anyptr; 24 | const int16_t *kptr; 25 | int m, i; 26 | 27 | kptr = k; 28 | *a = 4096; // i.e., (Word16_MAX >> 3)+1. 29 | *any = *a; 30 | a[1] = WEBRTC_SPL_RSHIFT_W16((*k), 3); 31 | 32 | for (m = 1; m < use_order; m++) 33 | { 34 | kptr++; 35 | aptr = a; 36 | aptr++; 37 | aptr2 = &a[m]; 38 | anyptr = any; 39 | anyptr++; 40 | 41 | any[m + 1] = WEBRTC_SPL_RSHIFT_W16((*kptr), 3); 42 | for (i = 0; i < m; i++) 43 | { 44 | *anyptr = (*aptr) 45 | + (int16_t)WEBRTC_SPL_MUL_16_16_RSFT((*aptr2), (*kptr), 15); 46 | anyptr++; 47 | aptr++; 48 | aptr2--; 49 | } 50 | 51 | aptr = a; 52 | anyptr = any; 53 | for (i = 0; i < (m + 2); i++) 54 | { 55 | *aptr = *anyptr; 56 | aptr++; 57 | anyptr++; 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /multimedia/webrtc/common_audio/signal_processing/spl_version.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file contains the function WebRtcSpl_get_version(). 14 | * The description header can be found in signal_processing_library.h 15 | * 16 | */ 17 | 18 | #include 19 | #include "webrtc/common_audio/signal_processing/include/signal_processing_library.h" 20 | 21 | int16_t WebRtcSpl_get_version(char* version, int16_t length_in_bytes) 22 | { 23 | strncpy(version, "1.2.0", length_in_bytes); 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /multimedia/webrtc/common_audio/signal_processing/sqrt_of_one_minus_x_squared.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file contains the function WebRtcSpl_SqrtOfOneMinusXSquared(). 14 | * The description header can be found in signal_processing_library.h 15 | * 16 | */ 17 | 18 | #include "webrtc/common_audio/signal_processing/include/signal_processing_library.h" 19 | 20 | void WebRtcSpl_SqrtOfOneMinusXSquared(int16_t *xQ15, int vector_length, 21 | int16_t *yQ15) 22 | { 23 | int32_t sq; 24 | int m; 25 | int16_t tmp; 26 | 27 | for (m = 0; m < vector_length; m++) 28 | { 29 | tmp = xQ15[m]; 30 | sq = WEBRTC_SPL_MUL_16_16(tmp, tmp); // x^2 in Q30 31 | sq = 1073741823 - sq; // 1-x^2, where 1 ~= 0.99999999906 is 1073741823 in Q30 32 | sq = WebRtcSpl_Sqrt(sq); // sqrt(1-x^2) in Q15 33 | yQ15[m] = (int16_t)sq; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /multimedia/webrtc/common_audio/signal_processing/webrtc_fft_t_rad.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file contains the Q14 radix-2 tables used in ARM9E optimization routines. 14 | * 15 | */ 16 | 17 | extern const unsigned short t_Q14S_rad8[2]; 18 | const unsigned short t_Q14S_rad8[2] = { 0x0000,0x2d41 }; 19 | 20 | //extern const int t_Q30S_rad8[2]; 21 | //const int t_Q30S_rad8[2] = { 0x00000000,0x2d413ccd }; 22 | 23 | extern const unsigned short t_Q14R_rad8[2]; 24 | const unsigned short t_Q14R_rad8[2] = { 0x2d41,0x2d41 }; 25 | 26 | //extern const int t_Q30R_rad8[2]; 27 | //const int t_Q30R_rad8[2] = { 0x2d413ccd,0x2d413ccd }; 28 | -------------------------------------------------------------------------------- /multimedia/webrtc/common_audio/vad/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 2 | # 3 | # Use of this source code is governed by a BSD-style license 4 | # that can be found in the LICENSE file in the root of the source 5 | # tree. An additional intellectual property rights grant can be found 6 | # in the file PATENTS. All contributing project authors may 7 | # be found in the AUTHORS file in the root of the source tree. 8 | 9 | LOCAL_PATH := $(call my-dir) 10 | 11 | include $(CLEAR_VARS) 12 | 13 | include $(LOCAL_PATH)/../../../android-webrtc.mk 14 | 15 | LOCAL_ARM_MODE := arm 16 | LOCAL_MODULE_CLASS := STATIC_LIBRARIES 17 | LOCAL_MODULE := libwebrtc_vad 18 | LOCAL_MODULE_TAGS := optional 19 | LOCAL_SRC_FILES := \ 20 | webrtc_vad.c \ 21 | vad_core.c \ 22 | vad_filterbank.c \ 23 | vad_gmm.c \ 24 | vad_sp.c 25 | 26 | # Flags passed to both C and C++ files. 27 | LOCAL_CFLAGS := \ 28 | $(MY_WEBRTC_COMMON_DEFS) 29 | 30 | LOCAL_C_INCLUDES := \ 31 | $(LOCAL_PATH)/include \ 32 | $(LOCAL_PATH)/../.. \ 33 | $(LOCAL_PATH)/../signal_processing/include \ 34 | external/webrtc 35 | 36 | LOCAL_SHARED_LIBRARIES := \ 37 | libdl \ 38 | libstlport 39 | 40 | ifeq ($(TARGET_OS)-$(TARGET_SIMULATOR),linux-true) 41 | LOCAL_LDLIBS += -ldl -lpthread 42 | endif 43 | 44 | ifneq ($(TARGET_SIMULATOR),true) 45 | LOCAL_SHARED_LIBRARIES += libdl 46 | endif 47 | 48 | ifndef NDK_ROOT 49 | include external/stlport/libstlport.mk 50 | endif 51 | include $(BUILD_STATIC_LIBRARY) 52 | -------------------------------------------------------------------------------- /multimedia/webrtc/common_audio/vad/Makefile: -------------------------------------------------------------------------------- 1 | include $(ROOT)/config.mk 2 | 3 | LOCAL_MODULE := libwebrtc_vad 4 | LOCAL_SRC_FILES := \ 5 | webrtc_vad.c \ 6 | vad_core.c \ 7 | vad_filterbank.c \ 8 | vad_gmm.c \ 9 | vad_sp.c 10 | 11 | 12 | include $(ROOT)/build_library.mk 13 | 14 | -------------------------------------------------------------------------------- /multimedia/webrtc/common_audio/vad/vad_gmm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | // Gaussian probability calculations internally used in vad_core.c. 12 | 13 | #ifndef WEBRTC_COMMON_AUDIO_VAD_VAD_GMM_H_ 14 | #define WEBRTC_COMMON_AUDIO_VAD_VAD_GMM_H_ 15 | 16 | #include "webrtc/typedefs.h" 17 | 18 | // Calculates the probability for |input|, given that |input| comes from a 19 | // normal distribution with mean and standard deviation (|mean|, |std|). 20 | // 21 | // Inputs: 22 | // - input : input sample in Q4. 23 | // - mean : mean input in the statistical model, Q7. 24 | // - std : standard deviation, Q7. 25 | // 26 | // Output: 27 | // 28 | // - delta : input used when updating the model, Q11. 29 | // |delta| = (|input| - |mean|) / |std|^2. 30 | // 31 | // Return: 32 | // (probability for |input|) = 33 | // 1 / |std| * exp(-(|input| - |mean|)^2 / (2 * |std|^2)); 34 | int32_t WebRtcVad_GaussianProbability(int16_t input, 35 | int16_t mean, 36 | int16_t std, 37 | int16_t* delta); 38 | 39 | #endif // WEBRTC_COMMON_AUDIO_VAD_VAD_GMM_H_ 40 | -------------------------------------------------------------------------------- /multimedia/webrtc/common_audio/vad/vad_gmm_unittest.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "testing/gtest/include/gtest/gtest.h" 12 | #include "webrtc/common_audio/vad/vad_unittest.h" 13 | #include "webrtc/typedefs.h" 14 | 15 | extern "C" { 16 | #include "webrtc/common_audio/vad/vad_gmm.h" 17 | } 18 | 19 | namespace { 20 | 21 | TEST_F(VadTest, vad_gmm) { 22 | int16_t delta = 0; 23 | // Input value at mean. 24 | EXPECT_EQ(1048576, WebRtcVad_GaussianProbability(0, 0, 128, &delta)); 25 | EXPECT_EQ(0, delta); 26 | EXPECT_EQ(1048576, WebRtcVad_GaussianProbability(16, 128, 128, &delta)); 27 | EXPECT_EQ(0, delta); 28 | EXPECT_EQ(1048576, WebRtcVad_GaussianProbability(-16, -128, 128, &delta)); 29 | EXPECT_EQ(0, delta); 30 | 31 | // Largest possible input to give non-zero probability. 32 | EXPECT_EQ(1024, WebRtcVad_GaussianProbability(59, 0, 128, &delta)); 33 | EXPECT_EQ(7552, delta); 34 | EXPECT_EQ(1024, WebRtcVad_GaussianProbability(75, 128, 128, &delta)); 35 | EXPECT_EQ(7552, delta); 36 | EXPECT_EQ(1024, WebRtcVad_GaussianProbability(-75, -128, 128, &delta)); 37 | EXPECT_EQ(-7552, delta); 38 | 39 | // Too large input, should give zero probability. 40 | EXPECT_EQ(0, WebRtcVad_GaussianProbability(105, 0, 128, &delta)); 41 | EXPECT_EQ(13440, delta); 42 | } 43 | } // namespace 44 | -------------------------------------------------------------------------------- /multimedia/webrtc/common_audio/vad/vad_unittest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_COMMON_AUDIO_VAD_VAD_UNITTEST_H 12 | #define WEBRTC_COMMON_AUDIO_VAD_VAD_UNITTEST_H 13 | 14 | #include // size_t 15 | 16 | #include "testing/gtest/include/gtest/gtest.h" 17 | 18 | #include "webrtc/typedefs.h" 19 | 20 | namespace { 21 | 22 | // Modes we support 23 | const int kModes[] = { 0, 1, 2, 3 }; 24 | const size_t kModesSize = sizeof(kModes) / sizeof(*kModes); 25 | 26 | // Rates we support. 27 | const int kRates[] = { 8000, 12000, 16000, 24000, 32000, 48000 }; 28 | const size_t kRatesSize = sizeof(kRates) / sizeof(*kRates); 29 | 30 | // Frame lengths we support. 31 | const int kMaxFrameLength = 1440; 32 | const int kFrameLengths[] = { 80, 120, 160, 240, 320, 480, 640, 960, 33 | kMaxFrameLength }; 34 | const size_t kFrameLengthsSize = sizeof(kFrameLengths) / sizeof(*kFrameLengths); 35 | 36 | } // namespace 37 | 38 | class VadTest : public ::testing::Test { 39 | protected: 40 | VadTest(); 41 | virtual void SetUp(); 42 | virtual void TearDown(); 43 | 44 | // Returns true if the rate and frame length combination is valid. 45 | bool ValidRatesAndFrameLengths(int rate, int frame_length); 46 | }; 47 | 48 | #endif // WEBRTC_COMMON_AUDIO_VAD_VAD_UNITTEST_H 49 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_device/Makefile: -------------------------------------------------------------------------------- 1 | include $(ROOT)/config.mk 2 | 3 | LOCAL_MODULE := libwebrtc_audio_device 4 | LOCAL_SRC_FILES := \ 5 | audio_device_buffer.cc \ 6 | audio_device_generic.cc \ 7 | audio_device_utility.cc \ 8 | audio_device_impl.cc 9 | 10 | ifeq ($(OS), mac) 11 | LOCAL_SRC_FILES += \ 12 | mac/audio_device_mac.cc \ 13 | mac/audio_device_utility_mac.cc \ 14 | mac/audio_mixer_manager_mac.cc \ 15 | mac/portaudio/pa_ringbuffer.c 16 | endif 17 | ifeq ($(OS), linux) 18 | LOCAL_SRC_FILES += \ 19 | linux/audio_device_alsa_linux.cc \ 20 | linux/audio_device_utility_linux.cc \ 21 | linux/audio_mixer_manager_alsa_linux.cc 22 | endif 23 | 24 | CFLAGS += \ 25 | -I ./$(OS) 26 | 27 | 28 | include $(ROOT)/build_library.mk 29 | 30 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_device/OWNERS: -------------------------------------------------------------------------------- 1 | henrikg@webrtc.org 2 | henrika@webrtc.org 3 | niklas.enbom@webrtc.org 4 | xians@webrtc.org 5 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_device/android/OWNERS: -------------------------------------------------------------------------------- 1 | leozwang@webrtc.org 2 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_device/android/audio_device_utility_android.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /* 12 | * Android audio device utility implementation 13 | */ 14 | 15 | #include "webrtc/modules/audio_device/android/audio_device_utility_android.h" 16 | 17 | #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" 18 | #include "webrtc/system_wrappers/interface/trace.h" 19 | 20 | namespace webrtc 21 | { 22 | 23 | AudioDeviceUtilityAndroid::AudioDeviceUtilityAndroid(const int32_t id) : 24 | _critSect(*CriticalSectionWrapper::CreateCriticalSection()), _id(id) 25 | { 26 | WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, id, 27 | "%s created", __FUNCTION__); 28 | } 29 | 30 | AudioDeviceUtilityAndroid::~AudioDeviceUtilityAndroid() 31 | { 32 | WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, _id, 33 | "%s destroyed", __FUNCTION__); 34 | { 35 | CriticalSectionScoped lock(&_critSect); 36 | } 37 | 38 | delete &_critSect; 39 | } 40 | 41 | int32_t AudioDeviceUtilityAndroid::Init() 42 | { 43 | 44 | WEBRTC_TRACE(kTraceStateInfo, kTraceAudioDevice, _id, 45 | " OS info: %s", "Android"); 46 | 47 | return 0; 48 | } 49 | 50 | } // namespace webrtc 51 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_device/android/audio_device_utility_android.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /* 12 | * Android audio device utility interface 13 | */ 14 | 15 | #ifndef WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_ANDROID_H 16 | #define WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_ANDROID_H 17 | 18 | #include "webrtc/modules/audio_device/audio_device_utility.h" 19 | #include "webrtc/modules/audio_device/include/audio_device.h" 20 | 21 | namespace webrtc 22 | { 23 | class CriticalSectionWrapper; 24 | 25 | class AudioDeviceUtilityAndroid: public AudioDeviceUtility 26 | { 27 | public: 28 | AudioDeviceUtilityAndroid(const int32_t id); 29 | ~AudioDeviceUtilityAndroid(); 30 | 31 | virtual int32_t Init(); 32 | 33 | private: 34 | CriticalSectionWrapper& _critSect; 35 | int32_t _id; 36 | }; 37 | 38 | } // namespace webrtc 39 | 40 | #endif // WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_ANDROID_H 41 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_device/audio_device_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_CONFIG_H 12 | #define WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_CONFIG_H 13 | 14 | // Enumerators 15 | // 16 | enum { kAdmMaxIdleTimeProcess = 1000 }; 17 | enum { GET_MIC_VOLUME_INTERVAL_MS = 1000 }; 18 | 19 | // Platform specifics 20 | // 21 | #if defined(_WIN32) 22 | #if (_MSC_VER >= 1400) 23 | // Windows Core Audio is the default audio layer in Windows. 24 | // Only supported for VS 2005 and higher. 25 | #define WEBRTC_WINDOWS_CORE_AUDIO_BUILD 26 | #endif 27 | #endif 28 | 29 | #if (defined(_DEBUG) && defined(_WIN32) && (_MSC_VER >= 1400)) 30 | #include 31 | #include 32 | #include 33 | #define DEBUG_PRINT(...) \ 34 | { \ 35 | TCHAR msg[256]; \ 36 | StringCchPrintf(msg, 256, __VA_ARGS__); \ 37 | OutputDebugString(msg); \ 38 | } 39 | #else 40 | #define DEBUG_PRINT(exp) ((void)0) 41 | #endif 42 | 43 | #endif // WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_CONFIG_H 44 | 45 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_device/audio_device_utility.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_H 12 | #define WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_H 13 | 14 | #include "webrtc/typedefs.h" 15 | 16 | namespace webrtc 17 | { 18 | 19 | class AudioDeviceUtility 20 | { 21 | public: 22 | static uint32_t GetTimeInMS(); 23 | static void WaitForKey(); 24 | static bool StringCompare(const char* str1, 25 | const char* str2, 26 | const uint32_t length); 27 | virtual int32_t Init() = 0; 28 | 29 | virtual ~AudioDeviceUtility() {} 30 | }; 31 | 32 | } // namespace webrtc 33 | 34 | #endif // WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_H 35 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_device/dummy/audio_device_utility_dummy.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | #include "webrtc/modules/audio_device/dummy/audio_device_utility_dummy.h" 11 | 12 | namespace webrtc { 13 | int32_t AudioDeviceUtilityDummy::Init() { return 0; } 14 | } // namespace webrtc 15 | 16 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_device/dummy/audio_device_utility_dummy.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_DUMMY_H 12 | #define WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_DUMMY_H 13 | 14 | #include "webrtc/modules/audio_device/audio_device_utility.h" 15 | #include "webrtc/modules/audio_device/include/audio_device.h" 16 | 17 | namespace webrtc 18 | { 19 | class CriticalSectionWrapper; 20 | 21 | class AudioDeviceUtilityDummy: public AudioDeviceUtility 22 | { 23 | public: 24 | AudioDeviceUtilityDummy(const int32_t id) {} 25 | virtual ~AudioDeviceUtilityDummy() {} 26 | 27 | virtual int32_t Init() OVERRIDE; 28 | }; 29 | } // namespace webrtc 30 | 31 | #endif // MODULES_AUDIO_DEVICE_MAIN_SOURCE_LINUX_AUDIO_DEVICE_UTILITY_DUMMY_H_ 32 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_device/ios/audio_device_utility_ios.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "webrtc/modules/audio_device/audio_device_config.h" 12 | #include "webrtc/modules/audio_device/ios/audio_device_utility_ios.h" 13 | 14 | #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" 15 | #include "webrtc/system_wrappers/interface/trace.h" 16 | 17 | namespace webrtc { 18 | AudioDeviceUtilityIPhone::AudioDeviceUtilityIPhone(const int32_t id) 19 | : 20 | _critSect(*CriticalSectionWrapper::CreateCriticalSection()), 21 | _id(id), 22 | _lastError(AudioDeviceModule::kAdmErrNone) { 23 | WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, id, 24 | "%s created", __FUNCTION__); 25 | } 26 | 27 | AudioDeviceUtilityIPhone::~AudioDeviceUtilityIPhone() { 28 | WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, _id, 29 | "%s destroyed", __FUNCTION__); 30 | CriticalSectionScoped lock(&_critSect); 31 | 32 | delete &_critSect; 33 | } 34 | 35 | int32_t AudioDeviceUtilityIPhone::Init() { 36 | WEBRTC_TRACE(kTraceModuleCall, kTraceAudioDevice, _id, 37 | "%s", __FUNCTION__); 38 | 39 | WEBRTC_TRACE(kTraceStateInfo, kTraceAudioDevice, _id, 40 | " OS info: %s", "iOS"); 41 | 42 | return 0; 43 | } 44 | 45 | } // namespace webrtc 46 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_device/ios/audio_device_utility_ios.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_IPHONE_H 12 | #define WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_IPHONE_H 13 | 14 | #include "webrtc/modules/audio_device/audio_device_utility.h" 15 | #include "webrtc/modules/audio_device/include/audio_device.h" 16 | 17 | namespace webrtc { 18 | class CriticalSectionWrapper; 19 | 20 | class AudioDeviceUtilityIPhone: public AudioDeviceUtility { 21 | public: 22 | AudioDeviceUtilityIPhone(const int32_t id); 23 | AudioDeviceUtilityIPhone(); 24 | virtual ~AudioDeviceUtilityIPhone(); 25 | 26 | virtual int32_t Init(); 27 | 28 | private: 29 | CriticalSectionWrapper& _critSect; 30 | int32_t _id; 31 | AudioDeviceModule::ErrorCode _lastError; 32 | }; 33 | 34 | } // namespace webrtc 35 | 36 | #endif // WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_IPHONE_H 37 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_device/linux/audio_device_utility_linux.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "webrtc/modules/audio_device/audio_device_config.h" // DEBUG_PRINT() 12 | #include "webrtc/modules/audio_device/linux/audio_device_utility_linux.h" 13 | #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" 14 | #include "webrtc/system_wrappers/interface/trace.h" 15 | 16 | namespace webrtc 17 | { 18 | 19 | AudioDeviceUtilityLinux::AudioDeviceUtilityLinux(const int32_t id) : 20 | _critSect(*CriticalSectionWrapper::CreateCriticalSection()), _id(id) 21 | { 22 | WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, id, 23 | "%s created", __FUNCTION__); 24 | } 25 | 26 | AudioDeviceUtilityLinux::~AudioDeviceUtilityLinux() 27 | { 28 | WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, _id, 29 | "%s destroyed", __FUNCTION__); 30 | { 31 | CriticalSectionScoped lock(&_critSect); 32 | 33 | // free stuff here... 34 | } 35 | 36 | delete &_critSect; 37 | } 38 | 39 | // ============================================================================ 40 | // API 41 | // ============================================================================ 42 | 43 | 44 | int32_t AudioDeviceUtilityLinux::Init() 45 | { 46 | 47 | WEBRTC_TRACE(kTraceStateInfo, kTraceAudioDevice, _id, 48 | " OS info: %s", "Linux"); 49 | 50 | return 0; 51 | } 52 | 53 | 54 | } // namespace webrtc 55 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_device/linux/audio_device_utility_linux.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_LINUX_H 12 | #define WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_LINUX_H 13 | 14 | #include "webrtc/modules/audio_device/audio_device_utility.h" 15 | #include "webrtc/modules/audio_device/include/audio_device.h" 16 | 17 | namespace webrtc 18 | { 19 | class CriticalSectionWrapper; 20 | 21 | class AudioDeviceUtilityLinux: public AudioDeviceUtility 22 | { 23 | public: 24 | AudioDeviceUtilityLinux(const int32_t id); 25 | virtual ~AudioDeviceUtilityLinux(); 26 | 27 | virtual int32_t Init() OVERRIDE; 28 | 29 | private: 30 | CriticalSectionWrapper& _critSect; 31 | int32_t _id; 32 | }; 33 | 34 | } // namespace webrtc 35 | 36 | #endif // MODULES_AUDIO_DEVICE_MAIN_SOURCE_LINUX_AUDIO_DEVICE_UTILITY_LINUX_H_ 37 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_device/mac/audio_device_utility_mac.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "webrtc/modules/audio_device/audio_device_config.h" // DEBUG_PRINT() 12 | #include "webrtc/modules/audio_device/mac/audio_device_utility_mac.h" 13 | #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" 14 | #include "webrtc/system_wrappers/interface/trace.h" 15 | 16 | namespace webrtc 17 | { 18 | 19 | AudioDeviceUtilityMac::AudioDeviceUtilityMac(const int32_t id) : 20 | _critSect(*CriticalSectionWrapper::CreateCriticalSection()), 21 | _id(id) 22 | { 23 | WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, id, 24 | "%s created", __FUNCTION__); 25 | } 26 | 27 | // ---------------------------------------------------------------------------- 28 | // AudioDeviceUtilityMac() - dtor 29 | // ---------------------------------------------------------------------------- 30 | 31 | AudioDeviceUtilityMac::~AudioDeviceUtilityMac() 32 | { 33 | WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, _id, 34 | "%s destroyed", __FUNCTION__); 35 | { 36 | CriticalSectionScoped lock(&_critSect); 37 | 38 | // free stuff here... 39 | } 40 | 41 | delete &_critSect; 42 | } 43 | 44 | int32_t AudioDeviceUtilityMac::Init() 45 | { 46 | 47 | WEBRTC_TRACE(kTraceStateInfo, kTraceAudioDevice, _id, 48 | " OS info: %s", "OS X"); 49 | 50 | return 0; 51 | } 52 | 53 | } // namespace webrtc 54 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_device/mac/audio_device_utility_mac.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_MAC_H 12 | #define WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_MAC_H 13 | 14 | #include "webrtc/modules/audio_device/audio_device_utility.h" 15 | #include "webrtc/modules/audio_device/include/audio_device.h" 16 | 17 | namespace webrtc 18 | { 19 | class CriticalSectionWrapper; 20 | 21 | class AudioDeviceUtilityMac: public AudioDeviceUtility 22 | { 23 | public: 24 | AudioDeviceUtilityMac(const int32_t id); 25 | ~AudioDeviceUtilityMac(); 26 | 27 | virtual int32_t Init(); 28 | 29 | private: 30 | CriticalSectionWrapper& _critSect; 31 | int32_t _id; 32 | }; 33 | 34 | } // namespace webrtc 35 | 36 | #endif // MODULES_AUDIO_DEVICE_MAIN_SOURCE_MAC_AUDIO_DEVICE_UTILITY_MAC_H_ 37 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_device/main/interface/audio_device.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_DEVICE_MAIN_INTERFACE_AUDIO_DEVICE_H_ 12 | #define MODULES_AUDIO_DEVICE_MAIN_INTERFACE_AUDIO_DEVICE_H_ 13 | 14 | #include "webrtc/modules/audio_device/include/audio_device.h" 15 | 16 | #endif // MODULES_AUDIO_DEVICE_MAIN_INTERFACE_AUDIO_DEVICE_H_ 17 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_device/main/source/audio_device.gypi: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 | # 3 | # Use of this source code is governed by a BSD-style license 4 | # that can be found in the LICENSE file in the root of the source 5 | # tree. An additional intellectual property rights grant can be found 6 | # in the file PATENTS. All contributing project authors may 7 | # be found in the AUTHORS file in the root of the source tree. 8 | 9 | { 10 | 'includes': [ 11 | '../../audio_device.gypi', 12 | ], 13 | } 14 | 15 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_device/test/README.txt: -------------------------------------------------------------------------------- 1 | INSTRUCTIONS: 2 | 3 | - Start with test #3 (Device enumeration) to get an overview of the available 4 | audio devices. 5 | - Next, proceed with test #4 (Device selection) to get more details about 6 | the supported functions for each audio device. 7 | - Verify two-way audio in test #5. 8 | Repeat this test for different selections of playout and recording devices. 9 | - More detailed tests (volume, mute etc.) can also be performed using #6-#11. 10 | 11 | NOTE: 12 | 13 | - Some tests requires that the user opens up the audio mixer dialog and 14 | verifies that a certain action (e.g. Mute ON/OFF) is executed correctly. 15 | - Files can be recorded during some tests to enable off-line analysis. 16 | - Full support of 'Default Communication' devices requires Windows 7. 17 | - If a test consists of several sub tests, press any key to start a new sub test. 18 | 19 | KNOWN ISSUES: 20 | 21 | - Microphone Boost control is not supported on Windows Vista or Windows 7. 22 | - Speaker and microphone volume controls will not work as intended on Windows 23 | Vista if a 'Default Communication' device is selected in any direction. 24 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_device/test/android/audio_device_android_test/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_device/test/android/audio_device_android_test/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | AudioDeviceAndroidTest 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_device/test/android/audio_device_android_test/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_device/test/android/audio_device_android_test/default.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system use, 7 | # "build.properties", and override values to adapt the script to your 8 | # project structure. 9 | 10 | # Project target. 11 | target=android-3 12 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_device/test/android/audio_device_android_test/gen/org/webrtc/voiceengine/test/R.java: -------------------------------------------------------------------------------- 1 | /* AUTO-GENERATED FILE. DO NOT MODIFY. 2 | * 3 | * This class was automatically generated by the 4 | * aapt tool from the resource data it found. It 5 | * should not be modified by hand. 6 | */ 7 | 8 | package org.webrtc.voiceengine.test; 9 | 10 | public final class R { 11 | public static final class attr { 12 | } 13 | public static final class drawable { 14 | public static final int icon=0x7f020000; 15 | } 16 | public static final class id { 17 | public static final int Button01=0x7f050000; 18 | } 19 | public static final class layout { 20 | public static final int main=0x7f030000; 21 | } 22 | public static final class string { 23 | public static final int app_name=0x7f040000; 24 | public static final int run_button=0x7f040001; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_device/test/android/audio_device_android_test/jni/org_webrtc_voiceengine_test_AudioDeviceAndroidTest.h: -------------------------------------------------------------------------------- 1 | /* DO NOT EDIT THIS FILE - it is machine generated */ 2 | #include 3 | /* Header for class org_webrtc_voiceengine_test_AudioDeviceAndroidTest */ 4 | 5 | #ifndef _Included_org_webrtc_voiceengine_test_AudioDeviceAndroidTest 6 | #define _Included_org_webrtc_voiceengine_test_AudioDeviceAndroidTest 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | /* 11 | * Class: org_webrtc_voiceengine_test_AudioDeviceAndroidTest 12 | * Method: NativeInit 13 | * Signature: ()Z 14 | */ 15 | JNIEXPORT jboolean JNICALL Java_org_webrtc_voiceengine_test_AudioDeviceAndroidTest_NativeInit 16 | (JNIEnv *, jclass); 17 | 18 | /* 19 | * Class: org_webrtc_voiceengine_test_AudioDeviceAndroidTest 20 | * Method: RunTest 21 | * Signature: (I)I 22 | */ 23 | JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AudioDeviceAndroidTest_RunTest 24 | (JNIEnv *, jobject, jint); 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | #endif 30 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_device/test/android/audio_device_android_test/res/drawable/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ideawu/rtc/585868fd245accad618efde7b9198866c238220f/multimedia/webrtc/modules/audio_device/test/android/audio_device_android_test/res/drawable/icon.png -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_device/test/android/audio_device_android_test/res/layout/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_device/test/android/audio_device_android_test/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WebRTC Audio Device Android Test 5 | Run Test 6 | 7 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_device/test/android/audio_device_android_test/src/org/webrtc/voiceengine/AudioDeviceAndroid.java: -------------------------------------------------------------------------------- 1 | ../../../../../../../source/android/org/webrtc/voiceengine/AudioDeviceAndroid.java 2 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_device/win/audio_device_utility_win.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_WIN_H 12 | #define WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_WIN_H 13 | 14 | #include "webrtc/modules/audio_device/audio_device_utility.h" 15 | #include "webrtc/modules/audio_device/include/audio_device.h" 16 | #include 17 | 18 | namespace webrtc 19 | { 20 | class CriticalSectionWrapper; 21 | 22 | class AudioDeviceUtilityWindows : public AudioDeviceUtility 23 | { 24 | public: 25 | AudioDeviceUtilityWindows(const int32_t id); 26 | ~AudioDeviceUtilityWindows(); 27 | 28 | virtual int32_t Init(); 29 | 30 | private: 31 | BOOL GetOSDisplayString(LPTSTR pszOS); 32 | 33 | private: 34 | CriticalSectionWrapper& _critSect; 35 | int32_t _id; 36 | AudioDeviceModule::ErrorCode _lastError; 37 | }; 38 | 39 | } // namespace webrtc 40 | 41 | #endif // WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_WIN_H 42 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_processing/Makefile: -------------------------------------------------------------------------------- 1 | include $(ROOT)/config.mk 2 | 3 | LOCAL_MODULE := libwebrtc_apm 4 | LOCAL_SRC_FILES := \ 5 | audio_buffer.cc \ 6 | audio_processing_impl.cc \ 7 | echo_cancellation_impl.cc \ 8 | echo_control_mobile_impl.cc \ 9 | gain_control_impl.cc \ 10 | high_pass_filter_impl.cc \ 11 | level_estimator_impl.cc \ 12 | noise_suppression_impl.cc \ 13 | processing_component.cc \ 14 | splitting_filter.cc \ 15 | voice_detection_impl.cc 16 | 17 | 18 | include $(ROOT)/build_library.mk 19 | 20 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_processing/aec/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 | # 3 | # Use of this source code is governed by a BSD-style license 4 | # that can be found in the LICENSE file in the root of the source 5 | # tree. An additional intellectual property rights grant can be found 6 | # in the file PATENTS. All contributing project authors may 7 | # be found in the AUTHORS file in the root of the source tree. 8 | 9 | LOCAL_PATH := $(call my-dir) 10 | 11 | include $(CLEAR_VARS) 12 | 13 | include $(LOCAL_PATH)/../../../../android-webrtc.mk 14 | 15 | LOCAL_MODULE_CLASS := STATIC_LIBRARIES 16 | LOCAL_MODULE := libwebrtc_aec 17 | LOCAL_MODULE_TAGS := optional 18 | LOCAL_SRC_FILES := \ 19 | echo_cancellation.c \ 20 | aec_resampler.c \ 21 | aec_core.c \ 22 | aec_rdft.c \ 23 | 24 | ifeq ($(TARGET_ARCH),x86) 25 | LOCAL_SRC_FILES += \ 26 | aec_core_sse2.c \ 27 | aec_rdft_sse2.c 28 | endif 29 | 30 | # Flags passed to both C and C++ files. 31 | LOCAL_CFLAGS := \ 32 | $(MY_WEBRTC_COMMON_DEFS) 33 | 34 | LOCAL_C_INCLUDES := \ 35 | $(LOCAL_PATH)/include \ 36 | $(LOCAL_PATH)/../utility \ 37 | $(LOCAL_PATH)/../../.. \ 38 | $(LOCAL_PATH)/../../../common_audio/signal_processing/include \ 39 | external/webrtc 40 | 41 | LOCAL_SHARED_LIBRARIES := \ 42 | libcutils \ 43 | libdl \ 44 | libstlport 45 | 46 | ifndef NDK_ROOT 47 | include external/stlport/libstlport.mk 48 | endif 49 | include $(BUILD_STATIC_LIBRARY) 50 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_processing/aec/Makefile: -------------------------------------------------------------------------------- 1 | include $(ROOT)/config.mk 2 | 3 | LOCAL_MODULE := libwebrtc_aec 4 | LOCAL_SRC_FILES := \ 5 | echo_cancellation.c \ 6 | aec_resampler.c \ 7 | aec_core.c \ 8 | aec_rdft.c \ 9 | 10 | 11 | ifeq ($(TARGET_ARCH), x86) 12 | LOCAL_SRC_FILES += \ 13 | aec_core_sse2.c \ 14 | aec_rdft_sse2.c 15 | endif 16 | 17 | 18 | include $(ROOT)/build_library.mk 19 | 20 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_processing/aec/aec_resampler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AEC_AEC_RESAMPLER_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_AEC_AEC_RESAMPLER_H_ 13 | 14 | #include "webrtc/modules/audio_processing/aec/aec_core.h" 15 | 16 | enum { kResamplingDelay = 1 }; 17 | enum { kResamplerBufferSize = FRAME_LEN * 4 }; 18 | 19 | // Unless otherwise specified, functions return 0 on success and -1 on error 20 | int WebRtcAec_CreateResampler(void **resampInst); 21 | int WebRtcAec_InitResampler(void *resampInst, int deviceSampleRateHz); 22 | int WebRtcAec_FreeResampler(void *resampInst); 23 | 24 | // Estimates skew from raw measurement. 25 | int WebRtcAec_GetSkew(void *resampInst, int rawSkew, float *skewEst); 26 | 27 | // Resamples input using linear interpolation. 28 | void WebRtcAec_ResampleLinear(void *resampInst, 29 | const short *inspeech, 30 | int size, 31 | float skew, 32 | short *outspeech, 33 | int *size_out); 34 | 35 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC_AEC_RESAMPLER_H_ 36 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_processing/aec/echo_cancellation_unittest.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | // TODO(bjornv): Make this a comprehensive test. 12 | 13 | #include "webrtc/modules/audio_processing/aec/include/echo_cancellation.h" 14 | 15 | #include 16 | #include 17 | 18 | extern "C" { 19 | #include "webrtc/modules/audio_processing/aec/aec_core.h" 20 | } 21 | 22 | #include "testing/gtest/include/gtest/gtest.h" 23 | 24 | namespace webrtc { 25 | 26 | TEST(EchoCancellationTest, CreateAndFreeHandlesErrors) { 27 | EXPECT_EQ(-1, WebRtcAec_Create(NULL)); 28 | void* handle = NULL; 29 | ASSERT_EQ(0, WebRtcAec_Create(&handle)); 30 | EXPECT_TRUE(handle != NULL); 31 | EXPECT_EQ(-1, WebRtcAec_Free(NULL)); 32 | EXPECT_EQ(0, WebRtcAec_Free(handle)); 33 | } 34 | 35 | TEST(EchoCancellationTest, ApplyAecCoreHandle) { 36 | void* handle = NULL; 37 | ASSERT_EQ(0, WebRtcAec_Create(&handle)); 38 | EXPECT_TRUE(handle != NULL); 39 | EXPECT_TRUE(WebRtcAec_aec_core(NULL) == NULL); 40 | AecCore* aec_core = WebRtcAec_aec_core(handle); 41 | EXPECT_TRUE(aec_core != NULL); 42 | // A simple test to verify that we can set and get a value from the lower 43 | // level |aec_core| handle. 44 | int delay = 111; 45 | WebRtcAec_SetSystemDelay(aec_core, delay); 46 | EXPECT_EQ(delay, WebRtcAec_system_delay(aec_core)); 47 | EXPECT_EQ(0, WebRtcAec_Free(handle)); 48 | } 49 | 50 | } // namespace webrtc 51 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_processing/aecm/Makefile: -------------------------------------------------------------------------------- 1 | include $(ROOT)/config.mk 2 | 3 | LOCAL_MODULE := libwebrtc_aecm 4 | LOCAL_SRC_FILES := \ 5 | echo_control_mobile.c \ 6 | aecm_core.c 7 | 8 | 9 | include $(ROOT)/build_library.mk 10 | 11 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_processing/aecm/aecm_core_neon_offsets.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 4 | * 5 | * Use of this source code is governed by a BSD-style license 6 | * that can be found in the LICENSE file in the root of the source 7 | * tree. An additional intellectual property rights grant can be found 8 | * in the file PATENTS. All contributing project authors may 9 | * be found in the AUTHORS file in the root of the source tree. 10 | */ 11 | 12 | #include "webrtc/modules/audio_processing/aecm/aecm_core.h" 13 | 14 | #include 15 | 16 | // Define offset variables that will be compiled and abstracted to constant 17 | // defines, which will then only be used in ARM assembly code. 18 | int offset_aecm_dfaCleanQDomain = offsetof(AecmCore_t, dfaCleanQDomain); 19 | int offset_aecm_outBuf = offsetof(AecmCore_t, outBuf); 20 | int offset_aecm_xBuf = offsetof(AecmCore_t, xBuf); 21 | int offset_aecm_dBufNoisy = offsetof(AecmCore_t, dBufNoisy); 22 | int offset_aecm_dBufClean = offsetof(AecmCore_t, dBufClean); 23 | int offset_aecm_channelStored = offsetof(AecmCore_t, channelStored); 24 | int offset_aecm_channelAdapt16 = offsetof(AecmCore_t, channelAdapt16); 25 | int offset_aecm_channelAdapt32 = offsetof(AecmCore_t, channelAdapt32); 26 | int offset_aecm_real_fft = offsetof(AecmCore_t, real_fft); 27 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_processing/agc/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 | # 3 | # Use of this source code is governed by a BSD-style license 4 | # that can be found in the LICENSE file in the root of the source 5 | # tree. An additional intellectual property rights grant can be found 6 | # in the file PATENTS. All contributing project authors may 7 | # be found in the AUTHORS file in the root of the source tree. 8 | 9 | LOCAL_PATH := $(call my-dir) 10 | 11 | include $(CLEAR_VARS) 12 | 13 | include $(LOCAL_PATH)/../../../../android-webrtc.mk 14 | 15 | LOCAL_ARM_MODE := arm 16 | LOCAL_MODULE_CLASS := STATIC_LIBRARIES 17 | LOCAL_MODULE := libwebrtc_agc 18 | LOCAL_MODULE_TAGS := optional 19 | LOCAL_SRC_FILES := \ 20 | analog_agc.c \ 21 | digital_agc.c 22 | 23 | # Flags passed to both C and C++ files. 24 | LOCAL_CFLAGS := \ 25 | $(MY_WEBRTC_COMMON_DEFS) 26 | 27 | LOCAL_C_INCLUDES := \ 28 | $(LOCAL_PATH)/include \ 29 | $(LOCAL_PATH)/../../.. \ 30 | $(LOCAL_PATH)/../../../common_audio/signal_processing/include \ 31 | external/webrtc 32 | 33 | LOCAL_SHARED_LIBRARIES := \ 34 | libcutils \ 35 | libdl \ 36 | libstlport 37 | 38 | ifndef NDK_ROOT 39 | include external/stlport/libstlport.mk 40 | endif 41 | include $(BUILD_STATIC_LIBRARY) 42 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_processing/agc/Makefile: -------------------------------------------------------------------------------- 1 | include $(ROOT)/config.mk 2 | 3 | LOCAL_MODULE := libwebrtc_agc 4 | LOCAL_SRC_FILES := \ 5 | analog_agc.c \ 6 | digital_agc.c 7 | 8 | 9 | include $(ROOT)/build_library.mk 10 | 11 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_processing/debug.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | option optimize_for = LITE_RUNTIME; 3 | package webrtc.audioproc; 4 | 5 | message Init { 6 | optional int32 sample_rate = 1; 7 | optional int32 device_sample_rate = 2; 8 | optional int32 num_input_channels = 3; 9 | optional int32 num_output_channels = 4; 10 | optional int32 num_reverse_channels = 5; 11 | } 12 | 13 | message ReverseStream { 14 | optional bytes data = 1; 15 | } 16 | 17 | message Stream { 18 | optional bytes input_data = 1; 19 | optional bytes output_data = 2; 20 | optional int32 delay = 3; 21 | optional sint32 drift = 4; 22 | optional int32 level = 5; 23 | } 24 | 25 | message Event { 26 | enum Type { 27 | INIT = 0; 28 | REVERSE_STREAM = 1; 29 | STREAM = 2; 30 | } 31 | 32 | required Type type = 1; 33 | 34 | optional Init init = 2; 35 | optional ReverseStream reverse_stream = 3; 36 | optional Stream stream = 4; 37 | } 38 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_processing/echo_cancellation_impl_wrapper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CANCELLATION_IMPL_WRAPPER_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CANCELLATION_IMPL_WRAPPER_H_ 13 | 14 | #include "webrtc/modules/audio_processing/include/audio_processing.h" 15 | #include "webrtc/modules/audio_processing/processing_component.h" 16 | 17 | namespace webrtc { 18 | 19 | class AudioProcessingImpl; 20 | class AudioBuffer; 21 | 22 | class EchoCancellationImplWrapper : public virtual EchoCancellation, 23 | public virtual ProcessingComponent { 24 | public: 25 | static EchoCancellationImplWrapper* Create( 26 | const AudioProcessingImpl* audioproc); 27 | virtual ~EchoCancellationImplWrapper() {} 28 | 29 | virtual int ProcessRenderAudio(const AudioBuffer* audio) = 0; 30 | virtual int ProcessCaptureAudio(AudioBuffer* audio) = 0; 31 | }; 32 | 33 | } // namespace webrtc 34 | 35 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CANCELLATION_IMPL_WRAPPER_H_ 36 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_processing/high_pass_filter_impl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_HIGH_PASS_FILTER_IMPL_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_HIGH_PASS_FILTER_IMPL_H_ 13 | 14 | #include "webrtc/modules/audio_processing/include/audio_processing.h" 15 | #include "webrtc/modules/audio_processing/processing_component.h" 16 | 17 | namespace webrtc { 18 | class AudioProcessingImpl; 19 | class AudioBuffer; 20 | 21 | class HighPassFilterImpl : public HighPassFilter, 22 | public ProcessingComponent { 23 | public: 24 | explicit HighPassFilterImpl(const AudioProcessingImpl* apm); 25 | virtual ~HighPassFilterImpl(); 26 | 27 | int ProcessCaptureAudio(AudioBuffer* audio); 28 | 29 | // HighPassFilter implementation. 30 | virtual bool is_enabled() const OVERRIDE; 31 | 32 | private: 33 | // HighPassFilter implementation. 34 | virtual int Enable(bool enable) OVERRIDE; 35 | 36 | // ProcessingComponent implementation. 37 | virtual void* CreateHandle() const OVERRIDE; 38 | virtual int InitializeHandle(void* handle) const OVERRIDE; 39 | virtual int ConfigureHandle(void* handle) const OVERRIDE; 40 | virtual int DestroyHandle(void* handle) const OVERRIDE; 41 | virtual int num_handles_required() const OVERRIDE; 42 | virtual int GetHandleError(void* handle) const OVERRIDE; 43 | 44 | const AudioProcessingImpl* apm_; 45 | }; 46 | } // namespace webrtc 47 | 48 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_HIGH_PASS_FILTER_IMPL_H_ 49 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_processing/ns/Makefile: -------------------------------------------------------------------------------- 1 | include $(ROOT)/config.mk 2 | 3 | LOCAL_MODULE := libwebrtc_ns 4 | LOCAL_SRC_FILES := \ 5 | noise_suppression_x.c \ 6 | nsx_core.c 7 | 8 | 9 | include $(ROOT)/build_library.mk 10 | 11 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_processing/ns/noise_suppression_x.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "webrtc/modules/audio_processing/ns/include/noise_suppression_x.h" 12 | 13 | #include 14 | 15 | #include "webrtc/common_audio/signal_processing/include/real_fft.h" 16 | #include "webrtc/modules/audio_processing/ns/nsx_core.h" 17 | #include "webrtc/modules/audio_processing/ns/nsx_defines.h" 18 | 19 | int WebRtcNsx_Create(NsxHandle** nsxInst) { 20 | NsxInst_t* self = malloc(sizeof(NsxInst_t)); 21 | *nsxInst = (NsxHandle*)self; 22 | 23 | if (self != NULL) { 24 | WebRtcSpl_Init(); 25 | self->real_fft = NULL; 26 | self->initFlag = 0; 27 | return 0; 28 | } else { 29 | return -1; 30 | } 31 | 32 | } 33 | 34 | int WebRtcNsx_Free(NsxHandle* nsxInst) { 35 | WebRtcSpl_FreeRealFFT(((NsxInst_t*)nsxInst)->real_fft); 36 | free(nsxInst); 37 | return 0; 38 | } 39 | 40 | int WebRtcNsx_Init(NsxHandle* nsxInst, uint32_t fs) { 41 | return WebRtcNsx_InitCore((NsxInst_t*)nsxInst, fs); 42 | } 43 | 44 | int WebRtcNsx_set_policy(NsxHandle* nsxInst, int mode) { 45 | return WebRtcNsx_set_policy_core((NsxInst_t*)nsxInst, mode); 46 | } 47 | 48 | int WebRtcNsx_Process(NsxHandle* nsxInst, short* speechFrame, 49 | short* speechFrameHB, short* outFrame, 50 | short* outFrameHB) { 51 | return WebRtcNsx_ProcessCore( 52 | (NsxInst_t*)nsxInst, speechFrame, speechFrameHB, outFrame, outFrameHB); 53 | } 54 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_processing/ns/nsx_core_neon_offsets.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "webrtc/modules/audio_processing/ns/nsx_core.h" 12 | 13 | #include 14 | 15 | // Define offset variables that will be compiled and abstracted to constant 16 | // defines, which will then only be used in ARM assembly code. 17 | int offset_nsx_anaLen = offsetof(NsxInst_t, anaLen); 18 | int offset_nsx_anaLen2 = offsetof(NsxInst_t, anaLen2); 19 | int offset_nsx_normData = offsetof(NsxInst_t, normData); 20 | int offset_nsx_analysisBuffer = offsetof(NsxInst_t, analysisBuffer); 21 | int offset_nsx_synthesisBuffer = offsetof(NsxInst_t, synthesisBuffer); 22 | int offset_nsx_blockLen10ms = offsetof(NsxInst_t, blockLen10ms); 23 | int offset_nsx_window = offsetof(NsxInst_t, window); 24 | int offset_nsx_real = offsetof(NsxInst_t, real); 25 | int offset_nsx_imag = offsetof(NsxInst_t, imag); 26 | int offset_nsx_noiseSupFilter = offsetof(NsxInst_t, noiseSupFilter); 27 | int offset_nsx_magnLen = offsetof(NsxInst_t, magnLen); 28 | int offset_nsx_noiseEstLogQuantile = offsetof(NsxInst_t, noiseEstLogQuantile); 29 | int offset_nsx_noiseEstQuantile = offsetof(NsxInst_t, noiseEstQuantile); 30 | int offset_nsx_qNoise = offsetof(NsxInst_t, qNoise); 31 | int offset_nsx_stages = offsetof(NsxInst_t, stages); 32 | int offset_nsx_blockIndex = offsetof(NsxInst_t, blockIndex); 33 | int offset_nsx_noiseEstCounter = offsetof(NsxInst_t, noiseEstCounter); 34 | int offset_nsx_noiseEstDensity = offsetof(NsxInst_t, noiseEstDensity); 35 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_processing/splitting_filter.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "webrtc/common_audio/signal_processing/include/signal_processing_library.h" 12 | #include "webrtc/modules/audio_processing/splitting_filter.h" 13 | 14 | namespace webrtc { 15 | 16 | void SplittingFilterAnalysis(const int16_t* in_data, 17 | int16_t* low_band, 18 | int16_t* high_band, 19 | int32_t* filter_state1, 20 | int32_t* filter_state2) 21 | { 22 | WebRtcSpl_AnalysisQMF(in_data, low_band, high_band, filter_state1, filter_state2); 23 | } 24 | 25 | void SplittingFilterSynthesis(const int16_t* low_band, 26 | const int16_t* high_band, 27 | int16_t* out_data, 28 | int32_t* filt_state1, 29 | int32_t* filt_state2) 30 | { 31 | WebRtcSpl_SynthesisQMF(low_band, high_band, out_data, filt_state1, filt_state2); 32 | } 33 | } // namespace webrtc 34 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_processing/utility/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 2 | # 3 | # Use of this source code is governed by a BSD-style license 4 | # that can be found in the LICENSE file in the root of the source 5 | # tree. An additional intellectual property rights grant can be found 6 | # in the file PATENTS. All contributing project authors may 7 | # be found in the AUTHORS file in the root of the source tree. 8 | 9 | LOCAL_PATH := $(call my-dir) 10 | 11 | include $(CLEAR_VARS) 12 | 13 | include $(LOCAL_PATH)/../../../../android-webrtc.mk 14 | 15 | LOCAL_ARM_MODE := arm 16 | LOCAL_MODULE_CLASS := STATIC_LIBRARIES 17 | LOCAL_MODULE := libwebrtc_apm_utility 18 | LOCAL_MODULE_TAGS := optional 19 | LOCAL_SRC_FILES := \ 20 | fft4g.c \ 21 | ring_buffer.c \ 22 | delay_estimator.c \ 23 | delay_estimator_wrapper.c 24 | 25 | # Flags passed to both C and C++ files. 26 | LOCAL_CFLAGS := \ 27 | $(MY_WEBRTC_COMMON_DEFS) 28 | 29 | # Include paths placed before CFLAGS/CPPFLAGS 30 | LOCAL_C_INCLUDES := \ 31 | $(LOCAL_PATH) \ 32 | $(LOCAL_PATH)/../../.. \ 33 | $(LOCAL_PATH)/../../../common_audio/signal_processing/include \ 34 | external/webrtc 35 | 36 | LOCAL_SHARED_LIBRARIES := \ 37 | libcutils \ 38 | libdl \ 39 | libstlport 40 | 41 | ifndef NDK_ROOT 42 | include external/stlport/libstlport.mk 43 | endif 44 | include $(BUILD_STATIC_LIBRARY) 45 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_processing/utility/Makefile: -------------------------------------------------------------------------------- 1 | include $(ROOT)/config.mk 2 | 3 | LOCAL_MODULE := libwebrtc_apm_utility 4 | LOCAL_SRC_FILES := \ 5 | fft4g.c \ 6 | ring_buffer.c \ 7 | delay_estimator.c \ 8 | delay_estimator_wrapper.c 9 | 10 | 11 | include $(ROOT)/build_library.mk 12 | 13 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_processing/utility/delay_estimator_internal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | // Header file including the delay estimator handle used for testing. 12 | 13 | #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_UTILITY_DELAY_ESTIMATOR_INTERNAL_H_ 14 | #define WEBRTC_MODULES_AUDIO_PROCESSING_UTILITY_DELAY_ESTIMATOR_INTERNAL_H_ 15 | 16 | #include "webrtc/modules/audio_processing/utility/delay_estimator.h" 17 | #include "webrtc/typedefs.h" 18 | 19 | typedef union { 20 | float float_; 21 | int32_t int32_; 22 | } SpectrumType; 23 | 24 | typedef struct { 25 | // Pointers to mean values of spectrum. 26 | SpectrumType* mean_far_spectrum; 27 | // |mean_far_spectrum| initialization indicator. 28 | int far_spectrum_initialized; 29 | 30 | int spectrum_size; 31 | 32 | // Far-end part of binary spectrum based delay estimation. 33 | BinaryDelayEstimatorFarend* binary_farend; 34 | } DelayEstimatorFarend; 35 | 36 | typedef struct { 37 | // Pointers to mean values of spectrum. 38 | SpectrumType* mean_near_spectrum; 39 | // |mean_near_spectrum| initialization indicator. 40 | int near_spectrum_initialized; 41 | 42 | int spectrum_size; 43 | 44 | // Binary spectrum based delay estimator 45 | BinaryDelayEstimator* binary_handle; 46 | } DelayEstimator; 47 | 48 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_UTILITY_DELAY_ESTIMATOR_INTERNAL_H_ 49 | -------------------------------------------------------------------------------- /multimedia/webrtc/modules/audio_processing/utility/fft4g.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_UTILITY_FFT4G_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_UTILITY_FFT4G_H_ 13 | 14 | void WebRtc_rdft(int, int, float *, int *, float *); 15 | void WebRtc_cdft(int, int, float *, int *, float *); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/OWNERS: -------------------------------------------------------------------------------- 1 | henrike@webrtc.org 2 | pwestin@webrtc.org 3 | perkj@webrtc.org 4 | henrika@webrtc.org 5 | henrikg@webrtc.org 6 | mflodman@webrtc.org 7 | niklas.enbom@webrtc.org -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/interface/asm_defines.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_ASM_DEFINES_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_ASM_DEFINES_H_ 13 | 14 | #if defined(__linux__) && defined(__ELF__) 15 | .section .note.GNU-stack,"",%progbits 16 | #endif 17 | 18 | // Define the macros used in ARM assembly code, so that for Mac or iOS builds 19 | // we add leading underscores for the function names. 20 | #ifdef __APPLE__ 21 | .macro GLOBAL_FUNCTION name 22 | .global _\name 23 | .endm 24 | .macro DEFINE_FUNCTION name 25 | _\name: 26 | .endm 27 | .macro CALL_FUNCTION name 28 | bl _\name 29 | .endm 30 | .macro GLOBAL_LABEL name 31 | .global _\name 32 | .endm 33 | #else 34 | .macro GLOBAL_FUNCTION name 35 | .global \name 36 | .endm 37 | .macro DEFINE_FUNCTION name 38 | \name: 39 | .endm 40 | .macro CALL_FUNCTION name 41 | bl \name 42 | .endm 43 | .macro GLOBAL_LABEL name 44 | .global \name 45 | .endm 46 | #endif 47 | 48 | // With Apple's clang compiler, for instructions ldrb, strh, etc., 49 | // the condition code is after the width specifier. Here we define 50 | // only the ones that are actually used in the assembly files. 51 | #if (defined __llvm__) && (defined __APPLE__) 52 | .macro streqh reg1, reg2, num 53 | strheq \reg1, \reg2, \num 54 | .endm 55 | #endif 56 | 57 | .text 58 | 59 | #endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_COMPILE_ASSERT_H_ 60 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/interface/compile_assert.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_COMPILE_ASSERT_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_COMPILE_ASSERT_H_ 13 | 14 | /* Use this macro to verify at compile time that certain restrictions are met. 15 | * The argument is the boolean expression to evaluate. 16 | * Example: 17 | * COMPILE_ASSERT(sizeof(foo) < 128); 18 | */ 19 | #define COMPILE_ASSERT(expression) switch(0){case 0: case expression:;} 20 | 21 | #endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_COMPILE_ASSERT_H_ 22 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/interface/condition_variable_wrapper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CONDITION_VARIABLE_WRAPPER_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CONDITION_VARIABLE_WRAPPER_H_ 13 | 14 | namespace webrtc { 15 | 16 | class CriticalSectionWrapper; 17 | 18 | class ConditionVariableWrapper { 19 | public: 20 | // Factory method, constructor disabled. 21 | static ConditionVariableWrapper* CreateConditionVariable(); 22 | 23 | virtual ~ConditionVariableWrapper() {} 24 | 25 | // Calling thread will atomically release crit_sect and wait until next 26 | // some other thread calls Wake() or WakeAll(). 27 | virtual void SleepCS(CriticalSectionWrapper& crit_sect) = 0; 28 | 29 | // Same as above but with a timeout. 30 | virtual bool SleepCS(CriticalSectionWrapper& crit_sect, 31 | unsigned long max_time_in_ms) = 0; 32 | 33 | // Wakes one thread calling SleepCS(). 34 | virtual void Wake() = 0; 35 | 36 | // Wakes all threads calling SleepCS(). 37 | virtual void WakeAll() = 0; 38 | }; 39 | 40 | } // namespace webrtc 41 | 42 | #endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CONDITION_VARIABLE_WRAPPER_H_ 43 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/interface/cpu_features_wrapper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CPU_FEATURES_WRAPPER_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CPU_FEATURES_WRAPPER_H_ 13 | 14 | #if defined(__cplusplus) || defined(c_plusplus) 15 | extern "C" { 16 | #endif 17 | 18 | #include "webrtc/typedefs.h" 19 | 20 | // List of features in x86. 21 | typedef enum { 22 | kSSE2, 23 | kSSE3 24 | } CPUFeature; 25 | 26 | // List of features in ARM. 27 | enum { 28 | kCPUFeatureARMv7 = (1 << 0), 29 | kCPUFeatureVFPv3 = (1 << 1), 30 | kCPUFeatureNEON = (1 << 2), 31 | kCPUFeatureLDREXSTREX = (1 << 3) 32 | }; 33 | 34 | typedef int (*WebRtc_CPUInfo)(CPUFeature feature); 35 | 36 | // Returns true if the CPU supports the feature. 37 | extern WebRtc_CPUInfo WebRtc_GetCPUInfo; 38 | 39 | // No CPU feature is available => straight C path. 40 | extern WebRtc_CPUInfo WebRtc_GetCPUInfoNoASM; 41 | 42 | // Return the features in an ARM device. 43 | // It detects the features in the hardware platform, and returns supported 44 | // values in the above enum definition as a bitmask. 45 | extern uint64_t WebRtc_GetCPUFeaturesARM(void); 46 | 47 | #if defined(__cplusplus) || defined(c_plusplus) 48 | } // extern "C" 49 | #endif 50 | 51 | #endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CPU_FEATURES_WRAPPER_H_ 52 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/interface/cpu_info.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CPU_INFO_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CPU_INFO_H_ 13 | 14 | #include "webrtc/typedefs.h" 15 | 16 | namespace webrtc { 17 | 18 | class CpuInfo { 19 | public: 20 | static uint32_t DetectNumberOfCores(); 21 | 22 | private: 23 | CpuInfo() {} 24 | static uint32_t number_of_cores_; 25 | }; 26 | 27 | } // namespace webrtc 28 | 29 | #endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CPU_INFO_H_ 30 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/interface/fix_interlocked_exchange_pointer_win.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | // Various inline functions and macros to fix compilation of 32 bit target 12 | // on MSVC with /Wp64 flag enabled. 13 | 14 | // The original code can be found here: 15 | // http://src.chromium.org/svn/trunk/src/base/fix_wp64.h 16 | 17 | #ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_FIX_INTERLOCKED_EXCHANGE_POINTER_WINDOWS_H_ 18 | #define WEBRTC_SYSTEM_WRAPPERS_SOURCE_FIX_INTERLOCKED_EXCHANGE_POINTER_WINDOWS_H_ 19 | 20 | #include 21 | 22 | // Platform SDK fixes when building with /Wp64 for a 32 bits target. 23 | #if !defined(_WIN64) && defined(_Wp64) 24 | 25 | #ifdef InterlockedExchangePointer 26 | #undef InterlockedExchangePointer 27 | // The problem is that the macro provided for InterlockedExchangePointer() is 28 | // doing a (LONG) C-style cast that triggers invariably the warning C4312 when 29 | // building on 32 bits. 30 | inline void* InterlockedExchangePointer(void* volatile* target, void* value) { 31 | return reinterpret_cast(static_cast(InterlockedExchange( 32 | reinterpret_cast(target), 33 | static_cast(reinterpret_cast(value))))); 34 | } 35 | #endif // #ifdef InterlockedExchangePointer 36 | 37 | #endif // #if !defined(_WIN64) && defined(_Wp64) 38 | 39 | #endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_FIX_INTERLOCKED_EXCHANGE_POINTER_WINDOWS_H_ 40 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/interface/sleep.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | // An OS-independent sleep function. 11 | 12 | #ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_SLEEP_H_ 13 | #define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_SLEEP_H_ 14 | 15 | namespace webrtc { 16 | 17 | // This function sleeps for the specified number of milliseconds. 18 | // It may return early if the thread is woken by some other event, 19 | // such as the delivery of a signal on Unix. 20 | void SleepMs(int msecs); 21 | 22 | } // namespace webrtc 23 | 24 | #endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_SLEEP_H_ 25 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/interface/stringize_macros.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | // Modified from the Chromium original: 12 | // src/base/strings/stringize_macros.h 13 | 14 | // This file defines preprocessor macros for stringizing preprocessor 15 | // symbols (or their output) and manipulating preprocessor symbols 16 | // that define strings. 17 | 18 | #ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_STRINGIZE_MACROS_H_ 19 | #define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_STRINGIZE_MACROS_H_ 20 | 21 | // This is not very useful as it does not expand defined symbols if 22 | // called directly. Use its counterpart without the _NO_EXPANSION 23 | // suffix, below. 24 | #define STRINGIZE_NO_EXPANSION(x) #x 25 | 26 | // Use this to quote the provided parameter, first expanding it if it 27 | // is a preprocessor symbol. 28 | // 29 | // For example, if: 30 | // #define A FOO 31 | // #define B(x) myobj->FunctionCall(x) 32 | // 33 | // Then: 34 | // STRINGIZE(A) produces "FOO" 35 | // STRINGIZE(B(y)) produces "myobj->FunctionCall(y)" 36 | #define STRINGIZE(x) STRINGIZE_NO_EXPANSION(x) 37 | 38 | #endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_STRINGIZE_MACROS_H_ 39 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/source/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 | # 3 | # Use of this source code is governed by a BSD-style license 4 | # that can be found in the LICENSE file in the root of the source 5 | # tree. An additional intellectual property rights grant can be found 6 | # in the file PATENTS. All contributing project authors may 7 | # be found in the AUTHORS file in the root of the source tree. 8 | 9 | LOCAL_PATH := $(call my-dir) 10 | 11 | include $(CLEAR_VARS) 12 | 13 | include $(LOCAL_PATH)/../../../android-webrtc.mk 14 | 15 | LOCAL_ARM_MODE := arm 16 | LOCAL_MODULE := libwebrtc_system_wrappers 17 | LOCAL_MODULE_TAGS := optional 18 | LOCAL_CPP_EXTENSION := .cc 19 | LOCAL_SRC_FILES := \ 20 | android/cpu-features.c \ 21 | cpu_features_android.c \ 22 | map.cc \ 23 | sort.cc \ 24 | aligned_malloc.cc \ 25 | atomic32_posix.cc \ 26 | condition_variable.cc \ 27 | cpu_features.cc \ 28 | cpu_info.cc \ 29 | critical_section.cc \ 30 | event.cc \ 31 | event_tracer.cc \ 32 | file_impl.cc \ 33 | list_no_stl.cc \ 34 | rw_lock.cc \ 35 | thread.cc \ 36 | trace_impl.cc \ 37 | condition_variable_posix.cc \ 38 | critical_section_posix.cc \ 39 | event_posix.cc \ 40 | sleep.cc \ 41 | thread_posix.cc \ 42 | tick_util.cc \ 43 | trace_posix.cc \ 44 | rw_lock_posix.cc 45 | 46 | LOCAL_CFLAGS := \ 47 | $(MY_WEBRTC_COMMON_DEFS) 48 | 49 | LOCAL_C_INCLUDES := \ 50 | $(LOCAL_PATH)/../.. \ 51 | $(LOCAL_PATH)/../interface \ 52 | $(LOCAL_PATH)/spreadsortlib \ 53 | external/webrtc 54 | 55 | LOCAL_SHARED_LIBRARIES := \ 56 | libcutils \ 57 | libdl \ 58 | libstlport 59 | 60 | ifndef NDK_ROOT 61 | include external/stlport/libstlport.mk 62 | endif 63 | include $(BUILD_STATIC_LIBRARY) 64 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/source/Makefile: -------------------------------------------------------------------------------- 1 | include $(ROOT)/config.mk 2 | 3 | LOCAL_MODULE := libwebrtc_system_wrappers 4 | LOCAL_SRC_FILES := \ 5 | map.cc \ 6 | sort.cc \ 7 | aligned_malloc.cc \ 8 | condition_variable.cc \ 9 | cpu_features.cc \ 10 | cpu_info.cc \ 11 | critical_section.cc \ 12 | event.cc \ 13 | event_tracer.cc \ 14 | file_impl.cc \ 15 | list_no_stl.cc \ 16 | logging.cc \ 17 | rw_lock.cc \ 18 | thread.cc \ 19 | trace_impl.cc \ 20 | sleep.cc \ 21 | tick_util.cc 22 | 23 | ifeq ($(OS), mac) 24 | LOCAL_SRC_FILES += \ 25 | condition_variable_posix.cc \ 26 | critical_section_posix.cc \ 27 | event_posix.cc \ 28 | thread_posix.cc \ 29 | trace_posix.cc \ 30 | rw_lock_posix.cc 31 | endif 32 | 33 | ifeq ($(OS), win) 34 | LOCAL_SRC_FILES += \ 35 | thread_win.cc \ 36 | condition_variable_native_win.cc \ 37 | critical_section_win.cc \ 38 | event_win.cc \ 39 | trace_win.cc \ 40 | rw_lock_win.cc 41 | endif 42 | 43 | 44 | include $(ROOT)/build_library.mk 45 | 46 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/source/android/cpu-features.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | // You can download Android source at 12 | // http://source.android.com/source/downloading.html 13 | // Original files are in ndk/sources/android/cpufeatures 14 | // Revision is Change-Id: I9a0629efba36a6023f05e5f092e7addcc1b7d2a9 15 | 16 | #ifndef CPU_FEATURES_H 17 | #define CPU_FEATURES_H 18 | 19 | #include 20 | #include 21 | 22 | __BEGIN_DECLS 23 | 24 | typedef enum { 25 | ANDROID_CPU_FAMILY_UNKNOWN = 0, 26 | ANDROID_CPU_FAMILY_ARM, 27 | ANDROID_CPU_FAMILY_X86, 28 | 29 | ANDROID_CPU_FAMILY_MAX /* do not remove */ 30 | 31 | } AndroidCpuFamily; 32 | 33 | /* Return family of the device's CPU */ 34 | extern AndroidCpuFamily android_getCpuFamily(void); 35 | 36 | enum { 37 | ANDROID_CPU_ARM_FEATURE_ARMv7 = (1 << 0), 38 | ANDROID_CPU_ARM_FEATURE_VFPv3 = (1 << 1), 39 | ANDROID_CPU_ARM_FEATURE_NEON = (1 << 2), 40 | ANDROID_CPU_ARM_FEATURE_LDREX_STREX = (1 << 3), 41 | }; 42 | 43 | enum { 44 | ANDROID_CPU_X86_FEATURE_SSSE3 = (1 << 0), 45 | ANDROID_CPU_X86_FEATURE_POPCNT = (1 << 1), 46 | ANDROID_CPU_X86_FEATURE_MOVBE = (1 << 2), 47 | }; 48 | 49 | extern uint64_t android_getCpuFeatures(void); 50 | 51 | /* Return the number of CPU cores detected on this device. */ 52 | extern int android_getCpuCount(void); 53 | 54 | __END_DECLS 55 | 56 | #endif /* CPU_FEATURES_H */ 57 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/source/atomic32_mac.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "webrtc/system_wrappers/interface/atomic32.h" 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | #include "webrtc/common_types.h" 18 | 19 | namespace webrtc { 20 | 21 | Atomic32::Atomic32(int32_t initial_value) 22 | : value_(initial_value) { 23 | assert(Is32bitAligned()); 24 | } 25 | 26 | Atomic32::~Atomic32() { 27 | } 28 | 29 | int32_t Atomic32::operator++() { 30 | return OSAtomicIncrement32Barrier(&value_); 31 | } 32 | 33 | int32_t Atomic32::operator--() { 34 | return OSAtomicDecrement32Barrier(&value_); 35 | } 36 | 37 | int32_t Atomic32::operator+=(int32_t value) { 38 | return OSAtomicAdd32Barrier(value, &value_); 39 | } 40 | 41 | int32_t Atomic32::operator-=(int32_t value) { 42 | return OSAtomicAdd32Barrier(-value, &value_); 43 | } 44 | 45 | bool Atomic32::CompareExchange(int32_t new_value, int32_t compare_value) { 46 | return OSAtomicCompareAndSwap32Barrier(compare_value, new_value, &value_); 47 | } 48 | 49 | int32_t Atomic32::Value() const { 50 | return value_; 51 | } 52 | 53 | } // namespace webrtc 54 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/source/atomic32_posix.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "webrtc/system_wrappers/interface/atomic32.h" 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | #include "webrtc/common_types.h" 18 | 19 | namespace webrtc { 20 | 21 | Atomic32::Atomic32(int32_t initial_value) 22 | : value_(initial_value) { 23 | assert(Is32bitAligned()); 24 | } 25 | 26 | Atomic32::~Atomic32() { 27 | } 28 | 29 | int32_t Atomic32::operator++() { 30 | return __sync_fetch_and_add(&value_, 1) + 1; 31 | } 32 | 33 | int32_t Atomic32::operator--() { 34 | return __sync_fetch_and_sub(&value_, 1) - 1; 35 | } 36 | 37 | int32_t Atomic32::operator+=(int32_t value) { 38 | int32_t return_value = __sync_fetch_and_add(&value_, value); 39 | return_value += value; 40 | return return_value; 41 | } 42 | 43 | int32_t Atomic32::operator-=(int32_t value) { 44 | int32_t return_value = __sync_fetch_and_sub(&value_, value); 45 | return_value -= value; 46 | return return_value; 47 | } 48 | 49 | bool Atomic32::CompareExchange(int32_t new_value, int32_t compare_value) { 50 | return __sync_bool_compare_and_swap(&value_, compare_value, new_value); 51 | } 52 | 53 | int32_t Atomic32::Value() const { 54 | return value_; 55 | } 56 | 57 | } // namespace webrtc 58 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/source/clock_unittest.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "webrtc/system_wrappers/interface/clock.h" 12 | 13 | #include "testing/gtest/include/gtest/gtest.h" 14 | 15 | namespace webrtc { 16 | 17 | TEST(ClockTest, NtpTime) { 18 | Clock* clock = Clock::GetRealTimeClock(); 19 | uint32_t seconds; 20 | uint32_t fractions; 21 | clock->CurrentNtp(seconds, fractions); 22 | int64_t milliseconds = clock->CurrentNtpInMilliseconds(); 23 | EXPECT_GE(milliseconds, Clock::NtpToMs(seconds, fractions)); 24 | EXPECT_NEAR(milliseconds, Clock::NtpToMs(seconds, fractions), 5); 25 | } 26 | } // namespace webrtc 27 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/source/condition_variable.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "webrtc/system_wrappers/interface/condition_variable_wrapper.h" 12 | 13 | #include 14 | 15 | #if defined(_WIN32) 16 | #include 17 | #include "webrtc/system_wrappers/source/condition_variable_event_win.h" 18 | #include "webrtc/system_wrappers/source/condition_variable_native_win.h" 19 | #elif defined(WEBRTC_LINUX) || defined(WEBRTC_MAC) 20 | #include 21 | #include "webrtc/system_wrappers/source/condition_variable_posix.h" 22 | #endif 23 | 24 | namespace webrtc { 25 | 26 | ConditionVariableWrapper* ConditionVariableWrapper::CreateConditionVariable() { 27 | #if defined(_WIN32) 28 | // Try to create native condition variable implementation. 29 | ConditionVariableWrapper* ret_val = ConditionVariableNativeWin::Create(); 30 | if (!ret_val) { 31 | // Native condition variable implementation does not exist. Create generic 32 | // condition variable based on events. 33 | ret_val = new ConditionVariableEventWin(); 34 | } 35 | return ret_val; 36 | #elif defined(WEBRTC_LINUX) || defined(WEBRTC_MAC) 37 | return ConditionVariablePosix::Create(); 38 | #else 39 | return NULL; 40 | #endif 41 | } 42 | 43 | } // namespace webrtc 44 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/source/condition_variable_event_win.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_CONDITION_VARIABLE_EVENT_WIN_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_SOURCE_CONDITION_VARIABLE_EVENT_WIN_H_ 13 | 14 | #include 15 | 16 | #include "webrtc/system_wrappers/interface/condition_variable_wrapper.h" 17 | 18 | namespace webrtc { 19 | 20 | class ConditionVariableEventWin : public ConditionVariableWrapper { 21 | public: 22 | ConditionVariableEventWin(); 23 | virtual ~ConditionVariableEventWin(); 24 | 25 | void SleepCS(CriticalSectionWrapper& crit_sect); 26 | bool SleepCS(CriticalSectionWrapper& crit_sect, unsigned long max_time_inMS); 27 | void Wake(); 28 | void WakeAll(); 29 | 30 | private: 31 | enum EventWakeUpType { 32 | WAKEALL_0 = 0, 33 | WAKEALL_1 = 1, 34 | WAKE = 2, 35 | EVENT_COUNT = 3 36 | }; 37 | 38 | unsigned int num_waiters_[2]; 39 | EventWakeUpType eventID_; 40 | CRITICAL_SECTION num_waiters_crit_sect_; 41 | HANDLE events_[EVENT_COUNT]; 42 | }; 43 | 44 | } // namespace webrtc 45 | 46 | #endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_CONDITION_VARIABLE_EVENT_WIN_H_ 47 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/source/condition_variable_posix.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_CONDITION_VARIABLE_POSIX_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_SOURCE_CONDITION_VARIABLE_POSIX_H_ 13 | 14 | #include 15 | 16 | #include "webrtc/system_wrappers/interface/condition_variable_wrapper.h" 17 | #include "webrtc/typedefs.h" 18 | 19 | namespace webrtc { 20 | 21 | class ConditionVariablePosix : public ConditionVariableWrapper { 22 | public: 23 | static ConditionVariableWrapper* Create(); 24 | virtual ~ConditionVariablePosix(); 25 | 26 | virtual void SleepCS(CriticalSectionWrapper& crit_sect) OVERRIDE; 27 | virtual bool SleepCS(CriticalSectionWrapper& crit_sect, 28 | unsigned long max_time_in_ms) OVERRIDE; 29 | virtual void Wake() OVERRIDE; 30 | virtual void WakeAll() OVERRIDE; 31 | 32 | private: 33 | ConditionVariablePosix(); 34 | int Construct(); 35 | 36 | private: 37 | pthread_cond_t cond_; 38 | }; 39 | 40 | } // namespace webrtc 41 | 42 | #endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_CONDITION_VARIABLE_POSIX_H_ 43 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/source/cpu_features_android.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #if defined(WEBRTC_CHROMIUM_BUILD) 12 | #include 13 | #else 14 | #include "webrtc/system_wrappers/source/android/cpu-features.h" 15 | #endif // defined(WEBRTC_CHROMIUM_BUILD) 16 | 17 | uint64_t WebRtc_GetCPUFeaturesARM(void) { 18 | return android_getCpuFeatures(); 19 | } 20 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/source/critical_section.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #if defined(_WIN32) 12 | #include 13 | #include "webrtc/system_wrappers/source/critical_section_win.h" 14 | #else 15 | #include "webrtc/system_wrappers/source/critical_section_posix.h" 16 | #endif 17 | 18 | namespace webrtc { 19 | 20 | CriticalSectionWrapper* CriticalSectionWrapper::CreateCriticalSection() { 21 | #ifdef _WIN32 22 | return new CriticalSectionWindows(); 23 | #else 24 | return new CriticalSectionPosix(); 25 | #endif 26 | } 27 | 28 | } // namespace webrtc 29 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/source/critical_section_posix.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | // General note: return values for the various pthread synchronization APIs 12 | // are explicitly ignored here. In Chromium, the same thing is done for release. 13 | // However, in debugging, failure in these APIs are logged. There is currently 14 | // no equivalent to DCHECK_EQ in WebRTC code so this is the best we can do here. 15 | // TODO(henrike): add logging when pthread synchronization APIs are failing. 16 | 17 | #include "webrtc/system_wrappers/source/critical_section_posix.h" 18 | 19 | namespace webrtc { 20 | 21 | CriticalSectionPosix::CriticalSectionPosix() { 22 | pthread_mutexattr_t attr; 23 | (void) pthread_mutexattr_init(&attr); 24 | (void) pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); 25 | (void) pthread_mutex_init(&mutex_, &attr); 26 | } 27 | 28 | CriticalSectionPosix::~CriticalSectionPosix() { 29 | (void) pthread_mutex_destroy(&mutex_); 30 | } 31 | 32 | void 33 | CriticalSectionPosix::Enter() { 34 | (void) pthread_mutex_lock(&mutex_); 35 | } 36 | 37 | void 38 | CriticalSectionPosix::Leave() { 39 | (void) pthread_mutex_unlock(&mutex_); 40 | } 41 | 42 | } // namespace webrtc 43 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/source/critical_section_posix.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_CRITICAL_SECTION_POSIX_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_SOURCE_CRITICAL_SECTION_POSIX_H_ 13 | 14 | #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" 15 | 16 | #include 17 | 18 | namespace webrtc { 19 | 20 | class CriticalSectionPosix : public CriticalSectionWrapper { 21 | public: 22 | CriticalSectionPosix(); 23 | 24 | virtual ~CriticalSectionPosix(); 25 | 26 | virtual void Enter() OVERRIDE; 27 | virtual void Leave() OVERRIDE; 28 | 29 | private: 30 | pthread_mutex_t mutex_; 31 | friend class ConditionVariablePosix; 32 | }; 33 | 34 | } // namespace webrtc 35 | 36 | #endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_CRITICAL_SECTION_POSIX_H_ 37 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/source/critical_section_win.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "webrtc/system_wrappers/source/critical_section_win.h" 12 | 13 | namespace webrtc { 14 | 15 | CriticalSectionWindows::CriticalSectionWindows() { 16 | InitializeCriticalSection(&crit); 17 | } 18 | 19 | CriticalSectionWindows::~CriticalSectionWindows() { 20 | DeleteCriticalSection(&crit); 21 | } 22 | 23 | void 24 | CriticalSectionWindows::Enter() { 25 | EnterCriticalSection(&crit); 26 | } 27 | 28 | void 29 | CriticalSectionWindows::Leave() { 30 | LeaveCriticalSection(&crit); 31 | } 32 | 33 | } // namespace webrtc 34 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/source/critical_section_win.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_CRITICAL_SECTION_WIN_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_SOURCE_CRITICAL_SECTION_WIN_H_ 13 | 14 | #include 15 | #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" 16 | #include "webrtc/typedefs.h" 17 | 18 | namespace webrtc { 19 | 20 | class CriticalSectionWindows : public CriticalSectionWrapper { 21 | public: 22 | CriticalSectionWindows(); 23 | 24 | virtual ~CriticalSectionWindows(); 25 | 26 | virtual void Enter(); 27 | virtual void Leave(); 28 | 29 | private: 30 | CRITICAL_SECTION crit; 31 | 32 | friend class ConditionVariableEventWin; 33 | friend class ConditionVariableNativeWin; 34 | }; 35 | 36 | } // namespace webrtc 37 | 38 | #endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_CRITICAL_SECTION_WIN_H_ 39 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/source/data_log_c_helpers_unittest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef SRC_SYSTEM_WRAPPERS_SOURCE_DATA_LOG_C_HELPERS_UNITTEST_H_ 12 | #define SRC_SYSTEM_WRAPPERS_SOURCE_DATA_LOG_C_HELPERS_UNITTEST_H_ 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | int WebRtcDataLogCHelper_TestCreateLog(); 19 | 20 | int WebRtcDataLogCHelper_TestReturnLog(); 21 | 22 | int WebRtcDataLogCHelper_TestCombine(); 23 | 24 | int WebRtcDataLogCHelper_TestAddTable(); 25 | 26 | int WebRtcDataLogCHelper_TestAddColumn(); 27 | 28 | int WebRtcDataLogCHelper_TestNextRow(); 29 | 30 | int WebRtcDataLogCHelper_TestInsertCell_int(); 31 | 32 | int WebRtcDataLogCHelper_TestInsertArray_int(); 33 | 34 | int WebRtcDataLogCHelper_TestInsertCell_float(); 35 | 36 | int WebRtcDataLogCHelper_TestInsertArray_float(); 37 | 38 | int WebRtcDataLogCHelper_TestInsertCell_double(); 39 | 40 | int WebRtcDataLogCHelper_TestInsertArray_double(); 41 | 42 | int WebRtcDataLogCHelper_TestInsertCell_int32(); 43 | 44 | int WebRtcDataLogCHelper_TestInsertArray_int32(); 45 | 46 | int WebRtcDataLogCHelper_TestInsertCell_uint32(); 47 | 48 | int WebRtcDataLogCHelper_TestInsertArray_uint32(); 49 | 50 | int WebRtcDataLogCHelper_TestInsertCell_int64(); 51 | 52 | int WebRtcDataLogCHelper_TestInsertArray_int64(); 53 | 54 | #ifdef __cplusplus 55 | } // end of extern "C" 56 | #endif 57 | 58 | #endif // SRC_SYSTEM_WRAPPERS_SOURCE_DATA_LOG_C_HELPERS_UNITTEST_H_ 59 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/source/event.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "webrtc/system_wrappers/interface/event_wrapper.h" 12 | 13 | #if defined(_WIN32) 14 | #include 15 | #include "webrtc/system_wrappers/source/event_win.h" 16 | #elif defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) 17 | #include 18 | #include 19 | #include "webrtc/system_wrappers/source/event_posix.h" 20 | #else 21 | #include 22 | #include "webrtc/system_wrappers/source/event_posix.h" 23 | #endif 24 | 25 | namespace webrtc { 26 | EventWrapper* EventWrapper::Create() { 27 | #if defined(_WIN32) 28 | return new EventWindows(); 29 | #else 30 | return EventPosix::Create(); 31 | #endif 32 | } 33 | } // namespace webrtc 34 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/source/event_posix.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_EVENT_POSIX_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_SOURCE_EVENT_POSIX_H_ 13 | 14 | #include "webrtc/system_wrappers/interface/event_wrapper.h" 15 | 16 | #include 17 | #include 18 | 19 | #include "webrtc/system_wrappers/interface/thread_wrapper.h" 20 | 21 | namespace webrtc { 22 | 23 | enum State { 24 | kUp = 1, 25 | kDown = 2 26 | }; 27 | 28 | class EventPosix : public EventWrapper { 29 | public: 30 | static EventWrapper* Create(); 31 | 32 | virtual ~EventPosix(); 33 | 34 | virtual EventTypeWrapper Wait(unsigned long max_time) OVERRIDE; 35 | virtual bool Set() OVERRIDE; 36 | virtual bool Reset() OVERRIDE; 37 | 38 | virtual bool StartTimer(bool periodic, unsigned long time) OVERRIDE; 39 | virtual bool StopTimer() OVERRIDE; 40 | 41 | private: 42 | EventPosix(); 43 | int Construct(); 44 | 45 | static bool Run(ThreadObj obj); 46 | bool Process(); 47 | EventTypeWrapper Wait(timespec& wake_at); 48 | 49 | private: 50 | pthread_cond_t cond_; 51 | pthread_mutex_t mutex_; 52 | 53 | ThreadWrapper* timer_thread_; 54 | EventPosix* timer_event_; 55 | timespec created_at_; 56 | 57 | bool periodic_; 58 | unsigned long time_; // In ms 59 | unsigned long count_; 60 | State state_; 61 | }; 62 | 63 | } // namespace webrtc 64 | 65 | #endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_EVENT_POSIX_H_ 66 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/source/event_win.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_EVENT_WIN_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_SOURCE_EVENT_WIN_H_ 13 | 14 | #include 15 | 16 | #include "webrtc/system_wrappers/interface/event_wrapper.h" 17 | 18 | #include "webrtc/typedefs.h" 19 | 20 | namespace webrtc { 21 | 22 | class EventWindows : public EventWrapper { 23 | public: 24 | EventWindows(); 25 | virtual ~EventWindows(); 26 | 27 | virtual EventTypeWrapper Wait(unsigned long max_time); 28 | virtual bool Set(); 29 | virtual bool Reset(); 30 | 31 | virtual bool StartTimer(bool periodic, unsigned long time); 32 | virtual bool StopTimer(); 33 | 34 | private: 35 | HANDLE event_; 36 | uint32_t timerID_; 37 | }; 38 | 39 | } // namespace webrtc 40 | 41 | #endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_EVENT_WIN_H_ 42 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/source/logging.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "webrtc/system_wrappers/interface/logging.h" 12 | 13 | #include 14 | 15 | #include 16 | 17 | #include "webrtc/common_types.h" 18 | #include "webrtc/system_wrappers/interface/trace.h" 19 | 20 | namespace webrtc { 21 | namespace { 22 | 23 | TraceLevel WebRtcSeverity(LoggingSeverity sev) { 24 | switch (sev) { 25 | // TODO(andrew): SENSITIVE doesn't have a corresponding webrtc level. 26 | case LS_SENSITIVE: return kTraceInfo; 27 | case LS_VERBOSE: return kTraceInfo; 28 | case LS_INFO: return kTraceTerseInfo; 29 | case LS_WARNING: return kTraceWarning; 30 | case LS_ERROR: return kTraceError; 31 | default: return kTraceNone; 32 | } 33 | } 34 | 35 | const char* DescribeFile(const char* file) { 36 | const char* end1 = ::strrchr(file, '/'); 37 | const char* end2 = ::strrchr(file, '\\'); 38 | if (!end1 && !end2) 39 | return file; 40 | else 41 | return (end1 > end2) ? end1 + 1 : end2 + 1; 42 | } 43 | 44 | } // namespace 45 | 46 | LogMessage::LogMessage(const char* file, int line, LoggingSeverity sev) 47 | : severity_(sev) { 48 | print_stream_ << "(" << DescribeFile(file) << ":" << line << "): "; 49 | } 50 | 51 | LogMessage::~LogMessage() { 52 | const std::string& str = print_stream_.str(); 53 | WEBRTC_TRACE(WebRtcSeverity(severity_), kTraceUndefined, 0, str.c_str()); 54 | } 55 | 56 | } // namespace webrtc 57 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/source/logging_no_op.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "webrtc/system_wrappers/interface/logging.h" 12 | 13 | namespace webrtc { 14 | 15 | LogMessage::LogMessage(const char*, int, LoggingSeverity) { 16 | // Avoid an unused-private-field warning. 17 | (void)severity_; 18 | } 19 | 20 | LogMessage::~LogMessage() { 21 | } 22 | 23 | } // namespace webrtc 24 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/source/rw_lock.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "webrtc/system_wrappers/interface/rw_lock_wrapper.h" 12 | 13 | #include 14 | 15 | #if defined(_WIN32) 16 | #include "webrtc/system_wrappers/source/rw_lock_generic.h" 17 | #include "webrtc/system_wrappers/source/rw_lock_win.h" 18 | #else 19 | #include "webrtc/system_wrappers/source/rw_lock_posix.h" 20 | #endif 21 | 22 | namespace webrtc { 23 | 24 | RWLockWrapper* RWLockWrapper::CreateRWLock() { 25 | #ifdef _WIN32 26 | // Native implementation is faster, so use that if available. 27 | RWLockWrapper* lock = RWLockWin::Create(); 28 | if (lock) { 29 | return lock; 30 | } 31 | return new RWLockGeneric(); 32 | #else 33 | return RWLockPosix::Create(); 34 | #endif 35 | } 36 | 37 | } // namespace webrtc 38 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/source/rw_lock_generic.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_RW_LOCK_GENERIC_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_SOURCE_RW_LOCK_GENERIC_H_ 13 | 14 | #include "webrtc/system_wrappers/interface/rw_lock_wrapper.h" 15 | #include "webrtc/typedefs.h" 16 | 17 | namespace webrtc { 18 | 19 | class CriticalSectionWrapper; 20 | class ConditionVariableWrapper; 21 | 22 | class RWLockGeneric : public RWLockWrapper { 23 | public: 24 | RWLockGeneric(); 25 | virtual ~RWLockGeneric(); 26 | 27 | virtual void AcquireLockExclusive() OVERRIDE; 28 | virtual void ReleaseLockExclusive() OVERRIDE; 29 | 30 | virtual void AcquireLockShared() OVERRIDE; 31 | virtual void ReleaseLockShared() OVERRIDE; 32 | 33 | private: 34 | CriticalSectionWrapper* critical_section_; 35 | ConditionVariableWrapper* read_condition_; 36 | ConditionVariableWrapper* write_condition_; 37 | 38 | int readers_active_; 39 | bool writer_active_; 40 | int readers_waiting_; 41 | int writers_waiting_; 42 | }; 43 | 44 | } // namespace webrtc 45 | 46 | #endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_RW_LOCK_GENERIC_H_ 47 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/source/rw_lock_posix.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "webrtc/system_wrappers/source/rw_lock_posix.h" 12 | 13 | namespace webrtc { 14 | 15 | RWLockPosix::RWLockPosix() : lock_() { 16 | } 17 | 18 | RWLockPosix::~RWLockPosix() { 19 | pthread_rwlock_destroy(&lock_); 20 | } 21 | 22 | RWLockPosix* RWLockPosix::Create() { 23 | RWLockPosix* ret_val = new RWLockPosix(); 24 | if (!ret_val->Init()) { 25 | delete ret_val; 26 | return NULL; 27 | } 28 | return ret_val; 29 | } 30 | 31 | bool RWLockPosix::Init() { 32 | return pthread_rwlock_init(&lock_, 0) == 0; 33 | } 34 | 35 | void RWLockPosix::AcquireLockExclusive() { 36 | pthread_rwlock_wrlock(&lock_); 37 | } 38 | 39 | void RWLockPosix::ReleaseLockExclusive() { 40 | pthread_rwlock_unlock(&lock_); 41 | } 42 | 43 | void RWLockPosix::AcquireLockShared() { 44 | pthread_rwlock_rdlock(&lock_); 45 | } 46 | 47 | void RWLockPosix::ReleaseLockShared() { 48 | pthread_rwlock_unlock(&lock_); 49 | } 50 | 51 | } // namespace webrtc 52 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/source/rw_lock_posix.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_RW_LOCK_POSIX_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_SOURCE_RW_LOCK_POSIX_H_ 13 | 14 | #include "webrtc/system_wrappers/interface/rw_lock_wrapper.h" 15 | #include "webrtc/typedefs.h" 16 | 17 | #include 18 | 19 | namespace webrtc { 20 | 21 | class RWLockPosix : public RWLockWrapper { 22 | public: 23 | static RWLockPosix* Create(); 24 | virtual ~RWLockPosix(); 25 | 26 | virtual void AcquireLockExclusive() OVERRIDE; 27 | virtual void ReleaseLockExclusive() OVERRIDE; 28 | 29 | virtual void AcquireLockShared() OVERRIDE; 30 | virtual void ReleaseLockShared() OVERRIDE; 31 | 32 | private: 33 | RWLockPosix(); 34 | bool Init(); 35 | 36 | pthread_rwlock_t lock_; 37 | }; 38 | 39 | } // namespace webrtc 40 | 41 | #endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_RW_LOCK_POSIX_H_ 42 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/source/rw_lock_win.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_RW_LOCK_WIN_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_SOURCE_RW_LOCK_WIN_H_ 13 | 14 | #include "webrtc/system_wrappers/interface/rw_lock_wrapper.h" 15 | 16 | #include 17 | 18 | namespace webrtc { 19 | 20 | class RWLockWin : public RWLockWrapper { 21 | public: 22 | static RWLockWin* Create(); 23 | ~RWLockWin() {} 24 | 25 | virtual void AcquireLockExclusive(); 26 | virtual void ReleaseLockExclusive(); 27 | 28 | virtual void AcquireLockShared(); 29 | virtual void ReleaseLockShared(); 30 | 31 | private: 32 | RWLockWin(); 33 | static bool LoadModule(); 34 | 35 | SRWLOCK lock_; 36 | }; 37 | 38 | } // namespace webrtc 39 | 40 | #endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_RW_LOCK_WIN_H_ 41 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/source/sleep.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | // An OS-independent sleep function. 11 | 12 | #include "webrtc/system_wrappers/interface/sleep.h" 13 | 14 | #ifdef _WIN32 15 | // For Sleep() 16 | #include 17 | #else 18 | // For nanosleep() 19 | #include 20 | #endif 21 | 22 | namespace webrtc { 23 | 24 | void SleepMs(int msecs) { 25 | #ifdef _WIN32 26 | Sleep(msecs); 27 | #else 28 | struct timespec short_wait; 29 | struct timespec remainder; 30 | short_wait.tv_sec = msecs / 1000; 31 | short_wait.tv_nsec = (msecs % 1000) * 1000 * 1000; 32 | nanosleep(&short_wait, &remainder); 33 | #endif 34 | } 35 | 36 | } // namespace webrtc 37 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/source/stringize_macros_unittest.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "webrtc/system_wrappers/interface/stringize_macros.h" 12 | 13 | #include "testing/gtest/include/gtest/gtest.h" 14 | 15 | // Macros as per documentation in header file. 16 | #define PREPROCESSOR_UTIL_UNITTEST_A FOO 17 | #define PREPROCESSOR_UTIL_UNITTEST_B(x) myobj->FunctionCall(x) 18 | #define PREPROCESSOR_UTIL_UNITTEST_C "foo" 19 | 20 | TEST(StringizeTest, Ansi) { 21 | EXPECT_STREQ( 22 | "PREPROCESSOR_UTIL_UNITTEST_A", 23 | STRINGIZE_NO_EXPANSION(PREPROCESSOR_UTIL_UNITTEST_A)); 24 | EXPECT_STREQ( 25 | "PREPROCESSOR_UTIL_UNITTEST_B(y)", 26 | STRINGIZE_NO_EXPANSION(PREPROCESSOR_UTIL_UNITTEST_B(y))); 27 | EXPECT_STREQ( 28 | "PREPROCESSOR_UTIL_UNITTEST_C", 29 | STRINGIZE_NO_EXPANSION(PREPROCESSOR_UTIL_UNITTEST_C)); 30 | 31 | EXPECT_STREQ("FOO", STRINGIZE(PREPROCESSOR_UTIL_UNITTEST_A)); 32 | EXPECT_STREQ("myobj->FunctionCall(y)", 33 | STRINGIZE(PREPROCESSOR_UTIL_UNITTEST_B(y))); 34 | EXPECT_STREQ("\"foo\"", STRINGIZE(PREPROCESSOR_UTIL_UNITTEST_C)); 35 | } 36 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/source/thread.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "webrtc/system_wrappers/interface/thread_wrapper.h" 12 | 13 | #if defined(_WIN32) 14 | #include "webrtc/system_wrappers/source/thread_win.h" 15 | #else 16 | #include "webrtc/system_wrappers/source/thread_posix.h" 17 | #endif 18 | 19 | namespace webrtc { 20 | 21 | ThreadWrapper* ThreadWrapper::CreateThread(ThreadRunFunction func, 22 | ThreadObj obj, ThreadPriority prio, 23 | const char* thread_name) { 24 | #if defined(_WIN32) 25 | return new ThreadWindows(func, obj, prio, thread_name); 26 | #else 27 | return ThreadPosix::Create(func, obj, prio, thread_name); 28 | #endif 29 | } 30 | 31 | bool ThreadWrapper::SetAffinity(const int* processor_numbers, 32 | const unsigned int amount_of_processors) { 33 | return false; 34 | } 35 | 36 | } // namespace webrtc 37 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/source/thread_posix_unittest.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "webrtc/system_wrappers/source/thread_posix.h" 12 | 13 | #include "testing/gtest/include/gtest/gtest.h" 14 | 15 | TEST(ThreadTestPosix, PrioritySettings) { 16 | // API assumes that max_prio - min_prio > 2. Test the extreme case. 17 | const int kMinPrio = -1; 18 | const int kMaxPrio = 2; 19 | 20 | int last_priority = kMinPrio; 21 | for (int priority = webrtc::kLowPriority; 22 | priority <= webrtc::kRealtimePriority; ++priority) { 23 | int system_priority = webrtc::ConvertToSystemPriority( 24 | static_cast(priority), kMinPrio, kMaxPrio); 25 | EXPECT_GT(system_priority, kMinPrio); 26 | EXPECT_LT(system_priority, kMaxPrio); 27 | EXPECT_GE(system_priority, last_priority); 28 | last_priority = system_priority; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/source/thread_unittest.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "webrtc/system_wrappers/interface/thread_wrapper.h" 12 | 13 | #include "testing/gtest/include/gtest/gtest.h" 14 | #include "webrtc/system_wrappers/interface/scoped_ptr.h" 15 | 16 | namespace webrtc { 17 | 18 | // Function that does nothing, and reports success. 19 | bool NullRunFunction(void* obj) { 20 | return true; 21 | } 22 | 23 | TEST(ThreadTest, StartStop) { 24 | ThreadWrapper* thread = ThreadWrapper::CreateThread(&NullRunFunction, NULL); 25 | unsigned int id = 42; 26 | ASSERT_TRUE(thread->Start(id)); 27 | EXPECT_TRUE(thread->Stop()); 28 | delete thread; 29 | } 30 | 31 | // Function that sets a boolean. 32 | bool SetFlagRunFunction(void* obj) { 33 | bool* obj_as_bool = static_cast(obj); 34 | *obj_as_bool = true; 35 | return true; 36 | } 37 | 38 | TEST(ThreadTest, RunFunctionIsCalled) { 39 | bool flag = false; 40 | ThreadWrapper* thread = ThreadWrapper::CreateThread(&SetFlagRunFunction, 41 | &flag); 42 | unsigned int id = 42; 43 | ASSERT_TRUE(thread->Start(id)); 44 | 45 | // At this point, the flag may be either true or false. 46 | EXPECT_TRUE(thread->Stop()); 47 | 48 | // We expect the thread to have run at least once. 49 | EXPECT_TRUE(flag); 50 | delete thread; 51 | } 52 | 53 | } // namespace webrtc 54 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/source/trace_impl_no_op.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "webrtc/system_wrappers/interface/trace.h" 12 | 13 | namespace webrtc { 14 | 15 | const int Trace::kBoilerplateLength = 71; 16 | const int Trace::kTimestampPosition = 13; 17 | const int Trace::kTimestampLength = 12; 18 | 19 | void Trace::CreateTrace() { 20 | } 21 | 22 | void Trace::ReturnTrace() { 23 | } 24 | 25 | int32_t Trace::SetLevelFilter(uint32_t filter) { 26 | return 0; 27 | } 28 | 29 | int32_t Trace::LevelFilter(uint32_t& filter) { 30 | return 0; 31 | } 32 | 33 | int32_t Trace::TraceFile(char file_name[1024]) { 34 | return -1; 35 | } 36 | 37 | int32_t Trace::SetTraceFile(const char* file_name, 38 | const bool add_file_counter) { 39 | return -1; 40 | } 41 | 42 | int32_t Trace::SetTraceCallback(TraceCallback* callback) { 43 | return -1; 44 | } 45 | 46 | void Trace::Add(const TraceLevel level, const TraceModule module, 47 | const int32_t id, const char* msg, ...) { 48 | } 49 | 50 | } // namespace webrtc 51 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/source/trace_posix.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_POSIX_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_POSIX_H_ 13 | 14 | #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" 15 | #include "webrtc/system_wrappers/source/trace_impl.h" 16 | 17 | namespace webrtc { 18 | 19 | class TracePosix : public TraceImpl { 20 | public: 21 | TracePosix(); 22 | virtual ~TracePosix(); 23 | 24 | // This method can be called on several different threads different from 25 | // the creating thread. 26 | virtual int32_t AddTime(char* trace_message, const TraceLevel level) const 27 | OVERRIDE; 28 | 29 | virtual int32_t AddBuildInfo(char* trace_message) const OVERRIDE; 30 | virtual int32_t AddDateTimeInfo(char* trace_message) const OVERRIDE; 31 | 32 | private: 33 | volatile mutable uint32_t prev_api_tick_count_; 34 | volatile mutable uint32_t prev_tick_count_; 35 | 36 | CriticalSectionWrapper& crit_sect_; 37 | }; 38 | 39 | } // namespace webrtc 40 | 41 | #endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_POSIX_H_ 42 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/source/trace_win.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_WIN_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_WIN_H_ 13 | 14 | #include 15 | #include 16 | 17 | #include "webrtc/system_wrappers/source/trace_impl.h" 18 | 19 | namespace webrtc { 20 | 21 | class TraceWindows : public TraceImpl { 22 | public: 23 | TraceWindows(); 24 | virtual ~TraceWindows(); 25 | 26 | virtual int32_t AddTime(char* trace_message, const TraceLevel level) const; 27 | 28 | virtual int32_t AddBuildInfo(char* trace_message) const; 29 | virtual int32_t AddDateTimeInfo(char* trace_message) const; 30 | private: 31 | volatile mutable uint32_t prev_api_tick_count_; 32 | volatile mutable uint32_t prev_tick_count_; 33 | }; 34 | 35 | } // namespace webrtc 36 | 37 | #endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_WIN_H_ 38 | -------------------------------------------------------------------------------- /multimedia/webrtc/system_wrappers/source/unittest_utilities_unittest.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "webrtc/system_wrappers/source/unittest_utilities.h" 12 | 13 | #include "testing/gtest/include/gtest/gtest.h" 14 | #include "webrtc/system_wrappers/interface/trace.h" 15 | 16 | namespace webrtc { 17 | 18 | // These tests merely check that the code compiles and that no 19 | // fatal accidents happen when logging. 20 | TEST(UnittestUtilities, TraceOn) { 21 | ScopedTracing trace(true); 22 | WEBRTC_TRACE(kTraceInfo, kTraceUtility, 0, "Log line that should appear"); 23 | // TODO(hta): Verify that output appears. 24 | // Note - output is written on another thread, so can take time to appear. 25 | } 26 | 27 | TEST(UnittestUtilities, TraceOff) { 28 | ScopedTracing trace(false); 29 | WEBRTC_TRACE(kTraceInfo, kTraceUtility, 0, 30 | "Log line that should not appear"); 31 | // TODO(hta): Verify that no output appears. 32 | } 33 | 34 | } // namespace webrtc 35 | -------------------------------------------------------------------------------- /server/Makefile: -------------------------------------------------------------------------------- 1 | OBJS = fde.o room.o server.o token.o 2 | CFLAGS = \ 3 | -Wall -Wno-sign-compare -g 4 | 5 | 6 | all: ${OBJS} 7 | g++ $(CFLAGS) rtc.cpp -o rtc.exe -I .. ../dist/lib/librtc-base.a voice/*.o ${OBJS} 8 | 9 | fde.o: fde.h fde.cpp 10 | g++ $(CFLAGS) -c fde.cpp -I .. 11 | room.o: room.h room.cpp 12 | g++ $(CFLAGS) -c room.cpp -I .. 13 | token.o: token.h token.cpp 14 | g++ $(CFLAGS) -c token.cpp -I .. 15 | server.o: server.h server.cpp 16 | g++ $(CFLAGS) -c server.cpp -I .. 17 | 18 | clean: 19 | rm -rf *.a *.o *.exe 20 | -------------------------------------------------------------------------------- /server/client.h: -------------------------------------------------------------------------------- 1 | #ifndef RTC_SERVER_CLIENT_H 2 | #define RTC_SERVER_CLIENT_H 3 | 4 | #include 5 | #include 6 | #include "base/udplink.h" 7 | 8 | class Address; 9 | class Room; 10 | 11 | class Client 12 | { 13 | public: 14 | int id; 15 | Address addr; 16 | UdpLink *link; 17 | Room *room; 18 | 19 | Client(){ 20 | reset(); 21 | } 22 | 23 | ~Client(){ 24 | } 25 | 26 | void reset(){ 27 | link = NULL; 28 | room = NULL; 29 | } 30 | }; 31 | 32 | 33 | class ClientSvc 34 | { 35 | private: 36 | std::list pool; 37 | std::map items; 38 | public: 39 | typedef std::map::iterator iterator; 40 | 41 | iterator begin(){ 42 | return items.begin(); 43 | } 44 | 45 | iterator end(){ 46 | return items.end(); 47 | } 48 | 49 | Client* get(int id){ 50 | std::map::iterator it = items.find(id); 51 | if(items.find(id) == items.end()){ 52 | return NULL; 53 | }else{ 54 | return it->second; 55 | } 56 | } 57 | 58 | Client* alloc(){ 59 | Client *t = NULL; 60 | if(pool.size() > 0){ 61 | t = pool.front(); 62 | pool.pop_front(); 63 | items[t->id] = t; 64 | }else{ 65 | t = new Client(); 66 | t->id = items.size(); 67 | items[t->id] = t; 68 | } 69 | t->reset(); 70 | return t; 71 | } 72 | 73 | void free(int id){ 74 | std::map::iterator it = items.find(id); 75 | if(it == items.end()){ 76 | return; 77 | }else{ 78 | pool.push_back(it->second); 79 | items.erase(it); 80 | } 81 | } 82 | }; 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /server/fde.cpp: -------------------------------------------------------------------------------- 1 | #include "fde.h" 2 | 3 | struct Fdevent* Fdevents::get_fde(int fd){ 4 | while((int)events.size() <= fd){ 5 | struct Fdevent *fde = new Fdevent(); 6 | fde->fd = events.size(); 7 | fde->s_flags = FDEVENT_NONE; 8 | fde->data.num = 0; 9 | fde->data.ptr = NULL; 10 | events.push_back(fde); 11 | } 12 | return events[fd]; 13 | } 14 | 15 | 16 | #ifdef HAVE_EPOLL 17 | #include "fde_epoll.cpp" 18 | #else 19 | #include "fde_select.cpp" 20 | #endif 21 | -------------------------------------------------------------------------------- /server/fde.h: -------------------------------------------------------------------------------- 1 | #ifndef UTIL_FDE_H 2 | #define UTIL_FDE_H 3 | 4 | #include 5 | 6 | #ifdef __linux__ 7 | #define HAVE_EPOLL 1 8 | #endif 9 | 10 | #define FDEVENT_NONE (0) 11 | #define FDEVENT_IN (1<<0) 12 | #define FDEVENT_PRI (1<<1) 13 | #define FDEVENT_OUT (1<<2) 14 | #define FDEVENT_HUP (1<<3) 15 | #define FDEVENT_ERR (1<<4) 16 | 17 | struct Fdevent{ 18 | int fd; 19 | int s_flags; // subscribed events 20 | int events; // ready events 21 | struct{ 22 | int num; 23 | void *ptr; 24 | }data; 25 | }; 26 | 27 | #ifdef HAVE_EPOLL 28 | #include 29 | #else 30 | #include 31 | #endif 32 | 33 | 34 | class Fdevents{ 35 | public: 36 | typedef std::vector events_t; 37 | private: 38 | #ifdef HAVE_EPOLL 39 | static const int MAX_FDS = 8 * 1024; 40 | int ep_fd; 41 | struct epoll_event ep_events[MAX_FDS]; 42 | #else 43 | int maxfd; 44 | fd_set readset; 45 | fd_set writeset; 46 | #endif 47 | events_t events; 48 | events_t ready_events; 49 | 50 | struct Fdevent *get_fde(int fd); 51 | public: 52 | Fdevents(); 53 | ~Fdevents(); 54 | 55 | bool isset(int fd, int flag); 56 | int set(int fd, int flags, int data_num, void *data_ptr); 57 | int del(int fd); 58 | int clr(int fd, int flags); 59 | const events_t* wait(int timeout_ms=-1); 60 | }; 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /server/include.h: -------------------------------------------------------------------------------- 1 | #ifndef SSDB_INCLUDE_H_ 2 | #define SSDB_INCLUDE_H_ 3 | 4 | #define __STDC_FORMAT_MACROS 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | 24 | static inline double millitime(){ 25 | struct timeval now; 26 | gettimeofday(&now, NULL); 27 | double ret = now.tv_sec + now.tv_usec/1000.0/1000.0; 28 | return ret; 29 | } 30 | 31 | 32 | 33 | #endif 34 | 35 | -------------------------------------------------------------------------------- /server/room.h: -------------------------------------------------------------------------------- 1 | #ifndef RTC_SERVER_ROOM_H 2 | #define RTC_SERVER_ROOM_H 3 | 4 | #include 5 | #include 6 | #include "base/net.h" 7 | #include "base/packet.h" 8 | #include "voice/mixer.h" 9 | #include "room.h" 10 | #include "client.h" 11 | 12 | class Room 13 | { 14 | private: 15 | std::map clients_; 16 | voice::Mixer mixer; 17 | int ticks; 18 | uint16_t data_seq_next; 19 | public: 20 | int id; 21 | 22 | Room(){ 23 | reset(); 24 | } 25 | 26 | void reset(){ 27 | ticks = 0; 28 | clients_.clear(); 29 | mixer.reset(); 30 | } 31 | 32 | void tick(); 33 | 34 | int join(Client *client); 35 | int quit(Client *client); 36 | 37 | int publish(Client *client, Packet *req); 38 | }; 39 | 40 | 41 | class RoomSvc 42 | { 43 | private: 44 | std::list pool; 45 | std::map items; 46 | public: 47 | typedef std::map::iterator iterator; 48 | 49 | iterator begin(){ 50 | return items.begin(); 51 | } 52 | 53 | iterator end(){ 54 | return items.end(); 55 | } 56 | 57 | Room* get(int id){ 58 | std::map::iterator it = items.find(id); 59 | if(items.find(id) == items.end()){ 60 | return NULL; 61 | }else{ 62 | return it->second; 63 | } 64 | } 65 | 66 | Room* alloc(){ 67 | Room *t = NULL; 68 | if(pool.size() > 0){ 69 | t = pool.front(); 70 | pool.pop_front(); 71 | items[t->id] = t; 72 | }else{ 73 | t = new Room(); 74 | t->id = items.size(); 75 | items[t->id] = t; 76 | } 77 | t->reset(); 78 | return t; 79 | } 80 | 81 | void free(int id){ 82 | std::map::iterator it = items.find(id); 83 | if(it == items.end()){ 84 | return; 85 | }else{ 86 | pool.push_back(it->second); 87 | items.erase(it); 88 | } 89 | } 90 | }; 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /server/server.h: -------------------------------------------------------------------------------- 1 | #ifndef RTC_SERVER_SERVER_H 2 | #define RTC_SERVER_SERVER_H 3 | 4 | #include "base/log.h" 5 | #include "fde.h" 6 | #include "room.h" 7 | #include "token.h" 8 | #include "client.h" 9 | 10 | class UdpLink; 11 | class Packet; 12 | class Address; 13 | 14 | /* 15 | Room types: 16 | Audio Conferencing 17 | Non-reliable Broacasting 18 | One-on-One Audio Chat 19 | Audio Broacasting 20 | Reliable Broacasting 21 | One-on-One Text Chat 22 | Group Text Chat 23 | */ 24 | 25 | class Server 26 | { 27 | public: 28 | RoomSvc rooms; 29 | ClientSvc clients; 30 | TokenSvc tokens; 31 | 32 | Server(); 33 | ~Server(); 34 | 35 | void tick(){ 36 | RoomSvc::iterator it; 37 | for(it=rooms.begin(); it!=rooms.end(); it++){ 38 | Room *room = it->second; 39 | room->tick(); 40 | } 41 | } 42 | 43 | UdpLink* proc_listen_link(UdpLink *listen_link, Fdevents *fdes); 44 | int proc_client_link(UdpLink *link, Fdevents *fdes); 45 | int proc_admin_listen_link(UdpLink *serv_link, Fdevents *fdes); 46 | int proc_admin_link(UdpLink *link, Fdevents *fdes); 47 | 48 | private: 49 | int proc_open(UdpLink *admin_link, Packet *req, Address *addr); 50 | int proc_sign(UdpLink *admin_link, Packet *req, Address *addr); 51 | int proc_close(UdpLink *link, Packet *req, Address *addr); 52 | Client* proc_join(UdpLink *serv_link, Packet *req, Address *addr); 53 | int proc_quit(UdpLink *link, Packet *req, Address *addr); 54 | int proc_pub(Client *client, Packet *req); 55 | }; 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /server/token.h: -------------------------------------------------------------------------------- 1 | #ifndef RTC_SERVER_TOKEN_H 2 | #define RTC_SERVER_TOKEN_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class TokenSvc 9 | { 10 | private: 11 | struct TokenItem 12 | { 13 | int room_id; 14 | uint32_t expired_at; 15 | }; 16 | uint32_t timer_ticks; 17 | uint32_t last_clean_ticks; 18 | std::map tokens; 19 | 20 | public: 21 | TokenSvc(); 22 | ~TokenSvc(); 23 | 24 | int tick(uint32_t timer_ticks); 25 | std::string create(int room_id, int ttl_sec); 26 | void erase(const std::string &token); 27 | int check_and_destroy(int room_id, const std::string &token); 28 | }; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /server/voice/Makefile: -------------------------------------------------------------------------------- 1 | include $(ROOT)/config.mk 2 | 3 | LOCAL_SRC_FILES = $(wildcard *.cpp) 4 | 5 | all: 6 | $(CC) -c $(LOCAL_SRC_FILES) $(CFLAGS) 7 | 8 | -------------------------------------------------------------------------------- /server/voice/channel.cpp: -------------------------------------------------------------------------------- 1 | #include "base/log.h" 2 | #include "channel.h" 3 | 4 | namespace voice{ 5 | 6 | Channel::Channel(){ 7 | id = 0; 8 | slow_start = 0; 9 | idle = 0; 10 | next_seq = 0; 11 | } 12 | 13 | Channel::~Channel(){ 14 | } 15 | 16 | int Channel::push_frame(const Frame &frame){ 17 | if(frames.size() > BUF_SIZE){ 18 | // maybe we should not drop these frames, we just force 19 | // the mixer to mix quicker 20 | while(frames.size() > BUF_SIZE){ 21 | frames.pop_front(); 22 | next_seq ++; 23 | } 24 | log_trace("buf exceed %d, drop, next_seq: %d", BUF_SIZE, next_seq); 25 | } 26 | frames.push_back(frame); 27 | return 1; 28 | } 29 | 30 | Frame* Channel::last_frame(){ 31 | return &this->out_frame; 32 | } 33 | 34 | const Frame* Channel::next_frame(){ 35 | if(slow_start < SLOW_START_TICKS){ 36 | log_trace("channel[%d] slow start %d", this->id, slow_start); 37 | slow_start ++; 38 | if(slow_start < SLOW_START_TICKS){ 39 | return NULL; 40 | } 41 | } 42 | 43 | while(frames.size() > 0){ 44 | out_frame = frames.front(); 45 | if(next_seq == 0 || out_frame.seq == next_seq){ 46 | frames.pop_front(); 47 | next_seq = out_frame.seq + 1; 48 | idle = 0; 49 | return &out_frame; 50 | }else if(out_frame.seq < next_seq){ 51 | // 丢弃乱序包 52 | frames.pop_front(); 53 | continue; 54 | }else if(out_frame.seq > next_seq){ 55 | // frame is lost 56 | // TODO: 57 | // simulate frame? 58 | next_seq ++; 59 | break; 60 | } 61 | } 62 | 63 | idle ++; 64 | out_frame.buf.clear(); 65 | return NULL; 66 | } 67 | 68 | }; // namespace 69 | -------------------------------------------------------------------------------- /server/voice/channel.h: -------------------------------------------------------------------------------- 1 | #ifndef RTC_AUDIO_CHANNEL_H 2 | #define RTC_AUDIO_CHANNEL_H 3 | 4 | #include 5 | #include "frame.h" 6 | #include "channel.h" 7 | 8 | namespace voice{ 9 | 10 | class Channel 11 | { 12 | private: 13 | const static int BUF_SIZE = 20; 14 | const static int SLOW_START_TICKS = BUF_SIZE/2; 15 | 16 | Frame out_frame; 17 | int slow_start; 18 | int idle; 19 | uint16_t next_seq; 20 | 21 | std::list frames; 22 | public: 23 | int id; 24 | 25 | Channel(); 26 | ~Channel(); 27 | 28 | bool ready(){ 29 | return slow_start >= SLOW_START_TICKS; 30 | } 31 | 32 | bool is_idle(){ 33 | return idle > BUF_SIZE; 34 | } 35 | 36 | int size(){ 37 | return frames.size(); 38 | } 39 | 40 | //Frame* simulate_lost_frame(int seq); 41 | 42 | Frame* last_frame(); 43 | const Frame* next_frame(); 44 | int push_frame(const Frame &frame); 45 | }; 46 | 47 | }; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /server/voice/include.h: -------------------------------------------------------------------------------- 1 | #include "../include.h" 2 | -------------------------------------------------------------------------------- /server/voice/mixer.h: -------------------------------------------------------------------------------- 1 | #ifndef RTC_AUDIO_MIXER_H 2 | #define RTC_AUDIO_MIXER_H 3 | 4 | #include 5 | #include "frame.h" 6 | #include "channel.h" 7 | 8 | namespace voice{ 9 | 10 | // ticks_per_frame 11 | class Mixer 12 | { 13 | private: 14 | Frame mixed_frame; 15 | std::map channels; 16 | std::vector mix_list; 17 | const static int BUF_SIZE = 3; 18 | public: 19 | void reset(){ 20 | std::map::iterator it; 21 | for(it = channels.begin(); it != channels.end(); it++){ 22 | Channel *channel = it->second; 23 | delete channel; 24 | } 25 | channels.clear(); 26 | } 27 | 28 | Channel* get_channel(int channel_id); 29 | void free_channel(int channel_id); 30 | int process_frame(int channel_id, const Frame &frame); 31 | 32 | // 当需要混声下一个frame时, 调用本方法. 33 | // 如果所有声道的下一个frame为空, 则返回NULL, 否则返回混声后的frame. 34 | Frame* mix(); 35 | 36 | // struct MixItem{channel, frame}; 37 | //std::vector *mixlist(); 38 | //Frame* mix_without_channel(channel_id); 39 | }; 40 | 41 | }; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /test/Makefile: -------------------------------------------------------------------------------- 1 | include $(ROOT)/config.mk 2 | 3 | all: 4 | $(CC) av.cpp -o av.exe \ 5 | $(CFLAGS) \ 6 | -I $(DIST_INC_DIR) \ 7 | -framework ApplicationServices -framework AudioToolbox -framework CoreAudio \ 8 | $(DIST_LIB_DIR)/librtc-base.a $(DIST_LIB_DIR)/librtc-multimedia.a 9 | 10 | $(CC) music_player.cpp -o music_player.exe \ 11 | -I .. \ 12 | -I ../deps/sfml-2.0/include \ 13 | -I ../deps/opus-1.0.3/include \ 14 | -L ../deps/sfml-2.0 -lsfml-audio -lsfml-system \ 15 | ../deps/opus-1.0.3/.libs/libopus.a \ 16 | $(DIST_LIB_DIR)/librtc-base.a 17 | 18 | export DYLD_LIBRARY_PATH="./deps/sfml-2.0:./deps/sndfile.framework/Versions/A" 19 | export DYLD_LIBRARY_PATH="../deps/sfml-2.0:../deps/sndfile.framework/Versions/A" 20 | 21 | -------------------------------------------------------------------------------- /test/av.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include "base/log.h" 14 | #include "base/net.h" 15 | #include "base/packet.h" 16 | #include "base/udplink.h" 17 | #include "voice_client.h" 18 | 19 | int main(int argc, char **argv){ 20 | int ret; 21 | 22 | rtc::VoiceClient *client = rtc::VoiceClient::create(); 23 | ret = client->init(); 24 | assert(ret == 0); 25 | ret = client->connect("127.0.0.1", 10210); 26 | assert(ret == 0); 27 | ret = client->join_room(0, "token"); 28 | assert(ret == 0); 29 | 30 | ret = client->start_send(); 31 | assert(ret == 0); 32 | ret = client->start_recv(); 33 | assert(ret == 0); 34 | 35 | client->run(); 36 | 37 | //sleep(2); 38 | //getchar(); 39 | return 0; 40 | } 41 | 42 | -------------------------------------------------------------------------------- /test/common.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | #include "base/log.h" 16 | #include "base/net.h" 17 | #include "base/packet.h" 18 | #include "base/udplink.h" 19 | 20 | 21 | UdpLink* link_connect(std::string host, int port){ 22 | int ret; 23 | UdpLink *link; 24 | link = UdpLink::client(host, port); 25 | 26 | Packet req; 27 | req.set_type(Packet::JOIN); 28 | req.set_seq(101); 29 | req.set_params("0", "token"); 30 | 31 | ret = link->send(req); 32 | log_debug("send %d bytes", ret); 33 | if(ret <= 0){ 34 | exit(0); 35 | } 36 | 37 | Packet resp; 38 | ret = link->recv(&resp); 39 | log_debug("recv %d bytes", ret); 40 | if(ret > 0){ 41 | log_debug("recv: %s", resp.repr().c_str()); 42 | }else{ 43 | exit(0); 44 | } 45 | 46 | int bufsize = 5000; 47 | ::setsockopt(link->fd(), SOL_SOCKET, SO_SNDBUF, &bufsize, sizeof(bufsize)); 48 | ::setsockopt(link->fd(), SOL_SOCKET, SO_RCVBUF, &bufsize, sizeof(bufsize)); 49 | return link; 50 | } 51 | --------------------------------------------------------------------------------