| 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/peer_connection_handler_base.h" | 5 #include "content/renderer/media/peer_connection_handler_base.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "content/renderer/media/media_stream_dependency_factory.h" | 9 #include "content/renderer/media/media_stream_dependency_factory.h" |
| 10 #include "content/renderer/media/media_stream_extra_data.h" | 10 #include "content/renderer/media/media_stream_extra_data.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 static_cast<MediaStreamExtraData*>(stream.extraData()); | 22 static_cast<MediaStreamExtraData*>(stream.extraData()); |
| 23 if (extra_data) | 23 if (extra_data) |
| 24 return extra_data->local_stream(); | 24 return extra_data->local_stream(); |
| 25 return NULL; | 25 return NULL; |
| 26 } | 26 } |
| 27 | 27 |
| 28 template <class TrackList> | 28 template <class TrackList> |
| 29 static webrtc::MediaStreamTrackInterface* GetLocalTrack( | 29 static webrtc::MediaStreamTrackInterface* GetLocalTrack( |
| 30 const std::string& source_id, | 30 const std::string& source_id, |
| 31 TrackList* tracks) { | 31 TrackList* tracks) { |
| 32 // TODO(hta): Look at MediaStreamTrackInterface - lookup by ID belongs below. | |
| 33 for (size_t i = 0; i < tracks->count(); ++i) { | 32 for (size_t i = 0; i < tracks->count(); ++i) { |
| 34 if (tracks->at(i)->label() == source_id) | 33 if (tracks->at(i)->id() == source_id) |
| 35 return tracks->at(i); | 34 return tracks->at(i); |
| 36 } | 35 } |
| 37 return NULL; | 36 return NULL; |
| 38 } | 37 } |
| 39 | 38 |
| 40 PeerConnectionHandlerBase::PeerConnectionHandlerBase( | 39 PeerConnectionHandlerBase::PeerConnectionHandlerBase( |
| 41 MediaStreamDependencyFactory* dependency_factory) | 40 MediaStreamDependencyFactory* dependency_factory) |
| 42 : dependency_factory_(dependency_factory), | 41 : dependency_factory_(dependency_factory), |
| 43 message_loop_proxy_(base::MessageLoopProxy::current()) { | 42 message_loop_proxy_(base::MessageLoopProxy::current()) { |
| 44 } | 43 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 74 audio_tracks->count()); | 73 audio_tracks->count()); |
| 75 WebKit::WebVector<WebKit::WebMediaStreamSource> video_source_vector( | 74 WebKit::WebVector<WebKit::WebMediaStreamSource> video_source_vector( |
| 76 video_tracks->count()); | 75 video_tracks->count()); |
| 77 | 76 |
| 78 // Add audio tracks. | 77 // Add audio tracks. |
| 79 size_t i = 0; | 78 size_t i = 0; |
| 80 for (; i < audio_tracks->count(); ++i) { | 79 for (; i < audio_tracks->count(); ++i) { |
| 81 webrtc::AudioTrackInterface* audio_track = audio_tracks->at(i); | 80 webrtc::AudioTrackInterface* audio_track = audio_tracks->at(i); |
| 82 DCHECK(audio_track); | 81 DCHECK(audio_track); |
| 83 audio_source_vector[i].initialize( | 82 audio_source_vector[i].initialize( |
| 84 UTF8ToUTF16(audio_track->label()), | 83 UTF8ToUTF16(audio_track->id()), |
| 85 WebKit::WebMediaStreamSource::TypeAudio, | 84 WebKit::WebMediaStreamSource::TypeAudio, |
| 86 UTF8ToUTF16(audio_track->label())); | 85 UTF8ToUTF16(audio_track->id())); |
| 87 } | 86 } |
| 88 | 87 |
| 89 // Add video tracks. | 88 // Add video tracks. |
| 90 for (i = 0; i < video_tracks->count(); ++i) { | 89 for (i = 0; i < video_tracks->count(); ++i) { |
| 91 webrtc::VideoTrackInterface* video_track = video_tracks->at(i); | 90 webrtc::VideoTrackInterface* video_track = video_tracks->at(i); |
| 92 DCHECK(video_track); | 91 DCHECK(video_track); |
| 93 video_source_vector[i].initialize( | 92 video_source_vector[i].initialize( |
| 94 UTF8ToUTF16(video_track->label()), | 93 UTF8ToUTF16(video_track->id()), |
| 95 WebKit::WebMediaStreamSource::TypeVideo, | 94 WebKit::WebMediaStreamSource::TypeVideo, |
| 96 UTF8ToUTF16(video_track->label())); | 95 UTF8ToUTF16(video_track->id())); |
| 97 } | 96 } |
| 98 WebKit::WebMediaStreamDescriptor descriptor; | 97 WebKit::WebMediaStreamDescriptor descriptor; |
| 99 descriptor.initialize(UTF8ToUTF16(stream->label()), | 98 descriptor.initialize(UTF8ToUTF16(stream->label()), |
| 100 audio_source_vector, video_source_vector); | 99 audio_source_vector, video_source_vector); |
| 101 descriptor.setExtraData(new MediaStreamExtraData(stream)); | 100 descriptor.setExtraData(new MediaStreamExtraData(stream)); |
| 102 return descriptor; | 101 return descriptor; |
| 103 } | 102 } |
| 104 | 103 |
| 105 webrtc::MediaStreamTrackInterface* | 104 webrtc::MediaStreamTrackInterface* |
| 106 PeerConnectionHandlerBase::GetLocalNativeMediaStreamTrack( | 105 PeerConnectionHandlerBase::GetLocalNativeMediaStreamTrack( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 118 } | 117 } |
| 119 if (component.source().type() == WebKit::WebMediaStreamSource::TypeVideo) { | 118 if (component.source().type() == WebKit::WebMediaStreamSource::TypeVideo) { |
| 120 return GetLocalTrack<webrtc::VideoTracks>( | 119 return GetLocalTrack<webrtc::VideoTracks>( |
| 121 source_id, native_stream->video_tracks()); | 120 source_id, native_stream->video_tracks()); |
| 122 } | 121 } |
| 123 NOTIMPLEMENTED(); // We have an unknown type of media stream track. | 122 NOTIMPLEMENTED(); // We have an unknown type of media stream track. |
| 124 return NULL; | 123 return NULL; |
| 125 } | 124 } |
| 126 | 125 |
| 127 } // namespace content | 126 } // namespace content |
| OLD | NEW |