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

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

Issue 1397773002: Change SetOutputScaling to set a single level, not left/right levels. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase+rename Created 5 years, 2 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
« no previous file with comments | « talk/app/webrtc/webrtcsession_unittest.cc ('k') | talk/media/base/mediachannel.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 flags(flags) {} 236 flags(flags) {}
237 uint32_t ssrc; 237 uint32_t ssrc;
238 int event_code; 238 int event_code;
239 int duration; 239 int duration;
240 int flags; 240 int flags;
241 }; 241 };
242 explicit FakeVoiceMediaChannel(FakeVoiceEngine* engine, 242 explicit FakeVoiceMediaChannel(FakeVoiceEngine* engine,
243 const AudioOptions& options) 243 const AudioOptions& options)
244 : engine_(engine), 244 : engine_(engine),
245 time_since_last_typing_(-1) { 245 time_since_last_typing_(-1) {
246 output_scalings_[0] = OutputScaling(); // For default channel. 246 output_scalings_[0] = 1.0; // For default channel.
247 SetOptions(options); 247 SetOptions(options);
248 } 248 }
249 ~FakeVoiceMediaChannel(); 249 ~FakeVoiceMediaChannel();
250 const std::vector<AudioCodec>& recv_codecs() const { return recv_codecs_; } 250 const std::vector<AudioCodec>& recv_codecs() const { return recv_codecs_; }
251 const std::vector<AudioCodec>& send_codecs() const { return send_codecs_; } 251 const std::vector<AudioCodec>& send_codecs() const { return send_codecs_; }
252 const std::vector<AudioCodec>& codecs() const { return send_codecs(); } 252 const std::vector<AudioCodec>& codecs() const { return send_codecs(); }
253 const std::vector<DtmfInfo>& dtmf_info_queue() const { 253 const std::vector<DtmfInfo>& dtmf_info_queue() const {
254 return dtmf_info_queue_; 254 return dtmf_info_queue_;
255 } 255 }
256 const AudioOptions& options() const { return options_; } 256 const AudioOptions& options() const { return options_; }
(...skipping 27 matching lines...) Expand all
284 return false; 284 return false;
285 } 285 }
286 if (enable && options) { 286 if (enable && options) {
287 return SetOptions(*options); 287 return SetOptions(*options);
288 } 288 }
289 return true; 289 return true;
290 } 290 }
291 virtual bool AddRecvStream(const StreamParams& sp) { 291 virtual bool AddRecvStream(const StreamParams& sp) {
292 if (!RtpHelper<VoiceMediaChannel>::AddRecvStream(sp)) 292 if (!RtpHelper<VoiceMediaChannel>::AddRecvStream(sp))
293 return false; 293 return false;
294 output_scalings_[sp.first_ssrc()] = OutputScaling(); 294 output_scalings_[sp.first_ssrc()] = 1.0;
295 return true; 295 return true;
296 } 296 }
297 virtual bool RemoveRecvStream(uint32_t ssrc) { 297 virtual bool RemoveRecvStream(uint32_t ssrc) {
298 if (!RtpHelper<VoiceMediaChannel>::RemoveRecvStream(ssrc)) 298 if (!RtpHelper<VoiceMediaChannel>::RemoveRecvStream(ssrc))
299 return false; 299 return false;
300 output_scalings_.erase(ssrc); 300 output_scalings_.erase(ssrc);
301 return true; 301 return true;
302 } 302 }
303 virtual bool SetRemoteRenderer(uint32_t ssrc, AudioRenderer* renderer) { 303 virtual bool SetRemoteRenderer(uint32_t ssrc, AudioRenderer* renderer) {
304 std::map<uint32_t, AudioRenderer*>::iterator it = 304 std::map<uint32_t, AudioRenderer*>::iterator it =
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 return false; 340 return false;
341 } 341 }
342 virtual bool InsertDtmf(uint32_t ssrc, 342 virtual bool InsertDtmf(uint32_t ssrc,
343 int event_code, 343 int event_code,
344 int duration, 344 int duration,
345 int flags) { 345 int flags) {
346 dtmf_info_queue_.push_back(DtmfInfo(ssrc, event_code, duration, flags)); 346 dtmf_info_queue_.push_back(DtmfInfo(ssrc, event_code, duration, flags));
347 return true; 347 return true;
348 } 348 }
349 349
350 virtual bool SetOutputScaling(uint32_t ssrc, double left, double right) { 350 virtual bool SetOutputVolume(uint32_t ssrc, double volume) {
351 if (0 == ssrc) { 351 if (0 == ssrc) {
352 std::map<uint32_t, OutputScaling>::iterator it; 352 std::map<uint32_t, double>::iterator it;
353 for (it = output_scalings_.begin(); it != output_scalings_.end(); ++it) { 353 for (it = output_scalings_.begin(); it != output_scalings_.end(); ++it) {
354 it->second.left = left; 354 it->second = volume;
355 it->second.right = right;
356 } 355 }
357 return true; 356 return true;
358 } else if (output_scalings_.find(ssrc) != output_scalings_.end()) { 357 } else if (output_scalings_.find(ssrc) != output_scalings_.end()) {
359 output_scalings_[ssrc].left = left; 358 output_scalings_[ssrc] = volume;
360 output_scalings_[ssrc].right = right;
361 return true; 359 return true;
362 } 360 }
363 return false; 361 return false;
364 } 362 }
365 bool GetOutputScaling(uint32_t ssrc, double* left, double* right) { 363 bool GetOutputVolume(uint32_t ssrc, double* volume) {
366 if (output_scalings_.find(ssrc) == output_scalings_.end()) 364 if (output_scalings_.find(ssrc) == output_scalings_.end())
367 return false; 365 return false;
368 *left = output_scalings_[ssrc].left; 366 *volume = output_scalings_[ssrc];
369 *right = output_scalings_[ssrc].right;
370 return true; 367 return true;
371 } 368 }
372 369
373 virtual bool GetStats(VoiceMediaInfo* info) { return false; } 370 virtual bool GetStats(VoiceMediaInfo* info) { return false; }
374 371
375 private: 372 private:
376 struct OutputScaling {
377 OutputScaling() : left(1.0), right(1.0) {}
378 double left, right;
379 };
380
381 class VoiceChannelAudioSink : public AudioRenderer::Sink { 373 class VoiceChannelAudioSink : public AudioRenderer::Sink {
382 public: 374 public:
383 explicit VoiceChannelAudioSink(AudioRenderer* renderer) 375 explicit VoiceChannelAudioSink(AudioRenderer* renderer)
384 : renderer_(renderer) { 376 : renderer_(renderer) {
385 renderer_->AddChannel(0); 377 renderer_->AddChannel(0);
386 renderer_->SetSink(this); 378 renderer_->SetSink(this);
387 } 379 }
388 virtual ~VoiceChannelAudioSink() { 380 virtual ~VoiceChannelAudioSink() {
389 if (renderer_) { 381 if (renderer_) {
390 renderer_->RemoveChannel(0); 382 renderer_->RemoveChannel(0);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 delete it->second; 431 delete it->second;
440 local_renderers_.erase(it); 432 local_renderers_.erase(it);
441 } 433 }
442 } 434 }
443 return true; 435 return true;
444 } 436 }
445 437
446 FakeVoiceEngine* engine_; 438 FakeVoiceEngine* engine_;
447 std::vector<AudioCodec> recv_codecs_; 439 std::vector<AudioCodec> recv_codecs_;
448 std::vector<AudioCodec> send_codecs_; 440 std::vector<AudioCodec> send_codecs_;
449 std::map<uint32_t, OutputScaling> output_scalings_; 441 std::map<uint32_t, double> output_scalings_;
450 std::vector<DtmfInfo> dtmf_info_queue_; 442 std::vector<DtmfInfo> dtmf_info_queue_;
451 int time_since_last_typing_; 443 int time_since_last_typing_;
452 AudioOptions options_; 444 AudioOptions options_;
453 std::map<uint32_t, VoiceChannelAudioSink*> local_renderers_; 445 std::map<uint32_t, VoiceChannelAudioSink*> local_renderers_;
454 std::map<uint32_t, AudioRenderer*> remote_renderers_; 446 std::map<uint32_t, AudioRenderer*> remote_renderers_;
455 }; 447 };
456 448
457 // A helper function to compare the FakeVoiceMediaChannel::DtmfInfo. 449 // A helper function to compare the FakeVoiceMediaChannel::DtmfInfo.
458 inline bool CompareDtmfInfo(const FakeVoiceMediaChannel::DtmfInfo& info, 450 inline bool CompareDtmfInfo(const FakeVoiceMediaChannel::DtmfInfo& info,
459 uint32_t ssrc, 451 uint32_t ssrc,
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
1010 1002
1011 private: 1003 private:
1012 std::vector<FakeDataMediaChannel*> channels_; 1004 std::vector<FakeDataMediaChannel*> channels_;
1013 std::vector<DataCodec> data_codecs_; 1005 std::vector<DataCodec> data_codecs_;
1014 DataChannelType last_channel_type_; 1006 DataChannelType last_channel_type_;
1015 }; 1007 };
1016 1008
1017 } // namespace cricket 1009 } // namespace cricket
1018 1010
1019 #endif // TALK_MEDIA_BASE_FAKEMEDIAENGINE_H_ 1011 #endif // TALK_MEDIA_BASE_FAKEMEDIAENGINE_H_
OLDNEW
« no previous file with comments | « talk/app/webrtc/webrtcsession_unittest.cc ('k') | talk/media/base/mediachannel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698