Cleaning up of Peerconnection API.
Removing RemoteMediaStream. Adding one universal implementation of MediaStream that is used for both remote and local media streams. Removed AudioDevice and VideoDevice since VideoCaptureModule and AudioDeviceModule now is reference counted. Changes LocalAudioTrackImpl and LocalVideoTrackImpl to AudioTrackImpl and VideoTrackImpl so they can be used to repressent both remote and local tracks. Renamed files to a better name. Review URL: http://webrtc-codereview.appspot.com/151001 git-svn-id: http://webrtc.googlecode.com/svn/trunk@627 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
c49db5ea48
commit
679e64d1fc
@ -667,35 +667,33 @@
|
||||
'libjingle_p2p',
|
||||
],
|
||||
} ], # inside_chromium_build
|
||||
['peer_connection_dev==1', {
|
||||
['peer_connection_dev==1', {
|
||||
'include_dirs': [
|
||||
'<(libjingle_mods)/source',
|
||||
],
|
||||
# sources= empties the list of source file and start new.
|
||||
# peer_connection_dev is independent of the main branch.
|
||||
# peer_connection_dev is independent of the main branch.
|
||||
'sources=': [
|
||||
'<(overrides)/talk/app/webrtc_dev/scoped_refptr.h',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/audio_device_dev.cc',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/local_audio_track_impl_dev.cc',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/local_stream_dev.h',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/local_stream_dev.cc',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/local_video_track_impl_dev.cc',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/media_stream_impl_dev.h',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/media_stream_impl_dev.cc',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/peerconnection_dev.h',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/peerconnection_impl_dev.cc',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/peerconnection_impl_dev.h',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/peerconnectionmanager_impl.cc',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/peerconnectionmanager_impl.h',
|
||||
'<(overrides)/talk/app/webrtc_dev/scoped_refptr.h',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/audiotrackimpl.h',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/audiotrackimpl.cc',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/mediastream.h',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/mediastreamimpl.h',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/mediastreamimpl.cc',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/peerconnection.h',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/peerconnectionimpl.cc',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/peerconnectionimpl.h',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/peerconnectionmanagerimpl.cc',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/peerconnectionmanagerimpl.h',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/peerconnectiontransport.cc',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/peerconnectiontransport.h',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/ref_count.h',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/remote_stream_dev.h',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/remote_stream_dev.cc',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/stream_dev.h',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/video_device_dev.cc',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/video_renderer_dev.cc',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/streamcollectionimpl.h',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/videorendererimpl.cc',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/videotrackimpl.cc',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/videotrackimpl.h',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/webrtc_devicemanager.h',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/webrtc_devicemanager.cc',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/webrtc_mediaengine.h',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/webrtc_mediaengine.cc',
|
||||
],
|
||||
}], # peer_connection_dev
|
||||
], # conditions
|
||||
@ -739,20 +737,21 @@
|
||||
'conditions': [
|
||||
['inside_chromium_build==1', {
|
||||
'dependencies': [
|
||||
'../../third_party/webrtc/modules/audio_device/main/source/audio_device.gyp:audio_device',
|
||||
]
|
||||
}, {
|
||||
'../../third_party/webrtc/modules/modules.gyp:audio_device',
|
||||
'../../third_party/webrtc/system_wrappers/source/system_wrappers.gyp:system_wrappers',
|
||||
],
|
||||
}, {
|
||||
'dependencies': [
|
||||
'../../src/modules/audio_device/main/source/audio_device.gyp:audio_device',
|
||||
]
|
||||
'../../src/modules/modules.gyp:audio_device',
|
||||
'../../src/system_wrappers/source/system_wrappers.gyp:system_wrappers',
|
||||
],
|
||||
}],
|
||||
], #conditions
|
||||
'sources': [
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/mediastreamimpl_unittest.cc',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/peerconnection_unittests.cc',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/local_stream_dev_unittest.cc',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/remote_stream_dev_unittest.cc',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/peerconnection_impl_dev_unittest.cc',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/peerconnectionmanager_unittest.cc',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/peerconnectionimpl_unittest.cc',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/peerconnectionmanager_unittest.cc',
|
||||
],
|
||||
}, { # peer_connection_dev != 1
|
||||
'type': 'none',
|
||||
|
@ -1,51 +0,0 @@
|
||||
/*
|
||||
* libjingle
|
||||
* Copyright 2004--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_dev/local_stream_dev.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
scoped_refptr<AudioDevice> AudioDevice::Create(const std::string& name,
|
||||
webrtc::AudioDeviceModule* adm) {
|
||||
RefCountImpl<AudioDevice>* device = new RefCountImpl<AudioDevice>();
|
||||
device->Initialize(name, adm);
|
||||
return device;
|
||||
}
|
||||
|
||||
const std::string& AudioDevice::name(){
|
||||
return name_;
|
||||
}
|
||||
|
||||
AudioDeviceModule* AudioDevice::module() {
|
||||
return adm_;
|
||||
}
|
||||
|
||||
void AudioDevice::Initialize(const std::string& name, AudioDeviceModule* adm) {
|
||||
name_ = name;
|
||||
adm_ = adm;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
@ -0,0 +1,106 @@
|
||||
/*
|
||||
* libjingle
|
||||
* Copyright 2004--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_dev/audiotrackimpl.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
AudioTrackImpl::AudioTrackImpl(const std::string& label, uint32 ssrc)
|
||||
: enabled_(true),
|
||||
kind_(kAudioTrackKind),
|
||||
label_(label),
|
||||
ssrc_(ssrc),
|
||||
audio_device_(NULL) {
|
||||
}
|
||||
|
||||
AudioTrackImpl::AudioTrackImpl(const std::string& label,
|
||||
AudioDeviceModule* audio_device)
|
||||
: enabled_(true),
|
||||
kind_(kAudioTrackKind),
|
||||
label_(label),
|
||||
ssrc_(0),
|
||||
audio_device_(audio_device) {
|
||||
}
|
||||
|
||||
// Get the AudioDeviceModule associated with this track.
|
||||
scoped_refptr<AudioDeviceModule> AudioTrackImpl::GetAudioDevice() {
|
||||
return audio_device_;
|
||||
}
|
||||
|
||||
// Implement MediaStreamTrack
|
||||
const std::string& AudioTrackImpl::kind() {
|
||||
return kind_;
|
||||
}
|
||||
|
||||
const std::string& AudioTrackImpl::label() {
|
||||
return label_;
|
||||
}
|
||||
|
||||
bool AudioTrackImpl::enabled() {
|
||||
return enabled_;
|
||||
}
|
||||
|
||||
bool AudioTrackImpl::set_enabled(bool enable) {
|
||||
bool fire_on_change = enable != enabled_;
|
||||
enabled_ = enable;
|
||||
if (fire_on_change)
|
||||
NotifierImpl<LocalAudioTrack>::FireOnChanged();
|
||||
}
|
||||
|
||||
uint32 AudioTrackImpl::ssrc() {
|
||||
return ssrc_;
|
||||
}
|
||||
|
||||
bool AudioTrackImpl::set_ssrc(uint32 ssrc) {
|
||||
ASSERT(ssrc_ == 0);
|
||||
ASSERT(ssrc != 0);
|
||||
if (ssrc_ != 0)
|
||||
return false;
|
||||
ssrc_ = ssrc;
|
||||
NotifierImpl<LocalAudioTrack>::FireOnChanged();
|
||||
return true;
|
||||
}
|
||||
|
||||
scoped_refptr<AudioTrack> AudioTrackImpl::Create(
|
||||
const std::string& label, uint32 ssrc) {
|
||||
RefCountImpl<AudioTrackImpl>* track =
|
||||
new RefCountImpl<AudioTrackImpl>(label, ssrc);
|
||||
return track;
|
||||
}
|
||||
|
||||
scoped_refptr<LocalAudioTrack> CreateLocalAudioTrack(
|
||||
const std::string& label,
|
||||
AudioDeviceModule* audio_device) {
|
||||
RefCountImpl<AudioTrackImpl>* track =
|
||||
new RefCountImpl<AudioTrackImpl>(label, audio_device);
|
||||
return track;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace webrtc
|
@ -24,65 +24,55 @@
|
||||
* 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_dev/local_stream_dev.h"
|
||||
|
||||
#ifndef TALK_APP_WEBRTC_AUDIOTRACKIMPL_H_
|
||||
#define TALK_APP_WEBRTC_AUDIOTRACKIMPL_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "talk/app/webrtc_dev/notifierimpl.h"
|
||||
#include "talk/app/webrtc_dev/scoped_refptr.h"
|
||||
#include "talk/app/webrtc_dev/mediastream.h"
|
||||
#ifdef WEBRTC_RELATIVE_PATH
|
||||
#include "modules/audio_device/main/interface/audio_device.h"
|
||||
#else
|
||||
#include "third_party/webrtc/files/include/audio_device.h"
|
||||
#endif
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class LocalVideoTrackImpl : public NotifierImpl<LocalVideoTrack> {
|
||||
class AudioTrackImpl : public NotifierImpl<LocalAudioTrack> {
|
||||
public:
|
||||
LocalVideoTrackImpl() {}
|
||||
explicit LocalVideoTrackImpl(VideoDevice* video_device)
|
||||
: enabled_(true),
|
||||
kind_(kVideoTrackKind),
|
||||
video_device_(video_device) {
|
||||
}
|
||||
// Creates an audio track. This can be used in remote media streams.
|
||||
// For local audio tracks use CreateLocalAudioTrack.
|
||||
static scoped_refptr<AudioTrack> Create(const std::string& label,
|
||||
uint32 ssrc);
|
||||
|
||||
virtual void SetRenderer(VideoRenderer* renderer) {
|
||||
video_renderer_ = renderer;
|
||||
NotifierImpl<LocalVideoTrack>::FireOnChanged();
|
||||
}
|
||||
|
||||
virtual scoped_refptr<VideoRenderer> GetRenderer() {
|
||||
return video_renderer_.get();
|
||||
}
|
||||
|
||||
// Get the VideoCapture device associated with this track.
|
||||
virtual scoped_refptr<VideoDevice> GetVideoCapture() {
|
||||
return video_device_.get();
|
||||
}
|
||||
// Get the AudioDeviceModule associated with this track.
|
||||
virtual scoped_refptr<AudioDeviceModule> GetAudioDevice();
|
||||
|
||||
// Implement MediaStreamTrack
|
||||
virtual const std::string& kind() {
|
||||
return kind_;
|
||||
}
|
||||
virtual const std::string& kind();
|
||||
virtual const std::string& label();
|
||||
virtual uint32 ssrc();
|
||||
virtual bool enabled();
|
||||
virtual bool set_enabled(bool enable);
|
||||
virtual bool set_ssrc(uint32 ssrc);
|
||||
|
||||
virtual const std::string& label() {
|
||||
return video_device_->name();
|
||||
}
|
||||
|
||||
virtual bool enabled() {
|
||||
return enabled_;
|
||||
}
|
||||
|
||||
virtual bool set_enabled(bool enable) {
|
||||
bool fire_on_change = enable != enabled_;
|
||||
enabled_ = enable;
|
||||
if (fire_on_change)
|
||||
NotifierImpl<LocalVideoTrack>::FireOnChanged();
|
||||
}
|
||||
protected:
|
||||
AudioTrackImpl(const std::string& label, uint32 ssrc);
|
||||
AudioTrackImpl(const std::string& label, AudioDeviceModule* audio_device);
|
||||
|
||||
private:
|
||||
bool enabled_;
|
||||
std::string kind_;
|
||||
scoped_refptr<VideoDevice> video_device_;
|
||||
scoped_refptr<VideoRenderer> video_renderer_;
|
||||
std::string label_;
|
||||
uint32 ssrc_;
|
||||
scoped_refptr<AudioDeviceModule> audio_device_;
|
||||
};
|
||||
|
||||
scoped_refptr<LocalVideoTrack> LocalVideoTrack::Create(
|
||||
VideoDevice* video_device) {
|
||||
RefCountImpl<LocalVideoTrackImpl>* track =
|
||||
new RefCountImpl<LocalVideoTrackImpl>(video_device);
|
||||
return track;
|
||||
}
|
||||
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // TALK_APP_WEBRTC_AUDIOTRACKIMPL_H_
|
@ -1,77 +0,0 @@
|
||||
/*
|
||||
* libjingle
|
||||
* Copyright 2004--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_dev/local_stream_dev.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class LocalAudioTrackImpl : public NotifierImpl<LocalAudioTrack> {
|
||||
public:
|
||||
LocalAudioTrackImpl(){};
|
||||
LocalAudioTrackImpl(AudioDevice* audio_device)
|
||||
: enabled_(true),
|
||||
kind_(kAudioTrackKind),
|
||||
audio_device_(audio_device) {
|
||||
}
|
||||
|
||||
// Get the AudioDevice associated with this track.
|
||||
virtual scoped_refptr<AudioDevice> GetAudioDevice() {
|
||||
return audio_device_.get();
|
||||
};
|
||||
|
||||
// Implement MediaStreamTrack
|
||||
virtual const std::string& kind() {
|
||||
return kind_;
|
||||
}
|
||||
|
||||
virtual const std::string& label() {
|
||||
return audio_device_->name();
|
||||
}
|
||||
|
||||
virtual bool enabled() {
|
||||
return enabled_;
|
||||
}
|
||||
|
||||
virtual bool set_enabled(bool enable) {
|
||||
bool fire_on_change = enable != enabled_;
|
||||
enabled_ = enable;
|
||||
if (fire_on_change)
|
||||
NotifierImpl<LocalAudioTrack>::FireOnChanged();
|
||||
}
|
||||
|
||||
private:
|
||||
bool enabled_;
|
||||
std::string kind_;
|
||||
scoped_refptr<AudioDevice> audio_device_;
|
||||
};
|
||||
|
||||
scoped_refptr<LocalAudioTrack> LocalAudioTrack::Create(AudioDevice* audio_device) {
|
||||
RefCountImpl<LocalAudioTrackImpl>* lstream =
|
||||
new RefCountImpl<LocalAudioTrackImpl>(audio_device);
|
||||
return lstream;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
@ -1,64 +0,0 @@
|
||||
/*
|
||||
* 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_dev/media_stream_impl_dev.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
MediaStreamImpl::MediaStreamImpl(const std::string& label)
|
||||
: label_(label),
|
||||
ready_state_(MediaStream::kInitializing) {
|
||||
}
|
||||
|
||||
// Implement MediaStream
|
||||
const std::string& MediaStreamImpl::label() const {
|
||||
return label_;
|
||||
}
|
||||
|
||||
MediaStream::ReadyState MediaStreamImpl::ready_state() const {
|
||||
return ready_state_;
|
||||
}
|
||||
|
||||
MediaStreamTrackListImpl::MediaStreamTrackListImpl() {
|
||||
}
|
||||
|
||||
// Implement MediaStreamTrackList.
|
||||
size_t MediaStreamTrackListImpl::count() const {
|
||||
return tracks_.size();
|
||||
}
|
||||
|
||||
scoped_refptr<MediaStreamTrack>
|
||||
MediaStreamTrackListImpl::at(size_t index) const {
|
||||
return tracks_[index];
|
||||
}
|
||||
|
||||
bool MediaStreamTrackListImpl::AddTrack(MediaStreamTrack* track) {
|
||||
tracks_.push_back(track);
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
@ -25,13 +25,14 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef TALK_APP_WEBRTC_STREAM_H_
|
||||
#define TALK_APP_WEBRTC_STREAM_H_
|
||||
#ifndef TALK_APP_WEBRTC_MEDIASTREAM_H_
|
||||
#define TALK_APP_WEBRTC_MEDIASTREAM_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "talk/app/webrtc_dev/ref_count.h"
|
||||
#include "talk/app/webrtc_dev/scoped_refptr.h"
|
||||
#include "talk/base/basictypes.h"
|
||||
|
||||
namespace cricket {
|
||||
class VideoRenderer;
|
||||
@ -67,6 +68,7 @@ class MediaStreamTrack : public RefCount,
|
||||
public:
|
||||
virtual const std::string& kind() = 0;
|
||||
virtual const std::string& label() = 0;
|
||||
virtual uint32 ssrc() = 0;
|
||||
virtual bool enabled() = 0;
|
||||
// Enable or disables a track.
|
||||
// For Remote streams - disable means that the video is not decoded,
|
||||
@ -74,61 +76,24 @@ class MediaStreamTrack : public RefCount,
|
||||
// For local streams this means that video is not captured
|
||||
// or audio is not captured.
|
||||
virtual bool set_enabled(bool enable) = 0;
|
||||
};
|
||||
|
||||
// Reference counted wrapper for an AudioDeviceModule.
|
||||
class AudioDevice : public RefCount {
|
||||
public:
|
||||
static scoped_refptr<AudioDevice> Create(const std::string& name,
|
||||
AudioDeviceModule* adm);
|
||||
|
||||
// Name of this device. Same as label of a MediaStreamTrack.
|
||||
const std::string& name();
|
||||
|
||||
AudioDeviceModule* module();
|
||||
|
||||
protected:
|
||||
AudioDevice() {}
|
||||
virtual ~AudioDevice() {}
|
||||
void Initialize(const std::string& name, AudioDeviceModule* adm);
|
||||
|
||||
std::string name_;
|
||||
AudioDeviceModule* adm_;
|
||||
};
|
||||
|
||||
// Reference counted wrapper for a VideoCaptureModule.
|
||||
class VideoDevice : public RefCount {
|
||||
public:
|
||||
static scoped_refptr<VideoDevice> Create(const std::string& name,
|
||||
VideoCaptureModule* vcm);
|
||||
// Name of this device. Same as label of a MediaStreamTrack.
|
||||
const std::string& name();
|
||||
|
||||
VideoCaptureModule* module();
|
||||
|
||||
protected:
|
||||
VideoDevice() {}
|
||||
~VideoDevice() {}
|
||||
void Initialize(const std::string& name, VideoCaptureModule* vcm);
|
||||
|
||||
std::string name_;
|
||||
VideoCaptureModule* vcm_;
|
||||
// Return false (or assert) if the ssrc is already set.
|
||||
virtual bool set_ssrc(uint32 ssrc) = 0;
|
||||
};
|
||||
|
||||
// Reference counted wrapper for a VideoRenderer.
|
||||
class VideoRenderer : public RefCount {
|
||||
public:
|
||||
static scoped_refptr<VideoRenderer> Create(cricket::VideoRenderer* renderer);
|
||||
virtual cricket::VideoRenderer* module();
|
||||
virtual cricket::VideoRenderer* renderer() = 0;
|
||||
|
||||
protected:
|
||||
VideoRenderer() {}
|
||||
~VideoRenderer() {}
|
||||
void Initialize(cricket::VideoRenderer* renderer);
|
||||
|
||||
cricket::VideoRenderer* renderer_;
|
||||
virtual ~VideoRenderer() {}
|
||||
};
|
||||
|
||||
// Creates a reference counted object of type webrtc::VideoRenderer.
|
||||
// webrtc::VideoRenderer take ownership of cricket::VideoRenderer.
|
||||
scoped_refptr<VideoRenderer> CreateVideoRenderer(
|
||||
cricket::VideoRenderer* renderer);
|
||||
|
||||
class VideoTrack : public MediaStreamTrack {
|
||||
public:
|
||||
// Set the video renderer for a local or remote stream.
|
||||
@ -144,15 +109,17 @@ class VideoTrack : public MediaStreamTrack {
|
||||
|
||||
class LocalVideoTrack : public VideoTrack {
|
||||
public:
|
||||
static scoped_refptr<LocalVideoTrack> Create(VideoDevice* video_device);
|
||||
|
||||
// Get the VideoCapture device associated with this track.
|
||||
virtual scoped_refptr<VideoDevice> GetVideoCapture() = 0;
|
||||
virtual scoped_refptr<VideoCaptureModule> GetVideoCapture() = 0;
|
||||
|
||||
protected:
|
||||
virtual ~LocalVideoTrack() {}
|
||||
};
|
||||
|
||||
scoped_refptr<LocalVideoTrack> CreateLocalVideoTrack(
|
||||
const std::string& label,
|
||||
VideoCaptureModule* video_device);
|
||||
|
||||
class AudioTrack : public MediaStreamTrack {
|
||||
public:
|
||||
protected:
|
||||
@ -161,14 +128,16 @@ class AudioTrack : public MediaStreamTrack {
|
||||
|
||||
class LocalAudioTrack : public AudioTrack {
|
||||
public:
|
||||
static scoped_refptr<LocalAudioTrack> Create(AudioDevice* audio_device);
|
||||
|
||||
// Get the AudioDevice associated with this track.
|
||||
virtual scoped_refptr<AudioDevice> GetAudioDevice() = 0;
|
||||
// Get the AudioDeviceModule associated with this track.
|
||||
virtual scoped_refptr<AudioDeviceModule> GetAudioDevice() = 0;
|
||||
protected:
|
||||
virtual ~LocalAudioTrack() {}
|
||||
};
|
||||
|
||||
scoped_refptr<LocalAudioTrack> CreateLocalAudioTrack(
|
||||
const std::string& label,
|
||||
AudioDeviceModule* audio_device);
|
||||
|
||||
// List of of tracks.
|
||||
class MediaStreamTrackList : public RefCount, public Notifier {
|
||||
public:
|
||||
@ -179,7 +148,8 @@ class MediaStreamTrackList : public RefCount, public Notifier {
|
||||
virtual ~MediaStreamTrackList() {}
|
||||
};
|
||||
|
||||
class MediaStream : public RefCount {
|
||||
class MediaStream : public RefCount,
|
||||
public Notifier {
|
||||
public:
|
||||
virtual const std::string& label() = 0;
|
||||
virtual scoped_refptr<MediaStreamTrackList> tracks() = 0;
|
||||
@ -192,24 +162,21 @@ class MediaStream : public RefCount {
|
||||
|
||||
virtual ReadyState ready_state() = 0;
|
||||
|
||||
// Only to be used by the implementation.
|
||||
virtual void set_ready_state(ReadyState state) = 0;
|
||||
|
||||
protected:
|
||||
virtual ~MediaStream() {}
|
||||
};
|
||||
|
||||
class LocalMediaStream : public MediaStream {
|
||||
public:
|
||||
static scoped_refptr<LocalMediaStream> Create(const std::string& label);
|
||||
virtual bool AddTrack(MediaStreamTrack* track) = 0;
|
||||
};
|
||||
|
||||
// Remote streams are created by the PeerConnection object and provided to the
|
||||
// client using PeerConnectionObserver::OnAddStream.
|
||||
// The client can provide the renderer to the PeerConnection object calling
|
||||
// VideoTrack::SetRenderer.
|
||||
class RemoteMediaStream : public MediaStream {
|
||||
public:
|
||||
};
|
||||
scoped_refptr<LocalMediaStream> CreateLocalMediaStream(
|
||||
const std::string& label);
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // TALK_APP_WEBRTC_STREAM_H_
|
||||
#endif // TALK_APP_WEBRTC_MEDIASTREAM_H_
|
@ -24,50 +24,66 @@
|
||||
* 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_dev/local_stream_dev.h"
|
||||
#include "talk/app/webrtc_dev/mediastreamimpl.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
scoped_refptr<LocalMediaStream> LocalMediaStream::Create(
|
||||
scoped_refptr<LocalMediaStream> CreateLocalMediaStream(
|
||||
const std::string& label) {
|
||||
RefCountImpl<LocalStreamImpl>* stream =
|
||||
new RefCountImpl<LocalStreamImpl>(label);
|
||||
return MediaStreamImpl::Create(label);
|
||||
}
|
||||
|
||||
scoped_refptr<MediaStreamImpl> MediaStreamImpl::Create(
|
||||
const std::string& label) {
|
||||
RefCountImpl<MediaStreamImpl>* stream =
|
||||
new RefCountImpl<MediaStreamImpl>(label);
|
||||
return stream;
|
||||
}
|
||||
|
||||
LocalStreamImpl::LocalStreamImpl(const std::string& label)
|
||||
: media_stream_impl_(label) {
|
||||
MediaStreamImpl::MediaStreamImpl(const std::string& label)
|
||||
: label_(label),
|
||||
ready_state_(MediaStream::kInitializing),
|
||||
track_list_(new RefCountImpl<MediaStreamTrackListImpl>()) {
|
||||
}
|
||||
|
||||
// Implement MediaStream
|
||||
const std::string& LocalStreamImpl::label() {
|
||||
return media_stream_impl_.label();
|
||||
const std::string& MediaStreamImpl::label() {
|
||||
return label_;
|
||||
}
|
||||
|
||||
scoped_refptr<MediaStreamTrackList> LocalStreamImpl::tracks() {
|
||||
return this;
|
||||
scoped_refptr<MediaStreamTrackList> MediaStreamImpl::tracks() {
|
||||
return track_list_;
|
||||
}
|
||||
|
||||
MediaStream::ReadyState LocalStreamImpl::ready_state() {
|
||||
return media_stream_impl_.ready_state();
|
||||
MediaStream::ReadyState MediaStreamImpl::ready_state() {
|
||||
return ready_state_;
|
||||
}
|
||||
|
||||
// Implement MediaStreamTrackList.
|
||||
size_t LocalStreamImpl::count() {
|
||||
return tracks_.count();
|
||||
void MediaStreamImpl::set_ready_state(MediaStream::ReadyState new_state) {
|
||||
ready_state_ = new_state;
|
||||
NotifierImpl<LocalMediaStream>::FireOnChanged();
|
||||
}
|
||||
|
||||
scoped_refptr<MediaStreamTrack> LocalStreamImpl::at(size_t index) {
|
||||
return tracks_.at(index);
|
||||
}
|
||||
|
||||
bool LocalStreamImpl::AddTrack(MediaStreamTrack* track) {
|
||||
bool MediaStreamImpl::AddTrack(MediaStreamTrack* track) {
|
||||
if (ready_state() != kInitializing)
|
||||
return false;
|
||||
|
||||
bool result = tracks_.AddTrack(track);
|
||||
track_list_->AddTrack(track);
|
||||
return true;
|
||||
}
|
||||
|
||||
void MediaStreamImpl::MediaStreamTrackListImpl::AddTrack(
|
||||
MediaStreamTrack* track) {
|
||||
tracks_.push_back(track);
|
||||
NotifierImpl<MediaStreamTrackList>::FireOnChanged();
|
||||
return result;
|
||||
}
|
||||
|
||||
size_t MediaStreamImpl::MediaStreamTrackListImpl::count() {
|
||||
return tracks_.size();
|
||||
}
|
||||
|
||||
scoped_refptr<MediaStreamTrack> MediaStreamImpl::MediaStreamTrackListImpl::at(
|
||||
size_t index) {
|
||||
return tracks_.at(index);
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
@ -25,24 +25,32 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef TALK_APP_WEBRTC_LOCAL_STREAM_H_
|
||||
#define TALK_APP_WEBRTC_LOCAL_STREAM_H_
|
||||
#ifndef TALK_APP_WEBRTC_MEDIASTREAMIMPL_H_
|
||||
#define TALK_APP_WEBRTC_MEDIASTREAMIMPL_H_
|
||||
|
||||
#include "talk/app/webrtc_dev/media_stream_impl_dev.h"
|
||||
#include "talk/app/webrtc_dev/stream_dev.h"
|
||||
#include "talk/base/scoped_ptr.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "talk/app/webrtc_dev/mediastream.h"
|
||||
#include "talk/app/webrtc_dev/notifierimpl.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class MediaStreamImpl;
|
||||
/////////////////////////////////////////////
|
||||
// Local streams are Created by the PeerConnections client and provided to a
|
||||
// PeerConnection object using the call PeerConnection::AddStream.
|
||||
|
||||
class LocalStreamImpl
|
||||
: public LocalMediaStream,
|
||||
public NotifierImpl<MediaStreamTrackList> {
|
||||
class MediaStreamImpl
|
||||
: public NotifierImpl<LocalMediaStream> {
|
||||
public:
|
||||
class MediaStreamTrackListImpl : public NotifierImpl<MediaStreamTrackList> {
|
||||
public:
|
||||
void AddTrack(MediaStreamTrack* track);
|
||||
virtual size_t count();
|
||||
virtual scoped_refptr<MediaStreamTrack> at(size_t index);
|
||||
|
||||
private:
|
||||
std::vector<scoped_refptr<MediaStreamTrack> > tracks_;
|
||||
};
|
||||
|
||||
static scoped_refptr<MediaStreamImpl> Create(const std::string& label);
|
||||
|
||||
// Implement LocalStream.
|
||||
virtual bool AddTrack(MediaStreamTrack* track);
|
||||
|
||||
@ -50,18 +58,17 @@ class LocalStreamImpl
|
||||
virtual const std::string& label();
|
||||
virtual scoped_refptr<MediaStreamTrackList> tracks();
|
||||
virtual ReadyState ready_state();
|
||||
|
||||
// Implement MediaStreamTrackList.
|
||||
virtual size_t count();
|
||||
virtual scoped_refptr<MediaStreamTrack> at(size_t index);
|
||||
virtual void set_ready_state(ReadyState new_state);
|
||||
void set_state(ReadyState new_state);
|
||||
|
||||
protected:
|
||||
explicit LocalStreamImpl(const std::string& label);
|
||||
explicit MediaStreamImpl(const std::string& label);
|
||||
|
||||
MediaStreamImpl media_stream_impl_;
|
||||
MediaStreamTrackListImpl tracks_;
|
||||
std::string label_;
|
||||
MediaStream::ReadyState ready_state_;
|
||||
scoped_refptr<MediaStreamTrackListImpl> track_list_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // TALK_APP_WEBRTC_LOCAL_STREAM_H_
|
||||
#endif // TALK_APP_WEBRTC_MEDIASTREAMIMPL_H_
|
@ -28,10 +28,10 @@
|
||||
#include <string>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "talk/app/webrtc_dev/local_stream_dev.h"
|
||||
#include "talk/app/webrtc_dev/mediastreamimpl.h"
|
||||
|
||||
static const char kStreamLabel1[] = "local_stream_1";
|
||||
const char* kVideoDeviceName = "dummy_video_cam_1";
|
||||
static const char kVideoDeviceName[] = "dummy_video_cam_1";
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -53,22 +53,18 @@ class TestObserver : public Observer {
|
||||
TEST(LocalStreamTest, Create) {
|
||||
// Create a local stream.
|
||||
std::string label(kStreamLabel1);
|
||||
scoped_refptr<LocalMediaStream> stream(LocalMediaStream::Create(label));
|
||||
scoped_refptr<LocalMediaStream> stream(CreateLocalMediaStream(label));
|
||||
|
||||
EXPECT_EQ(stream->label().compare(label), 0);
|
||||
// Check state.
|
||||
EXPECT_EQ(stream->ready_state(), MediaStream::kInitializing);
|
||||
|
||||
// Create a Video Device.
|
||||
std::string device_name(kVideoDeviceName);
|
||||
scoped_refptr<VideoDevice> device = VideoDevice::Create(device_name, NULL);
|
||||
EXPECT_EQ(device->name(), device_name);
|
||||
|
||||
// Create a local Video track.
|
||||
{
|
||||
TestObserver tracklist_observer;
|
||||
|
||||
scoped_refptr<LocalVideoTrack> video_track(LocalVideoTrack::Create(device));
|
||||
scoped_refptr<LocalVideoTrack> video_track(CreateLocalVideoTrack(
|
||||
kVideoDeviceName, NULL));
|
||||
|
||||
// Add an observer to the track list.
|
||||
scoped_refptr<MediaStreamTrackList> track_list(stream->tracks());
|
@ -25,13 +25,13 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef TALK_APP_WEBRTC_NOTIFIER_IMPL_H_
|
||||
#define TALK_APP_WEBRTC_NOTIFIER_IMPL_H_
|
||||
#ifndef TALK_APP_WEBRTC_NOTIFIERIMPL_H_
|
||||
#define TALK_APP_WEBRTC_NOTIFIERIMPL_H_
|
||||
|
||||
#include <list>
|
||||
|
||||
#include "talk/base/common.h"
|
||||
#include "talk/app/webrtc_dev/stream_dev.h"
|
||||
#include "talk/app/webrtc_dev/mediastream.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -70,4 +70,4 @@ class NotifierImpl : public T {
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // TALK_APP_WEBRTC_NOTIFIER_IMPL_H_
|
||||
#endif // TALK_APP_WEBRTC_NOTIFIERIMPL_H_
|
@ -30,7 +30,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "talk/app/webrtc_dev/stream_dev.h"
|
||||
#include "talk/app/webrtc_dev/mediastream.h"
|
||||
|
||||
namespace talk_base {
|
||||
class Thread;
|
||||
@ -67,10 +67,10 @@ class PeerConnectionObserver {
|
||||
virtual void OnStateChange(Readiness state) = 0;
|
||||
|
||||
// Triggered when media is received on a new stream from remote peer.
|
||||
virtual void OnAddStream(RemoteMediaStream* stream) = 0;
|
||||
virtual void OnAddStream(MediaStream* stream) = 0;
|
||||
|
||||
// Triggered when a remote peer close a stream.
|
||||
virtual void OnRemoveStream(RemoteMediaStream* stream) = 0;
|
||||
virtual void OnRemoveStream(MediaStream* stream) = 0;
|
||||
|
||||
protected:
|
||||
// Dtor protected as objects shouldn't be deleted via this interface.
|
||||
@ -156,7 +156,7 @@ class PeerConnectionManager : public RefCount {
|
||||
talk_base::Thread* worker_thread,
|
||||
PcNetworkManager* network_manager,
|
||||
PcPacketSocketFactory* packet_socket_factory,
|
||||
AudioDevice* default_adm);
|
||||
AudioDeviceModule* default_adm);
|
||||
|
||||
virtual scoped_refptr<PeerConnection> CreatePeerConnection(
|
||||
const std::string& config) = 0;
|
@ -1,44 +0,0 @@
|
||||
/*
|
||||
* 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/peerconnection_impl.h"
|
||||
|
||||
namespace webrtc {
|
||||
PeerConnection* PeerConnection::Create(
|
||||
const std::string& config,
|
||||
cricket::PortAllocator* port_allocator,
|
||||
talk_base::Thread* worker_thread,
|
||||
cricket::DeviceManager* device_manager) {
|
||||
return new PeerConnectionImpl(config, port_allocator,
|
||||
worker_thread, device_manager);
|
||||
}
|
||||
|
||||
PeerConnection* PeerConnection::Create(const std::string& config) {
|
||||
return new PeerConnectionImpl(config);
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
@ -26,78 +26,25 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "talk/app/webrtc_dev/peerconnection_impl_dev.h"
|
||||
#include "talk/app/webrtc_dev/peerconnectionimpl.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "talk/app/webrtc_dev/scoped_refptr_msg.h"
|
||||
#include "talk/app/webrtc_dev/streamcollectionimpl.h"
|
||||
#include "talk/base/logging.h"
|
||||
#include "talk/p2p/client/basicportallocator.h"
|
||||
#include "talk/session/phone/channelmanager.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// Implementation of StreamCollection intended for local streams.
|
||||
class LocalStreamCollection : public StreamCollection {
|
||||
public:
|
||||
static scoped_refptr<LocalStreamCollection> Create() {
|
||||
RefCountImpl<LocalStreamCollection>* implementation =
|
||||
new RefCountImpl<LocalStreamCollection>();
|
||||
return implementation;
|
||||
}
|
||||
|
||||
static scoped_refptr<LocalStreamCollection> Create(
|
||||
LocalStreamCollection* local_streams) {
|
||||
RefCountImpl<LocalStreamCollection>* implementation =
|
||||
new RefCountImpl<LocalStreamCollection>(local_streams);
|
||||
return implementation;
|
||||
}
|
||||
|
||||
virtual size_t count() {
|
||||
return local_media_streams_.size();
|
||||
}
|
||||
|
||||
virtual MediaStream* at(size_t index) {
|
||||
return local_media_streams_.at(index);
|
||||
}
|
||||
|
||||
void AddStream(LocalMediaStream* local_stream) {
|
||||
for (LocalStreamVector::iterator it = local_media_streams_.begin();
|
||||
it != local_media_streams_.end(); ++it) {
|
||||
if ((*it)->label().compare(local_stream->label()) == 0)
|
||||
return;
|
||||
}
|
||||
local_media_streams_.push_back(local_stream);
|
||||
}
|
||||
|
||||
void RemoveStream(LocalMediaStream* remove_stream) {
|
||||
for (LocalStreamVector::iterator it = local_media_streams_.begin();
|
||||
it != local_media_streams_.end(); ++it) {
|
||||
if ((*it)->label().compare(remove_stream->label()) == 0) {
|
||||
local_media_streams_.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
LocalStreamCollection() {}
|
||||
explicit LocalStreamCollection(LocalStreamCollection* original)
|
||||
: local_media_streams_(original->local_media_streams_) {
|
||||
}
|
||||
// Map of local media streams.
|
||||
typedef std::vector<scoped_refptr<LocalMediaStream> >
|
||||
LocalStreamVector;
|
||||
LocalStreamVector local_media_streams_;
|
||||
};
|
||||
|
||||
PeerConnectionImpl::PeerConnectionImpl(
|
||||
cricket::ChannelManager* channel_manager,
|
||||
talk_base::Thread* worker_thread,
|
||||
PcNetworkManager* network_manager,
|
||||
PcPacketSocketFactory* socket_factory)
|
||||
: observer_(NULL),
|
||||
local_media_streams_(LocalStreamCollection::Create()),
|
||||
local_media_streams_(StreamCollectionImpl::Create()),
|
||||
worker_thread_(worker_thread),
|
||||
channel_manager_(channel_manager),
|
||||
network_manager_(network_manager),
|
||||
@ -108,6 +55,7 @@ PeerConnectionImpl::PeerConnectionImpl(
|
||||
}
|
||||
|
||||
PeerConnectionImpl::~PeerConnectionImpl() {
|
||||
worker_thread_->Clear(this);
|
||||
}
|
||||
|
||||
bool PeerConnectionImpl::Initialize(const std::string& configuration) {
|
||||
@ -132,9 +80,9 @@ void PeerConnectionImpl::RemoveStream(LocalMediaStream* remove_stream) {
|
||||
}
|
||||
|
||||
void PeerConnectionImpl::CommitStreamChanges() {
|
||||
ScopedRefMessageData<LocalStreamCollection>* msg =
|
||||
new ScopedRefMessageData<LocalStreamCollection> (
|
||||
LocalStreamCollection::Create(local_media_streams_));
|
||||
ScopedRefMessageData<StreamCollectionImpl>* msg =
|
||||
new ScopedRefMessageData<StreamCollectionImpl> (
|
||||
StreamCollectionImpl::Create(local_media_streams_));
|
||||
worker_thread_->Post(this, MSG_COMMITSTREAMCHANGES, msg);
|
||||
}
|
||||
|
@ -25,13 +25,13 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef TALK_APP_WEBRTC_PEERCONNECTION_IMPL_H_
|
||||
#define TALK_APP_WEBRTC_PEERCONNECTION_IMPL_H_
|
||||
#ifndef TALK_APP_WEBRTC_PEERCONNECTIONIMPL_H_
|
||||
#define TALK_APP_WEBRTC_PEERCONNECTIONIMPL_H_
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "talk/app/webrtc_dev/peerconnection_dev.h"
|
||||
#include "talk/app/webrtc_dev/peerconnection.h"
|
||||
#include "talk/base/scoped_ptr.h"
|
||||
#include "talk/p2p/base/portallocator.h"
|
||||
|
||||
@ -40,7 +40,7 @@ class ChannelManager;
|
||||
}
|
||||
|
||||
namespace webrtc {
|
||||
class LocalStreamCollection;
|
||||
class StreamCollectionImpl;
|
||||
|
||||
class PeerConnectionImpl : public PeerConnection,
|
||||
public talk_base::MessageHandler {
|
||||
@ -98,7 +98,7 @@ class PeerConnectionImpl : public PeerConnection,
|
||||
};
|
||||
|
||||
PeerConnectionObserver* observer_;
|
||||
scoped_refptr<LocalStreamCollection> local_media_streams_;
|
||||
scoped_refptr<StreamCollectionImpl> local_media_streams_;
|
||||
|
||||
talk_base::Thread* worker_thread_; // Weak ref from PeerConnectionManager.
|
||||
cricket::ChannelManager* channel_manager_;
|
||||
@ -109,4 +109,4 @@ class PeerConnectionImpl : public PeerConnection,
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // TALK_APP_WEBRTC_PEERCONNECTION_IMPL_H_
|
||||
#endif // TALK_APP_WEBRTC_PEERCONNECTIONIMPL_H_
|
@ -28,9 +28,9 @@
|
||||
#include <string>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "talk/app/webrtc_dev/local_stream_dev.h"
|
||||
#include "talk/app/webrtc_dev/peerconnection_dev.h"
|
||||
#include "talk/app/webrtc_dev/peerconnection_impl_dev.h"
|
||||
#include "talk/app/webrtc_dev/mediastreamimpl.h"
|
||||
#include "talk/app/webrtc_dev/peerconnection.h"
|
||||
#include "talk/app/webrtc_dev/peerconnectionimpl.h"
|
||||
#include "talk/base/scoped_ptr.h"
|
||||
#include "talk/base/thread.h"
|
||||
|
||||
@ -40,7 +40,6 @@ namespace webrtc {
|
||||
|
||||
class PeerConnectionImplTest : public testing::Test {
|
||||
public:
|
||||
|
||||
protected:
|
||||
virtual void SetUp() {
|
||||
pc_factory_ = webrtc::PeerConnectionManager::Create();
|
||||
@ -56,12 +55,14 @@ class PeerConnectionImplTest : public testing::Test {
|
||||
TEST_F(PeerConnectionImplTest, AddRemoveStream) {
|
||||
// Create a local stream.
|
||||
std::string label(kStreamLabel1);
|
||||
scoped_refptr<LocalMediaStream> stream(LocalMediaStream::Create(label));
|
||||
scoped_refptr<LocalMediaStream> stream(CreateLocalMediaStream(label));
|
||||
|
||||
pc_->AddStream(stream);
|
||||
pc_->CommitStreamChanges();
|
||||
EXPECT_EQ(pc_->local_streams()->count(), 1l);
|
||||
EXPECT_EQ(pc_->local_streams()->at(0)->label().compare(kStreamLabel1), 0);
|
||||
EXPECT_EQ(1l, pc_->local_streams()->count());
|
||||
if (pc_->local_streams()->count() <= 0)
|
||||
return;
|
||||
EXPECT_EQ(0, pc_->local_streams()->at(0)->label().compare(kStreamLabel1));
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
@ -28,14 +28,20 @@
|
||||
#include <string>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "talk/app/webrtc_dev/local_stream_dev.h"
|
||||
#include "talk/app/webrtc_dev/peerconnectionmanager_impl.h"
|
||||
#include "talk/app/webrtc_dev/mediastreamimpl.h"
|
||||
#include "talk/app/webrtc_dev/peerconnectionmanagerimpl.h"
|
||||
#include "talk/base/basicpacketsocketfactory.h"
|
||||
#include "talk/base/scoped_ptr.h"
|
||||
#include "talk/base/thread.h"
|
||||
#include "talk/session/phone/webrtccommon.h"
|
||||
#include "talk/session/phone/webrtcvoe.h"
|
||||
|
||||
#ifdef WEBRTC_RELATIVE_PATH
|
||||
#include "modules/audio_device/main/source/audio_device_impl.h"
|
||||
#else
|
||||
#include "third_party/webrtc/files/include/audio_device_impl.h"
|
||||
#endif
|
||||
|
||||
static const char kAudioDeviceLabel[] = "dummy_audio_device";
|
||||
|
||||
namespace webrtc {
|
||||
@ -52,9 +58,8 @@ TEST(PeerConnectionManager, CreatePCUsingInternalModules) {
|
||||
|
||||
TEST(PeerConnectionManager, CreatePCUsingExternalModules) {
|
||||
// Create an audio device. Use the default sound card.
|
||||
AudioDeviceModule* module = AudioDeviceModule::Create(0);
|
||||
scoped_refptr<AudioDevice> audio_device(AudioDevice::Create(
|
||||
kAudioDeviceLabel, module));
|
||||
scoped_refptr<AudioDeviceModule> audio_device(
|
||||
AudioDeviceModuleImpl::Create(0));
|
||||
|
||||
// Creata a libjingle thread used as internal worker thread.
|
||||
talk_base::scoped_ptr<talk_base::Thread> w_thread(new talk_base::Thread);
|
||||
|
@ -25,13 +25,21 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "talk/app/webrtc_dev/peerconnection_impl_dev.h"
|
||||
#include "talk/app/webrtc_dev/peerconnectionmanager_impl.h"
|
||||
#include "talk/app/webrtc_dev/peerconnectionmanagerimpl.h"
|
||||
|
||||
#include "talk/app/webrtc_dev/peerconnectionimpl.h"
|
||||
#include "talk/app/webrtc_dev/webrtc_devicemanager.h"
|
||||
#include "talk/app/webrtc_dev/webrtc_mediaengine.h"
|
||||
#include "talk/base/basicpacketsocketfactory.h"
|
||||
#include "talk/base/thread.h"
|
||||
#include "talk/session/phone/channelmanager.h"
|
||||
#include "talk/session/phone/webrtcmediaengine.h"
|
||||
|
||||
#ifdef WEBRTC_RELATIVE_PATH
|
||||
#include "modules/audio_device/main/interface/audio_device.h"
|
||||
#else
|
||||
#include "third_party/webrtc/files/include/audio_device.h"
|
||||
#endif
|
||||
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -88,7 +96,7 @@ scoped_refptr<PeerConnectionManager> PeerConnectionManager::Create(
|
||||
talk_base::Thread* worker_thread,
|
||||
PcNetworkManager* network_manager,
|
||||
PcPacketSocketFactory* socket_factory,
|
||||
AudioDevice* default_adm) {
|
||||
AudioDeviceModule* default_adm) {
|
||||
RefCountImpl<PeerConnectionManagerImpl>* pc_manager =
|
||||
new RefCountImpl<PeerConnectionManagerImpl>(worker_thread,
|
||||
network_manager,
|
||||
@ -114,7 +122,7 @@ PeerConnectionManagerImpl::PeerConnectionManagerImpl(
|
||||
talk_base::Thread* worker_thread,
|
||||
PcNetworkManager* network_manager,
|
||||
PcPacketSocketFactory* socket_factory,
|
||||
AudioDevice* default_adm)
|
||||
AudioDeviceModule* default_adm)
|
||||
: worker_thread_ptr_(worker_thread),
|
||||
network_manager_(network_manager),
|
||||
socket_factory_(socket_factory),
|
||||
@ -132,14 +140,14 @@ bool PeerConnectionManagerImpl::Initialize() {
|
||||
if (worker_thread_.get() && !worker_thread_->Start())
|
||||
return false;
|
||||
cricket::DeviceManager* device_manager(new WebRtcDeviceManager());
|
||||
WebRtcMediaEngine* webrtc_media_engine = NULL;
|
||||
if (default_adm_.get() != NULL) {
|
||||
webrtc_media_engine = new WebRtcMediaEngine(default_adm_.get()->module(),
|
||||
NULL, // No secondary adm.
|
||||
NULL); // No vcm available.
|
||||
} else {
|
||||
webrtc_media_engine = new WebRtcMediaEngine();
|
||||
}
|
||||
cricket::WebRtcMediaEngine* webrtc_media_engine = NULL;
|
||||
|
||||
// TODO(perkj): Need to make sure only one VoE is created inside
|
||||
// WebRtcMediaEngine.
|
||||
webrtc_media_engine = new cricket::WebRtcMediaEngine(
|
||||
default_adm_.get(),
|
||||
NULL, // No secondary adm.
|
||||
NULL); // No vcm available.
|
||||
|
||||
channel_manager_.reset(new cricket::ChannelManager(
|
||||
webrtc_media_engine, device_manager, worker_thread_ptr_));
|
@ -24,14 +24,14 @@
|
||||
* 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_PEERCONNECTIONMANAGER_IMPL_H_
|
||||
#define TALK_APP_WEBRTC_PEERCONNECTIONMANAGER_IMPL_H_
|
||||
#ifndef TALK_APP_WEBRTC_PEERCONNECTIONMANAGERIMPL_H_
|
||||
#define TALK_APP_WEBRTC_PEERCONNECTIONMANAGERIMPL_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "talk/base/scoped_ptr.h"
|
||||
#include "talk/app/webrtc_dev/peerconnection_dev.h"
|
||||
#include "talk/app/webrtc_dev/stream_dev.h"
|
||||
#include "talk/app/webrtc_dev/peerconnection.h"
|
||||
#include "talk/app/webrtc_dev/mediastream.h"
|
||||
#include "talk/session/phone/channelmanager.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -46,7 +46,7 @@ class PeerConnectionManagerImpl : public PeerConnectionManager {
|
||||
PeerConnectionManagerImpl(talk_base::Thread* worker_thread,
|
||||
PcNetworkManager* network_manager,
|
||||
PcPacketSocketFactory* socket_factory,
|
||||
AudioDevice* default_adm);
|
||||
AudioDeviceModule* default_adm);
|
||||
virtual ~PeerConnectionManagerImpl();
|
||||
|
||||
private:
|
||||
@ -58,7 +58,7 @@ class PeerConnectionManagerImpl : public PeerConnectionManager {
|
||||
talk_base::scoped_ptr<cricket::ChannelManager> channel_manager_;
|
||||
|
||||
// External Audio device used for audio playback.
|
||||
scoped_refptr<AudioDevice> default_adm_;
|
||||
scoped_refptr<AudioDeviceModule> default_adm_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
@ -1,72 +0,0 @@
|
||||
/*
|
||||
* 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_dev/remote_stream_dev.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
scoped_refptr<RemoteMediaStream> RemoteMediaStreamImpl::Create(
|
||||
const std::string& label) {
|
||||
// To instantiate LocalStream use
|
||||
RefCountImpl<RemoteMediaStreamImpl>* stream =
|
||||
new RefCountImpl<RemoteMediaStreamImpl>(label);
|
||||
return stream;
|
||||
}
|
||||
|
||||
RemoteMediaStreamImpl::RemoteMediaStreamImpl(const std::string& label)
|
||||
: media_stream_impl_(label) {
|
||||
}
|
||||
|
||||
// Implement MediaStream
|
||||
const std::string& RemoteMediaStreamImpl::label() {
|
||||
return media_stream_impl_.label();
|
||||
}
|
||||
|
||||
scoped_refptr<MediaStreamTrackList> RemoteMediaStreamImpl::tracks() {
|
||||
return this;
|
||||
}
|
||||
|
||||
MediaStream::ReadyState RemoteMediaStreamImpl::ready_state() {
|
||||
return media_stream_impl_.ready_state();
|
||||
}
|
||||
|
||||
// Implement MediaStreamTrackList.
|
||||
size_t RemoteMediaStreamImpl::count() {
|
||||
return tracks_.count();
|
||||
}
|
||||
|
||||
scoped_refptr<MediaStreamTrack> RemoteMediaStreamImpl::at(size_t index) {
|
||||
return tracks_.at(index);
|
||||
}
|
||||
|
||||
bool RemoteMediaStreamImpl::AddTrack(MediaStreamTrack* track) {
|
||||
tracks_.AddTrack(track);
|
||||
NotifierImpl<MediaStreamTrackList>::FireOnChanged();
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
@ -1,63 +0,0 @@
|
||||
/*
|
||||
* 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_REMOTE_STREAM_H_
|
||||
#define TALK_APP_WEBRTC_REMOTE_STREAM_H_
|
||||
|
||||
#include "talk/app/webrtc_dev/media_stream_impl_dev.h"
|
||||
#include "talk/app/webrtc_dev/stream_dev.h"
|
||||
#include "talk/base/scoped_ptr.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
/////////////////////////////////////////////
|
||||
// Remote stream
|
||||
class RemoteMediaStreamImpl
|
||||
: public RemoteMediaStream,
|
||||
public NotifierImpl<MediaStreamTrackList> {
|
||||
public:
|
||||
static scoped_refptr<RemoteMediaStream> Create(const std::string& label);
|
||||
bool AddTrack(MediaStreamTrack* track);
|
||||
|
||||
// Implement MediaStream.
|
||||
virtual const std::string& label();
|
||||
virtual scoped_refptr<MediaStreamTrackList> tracks();
|
||||
virtual ReadyState ready_state();
|
||||
|
||||
// Implement MediaStreamTrackList.
|
||||
virtual size_t count();
|
||||
virtual scoped_refptr<MediaStreamTrack> at(size_t index);
|
||||
|
||||
protected:
|
||||
explicit RemoteMediaStreamImpl(const std::string& label);
|
||||
MediaStreamImpl media_stream_impl_;
|
||||
MediaStreamTrackListImpl tracks_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // TALK_APP_WEBRTC_REMOTE_STREAM_H_
|
@ -0,0 +1,101 @@
|
||||
/*
|
||||
* 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_STREAMCOLLECTIONIMPL_H_
|
||||
#define TALK_APP_WEBRTC_STREAMCOLLECTIONIMPL_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "talk/app/webrtc_dev/peerconnection.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// Implementation of StreamCollection.
|
||||
class StreamCollectionImpl : public StreamCollection {
|
||||
public:
|
||||
static scoped_refptr<StreamCollectionImpl> Create() {
|
||||
RefCountImpl<StreamCollectionImpl>* implementation =
|
||||
new RefCountImpl<StreamCollectionImpl>();
|
||||
return implementation;
|
||||
}
|
||||
|
||||
static scoped_refptr<StreamCollectionImpl> Create(
|
||||
StreamCollectionImpl* local_streams) {
|
||||
RefCountImpl<StreamCollectionImpl>* implementation =
|
||||
new RefCountImpl<StreamCollectionImpl>(local_streams);
|
||||
return implementation;
|
||||
}
|
||||
|
||||
virtual size_t count() {
|
||||
return media_streams_.size();
|
||||
}
|
||||
|
||||
virtual MediaStream* at(size_t index) {
|
||||
return media_streams_.at(index);
|
||||
}
|
||||
|
||||
void AddStream(MediaStream* stream) {
|
||||
for (StreamVector::iterator it = media_streams_.begin();
|
||||
it != media_streams_.end(); ++it) {
|
||||
if ((*it)->label().compare(stream->label()) == 0)
|
||||
return;
|
||||
}
|
||||
media_streams_.push_back(stream);
|
||||
}
|
||||
|
||||
void RemoveStream(MediaStream* remove_stream) {
|
||||
for (StreamVector::iterator it = media_streams_.begin();
|
||||
it != media_streams_.end(); ++it) {
|
||||
if ((*it)->label().compare(remove_stream->label()) == 0) {
|
||||
media_streams_.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MediaStream* FindFirstStream(const std::string& label) {
|
||||
for (StreamVector::iterator it = media_streams_.begin();
|
||||
it != media_streams_.end(); ++it) {
|
||||
if ((*it)->label().compare(label) == 0) {
|
||||
return (*it);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
protected:
|
||||
StreamCollectionImpl() {}
|
||||
explicit StreamCollectionImpl(StreamCollectionImpl* original)
|
||||
: media_streams_(original->media_streams_) {
|
||||
}
|
||||
typedef std::vector<scoped_refptr<MediaStream> > StreamVector;
|
||||
StreamVector media_streams_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // TALK_APP_WEBRTC_STREAMCOLLECTIONIMPL_H_
|
@ -1,51 +0,0 @@
|
||||
/*
|
||||
* libjingle
|
||||
* Copyright 2004--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_dev/local_stream_dev.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
scoped_refptr<VideoDevice> VideoDevice::Create(const std::string& name,
|
||||
VideoCaptureModule* vcm) {
|
||||
RefCountImpl<VideoDevice>* device = new RefCountImpl<VideoDevice>();
|
||||
device->Initialize(name,vcm);
|
||||
return device;
|
||||
}
|
||||
|
||||
const std::string& VideoDevice::name(){
|
||||
return name_;
|
||||
}
|
||||
|
||||
VideoCaptureModule* VideoDevice::module() {
|
||||
return vcm_;
|
||||
}
|
||||
|
||||
void VideoDevice::Initialize(const std::string& name, VideoCaptureModule* vcm) {
|
||||
name_ = name;
|
||||
vcm_ = vcm;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
@ -1,45 +0,0 @@
|
||||
/*
|
||||
* libjingle
|
||||
* Copyright 2004--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_dev/local_stream_dev.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
scoped_refptr<VideoRenderer> VideoRenderer::Create(cricket::VideoRenderer* renderer) {
|
||||
RefCountImpl<VideoRenderer>* r = new RefCountImpl<VideoRenderer>();
|
||||
r->Initialize(renderer);
|
||||
return r;
|
||||
}
|
||||
|
||||
cricket::VideoRenderer* VideoRenderer::module() {
|
||||
return renderer_;
|
||||
}
|
||||
|
||||
void VideoRenderer::Initialize(cricket::VideoRenderer* renderer) {
|
||||
renderer_ = renderer;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* libjingle
|
||||
* Copyright 2011, Google Inc.
|
||||
* Copyright 2004--2011, Google Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@ -25,38 +25,34 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include "talk/app/webrtc_dev/mediastreamimpl.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "talk/app/webrtc_dev/remote_stream_dev.h"
|
||||
|
||||
static const char kStreamLabel1[] = "remote_stream_1";
|
||||
#include "talk/session/phone/videorenderer.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// Helper class to test the Observer.
|
||||
class TestObserver : public Observer {
|
||||
// VideoRendererImpl take ownership of cricket::VideoRenderer.
|
||||
class VideoRendererImpl : public VideoRenderer {
|
||||
public:
|
||||
TestObserver() : changed_(0) {}
|
||||
void OnChanged() {
|
||||
++changed_;
|
||||
explicit VideoRendererImpl(cricket::VideoRenderer* renderer)
|
||||
: renderer_(renderer) {
|
||||
}
|
||||
int NoChanged() {
|
||||
return changed_;
|
||||
virtual cricket::VideoRenderer* renderer() {
|
||||
return renderer_;
|
||||
}
|
||||
|
||||
protected:
|
||||
int changed_;
|
||||
~VideoRendererImpl() {
|
||||
delete renderer_;
|
||||
}
|
||||
private:
|
||||
cricket::VideoRenderer* renderer_;
|
||||
};
|
||||
|
||||
TEST(RemoteStreamTest, Create) {
|
||||
// Create a Remote stream.
|
||||
std::string label(kStreamLabel1);
|
||||
scoped_refptr<RemoteMediaStream> stream(RemoteMediaStreamImpl::Create(label));
|
||||
|
||||
EXPECT_EQ(stream->label().compare(label), 0);
|
||||
// Check state.
|
||||
EXPECT_EQ(stream->ready_state(), MediaStream::kInitializing);
|
||||
scoped_refptr<VideoRenderer> CreateVideoRenderer(
|
||||
cricket::VideoRenderer* renderer) {
|
||||
RefCountImpl<VideoRendererImpl>* r =
|
||||
new RefCountImpl<VideoRendererImpl>(renderer);
|
||||
return r;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
@ -0,0 +1,112 @@
|
||||
/*
|
||||
* 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_dev/videotrackimpl.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
VideoTrackImpl::VideoTrackImpl(const std::string& label, uint32 ssrc)
|
||||
: enabled_(true),
|
||||
kind_(kVideoTrackKind),
|
||||
label_(label),
|
||||
ssrc_(ssrc),
|
||||
video_device_(NULL) {
|
||||
}
|
||||
|
||||
VideoTrackImpl::VideoTrackImpl(const std::string& label,
|
||||
VideoCaptureModule* video_device)
|
||||
: enabled_(true),
|
||||
kind_(kVideoTrackKind),
|
||||
label_(label),
|
||||
ssrc_(0),
|
||||
video_device_(video_device) {
|
||||
}
|
||||
|
||||
void VideoTrackImpl::SetRenderer(VideoRenderer* renderer) {
|
||||
video_renderer_ = renderer;
|
||||
NotifierImpl<LocalVideoTrack>::FireOnChanged();
|
||||
}
|
||||
|
||||
scoped_refptr<VideoRenderer> VideoTrackImpl::GetRenderer() {
|
||||
return video_renderer_;
|
||||
}
|
||||
|
||||
// Get the VideoCapture device associated with this track.
|
||||
scoped_refptr<VideoCaptureModule> VideoTrackImpl::GetVideoCapture() {
|
||||
return video_device_.get();
|
||||
}
|
||||
|
||||
const std::string& VideoTrackImpl::kind() {
|
||||
return kind_;
|
||||
}
|
||||
|
||||
const std::string& VideoTrackImpl::label() {
|
||||
return label_;
|
||||
}
|
||||
|
||||
bool VideoTrackImpl::enabled() {
|
||||
return enabled_;
|
||||
}
|
||||
|
||||
bool VideoTrackImpl::set_enabled(bool enable) {
|
||||
bool fire_on_change = enable != enabled_;
|
||||
enabled_ = enable;
|
||||
if (fire_on_change)
|
||||
NotifierImpl<LocalVideoTrack>::FireOnChanged();
|
||||
}
|
||||
|
||||
uint32 VideoTrackImpl::ssrc() {
|
||||
return ssrc_;
|
||||
}
|
||||
|
||||
bool VideoTrackImpl::set_ssrc(uint32 ssrc) {
|
||||
ASSERT(ssrc_ == 0);
|
||||
ASSERT(ssrc != 0);
|
||||
if (ssrc_ != 0)
|
||||
return false;
|
||||
ssrc_ = ssrc;
|
||||
NotifierImpl<LocalVideoTrack>::FireOnChanged();
|
||||
return true;
|
||||
}
|
||||
|
||||
scoped_refptr<VideoTrack> VideoTrackImpl::Create(const std::string& label,
|
||||
uint32 ssrc) {
|
||||
RefCountImpl<VideoTrackImpl>* track =
|
||||
new RefCountImpl<VideoTrackImpl>(label, ssrc);
|
||||
return track;
|
||||
}
|
||||
|
||||
scoped_refptr<LocalVideoTrack> CreateLocalVideoTrack(
|
||||
const std::string& label,
|
||||
VideoCaptureModule* video_device) {
|
||||
RefCountImpl<VideoTrackImpl>* track =
|
||||
new RefCountImpl<VideoTrackImpl>(label, video_device);
|
||||
return track;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
@ -25,44 +25,51 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef TALK_APP_WEBRTC_MEDIA_STREAM_IMPL_H_
|
||||
#define TALK_APP_WEBRTC_MEDIA_STREAM_IMPL_H_
|
||||
#ifndef TALK_APP_WEBRTC_VIDEOTRACKIMPL_H_
|
||||
#define TALK_APP_WEBRTC_VIDEOTRACKIMPL_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "talk/app/webrtc_dev/notifier_impl.h"
|
||||
#include "talk/app/webrtc_dev/ref_count.h"
|
||||
#include "talk/app/webrtc_dev/mediastream.h"
|
||||
#include "talk/app/webrtc_dev/notifierimpl.h"
|
||||
#include "talk/app/webrtc_dev/scoped_refptr.h"
|
||||
#include "talk/app/webrtc_dev/stream_dev.h"
|
||||
|
||||
#ifdef WEBRTC_RELATIVE_PATH
|
||||
#include "modules/video_capture/main/interface/video_capture.h"
|
||||
#else
|
||||
#include "third_party/webrtc/files/include/video_capture.h"
|
||||
#endif
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// MediaStreamImpl- help class for implementing the MediaStream interface.
|
||||
class MediaStreamImpl {
|
||||
class VideoTrackImpl : public NotifierImpl<LocalVideoTrack> {
|
||||
public:
|
||||
explicit MediaStreamImpl(const std::string& label);
|
||||
static scoped_refptr<VideoTrack> Create(const std::string& label,
|
||||
uint32 ssrc);
|
||||
virtual scoped_refptr<VideoCaptureModule> GetVideoCapture();
|
||||
virtual void SetRenderer(VideoRenderer* renderer);
|
||||
scoped_refptr<VideoRenderer> GetRenderer();
|
||||
|
||||
// Implement MediaStream
|
||||
const std::string& label() const;
|
||||
MediaStream::ReadyState ready_state() const;
|
||||
virtual const std::string& kind();
|
||||
virtual const std::string& label();
|
||||
virtual uint32 ssrc();
|
||||
virtual bool enabled();
|
||||
virtual bool set_enabled(bool enable);
|
||||
virtual bool set_ssrc(uint32 ssrc);
|
||||
|
||||
protected:
|
||||
VideoTrackImpl(const std::string& label, uint32 ssrc);
|
||||
VideoTrackImpl(const std::string& label, VideoCaptureModule* video_device);
|
||||
|
||||
private:
|
||||
bool enabled_;
|
||||
std::string kind_;
|
||||
std::string label_;
|
||||
MediaStream::ReadyState ready_state_;
|
||||
};
|
||||
|
||||
class MediaStreamTrackListImpl {
|
||||
public:
|
||||
MediaStreamTrackListImpl();
|
||||
// Implement MediaStreamTrackList.
|
||||
bool AddTrack(MediaStreamTrack* track);
|
||||
size_t count() const;
|
||||
scoped_refptr<MediaStreamTrack> at(size_t index) const;
|
||||
protected:
|
||||
std::vector<scoped_refptr<MediaStreamTrack> > tracks_;
|
||||
uint32 ssrc_;
|
||||
scoped_refptr<VideoCaptureModule> video_device_;
|
||||
scoped_refptr<VideoRenderer> video_renderer_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // TALK_APP_WEBRTC_MEDIA_STREAM_IMPL_H_
|
||||
#endif // TALK_APP_WEBRTC_VIDEOTRACKIMPL_H_
|
@ -1,153 +0,0 @@
|
||||
/*
|
||||
* 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_dev/webrtc_mediaengine.h"
|
||||
|
||||
#include "talk/base/logging.h"
|
||||
#include "talk/session/phone/webrtcvoiceengine.h"
|
||||
#include "talk/session/phone/webrtcvideoengine.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
WebRtcMediaEngine::WebRtcMediaEngine()
|
||||
: voice_(new cricket::WebRtcVoiceEngine()),
|
||||
video_(new cricket::WebRtcVideoEngine()) {
|
||||
}
|
||||
|
||||
WebRtcMediaEngine::WebRtcMediaEngine(webrtc::AudioDeviceModule* adm,
|
||||
webrtc::AudioDeviceModule* adm_sc, webrtc::VideoCaptureModule* vcm)
|
||||
: voice_(new cricket::WebRtcVoiceEngine(adm, adm_sc)),
|
||||
video_(new cricket::WebRtcVideoEngine(voice_, vcm)) {
|
||||
}
|
||||
|
||||
WebRtcMediaEngine::~WebRtcMediaEngine() {
|
||||
delete video_;
|
||||
delete voice_;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
@ -1,86 +0,0 @@
|
||||
/*
|
||||
* 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_MEDIA_ENGINE_H_
|
||||
#define TALK_APP_WEBRTC_MEDIA_ENGINE_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "talk/session/phone/mediaengine.h"
|
||||
|
||||
namespace cricket {
|
||||
class WebRtcVideoEngine;
|
||||
class WebRtcVoiceEngine;
|
||||
}
|
||||
|
||||
namespace webrtc {
|
||||
class AudioDeviceModule;
|
||||
class VideoCaptureModule;
|
||||
|
||||
// TODO(perkj) Write comments. Why do we need to override cricket::MediaEngine.
|
||||
class WebRtcMediaEngine : public cricket::MediaEngine {
|
||||
public:
|
||||
WebRtcMediaEngine();
|
||||
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:
|
||||
cricket::WebRtcVoiceEngine* voice_;
|
||||
cricket::WebRtcVideoEngine* video_;
|
||||
};
|
||||
|
||||
} // namespace WebRtcMediaEngine
|
||||
|
||||
#endif // TALK_APP_WEBRTC_MEDIA_ENGINE_H_
|
@ -27,7 +27,7 @@
|
||||
|
||||
#include "talk/app/webrtc/webrtcsessionchannel.h"
|
||||
|
||||
#include "talk/app/webrtc/stream_dev.h"
|
||||
#include "talk/app/webrtc/mediastream.h"
|
||||
#include "talk/app/webrtc/webrtc_json_dev.h"
|
||||
#include "talk/base/logging.h"
|
||||
#include "talk/base/thread.h"
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "talk/app/webrtc/stream_dev.h"
|
||||
#include "talk/app/webrtc/mediastream.h"
|
||||
#include "talk/base/messagehandler.h"
|
||||
#include "talk/base/scoped_ptr.h"
|
||||
#include "talk/base/sigslot.h"
|
||||
|
Loading…
x
Reference in New Issue
Block a user