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

Side by Side Diff: content/renderer/media/peer_connection_handler_base.cc

Issue 12084088: Renamed WebMediaStreamComponent and WebMediaStreamDescriptor to WebMediaStreamTrack & WebMediaStream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStreamCompo nent.h" 11 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStream.h"
12 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStreamDescr iptor.h"
13 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStreamSourc e.h" 12 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStreamSourc e.h"
13 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStreamTrack .h"
14 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" 14 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h"
15 15
16 namespace content { 16 namespace content {
17 17
18 // TODO(hta): Unify implementations of these functions from MediaStreamCenter 18 // TODO(hta): Unify implementations of these functions from MediaStreamCenter
19 static webrtc::LocalMediaStreamInterface* GetLocalNativeMediaStream( 19 static webrtc::LocalMediaStreamInterface* GetLocalNativeMediaStream(
20 const WebKit::WebMediaStreamDescriptor& stream) { 20 const WebKit::WebMediaStream& stream) {
21 MediaStreamExtraData* extra_data = 21 MediaStreamExtraData* extra_data =
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 for (size_t i = 0; i < tracks->count(); ++i) { 32 for (size_t i = 0; i < tracks->count(); ++i) {
33 if (tracks->at(i)->id() == source_id) 33 if (tracks->at(i)->id() == source_id)
34 return tracks->at(i); 34 return tracks->at(i);
35 } 35 }
36 return NULL; 36 return NULL;
37 } 37 }
38 38
39 PeerConnectionHandlerBase::PeerConnectionHandlerBase( 39 PeerConnectionHandlerBase::PeerConnectionHandlerBase(
40 MediaStreamDependencyFactory* dependency_factory) 40 MediaStreamDependencyFactory* dependency_factory)
41 : dependency_factory_(dependency_factory), 41 : dependency_factory_(dependency_factory),
42 message_loop_proxy_(base::MessageLoopProxy::current()) { 42 message_loop_proxy_(base::MessageLoopProxy::current()) {
43 } 43 }
44 44
45 PeerConnectionHandlerBase::~PeerConnectionHandlerBase() { 45 PeerConnectionHandlerBase::~PeerConnectionHandlerBase() {
46 } 46 }
47 47
48 bool PeerConnectionHandlerBase::AddStream( 48 bool PeerConnectionHandlerBase::AddStream(
49 const WebKit::WebMediaStreamDescriptor& stream, 49 const WebKit::WebMediaStream& stream,
50 const webrtc::MediaConstraintsInterface* constraints) { 50 const webrtc::MediaConstraintsInterface* constraints) {
51 webrtc::LocalMediaStreamInterface* native_stream = 51 webrtc::LocalMediaStreamInterface* native_stream =
52 GetLocalNativeMediaStream(stream); 52 GetLocalNativeMediaStream(stream);
53 if (!native_stream) 53 if (!native_stream)
54 return false; 54 return false;
55 return native_peer_connection_->AddStream(native_stream, constraints); 55 return native_peer_connection_->AddStream(native_stream, constraints);
56 } 56 }
57 57
58 void PeerConnectionHandlerBase::RemoveStream( 58 void PeerConnectionHandlerBase::RemoveStream(
59 const WebKit::WebMediaStreamDescriptor& stream) { 59 const WebKit::WebMediaStream& stream) {
60 webrtc::LocalMediaStreamInterface* native_stream = 60 webrtc::LocalMediaStreamInterface* native_stream =
61 GetLocalNativeMediaStream(stream); 61 GetLocalNativeMediaStream(stream);
62 if (native_stream) 62 if (native_stream)
63 native_peer_connection_->RemoveStream(native_stream); 63 native_peer_connection_->RemoveStream(native_stream);
64 DCHECK(native_stream); 64 DCHECK(native_stream);
65 } 65 }
66 66
67 WebKit::WebMediaStreamDescriptor 67 WebKit::WebMediaStream
68 PeerConnectionHandlerBase::CreateWebKitStreamDescriptor( 68 PeerConnectionHandlerBase::CreateWebKitStreamDescriptor(
69 webrtc::MediaStreamInterface* stream) { 69 webrtc::MediaStreamInterface* stream) {
70 webrtc::AudioTracks* audio_tracks = stream->audio_tracks(); 70 webrtc::AudioTracks* audio_tracks = stream->audio_tracks();
71 webrtc::VideoTracks* video_tracks = stream->video_tracks(); 71 webrtc::VideoTracks* video_tracks = stream->video_tracks();
72 WebKit::WebVector<WebKit::WebMediaStreamSource> audio_source_vector( 72 WebKit::WebVector<WebKit::WebMediaStreamSource> audio_source_vector(
73 audio_tracks->count()); 73 audio_tracks->count());
74 WebKit::WebVector<WebKit::WebMediaStreamSource> video_source_vector( 74 WebKit::WebVector<WebKit::WebMediaStreamSource> video_source_vector(
75 video_tracks->count()); 75 video_tracks->count());
76 76
77 // Add audio tracks. 77 // Add audio tracks.
78 size_t i = 0; 78 size_t i = 0;
79 for (; i < audio_tracks->count(); ++i) { 79 for (; i < audio_tracks->count(); ++i) {
80 webrtc::AudioTrackInterface* audio_track = audio_tracks->at(i); 80 webrtc::AudioTrackInterface* audio_track = audio_tracks->at(i);
81 DCHECK(audio_track); 81 DCHECK(audio_track);
82 audio_source_vector[i].initialize( 82 audio_source_vector[i].initialize(
83 UTF8ToUTF16(audio_track->id()), 83 UTF8ToUTF16(audio_track->id()),
84 WebKit::WebMediaStreamSource::TypeAudio, 84 WebKit::WebMediaStreamSource::TypeAudio,
85 UTF8ToUTF16(audio_track->id())); 85 UTF8ToUTF16(audio_track->id()));
86 } 86 }
87 87
88 // Add video tracks. 88 // Add video tracks.
89 for (i = 0; i < video_tracks->count(); ++i) { 89 for (i = 0; i < video_tracks->count(); ++i) {
90 webrtc::VideoTrackInterface* video_track = video_tracks->at(i); 90 webrtc::VideoTrackInterface* video_track = video_tracks->at(i);
91 DCHECK(video_track); 91 DCHECK(video_track);
92 video_source_vector[i].initialize( 92 video_source_vector[i].initialize(
93 UTF8ToUTF16(video_track->id()), 93 UTF8ToUTF16(video_track->id()),
94 WebKit::WebMediaStreamSource::TypeVideo, 94 WebKit::WebMediaStreamSource::TypeVideo,
95 UTF8ToUTF16(video_track->id())); 95 UTF8ToUTF16(video_track->id()));
96 } 96 }
97 WebKit::WebMediaStreamDescriptor descriptor; 97 WebKit::WebMediaStream descriptor;
98 descriptor.initialize(UTF8ToUTF16(stream->label()), 98 descriptor.initialize(UTF8ToUTF16(stream->label()),
99 audio_source_vector, video_source_vector); 99 audio_source_vector, video_source_vector);
100 descriptor.setExtraData(new MediaStreamExtraData(stream)); 100 descriptor.setExtraData(new MediaStreamExtraData(stream));
101 return descriptor; 101 return descriptor;
102 } 102 }
103 103
104 webrtc::MediaStreamTrackInterface* 104 webrtc::MediaStreamTrackInterface*
105 PeerConnectionHandlerBase::GetLocalNativeMediaStreamTrack( 105 PeerConnectionHandlerBase::GetLocalNativeMediaStreamTrack(
106 const WebKit::WebMediaStreamDescriptor& stream, 106 const WebKit::WebMediaStream& stream,
107 const WebKit::WebMediaStreamComponent& component) { 107 const WebKit::WebMediaStreamTrack& component) {
108 std::string source_id = UTF16ToUTF8(component.source().id()); 108 std::string source_id = UTF16ToUTF8(component.source().id());
109 webrtc::MediaStreamInterface* native_stream 109 webrtc::MediaStreamInterface* native_stream
110 = GetLocalNativeMediaStream(stream); 110 = GetLocalNativeMediaStream(stream);
111 if (!native_stream) { 111 if (!native_stream) {
112 return NULL; 112 return NULL;
113 } 113 }
114 if (component.source().type() == WebKit::WebMediaStreamSource::TypeAudio) { 114 if (component.source().type() == WebKit::WebMediaStreamSource::TypeAudio) {
115 return GetLocalTrack<webrtc::AudioTracks>( 115 return GetLocalTrack<webrtc::AudioTracks>(
116 source_id, native_stream->audio_tracks()); 116 source_id, native_stream->audio_tracks());
117 } 117 }
118 if (component.source().type() == WebKit::WebMediaStreamSource::TypeVideo) { 118 if (component.source().type() == WebKit::WebMediaStreamSource::TypeVideo) {
119 return GetLocalTrack<webrtc::VideoTracks>( 119 return GetLocalTrack<webrtc::VideoTracks>(
120 source_id, native_stream->video_tracks()); 120 source_id, native_stream->video_tracks());
121 } 121 }
122 NOTIMPLEMENTED(); // We have an unknown type of media stream track. 122 NOTIMPLEMENTED(); // We have an unknown type of media stream track.
123 return NULL; 123 return NULL;
124 } 124 }
125 125
126 } // namespace content 126 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/peer_connection_handler_base.h ('k') | content/renderer/media/peer_connection_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698