diff options
Diffstat (limited to 'content/browser/renderer_host/media')
14 files changed, 30 insertions, 149 deletions
diff --git a/content/browser/renderer_host/media/audio_input_renderer_host.cc b/content/browser/renderer_host/media/audio_input_renderer_host.cc index 93ed16c..ec61944 100644 --- a/content/browser/renderer_host/media/audio_input_renderer_host.cc +++ b/content/browser/renderer_host/media/audio_input_renderer_host.cc @@ -176,8 +176,6 @@ void AudioInputRendererHost::DoSendRecordingMessage( void AudioInputRendererHost::DoHandleError( media::AudioInputController* controller) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - MediaStreamManager::SendMessageToNativeLog( - "The AudioInputController signalled an error."); AudioEntry* entry = LookupByController(controller); if (!entry) @@ -312,8 +310,6 @@ void AudioInputRendererHost::OnCreateStream( entry->stream_id = stream_id; audio_entries_.insert(std::make_pair(stream_id, entry.release())); - MediaStreamManager::SendMessageToNativeLog( - "Audio input stream created successfully."); audio_log_->OnCreated(stream_id, audio_params, device_id, std::string()); } @@ -353,8 +349,6 @@ void AudioInputRendererHost::OnSetVolume(int stream_id, double volume) { } void AudioInputRendererHost::SendErrorMessage(int stream_id) { - MediaStreamManager::SendMessageToNativeLog( - "An error occurred in AudioInputRendererHost."); Send(new AudioInputMsg_NotifyStreamStateChanged( stream_id, media::AudioInputIPCDelegate::kError)); } diff --git a/content/browser/renderer_host/media/desktop_capture_device.cc b/content/browser/renderer_host/media/desktop_capture_device.cc index 74ecd80..4c84918 100644 --- a/content/browser/renderer_host/media/desktop_capture_device.cc +++ b/content/browser/renderer_host/media/desktop_capture_device.cc @@ -165,9 +165,8 @@ void DesktopCaptureDevice::Core::OnCaptureCompleted( capture_in_progress_ = false; if (!frame) { - std::string log("Failed to capture a frame."); - LOG(ERROR) << log; - client_->OnError(log); + LOG(ERROR) << "Failed to capture a frame."; + client_->OnError(); return; } diff --git a/content/browser/renderer_host/media/desktop_capture_device_aura.cc b/content/browser/renderer_host/media/desktop_capture_device_aura.cc index 7d9e7d9..03e9c89 100644 --- a/content/browser/renderer_host/media/desktop_capture_device_aura.cc +++ b/content/browser/renderer_host/media/desktop_capture_device_aura.cc @@ -405,7 +405,7 @@ void DesktopVideoCaptureMachine::OnWindowDestroyed(aura::Window* window) { Stop(base::Bind(&base::DoNothing)); - oracle_proxy_->ReportError("OnWindowDestroyed()"); + oracle_proxy_->ReportError(); } void DesktopVideoCaptureMachine::OnCompositingEnded( diff --git a/content/browser/renderer_host/media/desktop_capture_device_aura_unittest.cc b/content/browser/renderer_host/media/desktop_capture_device_aura_unittest.cc index e6abac3..2dd75f7 100644 --- a/content/browser/renderer_host/media/desktop_capture_device_aura_unittest.cc +++ b/content/browser/renderer_host/media/desktop_capture_device_aura_unittest.cc @@ -32,7 +32,7 @@ class MockDeviceClient : public media::VideoCaptureDevice::Client { MOCK_METHOD2(ReserveOutputBuffer, scoped_refptr<Buffer>(media::VideoFrame::Format format, const gfx::Size& dimensions)); - MOCK_METHOD1(OnError, void(const std::string& reason)); + MOCK_METHOD0(OnError, void()); MOCK_METHOD5(OnIncomingCapturedFrame, void(const uint8* data, int length, @@ -99,7 +99,7 @@ TEST_F(DesktopCaptureDeviceAuraTest, StartAndStop) { content::DesktopMediaID::RegisterAuraWindow(root_window()))); scoped_ptr<MockDeviceClient> client(new MockDeviceClient()); - EXPECT_CALL(*client, OnError(_)).Times(0); + EXPECT_CALL(*client, OnError()).Times(0); media::VideoCaptureParams capture_params; capture_params.requested_format.frame_size.SetSize(640, 480); diff --git a/content/browser/renderer_host/media/desktop_capture_device_unittest.cc b/content/browser/renderer_host/media/desktop_capture_device_unittest.cc index c51172a..90ac57b 100644 --- a/content/browser/renderer_host/media/desktop_capture_device_unittest.cc +++ b/content/browser/renderer_host/media/desktop_capture_device_unittest.cc @@ -43,7 +43,7 @@ class MockDeviceClient : public media::VideoCaptureDevice::Client { MOCK_METHOD2(ReserveOutputBuffer, scoped_refptr<Buffer>(media::VideoFrame::Format format, const gfx::Size& dimensions)); - MOCK_METHOD1(OnError, void(const std::string& reason)); + MOCK_METHOD0(OnError, void()); MOCK_METHOD5(OnIncomingCapturedFrame, void(const uint8* data, int length, @@ -164,7 +164,7 @@ TEST_F(DesktopCaptureDeviceTest, MAYBE_Capture) { int frame_size; scoped_ptr<MockDeviceClient> client(new MockDeviceClient()); - EXPECT_CALL(*client, OnError(_)).Times(0); + EXPECT_CALL(*client, OnError()).Times(0); EXPECT_CALL(*client, OnIncomingCapturedFrame(_, _, _, _, _)) .WillRepeatedly( DoAll(SaveArg<1>(&frame_size), @@ -204,7 +204,7 @@ TEST_F(DesktopCaptureDeviceTest, ScreenResolutionChangeConstantResolution) { int frame_size; scoped_ptr<MockDeviceClient> client(new MockDeviceClient()); - EXPECT_CALL(*client, OnError(_)).Times(0); + EXPECT_CALL(*client, OnError()).Times(0); EXPECT_CALL(*client, OnIncomingCapturedFrame(_, _, _, _, _)) .WillRepeatedly( DoAll(SaveArg<1>(&frame_size), @@ -251,7 +251,7 @@ TEST_F(DesktopCaptureDeviceTest, ScreenResolutionChangeVariableResolution) { base::WaitableEvent done_event(false, false); scoped_ptr<MockDeviceClient> client(new MockDeviceClient()); - EXPECT_CALL(*client, OnError(_)).Times(0); + EXPECT_CALL(*client, OnError()).Times(0); EXPECT_CALL(*client, OnIncomingCapturedFrame(_, _, _, _, _)) .WillRepeatedly( DoAll(SaveArg<4>(&format), diff --git a/content/browser/renderer_host/media/media_stream_manager.cc b/content/browser/renderer_host/media/media_stream_manager.cc index 6832d62..6ed73ca 100644 --- a/content/browser/renderer_host/media/media_stream_manager.cc +++ b/content/browser/renderer_host/media/media_stream_manager.cc @@ -13,22 +13,18 @@ #include "base/logging.h" #include "base/rand_util.h" #include "base/run_loop.h" -#include "base/strings/stringprintf.h" #include "base/threading/thread.h" -#include "content/browser/browser_main_loop.h" #include "content/browser/renderer_host/media/audio_input_device_manager.h" #include "content/browser/renderer_host/media/device_request_message_filter.h" #include "content/browser/renderer_host/media/media_stream_requester.h" #include "content/browser/renderer_host/media/media_stream_ui_proxy.h" #include "content/browser/renderer_host/media/video_capture_manager.h" #include "content/browser/renderer_host/media/web_contents_capture_util.h" -#include "content/browser/renderer_host/render_process_host_impl.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/content_browser_client.h" #include "content/public/browser/media_device_id.h" #include "content/public/browser/media_observer.h" #include "content/public/browser/media_request_state.h" -#include "content/public/browser/render_process_host.h" #include "content/public/common/content_switches.h" #include "content/public/common/media_stream_request.h" #include "media/audio/audio_manager_base.h" @@ -107,39 +103,6 @@ void ParseStreamType(const StreamOptions& options, } } -// Private helper method for SendMessageToNativeLog() that obtains the global -// MediaStreamManager instance on the UI thread before sending |message| to the -// webrtcLoggingPrivate API. -void DoAddLogMessage(const std::string& message) { - // Must be on the UI thread to access BrowserMainLoop. - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); - // May be null in tests. - // TODO(vrk): Handle this more elegantly by having native log messages become - // no-ops until MediaStreamManager is aware that a renderer process has - // started logging. crbug.com/333894 - if (content::BrowserMainLoop::GetInstance()) { - content::BrowserMainLoop::GetInstance()-> - media_stream_manager()->AddLogMessageOnUIThread(message); - } -} - -// Private helper method to generate a string for the log message that lists the -// human readable names of |devices|. -std::string GetLogMessageString(MediaStreamType stream_type, - const StreamDeviceInfoArray& devices) { - std::string output_string = - base::StringPrintf("Getting devices for stream type %d:\n", stream_type); - if (devices.empty()) { - output_string += "No devices found."; - } else { - for (StreamDeviceInfoArray::const_iterator it = devices.begin(); - it != devices.end(); ++it) { - output_string += " " + it->device.name + "\n"; - } - } - return output_string; -} - } // namespace @@ -1051,20 +1014,6 @@ void MediaStreamManager::SetupRequest(const std::string& label) { // Enumerate the devices if there is no valid device lists to be used. StartEnumeration(request); return; - } else { - // Cache is valid, so log the cached devices for MediaStream requests. - if (request->request_type == MEDIA_GENERATE_STREAM) { - std::string log_message("Using cached devices for request.\n"); - if (audio_type != MEDIA_NO_SERVICE) { - log_message += - GetLogMessageString(audio_type, audio_enumeration_cache_.devices); - } - if (video_type != MEDIA_NO_SERVICE) { - log_message += - GetLogMessageString(video_type, video_enumeration_cache_.devices); - } - SendMessageToNativeLog(log_message); - } } if (!SetupDeviceCaptureRequest(request)) { @@ -1454,11 +1403,7 @@ void MediaStreamManager::DevicesEnumerated( MediaStreamType stream_type, const StreamDeviceInfoArray& devices) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); DVLOG(1) << "DevicesEnumerated(" - << "{stream_type = " << stream_type << "})" << std::endl; - - std::string log_message = "New device enumeration result:\n" + - GetLogMessageString(stream_type, devices); - SendMessageToNativeLog(log_message); + << ", {stream_type = " << stream_type << "})"; // Only cache the device list when the device list has been changed. bool need_update_clients = false; @@ -1531,47 +1476,6 @@ void MediaStreamManager::DevicesEnumerated( DCHECK_GE(active_enumeration_ref_count_[stream_type], 0); } -// static -void MediaStreamManager::SendMessageToNativeLog(const std::string& message) { - BrowserThread::PostTask( - BrowserThread::UI, FROM_HERE, - base::Bind(DoAddLogMessage, message)); -} - -void MediaStreamManager::AddLogMessageOnUIThread(const std::string& message) { -#if defined(OS_ANDROID) - // It appears android_aosp is being built with ENABLE_WEBRTC=0, since it does - // not find RenderProcessHostImpl::WebRtcLogMessage. Logging is not enabled on - // Android anyway, so make this function a no-op. - // TODO(vrk): Figure out what's going on here and fix. - return; -#else - // Must be on the UI thread to access RenderProcessHost from process ID. - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - - // Grab all unique process ids that request a MediaStream or have a - // MediaStream running. - std::set<int> requesting_process_ids; - for (DeviceRequests::const_iterator it = requests_.begin(); - it != requests_.end(); ++it) { - DeviceRequest* request = it->second; - if (request->request_type == MEDIA_GENERATE_STREAM) - requesting_process_ids.insert(request->requesting_process_id); - } - - for (std::set<int>::const_iterator it = requesting_process_ids.begin(); - it != requesting_process_ids.end(); ++it) { - // Log the message to all renderers that are requesting a MediaStream or - // have a MediaStream running. - content::RenderProcessHostImpl* render_process_host_impl = - static_cast<content::RenderProcessHostImpl*>( - content::RenderProcessHost::FromID(*it)); - if (render_process_host_impl) - render_process_host_impl->WebRtcLogMessage(message); - } -#endif -} - void MediaStreamManager::HandleAccessRequestResponse( const std::string& label, const MediaStreamDevices& devices) { diff --git a/content/browser/renderer_host/media/media_stream_manager.h b/content/browser/renderer_host/media/media_stream_manager.h index 8c2edc4..eefab6b 100644 --- a/content/browser/renderer_host/media/media_stream_manager.h +++ b/content/browser/renderer_host/media/media_stream_manager.h @@ -185,15 +185,6 @@ class CONTENT_EXPORT MediaStreamManager // too late. (see http://crbug.com/247525#c14). virtual void WillDestroyCurrentMessageLoop() OVERRIDE; - // Sends log messages to the render processes making device requests, to be - // used by the webrtcLoggingPrivate API if requested. - void AddLogMessageOnUIThread(const std::string& message); - - // Adds |message| to native logs for outstanding device requests, for use by - // render processes requesting logging from webrtcLoggingPrivate API. Safe to - // call from any thread. - static void SendMessageToNativeLog(const std::string& message); - protected: // Used for testing. MediaStreamManager(); diff --git a/content/browser/renderer_host/media/video_capture_controller.cc b/content/browser/renderer_host/media/video_capture_controller.cc index 5dff5c2..f23f50f 100644 --- a/content/browser/renderer_host/media/video_capture_controller.cc +++ b/content/browser/renderer_host/media/video_capture_controller.cc @@ -121,7 +121,7 @@ class VideoCaptureController::VideoCaptureDeviceClient const gfx::Size& dimensions, base::TimeTicks timestamp, int frame_rate) OVERRIDE; - virtual void OnError(const std::string& reason) OVERRIDE; + virtual void OnError() OVERRIDE; private: scoped_refptr<Buffer> DoReserveOutputBuffer(media::VideoFrame::Format format, @@ -428,10 +428,7 @@ void VideoCaptureController::VideoCaptureDeviceClient::OnIncomingCapturedBuffer( timestamp)); } -void VideoCaptureController::VideoCaptureDeviceClient::OnError( - const std::string& reason) { - MediaStreamManager::SendMessageToNativeLog( - "Error on video capture: " + reason); +void VideoCaptureController::VideoCaptureDeviceClient::OnError() { BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind(&VideoCaptureController::DoErrorOnIOThread, controller_)); diff --git a/content/browser/renderer_host/media/video_capture_controller_unittest.cc b/content/browser/renderer_host/media/video_capture_controller_unittest.cc index b4de263..1852a71 100644 --- a/content/browser/renderer_host/media/video_capture_controller_unittest.cc +++ b/content/browser/renderer_host/media/video_capture_controller_unittest.cc @@ -407,7 +407,7 @@ TEST_F(VideoCaptureControllerTest, ErrorBeforeDeviceCreation) { // Start with one client. controller_->AddClient( route_id, client_a_.get(), base::kNullProcessHandle, 100, session_100); - device_->OnError("Test Error"); + device_->OnError(); EXPECT_CALL(*client_a_, DoError(route_id)).Times(1); base::RunLoop().RunUntilIdle(); Mock::VerifyAndClearExpectations(client_a_.get()); @@ -462,7 +462,7 @@ TEST_F(VideoCaptureControllerTest, ErrorAfterDeviceCreation) { device_->ReserveOutputBuffer(media::VideoFrame::I420, dims); ASSERT_TRUE(buffer); - device_->OnError("Test error"); + device_->OnError(); device_->OnIncomingCapturedBuffer(buffer, media::VideoFrame::I420, dims, diff --git a/content/browser/renderer_host/media/video_capture_device_impl.cc b/content/browser/renderer_host/media/video_capture_device_impl.cc index 88e5ab5..045eda6 100644 --- a/content/browser/renderer_host/media/video_capture_device_impl.cc +++ b/content/browser/renderer_host/media/video_capture_device_impl.cc @@ -155,10 +155,10 @@ void ThreadSafeCaptureOracle::Stop() { client_.reset(); } -void ThreadSafeCaptureOracle::ReportError(const std::string& reason) { +void ThreadSafeCaptureOracle::ReportError() { base::AutoLock guard(lock_); if (client_) - client_->OnError(reason); + client_->OnError(); } void ThreadSafeCaptureOracle::DidCaptureFrame( @@ -196,19 +196,16 @@ void VideoCaptureDeviceImpl::AllocateAndStart( } if (params.requested_format.frame_rate <= 0) { - std::string error_msg = base::StringPrintf( - "invalid frame_rate: %d", params.requested_format.frame_rate); - DVLOG(1) << error_msg; - client->OnError(error_msg); + DVLOG(1) << "invalid frame_rate: " << params.requested_format.frame_rate; + client->OnError(); return; } if (params.requested_format.frame_size.width() < kMinFrameWidth || params.requested_format.frame_size.height() < kMinFrameHeight) { - std::string error_msg = - "invalid frame size: " + params.requested_format.frame_size.ToString(); - DVLOG(1) << error_msg; - client->OnError(error_msg); + DVLOG(1) << "invalid frame size: " + << params.requested_format.frame_size.ToString(); + client->OnError(); return; } @@ -255,9 +252,8 @@ void VideoCaptureDeviceImpl::StopAndDeAllocate() { void VideoCaptureDeviceImpl::CaptureStarted(bool success) { DCHECK(thread_checker_.CalledOnValidThread()); if (!success) { - std::string reason("Failed to start capture machine."); - DVLOG(1) << reason; - Error(reason); + DVLOG(1) << "Failed to start capture machine."; + Error(); } } @@ -295,14 +291,14 @@ void VideoCaptureDeviceImpl::TransitionStateTo(State next_state) { state_ = next_state; } -void VideoCaptureDeviceImpl::Error(const std::string& reason) { +void VideoCaptureDeviceImpl::Error() { DCHECK(thread_checker_.CalledOnValidThread()); if (state_ == kIdle) return; if (oracle_proxy_) - oracle_proxy_->ReportError(reason); + oracle_proxy_->ReportError(); StopAndDeAllocate(); TransitionStateTo(kError); diff --git a/content/browser/renderer_host/media/video_capture_device_impl.h b/content/browser/renderer_host/media/video_capture_device_impl.h index 87d4c19..56bf1e0 100644 --- a/content/browser/renderer_host/media/video_capture_device_impl.h +++ b/content/browser/renderer_host/media/video_capture_device_impl.h @@ -71,7 +71,7 @@ class ThreadSafeCaptureOracle void Stop(); // Signal an error to the client. - void ReportError(const std::string& reason); + void ReportError(); private: friend class base::RefCountedThreadSafe<ThreadSafeCaptureOracle>; @@ -165,7 +165,7 @@ class CONTENT_EXPORT VideoCaptureDeviceImpl void CaptureStarted(bool success); // Stops capturing and notifies client_ of an error state. - void Error(const std::string& reason); + void Error(); // Tracks that all activity occurs on the media stream manager's thread. base::ThreadChecker thread_checker_; diff --git a/content/browser/renderer_host/media/video_capture_manager.cc b/content/browser/renderer_host/media/video_capture_manager.cc index 28242f4..ace6565 100644 --- a/content/browser/renderer_host/media/video_capture_manager.cc +++ b/content/browser/renderer_host/media/video_capture_manager.cc @@ -213,7 +213,7 @@ void VideoCaptureManager::DoStartDeviceOnDeviceThread( } if (!video_capture_device) { - device_client->OnError("Could not create capture device"); + device_client->OnError(); return; } diff --git a/content/browser/renderer_host/media/web_contents_video_capture_device.cc b/content/browser/renderer_host/media/web_contents_video_capture_device.cc index 95333fc..535111b 100644 --- a/content/browser/renderer_host/media/web_contents_video_capture_device.cc +++ b/content/browser/renderer_host/media/web_contents_video_capture_device.cc @@ -700,7 +700,7 @@ void WebContentsCaptureMachine::WebContentsDestroyed( subscription_.reset(); web_contents->DecrementCapturerCount(); - oracle_proxy_->ReportError("WebContentsDestroyed()"); + oracle_proxy_->ReportError(); } RenderWidgetHost* WebContentsCaptureMachine::GetTarget() { diff --git a/content/browser/renderer_host/media/web_contents_video_capture_device_unittest.cc b/content/browser/renderer_host/media/web_contents_video_capture_device_unittest.cc index 5787d2b..39b427b 100644 --- a/content/browser/renderer_host/media/web_contents_video_capture_device_unittest.cc +++ b/content/browser/renderer_host/media/web_contents_video_capture_device_unittest.cc @@ -361,7 +361,7 @@ class StubClient : public media::VideoCaptureDevice::Client { color_callback_.Run((SkColorSetRGB(yuv[0], yuv[1], yuv[2]))); } - virtual void OnError(const std::string& reason) OVERRIDE { + virtual void OnError() OVERRIDE { error_callback_.Run(); } |