Temp hook in WebRtcSession to VideoChannel.
Review URL: http://webrtc-codereview.appspot.com/195001 git-svn-id: http://webrtc.googlecode.com/svn/trunk@689 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
4b6f747373
commit
bafca109db
@ -522,6 +522,7 @@
|
||||
'<(libjingle_orig)/source/talk/p2p/client/basicportallocator.h',
|
||||
'<(libjingle_orig)/source/talk/p2p/client/httpportallocator.cc',
|
||||
'<(libjingle_orig)/source/talk/p2p/client/httpportallocator.h',
|
||||
'<(libjingle_mods)/source/talk/p2p/client/fakeportallocator.h',
|
||||
'<(libjingle_orig)/source/talk/p2p/client/sessionmanagertask.h',
|
||||
'<(libjingle_orig)/source/talk/p2p/client/sessionsendtask.h',
|
||||
'<(libjingle_orig)/source/talk/p2p/client/socketmonitor.cc',
|
||||
@ -530,8 +531,8 @@
|
||||
'<(libjingle_orig)/source/talk/session/phone/audiomonitor.h',
|
||||
'<(libjingle_orig)/source/talk/session/phone/call.cc',
|
||||
'<(libjingle_orig)/source/talk/session/phone/call.h',
|
||||
'<(libjingle_orig)/source/talk/session/phone/channel.cc',
|
||||
'<(libjingle_orig)/source/talk/session/phone/channel.h',
|
||||
'<(libjingle_mods)/source/talk/session/phone/channel.cc',
|
||||
'<(libjingle_mods)/source/talk/session/phone/channel.h',
|
||||
'<(libjingle_orig)/source/talk/session/phone/channelmanager.cc',
|
||||
'<(libjingle_orig)/source/talk/session/phone/channelmanager.h',
|
||||
'<(libjingle_orig)/source/talk/session/phone/codec.cc',
|
||||
@ -757,7 +758,7 @@
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/peerconnectionmanager_unittest.cc',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/peerconnectionmessage_unittest.cc',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/peerconnectionsignaling_unittest.cc',
|
||||
#'<(libjingle_mods)/source/talk/app/webrtc_dev/webrtcsession_unittest.cc',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/webrtcsession_unittest.cc',
|
||||
],
|
||||
} , {
|
||||
'type': 'none',
|
||||
|
@ -216,8 +216,12 @@ void WebRtcSession::OnTransportCandidatesReady(
|
||||
if (local_candidates_.size() == kAllowedCandidates)
|
||||
return;
|
||||
InsertTransportCandidates(candidates);
|
||||
if (local_candidates_.size() == kAllowedCandidates)
|
||||
pc_signaling_->Initialize(candidates);
|
||||
if (local_candidates_.size() == kAllowedCandidates) {
|
||||
pc_signaling_->Initialize(local_candidates_);
|
||||
// TODO(mallinath) - Remove signal when a new interface added for
|
||||
// PC signaling.
|
||||
SignalCandidatesReady(this, local_candidates_);
|
||||
}
|
||||
}
|
||||
|
||||
void WebRtcSession::OnTransportChannelGone(cricket::Transport* transport) {
|
||||
@ -303,12 +307,31 @@ bool WebRtcSession::GetVideoSourceParamInfo(
|
||||
|
||||
void WebRtcSession::ProcessLocalMediaChanges(
|
||||
const cricket::SessionDescription* sdesc) {
|
||||
//TODO(mallinath) - Handling of local media stream changes in active session
|
||||
// TODO(mallinath) - Handling of local media stream changes in active session
|
||||
}
|
||||
|
||||
void WebRtcSession::ProcessRemoteMediaChanges(
|
||||
const cricket::SessionDescription* sdesc) {
|
||||
//TODO(mallinath) - Handling of remote media stream changes in active session
|
||||
// TODO(mallinath) - Handling of remote media stream changes in active session
|
||||
}
|
||||
|
||||
void WebRtcSession::SetCaptureDevice(uint32 ssrc,
|
||||
VideoCaptureModule* camera) {
|
||||
// should be called from a signaling thread
|
||||
ASSERT(signaling_thread()->IsCurrent());
|
||||
video_channel_->SetCaptureDevice(ssrc, camera);
|
||||
}
|
||||
|
||||
void WebRtcSession::SetLocalRenderer(uint32 ssrc,
|
||||
cricket::VideoRenderer* renderer) {
|
||||
ASSERT(signaling_thread()->IsCurrent());
|
||||
video_channel_->SetLocalRenderer(ssrc, renderer);
|
||||
}
|
||||
|
||||
void WebRtcSession::SetRemoteRenderer(uint32 ssrc,
|
||||
cricket::VideoRenderer* renderer) {
|
||||
ASSERT(signaling_thread()->IsCurrent());
|
||||
video_channel_->SetRenderer(ssrc, renderer);
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -72,18 +72,21 @@ class WebRtcSession : public cricket::BaseSession,
|
||||
// Generic error message callback from WebRtcSession.
|
||||
// TODO(mallinath) - It may be necessary to supply error code as well.
|
||||
sigslot::signal0<> SignalError;
|
||||
// This signal added for testing. Shouldn't be registered by other
|
||||
// objects.
|
||||
sigslot::signal2<WebRtcSession*,
|
||||
cricket::Candidates&> SignalCandidatesReady;
|
||||
|
||||
void ProcessSessionUpdate(const cricket::SessionDescription* local_desc,
|
||||
const cricket::SessionDescription* remote_desc);
|
||||
|
||||
private:
|
||||
// Implements MediaProviderInterface.
|
||||
// TODO(mallinath): Add proper implementation.
|
||||
virtual void SetCaptureDevice(uint32 ssrc, VideoCaptureModule* camera) {};
|
||||
virtual void SetCaptureDevice(uint32 ssrc, VideoCaptureModule* camera);
|
||||
virtual void SetLocalRenderer(uint32 ssrc,
|
||||
cricket::VideoRenderer* renderer) {};
|
||||
cricket::VideoRenderer* renderer);
|
||||
virtual void SetRemoteRenderer(uint32 ssrc,
|
||||
cricket::VideoRenderer* renderer) {};
|
||||
cricket::VideoRenderer* renderer);
|
||||
|
||||
// Callback handling from PeerConnectionSignaling
|
||||
void OnSignalUpdateSessionDescription(
|
||||
@ -95,8 +98,9 @@ class WebRtcSession : public cricket::BaseSession,
|
||||
virtual void OnTransportRequestSignaling(cricket::Transport* transport);
|
||||
virtual void OnTransportConnecting(cricket::Transport* transport);
|
||||
virtual void OnTransportWritable(cricket::Transport* transport);
|
||||
virtual void OnTransportCandidatesReady(cricket::Transport* transport,
|
||||
const cricket::Candidates& candidates);
|
||||
virtual void OnTransportCandidatesReady(
|
||||
cricket::Transport* transport,
|
||||
const cricket::Candidates& candidates);
|
||||
virtual void OnTransportChannelGone(cricket::Transport* transport);
|
||||
|
||||
// Creates channels for voice and video.
|
||||
|
@ -32,12 +32,10 @@
|
||||
#include "talk/session/phone/channelmanager.h"
|
||||
#include "talk/p2p/client/fakeportallocator.h"
|
||||
|
||||
class MockPeerConnectionSignaling {
|
||||
|
||||
};
|
||||
|
||||
class WebRtcSessionTest : public testing::Test {
|
||||
class WebRtcSessionTest : public testing::Test,
|
||||
public sigslot::has_slots<> {
|
||||
public:
|
||||
cricket::MediaSessionDescriptionFactory* media_factory_;
|
||||
WebRtcSessionTest() {
|
||||
}
|
||||
|
||||
@ -53,16 +51,26 @@ class WebRtcSessionTest : public testing::Test {
|
||||
pc_signaling_.reset(
|
||||
new webrtc::PeerConnectionSignaling(channel_manager_.get(),
|
||||
signaling_thread_));
|
||||
media_factory_ =
|
||||
new cricket::MediaSessionDescriptionFactory(channel_manager_.get());
|
||||
}
|
||||
|
||||
bool InitializeSession() {
|
||||
return session_.get()->Initialize();
|
||||
}
|
||||
|
||||
bool CheckChannels() {
|
||||
return (session_->voice_channel() != NULL &&
|
||||
session_->video_channel() != NULL);
|
||||
}
|
||||
|
||||
bool CheckTransportChannels() {
|
||||
EXPECT_TRUE(session_->GetChannel(cricket::CN_AUDIO, "rtp") != NULL);
|
||||
EXPECT_TRUE(session_->GetChannel(cricket::CN_AUDIO, "rtcp") != NULL);
|
||||
EXPECT_TRUE(session_->GetChannel(cricket::CN_VIDEO, "video_rtp") != NULL);
|
||||
EXPECT_TRUE(session_->GetChannel(cricket::CN_VIDEO, "video_rtcp") != NULL);
|
||||
}
|
||||
|
||||
void Init() {
|
||||
ASSERT_TRUE(channel_manager_.get() != NULL);
|
||||
ASSERT_TRUE(session_.get() == NULL);
|
||||
@ -70,11 +78,38 @@ class WebRtcSessionTest : public testing::Test {
|
||||
session_.reset(new webrtc::WebRtcSession(
|
||||
channel_manager_.get(), worker_thread_, signaling_thread_,
|
||||
port_allocator_.get(), pc_signaling_.get()));
|
||||
session_->SignalCandidatesReady.connect(
|
||||
this, &WebRtcSessionTest::OnCandidatesReady);
|
||||
EXPECT_TRUE(InitializeSession());
|
||||
EXPECT_TRUE(CheckChannels());
|
||||
}
|
||||
void OnCandidatesReady(webrtc::WebRtcSession* session,
|
||||
cricket::Candidates& candidates) {
|
||||
for (cricket::Candidates::iterator iter = candidates.begin();
|
||||
iter != candidates.end(); ++iter) {
|
||||
local_candidates_.push_back(*iter);
|
||||
}
|
||||
}
|
||||
cricket::Candidates& local_candidates() {
|
||||
return local_candidates_;
|
||||
}
|
||||
cricket::SessionDescription* CreateOffer(bool video) {
|
||||
cricket::MediaSessionOptions options;
|
||||
options.is_video = true;
|
||||
// Source params not set
|
||||
cricket::SessionDescription* sdp = media_factory_->CreateOffer(options);
|
||||
return sdp;
|
||||
}
|
||||
cricket::SessionDescription* CreateAnswer(
|
||||
cricket::SessionDescription* offer, bool video) {
|
||||
cricket::MediaSessionOptions options;
|
||||
options.is_video = video;
|
||||
cricket::SessionDescription* sdp =
|
||||
media_factory_->CreateAnswer(offer, options);
|
||||
}
|
||||
|
||||
private:
|
||||
cricket::Candidates local_candidates_;
|
||||
cricket::Candidates remote_candidates_;
|
||||
talk_base::Thread* signaling_thread_;
|
||||
talk_base::Thread* worker_thread_;
|
||||
talk_base::scoped_ptr<cricket::PortAllocator> port_allocator_;
|
||||
@ -85,4 +120,9 @@ class WebRtcSessionTest : public testing::Test {
|
||||
|
||||
TEST_F(WebRtcSessionTest, TestInitialize) {
|
||||
WebRtcSessionTest::Init();
|
||||
EXPECT_TRUE(CheckChannels());
|
||||
CheckTransportChannels();
|
||||
talk_base::Thread::Current()->ProcessMessages(1000);
|
||||
EXPECT_EQ(4u, local_candidates().size());
|
||||
}
|
||||
|
||||
|
1296
third_party_mods/libjingle/source/talk/session/phone/channel.cc
Normal file
1296
third_party_mods/libjingle/source/talk/session/phone/channel.cc
Normal file
File diff suppressed because it is too large
Load Diff
510
third_party_mods/libjingle/source/talk/session/phone/channel.h
Normal file
510
third_party_mods/libjingle/source/talk/session/phone/channel.h
Normal file
@ -0,0 +1,510 @@
|
||||
/*
|
||||
* libjingle
|
||||
* Copyright 2004--2007, 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_SESSION_PHONE_CHANNEL_H_
|
||||
#define TALK_SESSION_PHONE_CHANNEL_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "talk/base/asyncudpsocket.h"
|
||||
#include "talk/base/criticalsection.h"
|
||||
#include "talk/base/network.h"
|
||||
#include "talk/base/sigslot.h"
|
||||
#include "talk/p2p/client/socketmonitor.h"
|
||||
#include "talk/p2p/base/session.h"
|
||||
#include "talk/session/phone/audiomonitor.h"
|
||||
#include "talk/session/phone/mediachannel.h"
|
||||
#include "talk/session/phone/mediaengine.h"
|
||||
#include "talk/session/phone/mediamonitor.h"
|
||||
#include "talk/session/phone/rtcpmuxfilter.h"
|
||||
#include "talk/session/phone/srtpfilter.h"
|
||||
|
||||
namespace webrtc {
|
||||
class VideoCaptureModule;
|
||||
}
|
||||
|
||||
namespace cricket {
|
||||
|
||||
class MediaContentDescription;
|
||||
struct CryptoParams;
|
||||
|
||||
enum {
|
||||
MSG_ENABLE = 1,
|
||||
MSG_DISABLE = 2,
|
||||
MSG_MUTE = 3,
|
||||
MSG_UNMUTE = 4,
|
||||
MSG_SETREMOTECONTENT = 5,
|
||||
MSG_SETLOCALCONTENT = 6,
|
||||
MSG_EARLYMEDIATIMEOUT = 8,
|
||||
MSG_PRESSDTMF = 9,
|
||||
MSG_SETRENDERER = 10,
|
||||
MSG_ADDSTREAM = 11,
|
||||
MSG_REMOVESTREAM = 12,
|
||||
MSG_SETRINGBACKTONE = 13,
|
||||
MSG_PLAYRINGBACKTONE = 14,
|
||||
MSG_SETMAXSENDBANDWIDTH = 15,
|
||||
MSG_SETRTCPCNAME = 18,
|
||||
MSG_SENDINTRAFRAME = 19,
|
||||
MSG_REQUESTINTRAFRAME = 20,
|
||||
MSG_RTPPACKET = 22,
|
||||
MSG_RTCPPACKET = 23,
|
||||
MSG_CHANNEL_ERROR = 24,
|
||||
MSG_ENABLECPUADAPTATION = 25,
|
||||
MSG_DISABLECPUADAPTATION = 26,
|
||||
MSG_SCALEVOLUME = 27
|
||||
};
|
||||
|
||||
// BaseChannel contains logic common to voice and video, including
|
||||
// enable/mute, marshaling calls to a worker thread, and
|
||||
// connection and media monitors.
|
||||
class BaseChannel
|
||||
: public talk_base::MessageHandler, public sigslot::has_slots<>,
|
||||
public MediaChannel::NetworkInterface {
|
||||
public:
|
||||
BaseChannel(talk_base::Thread* thread, MediaEngineInterface* media_engine,
|
||||
MediaChannel* channel, BaseSession* session,
|
||||
const std::string& content_name,
|
||||
TransportChannel* transport_channel);
|
||||
virtual ~BaseChannel();
|
||||
|
||||
talk_base::Thread* worker_thread() const { return worker_thread_; }
|
||||
BaseSession* session() const { return session_; }
|
||||
const std::string& content_name() { return content_name_; }
|
||||
TransportChannel* transport_channel() const {
|
||||
return transport_channel_;
|
||||
}
|
||||
TransportChannel* rtcp_transport_channel() const {
|
||||
return rtcp_transport_channel_;
|
||||
}
|
||||
bool enabled() const { return enabled_; }
|
||||
bool secure() const { return srtp_filter_.IsActive(); }
|
||||
|
||||
// Channel control
|
||||
bool SetRtcpCName(const std::string& cname);
|
||||
bool SetLocalContent(const MediaContentDescription* content,
|
||||
ContentAction action);
|
||||
bool SetRemoteContent(const MediaContentDescription* content,
|
||||
ContentAction action);
|
||||
bool SetMaxSendBandwidth(int max_bandwidth);
|
||||
|
||||
bool Enable(bool enable);
|
||||
bool Mute(bool mute);
|
||||
|
||||
// Multiplexing
|
||||
bool RemoveStream(uint32 ssrc);
|
||||
|
||||
// Monitoring
|
||||
void StartConnectionMonitor(int cms);
|
||||
void StopConnectionMonitor();
|
||||
|
||||
void set_srtp_signal_silent_time(uint32 silent_time) {
|
||||
srtp_filter_.set_signal_silent_time(silent_time);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void RegisterSendSink(T* sink,
|
||||
void (T::*OnPacket)(const void*, size_t, bool)) {
|
||||
talk_base::CritScope cs(&signal_send_packet_cs_);
|
||||
SignalSendPacket.disconnect(sink);
|
||||
SignalSendPacket.connect(sink, OnPacket);
|
||||
}
|
||||
|
||||
void UnregisterSendSink(sigslot::has_slots<>* sink) {
|
||||
talk_base::CritScope cs(&signal_send_packet_cs_);
|
||||
SignalSendPacket.disconnect(sink);
|
||||
}
|
||||
|
||||
bool HasSendSinks() {
|
||||
talk_base::CritScope cs(&signal_send_packet_cs_);
|
||||
return !SignalSendPacket.is_empty();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void RegisterRecvSink(T* sink,
|
||||
void (T::*OnPacket)(const void*, size_t, bool)) {
|
||||
talk_base::CritScope cs(&signal_recv_packet_cs_);
|
||||
SignalRecvPacket.disconnect(sink);
|
||||
SignalRecvPacket.connect(sink, OnPacket);
|
||||
}
|
||||
|
||||
void UnregisterRecvSink(sigslot::has_slots<>* sink) {
|
||||
talk_base::CritScope cs(&signal_recv_packet_cs_);
|
||||
SignalRecvPacket.disconnect(sink);
|
||||
}
|
||||
|
||||
bool HasRecvSinks() {
|
||||
talk_base::CritScope cs(&signal_recv_packet_cs_);
|
||||
return !SignalRecvPacket.is_empty();
|
||||
}
|
||||
|
||||
protected:
|
||||
MediaEngineInterface* media_engine() const { return media_engine_; }
|
||||
virtual MediaChannel* media_channel() const { return media_channel_; }
|
||||
void set_rtcp_transport_channel(TransportChannel* transport);
|
||||
bool writable() const { return writable_; }
|
||||
bool was_ever_writable() const { return was_ever_writable_; }
|
||||
bool has_local_content() const { return has_local_content_; }
|
||||
bool has_remote_content() const { return has_remote_content_; }
|
||||
void set_has_local_content(bool has) { has_local_content_ = has; }
|
||||
void set_has_remote_content(bool has) { has_remote_content_ = has; }
|
||||
bool muted() const { return muted_; }
|
||||
talk_base::Thread* signaling_thread() { return session_->signaling_thread(); }
|
||||
SrtpFilter* srtp_filter() { return &srtp_filter_; }
|
||||
|
||||
void Send(uint32 id, talk_base::MessageData *pdata = NULL);
|
||||
void Post(uint32 id, talk_base::MessageData *pdata = NULL);
|
||||
void PostDelayed(int cmsDelay, uint32 id = 0,
|
||||
talk_base::MessageData *pdata = NULL);
|
||||
void Clear(uint32 id = talk_base::MQID_ANY,
|
||||
talk_base::MessageList* removed = NULL);
|
||||
void FlushRtcpMessages();
|
||||
|
||||
// NetworkInterface implementation, called by MediaEngine
|
||||
virtual bool SendPacket(talk_base::Buffer* packet);
|
||||
virtual bool SendRtcp(talk_base::Buffer* packet);
|
||||
virtual int SetOption(SocketType type, talk_base::Socket::Option o, int val);
|
||||
|
||||
// From TransportChannel
|
||||
void OnWritableState(TransportChannel* channel);
|
||||
virtual void OnChannelRead(TransportChannel* channel, const char* data,
|
||||
size_t len);
|
||||
|
||||
bool PacketIsRtcp(const TransportChannel* channel, const char* data,
|
||||
size_t len);
|
||||
bool SendPacket(bool rtcp, talk_base::Buffer* packet);
|
||||
void HandlePacket(bool rtcp, talk_base::Buffer* packet);
|
||||
|
||||
// Setting the send codec based on the remote description.
|
||||
void OnSessionState(BaseSession* session, BaseSession::State state);
|
||||
void OnRemoteDescriptionUpdate(BaseSession* session);
|
||||
|
||||
void EnableMedia_w();
|
||||
void DisableMedia_w();
|
||||
void MuteMedia_w();
|
||||
void UnmuteMedia_w();
|
||||
void ChannelWritable_w();
|
||||
void ChannelNotWritable_w();
|
||||
|
||||
struct StreamMessageData : public talk_base::MessageData {
|
||||
StreamMessageData(uint32 s1, uint32 s2) : ssrc1(s1), ssrc2(s2) {}
|
||||
uint32 ssrc1;
|
||||
uint32 ssrc2;
|
||||
};
|
||||
virtual void RemoveStream_w(uint32 ssrc) = 0;
|
||||
|
||||
virtual void ChangeState() = 0;
|
||||
|
||||
struct SetRtcpCNameData : public talk_base::MessageData {
|
||||
explicit SetRtcpCNameData(const std::string& cname)
|
||||
: cname(cname), result(false) {}
|
||||
std::string cname;
|
||||
bool result;
|
||||
};
|
||||
bool SetRtcpCName_w(const std::string& cname);
|
||||
|
||||
struct SetContentData : public talk_base::MessageData {
|
||||
SetContentData(const MediaContentDescription* content,
|
||||
ContentAction action)
|
||||
: content(content), action(action), result(false) {}
|
||||
const MediaContentDescription* content;
|
||||
ContentAction action;
|
||||
bool result;
|
||||
};
|
||||
|
||||
// Gets the content appropriate to the channel (audio or video).
|
||||
virtual const MediaContentDescription* GetFirstContent(
|
||||
const SessionDescription* sdesc) = 0;
|
||||
virtual bool SetLocalContent_w(const MediaContentDescription* content,
|
||||
ContentAction action) = 0;
|
||||
virtual bool SetRemoteContent_w(const MediaContentDescription* content,
|
||||
ContentAction action) = 0;
|
||||
|
||||
bool SetSrtp_w(const std::vector<CryptoParams>& params, ContentAction action,
|
||||
ContentSource src);
|
||||
bool SetRtcpMux_w(bool enable, ContentAction action, ContentSource src);
|
||||
|
||||
struct SetBandwidthData : public talk_base::MessageData {
|
||||
explicit SetBandwidthData(int value) : value(value), result(false) {}
|
||||
int value;
|
||||
bool result;
|
||||
};
|
||||
bool SetMaxSendBandwidth_w(int max_bandwidth);
|
||||
|
||||
// From MessageHandler
|
||||
virtual void OnMessage(talk_base::Message *pmsg);
|
||||
|
||||
// Handled in derived classes
|
||||
virtual void OnConnectionMonitorUpdate(SocketMonitor *monitor,
|
||||
const std::vector<ConnectionInfo> &infos) = 0;
|
||||
|
||||
private:
|
||||
sigslot::signal3<const void*, size_t, bool> SignalSendPacket;
|
||||
sigslot::signal3<const void*, size_t, bool> SignalRecvPacket;
|
||||
talk_base::CriticalSection signal_send_packet_cs_;
|
||||
talk_base::CriticalSection signal_recv_packet_cs_;
|
||||
|
||||
talk_base::Thread *worker_thread_;
|
||||
MediaEngineInterface *media_engine_;
|
||||
BaseSession *session_;
|
||||
MediaChannel *media_channel_;
|
||||
|
||||
std::string content_name_;
|
||||
TransportChannel *transport_channel_;
|
||||
TransportChannel *rtcp_transport_channel_;
|
||||
SrtpFilter srtp_filter_;
|
||||
RtcpMuxFilter rtcp_mux_filter_;
|
||||
talk_base::scoped_ptr<SocketMonitor> socket_monitor_;
|
||||
bool enabled_;
|
||||
bool writable_;
|
||||
bool was_ever_writable_;
|
||||
bool has_local_content_;
|
||||
bool has_remote_content_;
|
||||
bool muted_;
|
||||
};
|
||||
|
||||
// VoiceChannel is a specialization that adds support for early media, DTMF,
|
||||
// and input/output level monitoring.
|
||||
class VoiceChannel : public BaseChannel {
|
||||
public:
|
||||
VoiceChannel(talk_base::Thread *thread, MediaEngineInterface *media_engine,
|
||||
VoiceMediaChannel *channel, BaseSession *session,
|
||||
const std::string& content_name, bool rtcp);
|
||||
~VoiceChannel();
|
||||
|
||||
// downcasts a MediaChannel
|
||||
virtual VoiceMediaChannel* media_channel() const {
|
||||
return static_cast<VoiceMediaChannel*>(BaseChannel::media_channel());
|
||||
}
|
||||
|
||||
// Add an incoming stream with the specified SSRC.
|
||||
bool AddStream(uint32 ssrc);
|
||||
|
||||
bool SetRingbackTone(const void* buf, int len);
|
||||
void SetEarlyMedia(bool enable);
|
||||
// This signal is emitted when we have gone a period of time without
|
||||
// receiving early media. When received, a UI should start playing its
|
||||
// own ringing sound
|
||||
sigslot::signal1<VoiceChannel*> SignalEarlyMediaTimeout;
|
||||
|
||||
bool PlayRingbackTone(uint32 ssrc, bool play, bool loop);
|
||||
bool PressDTMF(int digit, bool playout);
|
||||
bool SetOutputScaling(uint32 ssrc, double left, double right);
|
||||
|
||||
// Monitoring functions
|
||||
sigslot::signal2<VoiceChannel*, const std::vector<ConnectionInfo> &>
|
||||
SignalConnectionMonitor;
|
||||
|
||||
void StartMediaMonitor(int cms);
|
||||
void StopMediaMonitor();
|
||||
sigslot::signal2<VoiceChannel*, const VoiceMediaInfo&> SignalMediaMonitor;
|
||||
|
||||
void StartAudioMonitor(int cms);
|
||||
void StopAudioMonitor();
|
||||
bool IsAudioMonitorRunning() const;
|
||||
sigslot::signal2<VoiceChannel*, const AudioInfo&> SignalAudioMonitor;
|
||||
|
||||
int GetInputLevel_w();
|
||||
int GetOutputLevel_w();
|
||||
void GetActiveStreams_w(AudioInfo::StreamList* actives);
|
||||
|
||||
// Signal errors from VoiceMediaChannel. Arguments are:
|
||||
// ssrc(uint32), and error(VoiceMediaChannel::Error).
|
||||
sigslot::signal3<VoiceChannel*, uint32, VoiceMediaChannel::Error>
|
||||
SignalMediaError;
|
||||
|
||||
private:
|
||||
struct SetRingbackToneMessageData : public talk_base::MessageData {
|
||||
SetRingbackToneMessageData(const void* b, int l)
|
||||
: buf(b),
|
||||
len(l),
|
||||
result(false) {
|
||||
}
|
||||
const void* buf;
|
||||
int len;
|
||||
bool result;
|
||||
};
|
||||
struct PlayRingbackToneMessageData : public talk_base::MessageData {
|
||||
PlayRingbackToneMessageData(uint32 s, bool p, bool l)
|
||||
: ssrc(s),
|
||||
play(p),
|
||||
loop(l),
|
||||
result(false) {
|
||||
}
|
||||
uint32 ssrc;
|
||||
bool play;
|
||||
bool loop;
|
||||
bool result;
|
||||
};
|
||||
struct DtmfMessageData : public talk_base::MessageData {
|
||||
DtmfMessageData(int d, bool p)
|
||||
: digit(d),
|
||||
playout(p),
|
||||
result(false) {
|
||||
}
|
||||
int digit;
|
||||
bool playout;
|
||||
bool result;
|
||||
};
|
||||
struct ScaleVolumeMessageData : public talk_base::MessageData {
|
||||
ScaleVolumeMessageData(uint32 s, double l, double r)
|
||||
: ssrc(s),
|
||||
left(l),
|
||||
right(r),
|
||||
result(false) {
|
||||
}
|
||||
uint32 ssrc;
|
||||
double left;
|
||||
double right;
|
||||
bool result;
|
||||
};
|
||||
|
||||
// overrides from BaseChannel
|
||||
virtual void OnChannelRead(TransportChannel* channel,
|
||||
const char *data, size_t len);
|
||||
virtual void ChangeState();
|
||||
virtual const MediaContentDescription* GetFirstContent(
|
||||
const SessionDescription* sdesc);
|
||||
virtual bool SetLocalContent_w(const MediaContentDescription* content,
|
||||
ContentAction action);
|
||||
virtual bool SetRemoteContent_w(const MediaContentDescription* content,
|
||||
ContentAction action);
|
||||
|
||||
void AddStream_w(uint32 ssrc);
|
||||
void RemoveStream_w(uint32 ssrc);
|
||||
|
||||
bool SetRingbackTone_w(const void* buf, int len);
|
||||
bool PlayRingbackTone_w(uint32 ssrc, bool play, bool loop);
|
||||
void HandleEarlyMediaTimeout();
|
||||
bool PressDTMF_w(int digit, bool playout);
|
||||
bool SetOutputScaling_w(uint32 ssrc, double left, double right);
|
||||
|
||||
virtual void OnMessage(talk_base::Message *pmsg);
|
||||
virtual void OnConnectionMonitorUpdate(
|
||||
SocketMonitor *monitor, const std::vector<ConnectionInfo> &infos);
|
||||
virtual void OnMediaMonitorUpdate(
|
||||
VoiceMediaChannel *media_channel, const VoiceMediaInfo& info);
|
||||
void OnAudioMonitorUpdate(AudioMonitor *monitor, const AudioInfo& info);
|
||||
void OnVoiceChannelError(uint32 ssrc, VoiceMediaChannel::Error error);
|
||||
void SendLastMediaError();
|
||||
void OnSrtpError(uint32 ssrc, SrtpFilter::Mode mode, SrtpFilter::Error error);
|
||||
|
||||
static const int kEarlyMediaTimeout = 1000;
|
||||
bool received_media_;
|
||||
talk_base::scoped_ptr<VoiceMediaMonitor> media_monitor_;
|
||||
talk_base::scoped_ptr<AudioMonitor> audio_monitor_;
|
||||
};
|
||||
|
||||
// VideoChannel is a specialization for video.
|
||||
class VideoChannel : public BaseChannel {
|
||||
public:
|
||||
VideoChannel(talk_base::Thread *thread, MediaEngineInterface *media_engine,
|
||||
VideoMediaChannel *channel, BaseSession *session,
|
||||
const std::string& content_name, bool rtcp,
|
||||
VoiceChannel *voice_channel);
|
||||
~VideoChannel();
|
||||
|
||||
// downcasts a MediaChannel
|
||||
virtual VideoMediaChannel* media_channel() const {
|
||||
return static_cast<VideoMediaChannel*>(BaseChannel::media_channel());
|
||||
}
|
||||
|
||||
// Add an incoming stream with the specified SSRC.
|
||||
bool AddStream(uint32 ssrc, uint32 voice_ssrc);
|
||||
|
||||
bool SetRenderer(uint32 ssrc, VideoRenderer* renderer);
|
||||
|
||||
|
||||
sigslot::signal2<VideoChannel*, const std::vector<ConnectionInfo> &>
|
||||
SignalConnectionMonitor;
|
||||
|
||||
void StartMediaMonitor(int cms);
|
||||
void StopMediaMonitor();
|
||||
sigslot::signal2<VideoChannel*, const VideoMediaInfo&> SignalMediaMonitor;
|
||||
|
||||
bool SendIntraFrame();
|
||||
bool RequestIntraFrame();
|
||||
void EnableCpuAdaptation(bool enable);
|
||||
|
||||
sigslot::signal3<VideoChannel*, uint32, VideoMediaChannel::Error>
|
||||
SignalMediaError;
|
||||
|
||||
void SetCaptureDevice(uint32 ssrc, webrtc::VideoCaptureModule* camera);
|
||||
void SetLocalRenderer(uint32 ssrc, VideoRenderer* renderer);
|
||||
|
||||
private:
|
||||
// overrides from BaseChannel
|
||||
virtual void ChangeState();
|
||||
virtual const MediaContentDescription* GetFirstContent(
|
||||
const SessionDescription* sdesc);
|
||||
virtual bool SetLocalContent_w(const MediaContentDescription* content,
|
||||
ContentAction action);
|
||||
virtual bool SetRemoteContent_w(const MediaContentDescription* content,
|
||||
ContentAction action);
|
||||
|
||||
void AddStream_w(uint32 ssrc, uint32 voice_ssrc);
|
||||
void RemoveStream_w(uint32 ssrc);
|
||||
|
||||
void SendIntraFrame_w() {
|
||||
media_channel()->SendIntraFrame();
|
||||
}
|
||||
void RequestIntraFrame_w() {
|
||||
media_channel()->RequestIntraFrame();
|
||||
}
|
||||
void EnableCpuAdaptation_w(bool enable) {
|
||||
// TODO: The following call will clear all other options, which is
|
||||
// OK now since SetOptions is not used in video media channel. In the
|
||||
// future, add GetOptions() method and change the options.
|
||||
media_channel()->SetOptions(enable ? OPT_CPU_ADAPTATION : 0);
|
||||
}
|
||||
|
||||
struct RenderMessageData : public talk_base::MessageData {
|
||||
RenderMessageData(uint32 s, VideoRenderer* r) : ssrc(s), renderer(r) {}
|
||||
uint32 ssrc;
|
||||
VideoRenderer* renderer;
|
||||
};
|
||||
|
||||
|
||||
void SetRenderer_w(uint32 ssrc, VideoRenderer* renderer);
|
||||
|
||||
|
||||
virtual void OnMessage(talk_base::Message *pmsg);
|
||||
virtual void OnConnectionMonitorUpdate(
|
||||
SocketMonitor *monitor, const std::vector<ConnectionInfo> &infos);
|
||||
virtual void OnMediaMonitorUpdate(
|
||||
VideoMediaChannel *media_channel, const VideoMediaInfo& info);
|
||||
void OnVideoChannelError(uint32 ssrc, VideoMediaChannel::Error error);
|
||||
void OnSrtpError(uint32 ssrc, SrtpFilter::Mode mode, SrtpFilter::Error error);
|
||||
|
||||
VoiceChannel *voice_channel_;
|
||||
VideoRenderer *renderer_;
|
||||
talk_base::scoped_ptr<VideoMediaMonitor> media_monitor_;
|
||||
};
|
||||
|
||||
} // namespace cricket
|
||||
|
||||
#endif // TALK_SESSION_PHONE_CHANNEL_H_
|
Loading…
x
Reference in New Issue
Block a user