Move the WebRtcDeviceManager and WebRtcMediaEngine to libjingle.
Review URL: http://webrtc-codereview.appspot.com/139009 git-svn-id: http://webrtc.googlecode.com/svn/trunk@515 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
4d905f88c6
commit
5a15ab9e36
@ -563,6 +563,10 @@
|
||||
'<(libjingle_mods)/source/talk/app/webrtc/peerconnection_impl.h',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc/peerconnection_proxy.cc',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc/peerconnection_proxy.h',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc/webrtcdevicemanager.cc',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc/webrtcdevicemanager.h',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc/webrtcmediaengine.cc',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc/webrtcmediaengine.h',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc/webrtcsession.cc',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc/webrtcsession.h',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc/webrtc_json.cc',
|
||||
|
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* libjingle
|
||||
* Copyright 2011, Google Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "talk/app/webrtc/webrtcdevicemanager.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
using cricket::Device;
|
||||
using cricket::DeviceManager;
|
||||
|
||||
const int WebRtcDeviceManager::kDefaultDeviceId = -1;
|
||||
|
||||
WebRtcDeviceManager::WebRtcDeviceManager()
|
||||
: DeviceManager(),
|
||||
default_device_(DeviceManager::kDefaultDeviceName, kDefaultDeviceId) {
|
||||
}
|
||||
|
||||
WebRtcDeviceManager::~WebRtcDeviceManager() {
|
||||
Terminate();
|
||||
}
|
||||
|
||||
bool WebRtcDeviceManager::Init() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void WebRtcDeviceManager::Terminate() {
|
||||
}
|
||||
|
||||
bool WebRtcDeviceManager::GetAudioInputDevices(
|
||||
std::vector<Device>* devs) {
|
||||
return GetDefaultDevices(devs);
|
||||
}
|
||||
|
||||
bool WebRtcDeviceManager::GetAudioOutputDevices(
|
||||
std::vector<Device>* devs) {
|
||||
return GetDefaultDevices(devs);
|
||||
}
|
||||
|
||||
bool WebRtcDeviceManager::GetVideoCaptureDevices(
|
||||
std::vector<Device>* devs) {
|
||||
return GetDefaultDevices(devs);
|
||||
}
|
||||
|
||||
bool WebRtcDeviceManager::GetDefaultVideoCaptureDevice(
|
||||
Device* device) {
|
||||
*device = default_device_;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WebRtcDeviceManager::GetDefaultDevices(
|
||||
std::vector<cricket::Device>* devs) {
|
||||
if (!devs)
|
||||
return false;
|
||||
devs->clear();
|
||||
devs->push_back(default_device_);
|
||||
return true;
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* libjingle
|
||||
* Copyright 2011, Google Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef TALK_APP_WEBRTC_WEBRTCDEVICEMANAGER_H_
|
||||
#define TALK_APP_WEBRTC_WEBRTCDEVICEMANAGER_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "talk/session/phone/devicemanager.h"
|
||||
|
||||
class WebRtcDeviceManager : public cricket::DeviceManager {
|
||||
public:
|
||||
WebRtcDeviceManager();
|
||||
~WebRtcDeviceManager();
|
||||
virtual bool Init();
|
||||
virtual void Terminate();
|
||||
virtual bool GetAudioInputDevices(std::vector<cricket::Device>* devs);
|
||||
virtual bool GetAudioOutputDevices(std::vector<cricket::Device>* devs);
|
||||
virtual bool GetVideoCaptureDevices(std::vector<cricket::Device>* devs);
|
||||
virtual bool GetDefaultVideoCaptureDevice(cricket::Device* device);
|
||||
|
||||
private:
|
||||
static const int kDefaultDeviceId;
|
||||
bool GetDefaultDevices(std::vector<cricket::Device>* devs);
|
||||
|
||||
cricket::Device default_device_;
|
||||
};
|
||||
|
||||
#endif // TALK_APP_WEBRTC_WEBRTCDEVICEMANAGER_H_
|
@ -0,0 +1,143 @@
|
||||
/*
|
||||
* libjingle
|
||||
* Copyright 2011, Google Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "talk/app/webrtc/webrtcmediaengine.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "talk/session/phone/webrtcvoiceengine.h"
|
||||
#include "talk/session/phone/webrtcvideoengine.h"
|
||||
|
||||
WebRtcMediaEngine::WebRtcMediaEngine(webrtc::AudioDeviceModule* adm,
|
||||
webrtc::AudioDeviceModule* adm_sc, webrtc::VideoCaptureModule* vcm)
|
||||
: voice_(new cricket::WebRtcVoiceEngine(adm, adm_sc)),
|
||||
video_(new cricket::WebRtcVideoEngine(voice_.get(), vcm)) {
|
||||
}
|
||||
|
||||
WebRtcMediaEngine::~WebRtcMediaEngine() {
|
||||
}
|
||||
|
||||
bool WebRtcMediaEngine::Init() {
|
||||
if (!voice_->Init())
|
||||
return false;
|
||||
if (!video_->Init()) {
|
||||
voice_->Terminate();
|
||||
return false;
|
||||
}
|
||||
SignalVideoCaptureResult.repeat(video_->SignalCaptureResult);
|
||||
return true;
|
||||
}
|
||||
|
||||
void WebRtcMediaEngine::Terminate() {
|
||||
video_->Terminate();
|
||||
voice_->Terminate();
|
||||
}
|
||||
|
||||
int WebRtcMediaEngine::GetCapabilities() {
|
||||
return (voice_->GetCapabilities() | video_->GetCapabilities());
|
||||
}
|
||||
|
||||
cricket::VoiceMediaChannel* WebRtcMediaEngine::CreateChannel() {
|
||||
return voice_->CreateChannel();
|
||||
}
|
||||
|
||||
cricket::VideoMediaChannel* WebRtcMediaEngine::CreateVideoChannel(
|
||||
cricket::VoiceMediaChannel* channel) {
|
||||
return video_->CreateChannel(channel);
|
||||
}
|
||||
|
||||
cricket::SoundclipMedia* WebRtcMediaEngine::CreateSoundclip() {
|
||||
return voice_->CreateSoundclip();
|
||||
}
|
||||
|
||||
bool WebRtcMediaEngine::SetAudioOptions(int o) {
|
||||
return voice_->SetOptions(o);
|
||||
}
|
||||
|
||||
bool WebRtcMediaEngine::SetVideoOptions(int o) {
|
||||
return video_->SetOptions(o);
|
||||
}
|
||||
|
||||
bool WebRtcMediaEngine::SetDefaultVideoEncoderConfig(
|
||||
const cricket::VideoEncoderConfig& config) {
|
||||
return video_->SetDefaultEncoderConfig(config);
|
||||
}
|
||||
|
||||
bool WebRtcMediaEngine::SetSoundDevices(const cricket::Device* in_device,
|
||||
const cricket::Device* out_device) {
|
||||
return voice_->SetDevices(in_device, out_device);
|
||||
}
|
||||
|
||||
bool WebRtcMediaEngine::SetVideoCaptureDevice(
|
||||
const cricket::Device* cam_device) {
|
||||
return video_->SetCaptureDevice(cam_device);
|
||||
}
|
||||
|
||||
bool WebRtcMediaEngine::GetOutputVolume(int* level) {
|
||||
return voice_->GetOutputVolume(level);
|
||||
}
|
||||
|
||||
bool WebRtcMediaEngine::SetOutputVolume(int level) {
|
||||
return voice_->SetOutputVolume(level);
|
||||
}
|
||||
|
||||
int WebRtcMediaEngine::GetInputLevel() {
|
||||
return voice_->GetInputLevel();
|
||||
}
|
||||
|
||||
bool WebRtcMediaEngine::SetLocalMonitor(bool enable) {
|
||||
return voice_->SetLocalMonitor(enable);
|
||||
}
|
||||
|
||||
bool WebRtcMediaEngine::SetLocalRenderer(cricket::VideoRenderer* renderer) {
|
||||
return video_->SetLocalRenderer(renderer);
|
||||
}
|
||||
|
||||
cricket::CaptureResult WebRtcMediaEngine::SetVideoCapture(bool capture) {
|
||||
return video_->SetCapture(capture);
|
||||
}
|
||||
|
||||
const std::vector<cricket::AudioCodec>& WebRtcMediaEngine::audio_codecs() {
|
||||
return voice_->codecs();
|
||||
}
|
||||
|
||||
const std::vector<cricket::VideoCodec>& WebRtcMediaEngine::video_codecs() {
|
||||
return video_->codecs();
|
||||
}
|
||||
|
||||
void WebRtcMediaEngine::SetVoiceLogging(int min_sev, const char* filter) {
|
||||
return voice_->SetLogging(min_sev, filter);
|
||||
}
|
||||
|
||||
void WebRtcMediaEngine::SetVideoLogging(int min_sev, const char* filter) {
|
||||
return video_->SetLogging(min_sev, filter);
|
||||
}
|
||||
|
||||
bool WebRtcMediaEngine::SetVideoCaptureModule(
|
||||
webrtc::VideoCaptureModule* vcm) {
|
||||
return video_->SetCaptureModule(vcm);
|
||||
}
|
@ -0,0 +1,89 @@
|
||||
/*
|
||||
* libjingle
|
||||
* Copyright 2011, Google Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef TALK_APP_WEBRTC_WEBRTCMEDIAENGINE_H_
|
||||
#define TALK_APP_WEBRTC_WEBRTCMEDIAENGINE_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "talk/base/scoped_ptr.h"
|
||||
#include "talk/session/phone/mediaengine.h"
|
||||
|
||||
namespace cricket {
|
||||
|
||||
class WebRtcVideoEngine;
|
||||
class WebRtcVoiceEngine;
|
||||
}
|
||||
|
||||
namespace webrtc {
|
||||
class AudioDeviceModule;
|
||||
class VideoCaptureModule;
|
||||
}
|
||||
|
||||
// TODO(ronghuawu): chromium doesn't need to know the
|
||||
// detail about the cricket::MediaEngine interface.
|
||||
class WebRtcMediaEngine : public cricket::MediaEngine {
|
||||
public:
|
||||
WebRtcMediaEngine(webrtc::AudioDeviceModule* adm,
|
||||
webrtc::AudioDeviceModule* adm_sc, webrtc::VideoCaptureModule* vcm);
|
||||
virtual ~WebRtcMediaEngine();
|
||||
virtual bool Init();
|
||||
virtual void Terminate();
|
||||
virtual int GetCapabilities();
|
||||
virtual cricket::VoiceMediaChannel *CreateChannel();
|
||||
virtual cricket::VideoMediaChannel *CreateVideoChannel(
|
||||
cricket::VoiceMediaChannel* channel);
|
||||
virtual cricket::SoundclipMedia *CreateSoundclip();
|
||||
virtual bool SetAudioOptions(int o);
|
||||
virtual bool SetVideoOptions(int o);
|
||||
virtual bool SetDefaultVideoEncoderConfig(
|
||||
const cricket::VideoEncoderConfig& config);
|
||||
virtual bool SetSoundDevices(const cricket::Device* in_device,
|
||||
const cricket::Device* out_device);
|
||||
virtual bool SetVideoCaptureDevice(const cricket::Device* cam_device);
|
||||
virtual bool GetOutputVolume(int* level);
|
||||
virtual bool SetOutputVolume(int level);
|
||||
virtual int GetInputLevel();
|
||||
virtual bool SetLocalMonitor(bool enable);
|
||||
virtual bool SetLocalRenderer(cricket::VideoRenderer* renderer);
|
||||
virtual cricket::CaptureResult SetVideoCapture(bool capture);
|
||||
virtual const std::vector<cricket::AudioCodec>& audio_codecs();
|
||||
virtual const std::vector<cricket::VideoCodec>& video_codecs();
|
||||
virtual void SetVoiceLogging(int min_sev, const char* filter);
|
||||
virtual void SetVideoLogging(int min_sev, const char* filter);
|
||||
|
||||
// Allow the VCM be set later if not ready during the construction time
|
||||
bool SetVideoCaptureModule(webrtc::VideoCaptureModule* vcm);
|
||||
|
||||
protected:
|
||||
WebRtcMediaEngine();
|
||||
|
||||
talk_base::scoped_ptr<cricket::WebRtcVoiceEngine> voice_;
|
||||
talk_base::scoped_ptr<cricket::WebRtcVideoEngine> video_;
|
||||
};
|
||||
|
||||
#endif // TALK_APP_WEBRTC_WEBRTCMEDIAENGINE_H_
|
Loading…
Reference in New Issue
Block a user