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

Unified Diff: content/renderer/media/media_stream_impl.cc

Issue 11783059: Ensures that WebRTC works for device selection using a different sample rate than default (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed content_unittests Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/media/media_stream_impl.cc
diff --git a/content/renderer/media/media_stream_impl.cc b/content/renderer/media/media_stream_impl.cc
index 174bb25f55328e9cc67f438e5a699dbbdd39117d..597a0a22457acb58748f7accbf47fdbc15f18902 100644
--- a/content/renderer/media/media_stream_impl.cc
+++ b/content/renderer/media/media_stream_impl.cc
@@ -68,36 +68,6 @@ void UpdateOptionsIfTabMediaRequest(
}
}
-// Get session ID for the selected microphone to ensure that we start
-// capturing audio using the correct input device.
-static int GetSessionId(const WebKit::WebMediaStreamDescriptor& descriptor) {
- WebKit::WebVector<WebKit::WebMediaStreamComponent> audio_components;
- descriptor.audioSources(audio_components);
- if (audio_components.size() != 1) {
- // TODO(henrika): add support for more than one audio track.
- NOTIMPLEMENTED();
- return -1;
- }
-
- if (!audio_components[0].isEnabled()) {
- DVLOG(1) << "audio track is disabled";
- return -1;
- }
-
- const WebKit::WebMediaStreamSource& source = audio_components[0].source();
- MediaStreamSourceExtraData* source_data =
- static_cast<MediaStreamSourceExtraData*>(source.extraData());
- if (!source_data) {
- // TODO(henrika): Implement support for sources from remote MediaStreams.
- NOTIMPLEMENTED();
- return -1;
- }
- DVLOG(1) << "local audio track source name: "
- << source_data->device_info().device.name;
-
- return source_data->device_info().session_id;
-}
-
static int g_next_request_id = 0;
// Creates a WebKit representation of a stream sources based on
@@ -319,17 +289,9 @@ MediaStreamImpl::GetAudioRenderer(const GURL& url) {
// WebRtcAudioDeviceImpl can only support one renderer.
return NULL;
} else if (extra_data->local_stream()) {
- DVLOG(1) << "creating local audio renderer for stream:"
- << extra_data->local_stream()->label();
-
- // Get session ID for the local media stream.
- int session_id = GetSessionId(descriptor);
- if (session_id == -1)
- return NULL;
-
- // Create the local audio renderer using the specified session ID.
+ // Create the local audio renderer if the stream contains audio tracks.
scoped_refptr<WebRtcLocalAudioRenderer> local_renderer =
- CreateLocalAudioRenderer(session_id);
+ CreateLocalAudioRenderer(extra_data->local_stream());
return local_renderer;
}
@@ -345,6 +307,7 @@ void MediaStreamImpl::OnStreamGenerated(
const StreamDeviceInfoArray& audio_array,
const StreamDeviceInfoArray& video_array) {
DCHECK(CalledOnValidThread());
+ DVLOG(1) << "MediaStreamImpl::OnStreamGenerated stream:" << label;
UserMediaRequestInfo* request_info = FindUserMediaRequestInfo(request_id);
if (!request_info) {
@@ -411,6 +374,8 @@ void MediaStreamImpl::OnStreamGenerationFailed(int request_id) {
void MediaStreamImpl::OnCreateNativeSourcesComplete(
WebKit::WebMediaStreamDescriptor* description,
bool request_succeeded) {
+ DVLOG(1) << "MediaStreamImpl::OnCreateNativeSourcesComplete stream:"
+ << UTF16ToUTF8(description->label());
tommi (sloooow) - chröme 2013/01/15 17:43:49 doesn't DVLOG support utf16?
henrika (OOO until Aug 14) 2013/01/16 16:37:17 Correct. Done.
UserMediaRequestInfo* request_info = FindUserMediaRequestInfo(description);
if (!request_info) {
// This can happen if the request is canceled or the frame reloads while
@@ -597,18 +562,19 @@ scoped_refptr<WebRtcAudioRenderer> MediaStreamImpl::CreateRemoteAudioRenderer(
}
scoped_refptr<WebRtcLocalAudioRenderer>
-MediaStreamImpl::CreateLocalAudioRenderer(int session_id) {
- DCHECK_NE(session_id, -1);
- // Ensure that the existing capturer reads data from the selected microphone.
+MediaStreamImpl::CreateLocalAudioRenderer(
+ webrtc::MediaStreamInterface* stream) {
+ if (!stream->audio_tracks() || stream->audio_tracks()->count() == 0)
+ return NULL;
+
+ DVLOG(1) << "MediaStreamImpl::CreateLocalAudioRenderer label:"
+ << stream->label();
+
scoped_refptr<WebRtcAudioCapturer> source =
dependency_factory_->GetWebRtcAudioDevice()->capturer();
if (!source) {
- // The WebRtcAudioCapturer instance can be NULL e.g. if an unsupported
- // sample rate is used.
- // TODO(henrika): extend support of capture sample rates.
return NULL;
}
- source->SetDevice(session_id);
// Create a new WebRtcLocalAudioRenderer instance and connect it to the
// existing WebRtcAudioCapturer so that the renderer can use it as source.

Powered by Google App Engine
This is Rietveld 408576698