OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/media/media_stream_impl.h" | 5 #include "content/renderer/media/media_stream_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 | 121 |
122 MediaStreamImpl::~MediaStreamImpl() { | 122 MediaStreamImpl::~MediaStreamImpl() { |
123 } | 123 } |
124 | 124 |
125 void MediaStreamImpl::OnLocalMediaStreamStop( | 125 void MediaStreamImpl::OnLocalMediaStreamStop( |
126 const std::string& label) { | 126 const std::string& label) { |
127 DVLOG(1) << "MediaStreamImpl::OnLocalMediaStreamStop(" << label << ")"; | 127 DVLOG(1) << "MediaStreamImpl::OnLocalMediaStreamStop(" << label << ")"; |
128 | 128 |
129 UserMediaRequestInfo* user_media_request = FindUserMediaRequestInfo(label); | 129 UserMediaRequestInfo* user_media_request = FindUserMediaRequestInfo(label); |
130 if (user_media_request) { | 130 if (user_media_request) { |
131 if (dependency_factory_->GetWebRtcAudioDevice()) { | 131 dependency_factory_->StopLocalAudioSource(user_media_request->descriptor); |
132 scoped_refptr<WebRtcAudioCapturer> capturer = | |
133 dependency_factory_->GetWebRtcAudioDevice()->capturer(); | |
134 if (capturer) | |
135 capturer->Stop(); | |
136 } | |
137 | 132 |
138 media_stream_dispatcher_->StopStream(label); | 133 media_stream_dispatcher_->StopStream(label); |
139 DeleteUserMediaRequestInfo(user_media_request); | 134 DeleteUserMediaRequestInfo(user_media_request); |
140 } else { | 135 } else { |
141 DVLOG(1) << "MediaStreamImpl::OnLocalMediaStreamStop: the stream has " | 136 DVLOG(1) << "MediaStreamImpl::OnLocalMediaStreamStop: the stream has " |
142 << "already been stopped."; | 137 << "already been stopped."; |
143 } | 138 } |
144 } | 139 } |
145 | 140 |
146 void MediaStreamImpl::requestUserMedia( | 141 void MediaStreamImpl::requestUserMedia( |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 | 483 |
489 while (request_it != user_media_requests_.end()) { | 484 while (request_it != user_media_requests_.end()) { |
490 if ((*request_it)->frame == frame) { | 485 if ((*request_it)->frame == frame) { |
491 DVLOG(1) << "MediaStreamImpl::FrameWillClose: " | 486 DVLOG(1) << "MediaStreamImpl::FrameWillClose: " |
492 << "Cancel user media request " << (*request_it)->request_id; | 487 << "Cancel user media request " << (*request_it)->request_id; |
493 // If the request is generated, it means that the MediaStreamDispatcher | 488 // If the request is generated, it means that the MediaStreamDispatcher |
494 // has generated a stream for us and we need to let the | 489 // has generated a stream for us and we need to let the |
495 // MediaStreamDispatcher know that the stream is no longer wanted. | 490 // MediaStreamDispatcher know that the stream is no longer wanted. |
496 // If not, we cancel the request and delete the request object. | 491 // If not, we cancel the request and delete the request object. |
497 if ((*request_it)->generated) { | 492 if ((*request_it)->generated) { |
| 493 // Stop the local audio track before closing the device in the browser. |
| 494 dependency_factory_->StopLocalAudioSource((*request_it)->descriptor); |
| 495 |
498 media_stream_dispatcher_->StopStream( | 496 media_stream_dispatcher_->StopStream( |
499 UTF16ToUTF8((*request_it)->descriptor.label())); | 497 UTF16ToUTF8((*request_it)->descriptor.label())); |
500 } else { | 498 } else { |
501 media_stream_dispatcher_->CancelGenerateStream( | 499 media_stream_dispatcher_->CancelGenerateStream( |
502 (*request_it)->request_id); | 500 (*request_it)->request_id); |
503 } | 501 } |
504 request_it = user_media_requests_.erase(request_it); | 502 request_it = user_media_requests_.erase(request_it); |
505 } else { | 503 } else { |
506 ++request_it; | 504 ++request_it; |
507 } | 505 } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 const StreamStopCallback& stop_callback) { | 587 const StreamStopCallback& stop_callback) { |
590 stream_stop_callback_ = stop_callback; | 588 stream_stop_callback_ = stop_callback; |
591 } | 589 } |
592 | 590 |
593 void MediaStreamExtraData::OnLocalStreamStop() { | 591 void MediaStreamExtraData::OnLocalStreamStop() { |
594 if (!stream_stop_callback_.is_null()) | 592 if (!stream_stop_callback_.is_null()) |
595 stream_stop_callback_.Run(stream_->label()); | 593 stream_stop_callback_.Run(stream_->label()); |
596 } | 594 } |
597 | 595 |
598 } // namespace content | 596 } // namespace content |
OLD | NEW |