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

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

Issue 10804004: Remove the deprecated PeerConnection that uses the ROAP protocol. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed trailing whitespace in webrtc.py Created 8 years, 4 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/renderer/media/peer_connection_handler.h"
6
7 #include "base/bind.h"
8 #include "base/location.h"
9 #include "base/logging.h"
10 #include "base/utf_string_conversions.h"
11 #include "content/renderer/media/media_stream_dependency_factory.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre amDescriptor.h"
13 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre amSource.h"
14 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConne ctionHandlerClient.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h"
16
17 PeerConnectionHandler::PeerConnectionHandler(
18 WebKit::WebPeerConnectionHandlerClient* client,
19 MediaStreamDependencyFactory* dependency_factory)
20 : PeerConnectionHandlerBase(dependency_factory),
21 client_(client) {
22 }
23
24 PeerConnectionHandler::~PeerConnectionHandler() {
25 }
26
27 void PeerConnectionHandler::initialize(
28 const WebKit::WebString& server_configuration,
29 const WebKit::WebString& username) {
30 native_peer_connection_ = dependency_factory_->CreateRoapPeerConnection(
31 UTF16ToUTF8(server_configuration),
32 this);
33 CHECK(native_peer_connection_);
34 }
35
36 void PeerConnectionHandler::produceInitialOffer(
37 const WebKit::WebVector<WebKit::WebMediaStreamDescriptor>&
38 pending_add_streams) {
39 for (size_t i = 0; i < pending_add_streams.size(); ++i)
40 AddStream(pending_add_streams[i]);
41 native_peer_connection_->CommitStreamChanges();
42 }
43
44 void PeerConnectionHandler::handleInitialOffer(const WebKit::WebString& sdp) {
45 native_peer_connection_->ProcessSignalingMessage(UTF16ToUTF8(sdp));
46 }
47
48 void PeerConnectionHandler::processSDP(const WebKit::WebString& sdp) {
49 native_peer_connection_->ProcessSignalingMessage(UTF16ToUTF8(sdp));
50 }
51
52 void PeerConnectionHandler::processPendingStreams(
53 const WebKit::WebVector<WebKit::WebMediaStreamDescriptor>&
54 pending_add_streams,
55 const WebKit::WebVector<WebKit::WebMediaStreamDescriptor>&
56 pending_remove_streams) {
57 for (size_t i = 0; i < pending_add_streams.size(); ++i)
58 AddStream(pending_add_streams[i]);
59 for (size_t i = 0; i < pending_remove_streams.size(); ++i)
60 RemoveStream(pending_remove_streams[i]);
61 native_peer_connection_->CommitStreamChanges();
62 }
63
64 void PeerConnectionHandler::sendDataStreamMessage(
65 const char* data,
66 size_t length) {
67 // TODO(grunell): Implement.
68 NOTIMPLEMENTED();
69 }
70
71 void PeerConnectionHandler::stop() {
72 DVLOG(1) << "PeerConnectionHandler::stop";
73 // TODO(ronghuawu): There's an issue with signaling messages being sent during
74 // close. We need to investigate further. Not calling Close() on native
75 // PeerConnection is OK for now.
76 native_peer_connection_ = NULL;
77 }
78
79 void PeerConnectionHandler::OnError() {
80 // TODO(grunell): Implement.
81 NOTIMPLEMENTED();
82 }
83
84 void PeerConnectionHandler::OnMessage(const std::string& msg) {
85 // TODO(grunell): Implement.
86 NOTIMPLEMENTED();
87 }
88
89 void PeerConnectionHandler::OnSignalingMessage(const std::string& msg) {
90 if (!message_loop_proxy_->BelongsToCurrentThread()) {
91 message_loop_proxy_->PostTask(FROM_HERE, base::Bind(
92 &PeerConnectionHandler::OnSignalingMessage,
93 base::Unretained(this),
94 msg));
95 return;
96 }
97 client_->didGenerateSDP(UTF8ToUTF16(msg));
98 }
99
100 void PeerConnectionHandler::OnStateChange(StateType state_changed) {
101 // TODO(grunell): Implement.
102 NOTIMPLEMENTED();
103 }
104
105 void PeerConnectionHandler::OnAddStream(webrtc::MediaStreamInterface* stream) {
106 if (!stream)
107 return;
108
109 if (!message_loop_proxy_->BelongsToCurrentThread()) {
110 message_loop_proxy_->PostTask(FROM_HERE, base::Bind(
111 &PeerConnectionHandler::OnAddStreamCallback,
112 base::Unretained(this),
113 stream));
114 } else {
115 OnAddStreamCallback(stream);
116 }
117 }
118
119 void PeerConnectionHandler::OnRemoveStream(
120 webrtc::MediaStreamInterface* stream) {
121 if (!stream)
122 return;
123
124 if (!message_loop_proxy_->BelongsToCurrentThread()) {
125 message_loop_proxy_->PostTask(FROM_HERE, base::Bind(
126 &PeerConnectionHandler::OnRemoveStreamCallback,
127 base::Unretained(this),
128 stream));
129 } else {
130 OnRemoveStreamCallback(stream);
131 }
132 }
133
134 void PeerConnectionHandler::OnIceCandidate(
135 const webrtc::IceCandidateInterface* candidate) {
136 // Not used by ROAP PeerConnection.
137 NOTREACHED();
138 }
139
140 void PeerConnectionHandler::OnIceComplete() {
141 // Not used by ROAP PeerConnection.
142 NOTREACHED();
143 }
144
145 void PeerConnectionHandler::OnAddStreamCallback(
146 webrtc::MediaStreamInterface* stream) {
147 DCHECK(remote_streams_.find(stream) == remote_streams_.end());
148 WebKit::WebMediaStreamDescriptor descriptor =
149 CreateWebKitStreamDescriptor(stream);
150 remote_streams_.insert(
151 std::pair<webrtc::MediaStreamInterface*,
152 WebKit::WebMediaStreamDescriptor>(stream, descriptor));
153 client_->didAddRemoteStream(descriptor);
154 }
155
156 void PeerConnectionHandler::OnRemoveStreamCallback(
157 webrtc::MediaStreamInterface* stream) {
158 RemoteStreamMap::iterator it = remote_streams_.find(stream);
159 if (it == remote_streams_.end()) {
160 NOTREACHED() << "Stream not found";
161 return;
162 }
163 WebKit::WebMediaStreamDescriptor descriptor = it->second;
164 DCHECK(!descriptor.isNull());
165 remote_streams_.erase(it);
166 client_->didRemoveRemoteStream(descriptor);
167 }
OLDNEW
« no previous file with comments | « content/renderer/media/peer_connection_handler.h ('k') | content/renderer/media/peer_connection_handler_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698