blob: a2ee6587610b973d1cf7c78740d962c626a79fce [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
43
44#if !defined(LIBPEERCONNECTION_LIB) && \
45 !defined(LIBPEERCONNECTION_IMPLEMENTATION)
46
47WRME_EXPORT
48cricket::MediaEngineInterface* CreateWebRtcMediaEngine(
49 webrtc::AudioDeviceModule* adm, webrtc::AudioDeviceModule* adm_sc,
50 cricket::WebRtcVideoEncoderFactory* encoder_factory,
51 cricket::WebRtcVideoDecoderFactory* decoder_factory);
52
53WRME_EXPORT
54void DestroyWebRtcMediaEngine(cricket::MediaEngineInterface* media_engine);
55
56namespace cricket {
57
58class WebRtcMediaEngine : public cricket::MediaEngineInterface {
59 public:
60 WebRtcMediaEngine(
61 webrtc::AudioDeviceModule* adm,
62 webrtc::AudioDeviceModule* adm_sc,
63 cricket::WebRtcVideoEncoderFactory* encoder_factory,
64 cricket::WebRtcVideoDecoderFactory* decoder_factory)
65 : delegate_(CreateWebRtcMediaEngine(
66 adm, adm_sc, encoder_factory, decoder_factory)) {
67 }
68 virtual ~WebRtcMediaEngine() {
69 DestroyWebRtcMediaEngine(delegate_);
70 }
71 virtual bool Init(talk_base::Thread* worker_thread) OVERRIDE {
72 return delegate_->Init(worker_thread);
73 }
74 virtual void Terminate() OVERRIDE {
75 delegate_->Terminate();
76 }
77 virtual int GetCapabilities() OVERRIDE {
78 return delegate_->GetCapabilities();
79 }
80 virtual VoiceMediaChannel* CreateChannel() OVERRIDE {
81 return delegate_->CreateChannel();
82 }
83 virtual VideoMediaChannel* CreateVideoChannel(
84 VoiceMediaChannel* voice_media_channel) OVERRIDE {
85 return delegate_->CreateVideoChannel(voice_media_channel);
86 }
87 virtual SoundclipMedia* CreateSoundclip() OVERRIDE {
88 return delegate_->CreateSoundclip();
89 }
90 virtual bool SetAudioOptions(int options) OVERRIDE {
91 return delegate_->SetAudioOptions(options);
92 }
93 virtual bool SetVideoOptions(int options) OVERRIDE {
94 return delegate_->SetVideoOptions(options);
95 }
96 virtual bool SetAudioDelayOffset(int offset) OVERRIDE {
97 return delegate_->SetAudioDelayOffset(offset);
98 }
99 virtual bool SetDefaultVideoEncoderConfig(
100 const VideoEncoderConfig& config) OVERRIDE {
101 return delegate_->SetDefaultVideoEncoderConfig(config);
102 }
103 virtual bool SetSoundDevices(
104 const Device* in_device, const Device* out_device) OVERRIDE {
105 return delegate_->SetSoundDevices(in_device, out_device);
106 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000107 virtual bool GetOutputVolume(int* level) OVERRIDE {
108 return delegate_->GetOutputVolume(level);
109 }
110 virtual bool SetOutputVolume(int level) OVERRIDE {
111 return delegate_->SetOutputVolume(level);
112 }
113 virtual int GetInputLevel() OVERRIDE {
114 return delegate_->GetInputLevel();
115 }
116 virtual bool SetLocalMonitor(bool enable) OVERRIDE {
117 return delegate_->SetLocalMonitor(enable);
118 }
119 virtual bool SetLocalRenderer(VideoRenderer* renderer) OVERRIDE {
120 return delegate_->SetLocalRenderer(renderer);
121 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000122 virtual const std::vector<AudioCodec>& audio_codecs() OVERRIDE {
123 return delegate_->audio_codecs();
124 }
125 virtual const std::vector<RtpHeaderExtension>&
126 audio_rtp_header_extensions() OVERRIDE {
127 return delegate_->audio_rtp_header_extensions();
128 }
129 virtual const std::vector<VideoCodec>& video_codecs() OVERRIDE {
130 return delegate_->video_codecs();
131 }
132 virtual const std::vector<RtpHeaderExtension>&
133 video_rtp_header_extensions() OVERRIDE {
134 return delegate_->video_rtp_header_extensions();
135 }
136 virtual void SetVoiceLogging(int min_sev, const char* filter) OVERRIDE {
137 delegate_->SetVoiceLogging(min_sev, filter);
138 }
139 virtual void SetVideoLogging(int min_sev, const char* filter) OVERRIDE {
140 delegate_->SetVideoLogging(min_sev, filter);
141 }
142 virtual bool RegisterVoiceProcessor(
143 uint32 ssrc, VoiceProcessor* video_processor,
144 MediaProcessorDirection direction) OVERRIDE {
145 return delegate_->RegisterVoiceProcessor(ssrc, video_processor, direction);
146 }
147 virtual bool UnregisterVoiceProcessor(
148 uint32 ssrc, VoiceProcessor* video_processor,
149 MediaProcessorDirection direction) OVERRIDE {
150 return delegate_->UnregisterVoiceProcessor(ssrc, video_processor,
151 direction);
152 }
153 virtual VideoFormat GetStartCaptureFormat() const OVERRIDE {
154 return delegate_->GetStartCaptureFormat();
155 }
156 virtual sigslot::repeater2<VideoCapturer*, CaptureState>&
157 SignalVideoCaptureStateChange() {
158 return delegate_->SignalVideoCaptureStateChange();
159 }
160
161 private:
162 cricket::MediaEngineInterface* delegate_;
163};
164
165} // namespace cricket
166#else
167
168#include "talk/media/webrtc/webrtcvideoengine.h"
169#include "talk/media/webrtc/webrtcvoiceengine.h"
170
171namespace cricket {
172typedef CompositeMediaEngine<WebRtcVoiceEngine, WebRtcVideoEngine>
173 WebRtcCompositeMediaEngine;
174
175class WebRtcMediaEngine : public WebRtcCompositeMediaEngine {
176 public:
177 WebRtcMediaEngine(webrtc::AudioDeviceModule* adm,
178 webrtc::AudioDeviceModule* adm_sc,
179 WebRtcVideoEncoderFactory* encoder_factory,
180 WebRtcVideoDecoderFactory* decoder_factory) {
181 voice_.SetAudioDeviceModule(adm, adm_sc);
182 video_.SetVoiceEngine(&voice_);
183 video_.EnableTimedRender();
184 video_.SetExternalEncoderFactory(encoder_factory);
185 video_.SetExternalDecoderFactory(decoder_factory);
186 }
187};
188
189} // namespace cricket
190
191#endif // !defined(LIBPEERCONNECTION_LIB) &&
192 // !defined(LIBPEERCONNECTION_IMPLEMENTATION)
193
194#endif // TALK_MEDIA_WEBRTCMEDIAENGINE_H_