blob: cf6a5cf2e59689fbaf877fcf7d69ab41eba78ef3 [file] [log] [blame]
pbos@webrtc.org289a35c2014-06-03 14:51:34 +00001/*
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
pbos@webrtc.org9e65a3b2014-06-11 13:42:37 +000028#include "talk/media/webrtc/webrtcmediaengine.h"
henrike@webrtc.org0481f152014-08-19 14:56:59 +000029#include "talk/media/webrtc/webrtcvideoengine2.h"
henrike@webrtc.org0481f152014-08-19 14:56:59 +000030#include "talk/media/webrtc/webrtcvoiceengine.h"
henrike@webrtc.org0481f152014-08-19 14:56:59 +000031
32namespace cricket {
33
pbos@webrtc.orge77c9c82015-03-11 10:49:33 +000034class WebRtcMediaEngine2
35 : public CompositeMediaEngine<WebRtcVoiceEngine, WebRtcVideoEngine2> {
henrike@webrtc.org0481f152014-08-19 14:56:59 +000036 public:
37 WebRtcMediaEngine2(webrtc::AudioDeviceModule* adm,
henrike@webrtc.org0481f152014-08-19 14:56:59 +000038 WebRtcVideoEncoderFactory* encoder_factory,
39 WebRtcVideoDecoderFactory* decoder_factory) {
Fredrik Solenbergccb49e72015-05-19 11:37:56 +020040 voice_.SetAudioDeviceModule(adm);
pbos@webrtc.org0a2087a2014-09-23 09:40:22 +000041 video_.SetExternalDecoderFactory(decoder_factory);
42 video_.SetExternalEncoderFactory(encoder_factory);
henrike@webrtc.org0481f152014-08-19 14:56:59 +000043 }
44};
henrike@webrtc.org0481f152014-08-19 14:56:59 +000045
46} // namespace cricket
pbos@webrtc.org9e65a3b2014-06-11 13:42:37 +000047
pbos@webrtc.org9e65a3b2014-06-11 13:42:37 +000048cricket::MediaEngineInterface* CreateWebRtcMediaEngine(
49 webrtc::AudioDeviceModule* adm,
pbos@webrtc.org9e65a3b2014-06-11 13:42:37 +000050 cricket::WebRtcVideoEncoderFactory* encoder_factory,
51 cricket::WebRtcVideoDecoderFactory* decoder_factory) {
Fredrik Solenbergccb49e72015-05-19 11:37:56 +020052 return new cricket::WebRtcMediaEngine2(adm, encoder_factory,
tommi@webrtc.orgb789f622015-03-22 12:50:30 +000053 decoder_factory);
pbos@webrtc.org9e65a3b2014-06-11 13:42:37 +000054}
55
pbos@webrtc.org9e65a3b2014-06-11 13:42:37 +000056void DestroyWebRtcMediaEngine(cricket::MediaEngineInterface* media_engine) {
henrike@webrtc.org0481f152014-08-19 14:56:59 +000057 delete media_engine;
pbos@webrtc.org9e65a3b2014-06-11 13:42:37 +000058}
henrike@webrtc.org0481f152014-08-19 14:56:59 +000059
60namespace cricket {
61
buildbot@webrtc.org95bbd182014-08-20 07:49:30 +000062// Used by PeerConnectionFactory to create a media engine passed into
63// ChannelManager.
henrike@webrtc.org0481f152014-08-19 14:56:59 +000064MediaEngineInterface* WebRtcMediaEngineFactory::Create(
65 webrtc::AudioDeviceModule* adm,
henrike@webrtc.org0481f152014-08-19 14:56:59 +000066 WebRtcVideoEncoderFactory* encoder_factory,
67 WebRtcVideoDecoderFactory* decoder_factory) {
Fredrik Solenbergccb49e72015-05-19 11:37:56 +020068 return CreateWebRtcMediaEngine(adm, encoder_factory, decoder_factory);
henrike@webrtc.org0481f152014-08-19 14:56:59 +000069}
70
71} // namespace cricket