audio_webrtc_transport.cxx 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /* Copyright (C) 2012 Doubango Telecom <http://www.doubango.org>
  2. *
  3. * This file is part of Open Source Doubango Framework.
  4. *
  5. * DOUBANGO is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * DOUBANGO is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with DOUBANGO.
  17. */
  18. #include "audio_webrtc_transport.h"
  19. #include "audio_webrtc_producer.h"
  20. #include "audio_webrtc_consumer.h"
  21. #include "tsk_debug.h"
  22. using namespace webrtc;
  23. AudioTransportImpl::AudioTransportImpl(AudioDeviceModule* audioDevice) :
  24. _audioDevice(audioDevice),
  25. _fullDuplex(false),
  26. _speakerVolume(false),
  27. _speakerMute(false),
  28. _microphoneVolume(false),
  29. _microphoneMute(false),
  30. _microphoneBoost(false),
  31. _microphoneAGC(false),
  32. _loopBackMeasurements(false),
  33. _consumer(tsk_null),
  34. _producer(tsk_null)
  35. {
  36. }
  37. AudioTransportImpl::~AudioTransportImpl()
  38. {
  39. }
  40. void AudioTransportImpl::SetFullDuplex(bool enable)
  41. {
  42. _fullDuplex = enable;
  43. }
  44. WebRtc_Word32 AudioTransportImpl::RecordedDataIsAvailable(
  45. const void* audioSamples,
  46. const WebRtc_UWord32 nSamples,
  47. const WebRtc_UWord8 nBytesPerSample,
  48. const WebRtc_UWord8 nChannels,
  49. const WebRtc_UWord32 samplesPerSec,
  50. const WebRtc_UWord32 totalDelayMS,
  51. const WebRtc_Word32 clockDrift,
  52. const WebRtc_UWord32 currentMicLevel,
  53. WebRtc_UWord32& newMicLevel)
  54. {
  55. if(!_producer) {
  56. DOUBANGO_AUDIO_WEBRTC_DEBUG_ERROR("No wrapped producer");
  57. return 0;
  58. }
  59. return audio_producer_webrtc_handle_data_10ms(_producer, audioSamples, nSamples, nBytesPerSample, samplesPerSec, nChannels);
  60. }
  61. WebRtc_Word32 AudioTransportImpl::NeedMorePlayData(
  62. const WebRtc_UWord32 nSamples,
  63. const WebRtc_UWord8 nBytesPerSample,
  64. const WebRtc_UWord8 nChannels,
  65. const WebRtc_UWord32 samplesPerSec,
  66. void* audioSamples,
  67. WebRtc_UWord32& nSamplesOut)
  68. {
  69. if(!_consumer) {
  70. DOUBANGO_AUDIO_WEBRTC_DEBUG_ERROR("No wrapped consumer");
  71. return 0;
  72. }
  73. return audio_consumer_webrtc_get_data_10ms(_consumer, audioSamples, nSamples, nBytesPerSample, nChannels, samplesPerSec, nSamplesOut);
  74. }