blob: efca26c08b725c580150fefe395c0531a4e71e52 [file] [log] [blame]
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001/*
2 * libjingle
3 * Copyright 2011 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
28#ifndef TALK_MEDIA_WEBRTCMEDIAENGINE_H_
29#define TALK_MEDIA_WEBRTCMEDIAENGINE_H_
30
31#include "talk/media/base/mediaengine.h"
32#include "talk/media/webrtc/webrtcexport.h"
33
34namespace webrtc {
35class AudioDeviceModule;
36class VideoCaptureModule;
37}
38namespace cricket {
39class WebRtcVideoDecoderFactory;
40class WebRtcVideoEncoderFactory;
41}
42
henrike@webrtc.org28e20752013-07-10 00:45:36 +000043#if !defined(LIBPEERCONNECTION_LIB) && \
44 !defined(LIBPEERCONNECTION_IMPLEMENTATION)
45
46WRME_EXPORT
47cricket::MediaEngineInterface* CreateWebRtcMediaEngine(
48 webrtc::AudioDeviceModule* adm, webrtc::AudioDeviceModule* adm_sc,
49 cricket::WebRtcVideoEncoderFactory* encoder_factory,
50 cricket::WebRtcVideoDecoderFactory* decoder_factory);
51
52WRME_EXPORT
53void DestroyWebRtcMediaEngine(cricket::MediaEngineInterface* media_engine);
54
henrike@webrtc.org0481f152014-08-19 14:56:59 +000055#endif // !defined(LIBPEERCONNECTION_LIB) &&
56 // !defined(LIBPEERCONNECTION_IMPLEMENTATION)
57
buildbot@webrtc.org58e7c862014-06-20 00:26:50 +000058namespace cricket {
59
henrike@webrtc.org0481f152014-08-19 14:56:59 +000060class WebRtcMediaEngineFactory {
buildbot@webrtc.org58e7c862014-06-20 00:26:50 +000061 public:
henrike@webrtc.org0481f152014-08-19 14:56:59 +000062 static MediaEngineInterface* Create();
63 static MediaEngineInterface* Create(
buildbot@webrtc.org58e7c862014-06-20 00:26:50 +000064 webrtc::AudioDeviceModule* adm,
65 webrtc::AudioDeviceModule* adm_sc,
buildbot@webrtc.orgbb2d6582014-06-20 14:58:56 +000066 cricket::WebRtcVideoEncoderFactory* encoder_factory,
67 cricket::WebRtcVideoDecoderFactory* decoder_factory)
68 : delegate_(CreateWebRtcMediaEngine(
69 adm, adm_sc, encoder_factory, decoder_factory)) {
70 }
71 virtual ~WebRtcMediaEngine() {
72 DestroyWebRtcMediaEngine(delegate_);
73 }
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000074 virtual bool Init(rtc::Thread* worker_thread) OVERRIDE {
buildbot@webrtc.orgbb2d6582014-06-20 14:58:56 +000075 return delegate_->Init(worker_thread);
76 }
77 virtual void Terminate() OVERRIDE {
78 delegate_->Terminate();
79 }
80 virtual int GetCapabilities() OVERRIDE {
81 return delegate_->GetCapabilities();
82 }
83 virtual VoiceMediaChannel* CreateChannel() OVERRIDE {
84 return delegate_->CreateChannel();
85 }
86 virtual VideoMediaChannel* CreateVideoChannel(
87 VoiceMediaChannel* voice_media_channel) OVERRIDE {
88 return delegate_->CreateVideoChannel(voice_media_channel);
89 }
90 virtual SoundclipMedia* CreateSoundclip() OVERRIDE {
91 return delegate_->CreateSoundclip();
92 }
93 virtual AudioOptions GetAudioOptions() const OVERRIDE {
94 return delegate_->GetAudioOptions();
95 }
96 virtual bool SetAudioOptions(const AudioOptions& options) OVERRIDE {
97 return delegate_->SetAudioOptions(options);
98 }
99 virtual bool SetVideoOptions(const VideoOptions& options) OVERRIDE {
100 return delegate_->SetVideoOptions(options);
101 }
102 virtual bool SetAudioDelayOffset(int offset) OVERRIDE {
103 return delegate_->SetAudioDelayOffset(offset);
104 }
105 virtual bool SetDefaultVideoEncoderConfig(
106 const VideoEncoderConfig& config) OVERRIDE {
107 return delegate_->SetDefaultVideoEncoderConfig(config);
108 }
109 virtual VideoEncoderConfig GetDefaultVideoEncoderConfig() const OVERRIDE {
110 return delegate_->GetDefaultVideoEncoderConfig();
111 }
112 virtual bool SetSoundDevices(
113 const Device* in_device, const Device* out_device) OVERRIDE {
114 return delegate_->SetSoundDevices(in_device, out_device);
115 }
116 virtual bool GetOutputVolume(int* level) OVERRIDE {
117 return delegate_->GetOutputVolume(level);
118 }
119 virtual bool SetOutputVolume(int level) OVERRIDE {
120 return delegate_->SetOutputVolume(level);
121 }
122 virtual int GetInputLevel() OVERRIDE {
123 return delegate_->GetInputLevel();
124 }
125 virtual bool SetLocalMonitor(bool enable) OVERRIDE {
126 return delegate_->SetLocalMonitor(enable);
127 }
128 virtual bool SetLocalRenderer(VideoRenderer* renderer) OVERRIDE {
129 return delegate_->SetLocalRenderer(renderer);
130 }
131 virtual const std::vector<AudioCodec>& audio_codecs() OVERRIDE {
132 return delegate_->audio_codecs();
133 }
134 virtual const std::vector<RtpHeaderExtension>&
135 audio_rtp_header_extensions() OVERRIDE {
136 return delegate_->audio_rtp_header_extensions();
137 }
138 virtual const std::vector<VideoCodec>& video_codecs() OVERRIDE {
139 return delegate_->video_codecs();
140 }
141 virtual const std::vector<RtpHeaderExtension>&
142 video_rtp_header_extensions() OVERRIDE {
143 return delegate_->video_rtp_header_extensions();
144 }
145 virtual void SetVoiceLogging(int min_sev, const char* filter) OVERRIDE {
146 delegate_->SetVoiceLogging(min_sev, filter);
147 }
148 virtual void SetVideoLogging(int min_sev, const char* filter) OVERRIDE {
149 delegate_->SetVideoLogging(min_sev, filter);
150 }
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000151 virtual bool StartAecDump(rtc::PlatformFile file) OVERRIDE {
buildbot@webrtc.orgbb2d6582014-06-20 14:58:56 +0000152 return delegate_->StartAecDump(file);
153 }
154 virtual bool RegisterVoiceProcessor(
155 uint32 ssrc, VoiceProcessor* video_processor,
156 MediaProcessorDirection direction) OVERRIDE {
157 return delegate_->RegisterVoiceProcessor(ssrc, video_processor, direction);
158 }
159 virtual bool UnregisterVoiceProcessor(
160 uint32 ssrc, VoiceProcessor* video_processor,
161 MediaProcessorDirection direction) OVERRIDE {
162 return delegate_->UnregisterVoiceProcessor(ssrc, video_processor,
163 direction);
164 }
165 virtual VideoFormat GetStartCaptureFormat() const OVERRIDE {
166 return delegate_->GetStartCaptureFormat();
167 }
168 virtual sigslot::repeater2<VideoCapturer*, CaptureState>&
169 SignalVideoCaptureStateChange() {
170 return delegate_->SignalVideoCaptureStateChange();
171 }
172
173 private:
174 cricket::MediaEngineInterface* delegate_;
buildbot@webrtc.org58e7c862014-06-20 00:26:50 +0000175};
176
177} // namespace cricket
buildbot@webrtc.orgbb2d6582014-06-20 14:58:56 +0000178#else
179
180#include "talk/media/webrtc/webrtcvideoengine.h"
181#ifdef WEBRTC_CHROMIUM_BUILD
182#include "talk/media/webrtc/webrtcvideoengine2.h"
183#endif
184#include "talk/media/webrtc/webrtcvoiceengine.h"
185
186namespace cricket {
187typedef CompositeMediaEngine<WebRtcVoiceEngine, WebRtcVideoEngine>
188 WebRtcCompositeMediaEngine;
189
190class WebRtcMediaEngine : public WebRtcCompositeMediaEngine {
191 public:
192 WebRtcMediaEngine(webrtc::AudioDeviceModule* adm,
193 webrtc::AudioDeviceModule* adm_sc,
194 WebRtcVideoEncoderFactory* encoder_factory,
henrike@webrtc.org0481f152014-08-19 14:56:59 +0000195 WebRtcVideoDecoderFactory* decoder_factory);
buildbot@webrtc.orgbb2d6582014-06-20 14:58:56 +0000196};
197
buildbot@webrtc.orgbb2d6582014-06-20 14:58:56 +0000198} // namespace cricket
199
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000200#endif // TALK_MEDIA_WEBRTCMEDIAENGINE_H_