Index: content/renderer/media/peer_connection_handler.cc |
diff --git a/content/renderer/media/peer_connection_handler.cc b/content/renderer/media/peer_connection_handler.cc |
index 74acf2e4d47210257a9e401fc484b64d048ac764..747e95f3166ecc5a8b4c701ff999b2cf540e6b50 100644 |
--- a/content/renderer/media/peer_connection_handler.cc |
+++ b/content/renderer/media/peer_connection_handler.cc |
@@ -22,32 +22,13 @@ PeerConnectionHandler::PeerConnectionHandler( |
WebKit::WebPeerConnectionHandlerClient* client, |
MediaStreamImpl* msi, |
MediaStreamDependencyFactory* dependency_factory) |
- : client_(client), |
- media_stream_impl_(msi), |
- dependency_factory_(dependency_factory), |
- message_loop_proxy_(base::MessageLoopProxy::current()) { |
+ : PeerConnectionHandlerBase(msi, dependency_factory), |
+ client_(client) { |
} |
PeerConnectionHandler::~PeerConnectionHandler() { |
} |
-void PeerConnectionHandler::SetVideoRenderer( |
- const std::string& stream_label, |
- webrtc::VideoRendererWrapperInterface* renderer) { |
- webrtc::MediaStreamInterface* stream = |
- native_peer_connection_->remote_streams()->find(stream_label); |
- webrtc::VideoTracks* video_tracks = stream->video_tracks(); |
- // We assume there is only one enabled video track. |
- for (size_t i = 0; i < video_tracks->count(); ++i) { |
- webrtc::VideoTrackInterface* video_track = video_tracks->at(i); |
- if (video_track->enabled()) { |
- video_track->SetRenderer(renderer); |
- return; |
- } |
- } |
- DVLOG(1) << "No enabled video track."; |
-} |
- |
void PeerConnectionHandler::initialize( |
const WebKit::WebString& server_configuration, |
const WebKit::WebString& username) { |
@@ -60,7 +41,8 @@ void PeerConnectionHandler::initialize( |
void PeerConnectionHandler::produceInitialOffer( |
const WebKit::WebVector<WebKit::WebMediaStreamDescriptor>& |
pending_add_streams) { |
- AddStreams(pending_add_streams); |
+ for (size_t i = 0; i < pending_add_streams.size(); ++i) |
+ AddStream(pending_add_streams[i]); |
native_peer_connection_->CommitStreamChanges(); |
} |
@@ -77,8 +59,10 @@ void PeerConnectionHandler::processPendingStreams( |
pending_add_streams, |
const WebKit::WebVector<WebKit::WebMediaStreamDescriptor>& |
pending_remove_streams) { |
- AddStreams(pending_add_streams); |
- RemoveStreams(pending_remove_streams); |
+ for (size_t i = 0; i < pending_add_streams.size(); ++i) |
+ AddStream(pending_add_streams[i]); |
+ for (size_t i = 0; i < pending_remove_streams.size(); ++i) |
+ RemoveStream(pending_remove_streams[i]); |
native_peer_connection_->CommitStreamChanges(); |
} |
@@ -94,7 +78,7 @@ void PeerConnectionHandler::stop() { |
// close. We need to investigate further. Not calling Close() on native |
// PeerConnection is OK for now. |
native_peer_connection_ = NULL; |
- media_stream_impl_->ClosePeerConnection(); |
+ media_stream_impl_->ClosePeerConnection(this); |
} |
void PeerConnectionHandler::OnError() { |
@@ -154,54 +138,13 @@ void PeerConnectionHandler::OnRemoveStream( |
void PeerConnectionHandler::OnIceCandidate( |
const webrtc::IceCandidateInterface* candidate) { |
- // TODO(grunell): Implement. |
- NOTIMPLEMENTED(); |
+ // Not used by ROAP PeerConnection. |
+ NOTREACHED(); |
} |
void PeerConnectionHandler::OnIceComplete() { |
- // TODO(grunell): Implement. |
- NOTIMPLEMENTED(); |
-} |
- |
-void PeerConnectionHandler::AddStreams( |
- const WebKit::WebVector<WebKit::WebMediaStreamDescriptor>& streams) { |
- for (size_t i = 0; i < streams.size(); ++i) { |
- talk_base::scoped_refptr<webrtc::LocalMediaStreamInterface> stream = |
- dependency_factory_->CreateLocalMediaStream( |
- UTF16ToUTF8(streams[i].label())); |
- WebKit::WebVector<WebKit::WebMediaStreamSource> source_vector; |
- streams[i].sources(source_vector); |
- |
- // Get and add all tracks. |
- for (size_t j = 0; j < source_vector.size(); ++j) { |
- webrtc::MediaStreamTrackInterface* track = |
- media_stream_impl_->GetLocalMediaStreamTrack( |
- UTF16ToUTF8(source_vector[j].id())); |
- DCHECK(track); |
- if (source_vector[j].type() == WebKit::WebMediaStreamSource::TypeVideo) { |
- stream->AddTrack(static_cast<webrtc::VideoTrackInterface*>(track)); |
- } else { |
- stream->AddTrack(static_cast<webrtc::AudioTrackInterface*>(track)); |
- } |
- } |
- |
- native_peer_connection_->AddStream(stream); |
- } |
-} |
- |
-void PeerConnectionHandler::RemoveStreams( |
- const WebKit::WebVector<WebKit::WebMediaStreamDescriptor>& streams) { |
- talk_base::scoped_refptr<webrtc::StreamCollectionInterface> native_streams = |
- native_peer_connection_->local_streams(); |
- // TODO(perkj): Change libJingle PeerConnection::RemoveStream API to take a |
- // label as input instead of stream and return bool. |
- for (size_t i = 0; i < streams.size() && native_streams != NULL; ++i) { |
- webrtc::LocalMediaStreamInterface* stream = |
- static_cast<webrtc::LocalMediaStreamInterface*>(native_streams->find( |
- UTF16ToUTF8(streams[i].label()))); |
- DCHECK(stream); |
- native_peer_connection_->RemoveStream(stream); |
- } |
+ // Not used by ROAP PeerConnection. |
+ NOTREACHED(); |
} |
void PeerConnectionHandler::OnAddStreamCallback( |
@@ -227,40 +170,3 @@ void PeerConnectionHandler::OnRemoveStreamCallback( |
remote_streams_.erase(it); |
client_->didRemoveRemoteStream(descriptor); |
} |
- |
-WebKit::WebMediaStreamDescriptor |
-PeerConnectionHandler::CreateWebKitStreamDescriptor( |
- webrtc::MediaStreamInterface* stream) { |
- webrtc::AudioTracks* audio_tracks = stream->audio_tracks(); |
- webrtc::VideoTracks* video_tracks = stream->video_tracks(); |
- WebKit::WebVector<WebKit::WebMediaStreamSource> source_vector( |
- audio_tracks->count() + video_tracks->count()); |
- |
- // Add audio tracks. |
- size_t i = 0; |
- for (; i < audio_tracks->count(); ++i) { |
- webrtc::AudioTrackInterface* audio_track = audio_tracks->at(i); |
- DCHECK(audio_track); |
- source_vector[i].initialize( |
- // TODO(grunell): Set id to something unique. |
- UTF8ToUTF16(audio_track->label()), |
- WebKit::WebMediaStreamSource::TypeAudio, |
- UTF8ToUTF16(audio_track->label())); |
- } |
- |
- // Add video tracks. |
- for (i = 0; i < video_tracks->count(); ++i) { |
- webrtc::VideoTrackInterface* video_track = video_tracks->at(i); |
- DCHECK(video_track); |
- source_vector[audio_tracks->count() + i].initialize( |
- // TODO(grunell): Set id to something unique. |
- UTF8ToUTF16(video_track->label()), |
- WebKit::WebMediaStreamSource::TypeVideo, |
- UTF8ToUTF16(video_track->label())); |
- } |
- |
- WebKit::WebMediaStreamDescriptor descriptor; |
- descriptor.initialize(UTF8ToUTF16(stream->label()), source_vector); |
- |
- return descriptor; |
-} |