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_center.h" | 5 #include "content/renderer/media/media_stream_center.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "content/common/media/media_stream_messages.h" | 11 #include "content/common/media/media_stream_messages.h" |
12 #include "content/public/common/content_switches.h" | 12 #include "content/public/common/content_switches.h" |
13 #include "content/public/renderer/render_thread.h" | 13 #include "content/public/renderer/render_thread.h" |
14 #include "content/renderer/media/media_stream.h" | 14 #include "content/renderer/media/media_stream.h" |
15 #include "content/renderer/media/media_stream_dependency_factory.h" | 15 #include "content/renderer/media/media_stream_dependency_factory.h" |
16 #include "content/renderer/media/media_stream_source.h" | 16 #include "content/renderer/media/media_stream_source.h" |
| 17 #include "content/renderer/media/media_stream_video_source.h" |
17 #include "content/renderer/media/media_stream_video_track.h" | 18 #include "content/renderer/media/media_stream_video_track.h" |
| 19 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" |
18 #include "third_party/WebKit/public/platform/WebMediaStream.h" | 20 #include "third_party/WebKit/public/platform/WebMediaStream.h" |
19 #include "third_party/WebKit/public/platform/WebMediaStreamCenterClient.h" | 21 #include "third_party/WebKit/public/platform/WebMediaStreamCenterClient.h" |
20 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" | 22 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" |
21 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" | 23 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" |
22 #include "third_party/WebKit/public/platform/WebMediaStreamTrackSourcesRequest.h
" | 24 #include "third_party/WebKit/public/platform/WebMediaStreamTrackSourcesRequest.h
" |
23 #include "third_party/WebKit/public/platform/WebSourceInfo.h" | 25 #include "third_party/WebKit/public/platform/WebSourceInfo.h" |
24 #include "third_party/WebKit/public/platform/WebVector.h" | 26 #include "third_party/WebKit/public/platform/WebVector.h" |
25 #include "third_party/WebKit/public/web/WebFrame.h" | 27 #include "third_party/WebKit/public/web/WebFrame.h" |
26 | 28 |
27 using blink::WebFrame; | 29 using blink::WebFrame; |
(...skipping 11 matching lines...) Expand all Loading... |
39 DCHECK_EQ(source.type(), blink::WebMediaStreamSource::TypeAudio); | 41 DCHECK_EQ(source.type(), blink::WebMediaStreamSource::TypeAudio); |
40 factory->CreateLocalAudioTrack(track); | 42 factory->CreateLocalAudioTrack(track); |
41 } | 43 } |
42 | 44 |
43 void CreateNativeVideoMediaStreamTrack( | 45 void CreateNativeVideoMediaStreamTrack( |
44 const blink::WebMediaStreamTrack& track, | 46 const blink::WebMediaStreamTrack& track, |
45 MediaStreamDependencyFactory* factory) { | 47 MediaStreamDependencyFactory* factory) { |
46 DCHECK(track.extraData() == NULL); | 48 DCHECK(track.extraData() == NULL); |
47 blink::WebMediaStreamSource source = track.source(); | 49 blink::WebMediaStreamSource source = track.source(); |
48 DCHECK_EQ(source.type(), blink::WebMediaStreamSource::TypeVideo); | 50 DCHECK_EQ(source.type(), blink::WebMediaStreamSource::TypeVideo); |
49 | 51 MediaStreamVideoSource* native_source = |
50 if (!source.extraData()) { | 52 MediaStreamVideoSource::GetVideoSource(source); |
| 53 if (!native_source) { |
51 // TODO(perkj): Implement support for sources from | 54 // TODO(perkj): Implement support for sources from |
52 // remote MediaStreams. | 55 // remote MediaStreams. |
53 NOTIMPLEMENTED(); | 56 NOTIMPLEMENTED(); |
54 return; | 57 return; |
55 } | 58 } |
56 MediaStreamTrack* native_track = new MediaStreamVideoTrack(factory); | |
57 native_track->SetEnabled(track.isEnabled()); | |
58 blink::WebMediaStreamTrack writable_track(track); | 59 blink::WebMediaStreamTrack writable_track(track); |
59 writable_track.setExtraData(native_track); | 60 writable_track.setExtraData( |
| 61 new MediaStreamVideoTrack(native_source, source.constraints(), |
| 62 MediaStreamVideoSource::ConstraintsCallback(), |
| 63 track.isEnabled(), factory)); |
60 } | 64 } |
61 | 65 |
62 void CreateNativeMediaStreamTrack(const blink::WebMediaStreamTrack& track, | 66 void CreateNativeMediaStreamTrack(const blink::WebMediaStreamTrack& track, |
63 MediaStreamDependencyFactory* factory) { | 67 MediaStreamDependencyFactory* factory) { |
64 DCHECK(!track.isNull() && !track.extraData()); | 68 DCHECK(!track.isNull() && !track.extraData()); |
65 DCHECK(!track.source().isNull()); | 69 DCHECK(!track.source().isNull()); |
66 | 70 |
67 switch (track.source().type()) { | 71 switch (track.source().type()) { |
68 case blink::WebMediaStreamSource::TypeAudio: | 72 case blink::WebMediaStreamSource::TypeAudio: |
69 CreateNativeAudioMediaStreamTrack(track, factory); | 73 CreateNativeAudioMediaStreamTrack(track, factory); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 device.type == MEDIA_DEVICE_AUDIO_CAPTURE | 249 device.type == MEDIA_DEVICE_AUDIO_CAPTURE |
246 ? blink::WebSourceInfo::SourceKindAudio | 250 ? blink::WebSourceInfo::SourceKindAudio |
247 : blink::WebSourceInfo::SourceKindVideo, | 251 : blink::WebSourceInfo::SourceKindVideo, |
248 blink::WebString::fromUTF8(device.name), | 252 blink::WebString::fromUTF8(device.name), |
249 video_facing); | 253 video_facing); |
250 } | 254 } |
251 request_it->second.requestSucceeded(sourceInfos); | 255 request_it->second.requestSucceeded(sourceInfos); |
252 } | 256 } |
253 | 257 |
254 } // namespace content | 258 } // namespace content |
OLD | NEW |