Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Side by Side Diff: talk/media/base/fakemediaengine.h

Issue 1311533009: - Rename VoiceChannel::MuteStream() -> SetAudioSend() (incl. media channel) (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@lj_remove_typingmonitor_files
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2004 Google Inc. 3 * Copyright 2004 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 if (std::find(receive_streams_.begin(), receive_streams_.end(), sp) != 130 if (std::find(receive_streams_.begin(), receive_streams_.end(), sp) !=
131 receive_streams_.end()) { 131 receive_streams_.end()) {
132 return false; 132 return false;
133 } 133 }
134 receive_streams_.push_back(sp); 134 receive_streams_.push_back(sp);
135 return true; 135 return true;
136 } 136 }
137 virtual bool RemoveRecvStream(uint32 ssrc) { 137 virtual bool RemoveRecvStream(uint32 ssrc) {
138 return RemoveStreamBySsrc(&receive_streams_, ssrc); 138 return RemoveStreamBySsrc(&receive_streams_, ssrc);
139 } 139 }
140 virtual bool MuteStream(uint32 ssrc, bool on) {
141 if (!HasSendStream(ssrc) && ssrc != 0)
142 return false;
143 if (on)
144 muted_streams_.insert(ssrc);
145 else
146 muted_streams_.erase(ssrc);
147 return true;
148 }
149 bool IsStreamMuted(uint32 ssrc) const { 140 bool IsStreamMuted(uint32 ssrc) const {
150 bool ret = muted_streams_.find(ssrc) != muted_streams_.end(); 141 bool ret = muted_streams_.find(ssrc) != muted_streams_.end();
151 // If |ssrc = 0| check if the first send stream is muted. 142 // If |ssrc = 0| check if the first send stream is muted.
152 if (!ret && ssrc == 0 && !send_streams_.empty()) { 143 if (!ret && ssrc == 0 && !send_streams_.empty()) {
153 return muted_streams_.find(send_streams_[0].first_ssrc()) != 144 return muted_streams_.find(send_streams_[0].first_ssrc()) !=
154 muted_streams_.end(); 145 muted_streams_.end();
155 } 146 }
156 return ret; 147 return ret;
157 } 148 }
158 const std::vector<StreamParams>& send_streams() const { 149 const std::vector<StreamParams>& send_streams() const {
(...skipping 22 matching lines...) Expand all
181 if (send_streams_.empty()) 172 if (send_streams_.empty())
182 return ""; 173 return "";
183 return send_streams_[0].cname; 174 return send_streams_[0].cname;
184 } 175 }
185 176
186 bool ready_to_send() const { 177 bool ready_to_send() const {
187 return ready_to_send_; 178 return ready_to_send_;
188 } 179 }
189 180
190 protected: 181 protected:
182 bool MuteStream(uint32 ssrc, bool on) {
183 if (!HasSendStream(ssrc) && ssrc != 0)
184 return false;
185 if (on)
186 muted_streams_.insert(ssrc);
187 else
188 muted_streams_.erase(ssrc);
189 return true;
190 }
191 bool set_sending(bool send) { 191 bool set_sending(bool send) {
192 sending_ = send; 192 sending_ = send;
193 return true; 193 return true;
194 } 194 }
195 void set_playout(bool playout) { playout_ = playout; } 195 void set_playout(bool playout) { playout_ = playout; }
196 virtual void OnPacketReceived(rtc::Buffer* packet, 196 virtual void OnPacketReceived(rtc::Buffer* packet,
197 const rtc::PacketTime& packet_time) { 197 const rtc::PacketTime& packet_time) {
198 rtp_packets_.push_back(std::string(packet->data<char>(), packet->size())); 198 rtp_packets_.push_back(std::string(packet->data<char>(), packet->size()));
199 } 199 }
200 virtual void OnRtcpReceived(rtc::Buffer* packet, 200 virtual void OnRtcpReceived(rtc::Buffer* packet,
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 virtual bool SetPlayout(bool playout) { 276 virtual bool SetPlayout(bool playout) {
277 set_playout(playout); 277 set_playout(playout);
278 return true; 278 return true;
279 } 279 }
280 virtual bool SetSend(SendFlags flag) { 280 virtual bool SetSend(SendFlags flag) {
281 if (fail_set_send_) { 281 if (fail_set_send_) {
282 return false; 282 return false;
283 } 283 }
284 return set_sending(flag != SEND_NOTHING); 284 return set_sending(flag != SEND_NOTHING);
285 } 285 }
286 virtual bool SetAudioSend(uint32 ssrc, bool mute,
287 const AudioOptions* options,
288 AudioRenderer* renderer) {
289 std::map<uint32, VoiceChannelAudioSink*>::iterator it =
290 local_renderers_.find(ssrc);
291 if (renderer) {
292 if (it != local_renderers_.end()) {
293 ASSERT(it->second->renderer() == renderer);
294 } else {
295 local_renderers_.insert(std::make_pair(
296 ssrc, new VoiceChannelAudioSink(renderer)));
297 }
298 } else {
299 if (it != local_renderers_.end()) {
300 delete it->second;
301 local_renderers_.erase(it);
302 } else {
303 return false;
304 }
305 }
306 bool result = RtpHelper<VoiceMediaChannel>::MuteStream(ssrc, mute);
307 if (result && !mute && options) {
308 return SetOptions(*options);
309 } else {
310 return result;
311 }
312 }
pthatcher1 2015/09/09 07:16:12 I think it will make the intention of this CL more
the sun 2015/09/09 09:50:50 Done.
286 virtual bool SetMaxSendBandwidth(int bps) { return true; } 313 virtual bool SetMaxSendBandwidth(int bps) { return true; }
287 virtual bool AddRecvStream(const StreamParams& sp) { 314 virtual bool AddRecvStream(const StreamParams& sp) {
288 if (!RtpHelper<VoiceMediaChannel>::AddRecvStream(sp)) 315 if (!RtpHelper<VoiceMediaChannel>::AddRecvStream(sp))
289 return false; 316 return false;
290 output_scalings_[sp.first_ssrc()] = OutputScaling(); 317 output_scalings_[sp.first_ssrc()] = OutputScaling();
291 return true; 318 return true;
292 } 319 }
293 virtual bool RemoveRecvStream(uint32 ssrc) { 320 virtual bool RemoveRecvStream(uint32 ssrc) {
294 if (!RtpHelper<VoiceMediaChannel>::RemoveRecvStream(ssrc)) 321 if (!RtpHelper<VoiceMediaChannel>::RemoveRecvStream(ssrc))
295 return false; 322 return false;
(...skipping 13 matching lines...) Expand all
309 } else { 336 } else {
310 if (it != remote_renderers_.end()) { 337 if (it != remote_renderers_.end()) {
311 it->second->RemoveChannel(0); 338 it->second->RemoveChannel(0);
312 remote_renderers_.erase(it); 339 remote_renderers_.erase(it);
313 } else { 340 } else {
314 return false; 341 return false;
315 } 342 }
316 } 343 }
317 return true; 344 return true;
318 } 345 }
319 virtual bool SetLocalRenderer(uint32 ssrc, AudioRenderer* renderer) {
320 std::map<uint32, VoiceChannelAudioSink*>::iterator it =
321 local_renderers_.find(ssrc);
322 if (renderer) {
323 if (it != local_renderers_.end()) {
324 ASSERT(it->second->renderer() == renderer);
325 } else {
326 local_renderers_.insert(std::make_pair(
327 ssrc, new VoiceChannelAudioSink(renderer)));
328 }
329 } else {
330 if (it != local_renderers_.end()) {
331 delete it->second;
332 local_renderers_.erase(it);
333 } else {
334 return false;
335 }
336 }
337 return true;
338 }
339 346
340 virtual bool GetActiveStreams(AudioInfo::StreamList* streams) { return true; } 347 virtual bool GetActiveStreams(AudioInfo::StreamList* streams) { return true; }
341 virtual int GetOutputLevel() { return 0; } 348 virtual int GetOutputLevel() { return 0; }
342 void set_time_since_last_typing(int ms) { time_since_last_typing_ = ms; } 349 void set_time_since_last_typing(int ms) { time_since_last_typing_ = ms; }
343 virtual int GetTimeSinceLastTyping() { return time_since_last_typing_; } 350 virtual int GetTimeSinceLastTyping() { return time_since_last_typing_; }
344 virtual void SetTypingDetectionParameters( 351 virtual void SetTypingDetectionParameters(
345 int time_window, int cost_per_typing, int reporting_threshold, 352 int time_window, int cost_per_typing, int reporting_threshold,
346 int penalty_decay, int type_event_delay) {} 353 int penalty_decay, int type_event_delay) {}
347 354
348 virtual bool SetRingbackTone(const char* buf, int len) { return true; } 355 virtual bool SetRingbackTone(const char* buf, int len) { return true; }
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 if (ssrc != 0 && renderers_.find(ssrc) == renderers_.end()) { 560 if (ssrc != 0 && renderers_.find(ssrc) == renderers_.end()) {
554 return false; 561 return false;
555 } 562 }
556 if (ssrc != 0) { 563 if (ssrc != 0) {
557 renderers_[ssrc] = r; 564 renderers_[ssrc] = r;
558 } 565 }
559 return true; 566 return true;
560 } 567 }
561 568
562 virtual bool SetSend(bool send) { return set_sending(send); } 569 virtual bool SetSend(bool send) { return set_sending(send); }
570 virtual bool SetVideoSend(uint32 ssrc, bool mute,
571 const VideoOptions* options) {
572 bool result = RtpHelper<VideoMediaChannel>::MuteStream(ssrc, mute);
573 if (result && !mute && options) {
574 return SetOptions(*options);
575 } else {
576 return result;
577 }
578 }
563 virtual bool SetCapturer(uint32 ssrc, VideoCapturer* capturer) { 579 virtual bool SetCapturer(uint32 ssrc, VideoCapturer* capturer) {
564 capturers_[ssrc] = capturer; 580 capturers_[ssrc] = capturer;
565 return true; 581 return true;
566 } 582 }
567 bool HasCapturer(uint32 ssrc) const { 583 bool HasCapturer(uint32 ssrc) const {
568 return capturers_.find(ssrc) != capturers_.end(); 584 return capturers_.find(ssrc) != capturers_.end();
569 } 585 }
570 virtual bool SetMaxSendBandwidth(int bps) { 586 virtual bool SetMaxSendBandwidth(int bps) {
571 max_bps_ = bps; 587 max_bps_ = bps;
572 return true; 588 return true;
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
1052 1068
1053 private: 1069 private:
1054 std::vector<FakeDataMediaChannel*> channels_; 1070 std::vector<FakeDataMediaChannel*> channels_;
1055 std::vector<DataCodec> data_codecs_; 1071 std::vector<DataCodec> data_codecs_;
1056 DataChannelType last_channel_type_; 1072 DataChannelType last_channel_type_;
1057 }; 1073 };
1058 1074
1059 } // namespace cricket 1075 } // namespace cricket
1060 1076
1061 #endif // TALK_MEDIA_BASE_FAKEMEDIAENGINE_H_ 1077 #endif // TALK_MEDIA_BASE_FAKEMEDIAENGINE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698