Index: webrtc/call/call.cc |
diff --git a/webrtc/call/call.cc b/webrtc/call/call.cc |
index 41b2c83d382a9be2f8d21adea1f550cf6eaf6131..c5c16c9f77084c156a4c4ca37c2e01a891b57dc7 100644 |
--- a/webrtc/call/call.cc |
+++ b/webrtc/call/call.cc |
@@ -14,6 +14,7 @@ |
#include <vector> |
#include "webrtc/audio/audio_receive_stream.h" |
+#include "webrtc/audio/audio_send_stream.h" |
#include "webrtc/base/checks.h" |
#include "webrtc/base/scoped_ptr.h" |
#include "webrtc/base/thread_annotations.h" |
@@ -111,6 +112,7 @@ class Call : public webrtc::Call, public PacketReceiver { |
GUARDED_BY(receive_crit_); |
rtc::scoped_ptr<RWLockWrapper> send_crit_; |
+ std::map<uint32_t, AudioSendStream*> audio_send_ssrcs_ GUARDED_BY(send_crit_); |
tommi
2015/10/14 13:21:18
document where ownership of the send stream lies?
the sun
2015/10/14 14:25:24
Done.
|
std::map<uint32_t, VideoSendStream*> video_send_ssrcs_ GUARDED_BY(send_crit_); |
std::set<VideoSendStream*> video_send_streams_ GUARDED_BY(send_crit_); |
@@ -162,6 +164,7 @@ Call::Call(const Call::Config& config) |
} |
Call::~Call() { |
+ RTC_CHECK_EQ(0u, audio_send_ssrcs_.size()); |
tommi
2015/10/14 13:21:18
nit: RTC_CHECK(audio_send_ssrcs_.empty()); I see
the sun
2015/10/14 14:25:24
Done.
|
RTC_CHECK_EQ(0u, video_send_ssrcs_.size()); |
RTC_CHECK_EQ(0u, video_send_streams_.size()); |
RTC_CHECK_EQ(0u, audio_receive_ssrcs_.size()); |
@@ -176,10 +179,37 @@ PacketReceiver* Call::Receiver() { return this; } |
webrtc::AudioSendStream* Call::CreateAudioSendStream( |
const webrtc::AudioSendStream::Config& config) { |
- return nullptr; |
+ TRACE_EVENT0("webrtc", "Call::CreateAudioSendStream"); |
+ LOG(LS_INFO) << "CreateAudioSendStream: " << config.ToString(); |
+ AudioSendStream* send_stream = new AudioSendStream(config); |
+ { |
+ rtc::CritScope lock(&network_enabled_crit_); |
+ WriteLockScoped write_lock(*send_crit_); |
+ RTC_DCHECK(audio_send_ssrcs_.find(config.rtp.ssrc) == |
+ audio_send_ssrcs_.end()); |
+ audio_send_ssrcs_[config.rtp.ssrc] = send_stream; |
+ |
+ if (!network_enabled_) |
+ send_stream->SignalNetworkState(kNetworkDown); |
+ } |
+ return send_stream; |
tommi
2015/10/14 13:21:18
is it guaranteed that CreateAudioSendStream() and
the sun
2015/10/14 14:25:24
Well, from what I can make out, in libjingle only
|
} |
void Call::DestroyAudioSendStream(webrtc::AudioSendStream* send_stream) { |
+ TRACE_EVENT0("webrtc", "Call::DestroyAudioSendStream"); |
+ RTC_DCHECK(send_stream != nullptr); |
+ |
+ send_stream->Stop(); |
+ |
+ AudioSendStream* audio_send_stream = |
+ static_cast<AudioSendStream*>(send_stream); |
tommi
2015/10/14 13:21:18
I'm not groking this cast :)
the sun
2015/10/14 14:25:24
We're casting a webrtc::AudioSendStream to a webrt
tommi
2015/10/14 14:49:28
Ah :) that wasn't obvious to me especially since
the sun
2015/10/15 12:56:06
I've added explicit casts for the audio functions;
|
+ { |
+ WriteLockScoped write_lock(*send_crit_); |
+ size_t num_deleted = audio_send_ssrcs_.erase( |
+ audio_send_stream->config().rtp.ssrc); |
+ RTC_DCHECK(num_deleted == 1); |
+ } |
+ delete audio_send_stream; |
} |
webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream( |
@@ -360,6 +390,7 @@ Call::Stats Call::GetStats() const { |
stats.pacer_delay_ms = channel_group_->GetPacerQueuingDelayMs(); |
{ |
ReadLockScoped read_lock(*send_crit_); |
+ // TODO(solenberg): Add audio send streams. |
for (const auto& kv : video_send_ssrcs_) { |
int rtt_ms = kv.second->GetRtt(); |
if (rtt_ms > 0) |
@@ -399,6 +430,9 @@ void Call::SignalNetworkState(NetworkState state) { |
channel_group_->SignalNetworkState(state); |
{ |
ReadLockScoped write_lock(*send_crit_); |
+ for (auto& kv : audio_send_ssrcs_) { |
tommi
2015/10/14 13:21:18
no chance ov avoiding holding these locks (network
the sun
2015/10/14 14:25:24
See above comment...
|
+ kv.second->SignalNetworkState(state); |
+ } |
for (auto& kv : video_send_ssrcs_) { |
kv.second->SignalNetworkState(state); |
} |