pbos@webrtc.org | 289a35c | 2014-06-03 14:51:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | * libjingle |
| 3 | * Copyright 2014 Google Inc. |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions are met: |
| 7 | * |
| 8 | * 1. Redistributions of source code must retain the above copyright notice, |
| 9 | * this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
| 11 | * this list of conditions and the following disclaimer in the documentation |
| 12 | * and/or other materials provided with the distribution. |
| 13 | * 3. The name of the author may not be used to endorse or promote products |
| 14 | * derived from this software without specific prior written permission. |
| 15 | * |
| 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
| 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
| 19 | * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 20 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 21 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
| 22 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 23 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| 24 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| 25 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 | */ |
| 27 | |
buildbot@webrtc.org | 95bbd18 | 2014-08-20 07:49:30 +0000 | [diff] [blame^] | 28 | #if defined(LIBPEERCONNECTION_LIB) || \ |
| 29 | defined(LIBPEERCONNECTION_IMPLEMENTATION) |
| 30 | |
pbos@webrtc.org | 9e65a3b | 2014-06-11 13:42:37 +0000 | [diff] [blame] | 31 | #include "talk/media/webrtc/webrtcmediaengine.h" |
henrike@webrtc.org | 0481f15 | 2014-08-19 14:56:59 +0000 | [diff] [blame] | 32 | #include "talk/media/webrtc/webrtcvideoengine.h" |
| 33 | #ifdef WEBRTC_CHROMIUM_BUILD |
| 34 | #include "talk/media/webrtc/webrtcvideoengine2.h" |
| 35 | #endif |
| 36 | #include "talk/media/webrtc/webrtcvoiceengine.h" |
| 37 | #ifdef WEBRTC_CHROMIUM_BUILD |
pbos@webrtc.org | 9e65a3b | 2014-06-11 13:42:37 +0000 | [diff] [blame] | 38 | #include "webrtc/system_wrappers/interface/field_trial.h" |
henrike@webrtc.org | 0481f15 | 2014-08-19 14:56:59 +0000 | [diff] [blame] | 39 | #endif |
| 40 | |
| 41 | namespace cricket { |
| 42 | |
| 43 | class WebRtcMediaEngine : |
| 44 | public CompositeMediaEngine<WebRtcVoiceEngine, WebRtcVideoEngine> { |
| 45 | public: |
| 46 | WebRtcMediaEngine() {} |
| 47 | WebRtcMediaEngine(webrtc::AudioDeviceModule* adm, |
| 48 | webrtc::AudioDeviceModule* adm_sc, |
| 49 | WebRtcVideoEncoderFactory* encoder_factory, |
| 50 | WebRtcVideoDecoderFactory* decoder_factory) { |
| 51 | voice_.SetAudioDeviceModule(adm, adm_sc); |
| 52 | video_.SetVoiceEngine(&voice_); |
| 53 | video_.EnableTimedRender(); |
| 54 | video_.SetExternalEncoderFactory(encoder_factory); |
| 55 | video_.SetExternalDecoderFactory(decoder_factory); |
| 56 | } |
| 57 | }; |
| 58 | |
| 59 | #ifdef WEBRTC_CHROMIUM_BUILD |
| 60 | class WebRtcMediaEngine2 : |
| 61 | public CompositeMediaEngine<WebRtcVoiceEngine, WebRtcVideoEngine2> { |
| 62 | public: |
| 63 | WebRtcMediaEngine2(webrtc::AudioDeviceModule* adm, |
| 64 | webrtc::AudioDeviceModule* adm_sc, |
| 65 | WebRtcVideoEncoderFactory* encoder_factory, |
| 66 | WebRtcVideoDecoderFactory* decoder_factory) { |
| 67 | voice_.SetAudioDeviceModule(adm, adm_sc); |
| 68 | video_.SetVoiceEngine(&voice_); |
| 69 | video_.EnableTimedRender(); |
| 70 | } |
| 71 | }; |
| 72 | #endif // WEBRTC_CHROMIUM_BUILD |
| 73 | |
| 74 | } // namespace cricket |
pbos@webrtc.org | 9e65a3b | 2014-06-11 13:42:37 +0000 | [diff] [blame] | 75 | |
| 76 | WRME_EXPORT |
| 77 | cricket::MediaEngineInterface* CreateWebRtcMediaEngine( |
| 78 | webrtc::AudioDeviceModule* adm, |
| 79 | webrtc::AudioDeviceModule* adm_sc, |
| 80 | cricket::WebRtcVideoEncoderFactory* encoder_factory, |
| 81 | cricket::WebRtcVideoDecoderFactory* decoder_factory) { |
| 82 | #ifdef WEBRTC_CHROMIUM_BUILD |
| 83 | if (webrtc::field_trial::FindFullName("WebRTC-NewVideoAPI") == "Enabled") { |
| 84 | return new cricket::WebRtcMediaEngine2( |
| 85 | adm, adm_sc, encoder_factory, decoder_factory); |
| 86 | } |
| 87 | #endif // WEBRTC_CHROMIUM_BUILD |
henrike@webrtc.org | 0481f15 | 2014-08-19 14:56:59 +0000 | [diff] [blame] | 88 | // This is just to get a diff to run pulse. |
pbos@webrtc.org | 9e65a3b | 2014-06-11 13:42:37 +0000 | [diff] [blame] | 89 | return new cricket::WebRtcMediaEngine( |
| 90 | adm, adm_sc, encoder_factory, decoder_factory); |
| 91 | } |
| 92 | |
| 93 | WRME_EXPORT |
| 94 | void DestroyWebRtcMediaEngine(cricket::MediaEngineInterface* media_engine) { |
henrike@webrtc.org | 0481f15 | 2014-08-19 14:56:59 +0000 | [diff] [blame] | 95 | delete media_engine; |
pbos@webrtc.org | 9e65a3b | 2014-06-11 13:42:37 +0000 | [diff] [blame] | 96 | } |
henrike@webrtc.org | 0481f15 | 2014-08-19 14:56:59 +0000 | [diff] [blame] | 97 | |
| 98 | namespace cricket { |
| 99 | |
henrike@webrtc.org | 0481f15 | 2014-08-19 14:56:59 +0000 | [diff] [blame] | 100 | // Used by ChannelManager when no media engine is passed in to it |
| 101 | // explicitly (acts as a default). |
| 102 | MediaEngineInterface* WebRtcMediaEngineFactory::Create() { |
| 103 | return new cricket::WebRtcMediaEngine(); |
| 104 | } |
| 105 | |
buildbot@webrtc.org | 95bbd18 | 2014-08-20 07:49:30 +0000 | [diff] [blame^] | 106 | // Used by PeerConnectionFactory to create a media engine passed into |
| 107 | // ChannelManager. |
henrike@webrtc.org | 0481f15 | 2014-08-19 14:56:59 +0000 | [diff] [blame] | 108 | MediaEngineInterface* WebRtcMediaEngineFactory::Create( |
| 109 | webrtc::AudioDeviceModule* adm, |
| 110 | webrtc::AudioDeviceModule* adm_sc, |
| 111 | WebRtcVideoEncoderFactory* encoder_factory, |
| 112 | WebRtcVideoDecoderFactory* decoder_factory) { |
henrike@webrtc.org | 0481f15 | 2014-08-19 14:56:59 +0000 | [diff] [blame] | 113 | return CreateWebRtcMediaEngine(adm, adm_sc, encoder_factory, decoder_factory); |
henrike@webrtc.org | 0481f15 | 2014-08-19 14:56:59 +0000 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | } // namespace cricket |
buildbot@webrtc.org | 95bbd18 | 2014-08-20 07:49:30 +0000 | [diff] [blame^] | 117 | |
| 118 | #endif // defined(LIBPEERCONNECTION_LIB) || |
| 119 | // defined(LIBPEERCONNECTION_IMPLEMENTATION) |