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

Side by Side Diff: webrtc/examples/unityplugin/unity_plugin_apis.cc

Issue 2987723002: Update native plugin dll for turn servers and video. (Closed)
Patch Set: misc change Created 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/examples/unityplugin/unity_plugin_apis.h" 11 #include "webrtc/examples/unityplugin/unity_plugin_apis.h"
12 12
13 #include <map> 13 #include <map>
14 #include <string> 14 #include <string>
15 15
16 #include "webrtc/examples/unityplugin/simple_peer_connection.h" 16 #include "webrtc/examples/unityplugin/simple_peer_connection.h"
17 17
18 namespace { 18 namespace {
19 static int g_peer_connection_id = 1; 19 static int g_peer_connection_id = 1;
20 static std::map<int, rtc::scoped_refptr<SimplePeerConnection>> 20 static std::map<int, rtc::scoped_refptr<SimplePeerConnection>>
21 g_peer_connection_map; 21 g_peer_connection_map;
22 } // namespace 22 } // namespace
23 23
24 int CreatePeerConnection() { 24 int CreatePeerConnection(const char** turn_urls,
25 const int no_of_urls,
26 const char* username,
27 const char* credential) {
25 g_peer_connection_map[g_peer_connection_id] = 28 g_peer_connection_map[g_peer_connection_id] =
26 new rtc::RefCountedObject<SimplePeerConnection>(); 29 new rtc::RefCountedObject<SimplePeerConnection>();
27 30
28 if (!g_peer_connection_map[g_peer_connection_id]->InitializePeerConnection( 31 if (!g_peer_connection_map[g_peer_connection_id]->InitializePeerConnection(
29 false)) 32 turn_urls, no_of_urls, username, credential, false))
30 return -1; 33 return -1;
31 34
32 return g_peer_connection_id++; 35 return g_peer_connection_id++;
33 } 36 }
34 37
35 bool ClosePeerConnection(int peer_connection_id) { 38 bool ClosePeerConnection(int peer_connection_id) {
36 if (!g_peer_connection_map.count(peer_connection_id)) 39 if (!g_peer_connection_map.count(peer_connection_id))
37 return false; 40 return false;
38 41
39 g_peer_connection_map[peer_connection_id]->DeletePeerConnection(); 42 g_peer_connection_map[peer_connection_id]->DeletePeerConnection();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 85
83 bool SetAudioControl(int peer_connection_id, bool is_mute, bool is_record) { 86 bool SetAudioControl(int peer_connection_id, bool is_mute, bool is_record) {
84 if (!g_peer_connection_map.count(peer_connection_id)) 87 if (!g_peer_connection_map.count(peer_connection_id))
85 return false; 88 return false;
86 89
87 g_peer_connection_map[peer_connection_id]->SetAudioControl(is_mute, 90 g_peer_connection_map[peer_connection_id]->SetAudioControl(is_mute,
88 is_record); 91 is_record);
89 return true; 92 return true;
90 } 93 }
91 94
92 // Register callback functions. 95 bool SetRemoteDescription(int peer_connection_id,
93 bool RegisterOnVideoFramReady(int peer_connection_id, 96 const char* type,
94 VIDEOFRAMEREADY_CALLBACK callback) { 97 const char* sdp) {
95 if (!g_peer_connection_map.count(peer_connection_id)) 98 if (!g_peer_connection_map.count(peer_connection_id))
96 return false; 99 return false;
97 100
98 g_peer_connection_map[peer_connection_id]->RegisterOnVideoFramReady(callback); 101 return g_peer_connection_map[peer_connection_id]->SetRemoteDescription(type,
102 sdp);
103 }
104
105 bool AddIceCandidate(const int peer_connection_id,
106 const char* candidate,
107 const int sdp_mlineindex,
108 const char* sdp_mid) {
109 if (!g_peer_connection_map.count(peer_connection_id))
110 return false;
111
112 return g_peer_connection_map[peer_connection_id]->AddIceCandidate(
113 candidate, sdp_mlineindex, sdp_mid);
114 }
115
116 // Register callback functions.
117 bool RegisterOnLocalI420FrameReady(int peer_connection_id,
118 I420FRAMEREADY_CALLBACK callback) {
119 if (!g_peer_connection_map.count(peer_connection_id))
120 return false;
121
122 g_peer_connection_map[peer_connection_id]->RegisterOnLocalI420FrameReady(
123 callback);
124 return true;
125 }
126
127 bool RegisterOnRemoteI420FrameReady(int peer_connection_id,
128 I420FRAMEREADY_CALLBACK callback) {
129 if (!g_peer_connection_map.count(peer_connection_id))
130 return false;
131
132 g_peer_connection_map[peer_connection_id]->RegisterOnRemoteI420FrameReady(
133 callback);
99 return true; 134 return true;
100 } 135 }
101 136
102 bool RegisterOnLocalDataChannelReady(int peer_connection_id, 137 bool RegisterOnLocalDataChannelReady(int peer_connection_id,
103 LOCALDATACHANNELREADY_CALLBACK callback) { 138 LOCALDATACHANNELREADY_CALLBACK callback) {
104 if (!g_peer_connection_map.count(peer_connection_id)) 139 if (!g_peer_connection_map.count(peer_connection_id))
105 return false; 140 return false;
106 141
107 g_peer_connection_map[peer_connection_id]->RegisterOnLocalDataChannelReady( 142 g_peer_connection_map[peer_connection_id]->RegisterOnLocalDataChannelReady(
108 callback); 143 callback);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 bool RegisterOnIceCandiateReadytoSend( 186 bool RegisterOnIceCandiateReadytoSend(
152 int peer_connection_id, 187 int peer_connection_id,
153 ICECANDIDATEREADYTOSEND_CALLBACK callback) { 188 ICECANDIDATEREADYTOSEND_CALLBACK callback) {
154 if (!g_peer_connection_map.count(peer_connection_id)) 189 if (!g_peer_connection_map.count(peer_connection_id))
155 return false; 190 return false;
156 191
157 g_peer_connection_map[peer_connection_id]->RegisterOnIceCandiateReadytoSend( 192 g_peer_connection_map[peer_connection_id]->RegisterOnIceCandiateReadytoSend(
158 callback); 193 callback);
159 return true; 194 return true;
160 } 195 }
161
162 int ReceivedSdp(int peer_connection_id, const char* sdp) {
163 // Create a peer_connection if no one exists.
164 int id = -1;
165 if (g_peer_connection_map.count(peer_connection_id)) {
166 id = peer_connection_id;
167 } else {
168 id = g_peer_connection_id++;
169 g_peer_connection_map[id] =
170 new rtc::RefCountedObject<SimplePeerConnection>();
171 if (!g_peer_connection_map[id]->InitializePeerConnection(true))
172 return -1;
173 }
174
175 g_peer_connection_map[id]->ReceivedSdp(sdp);
176 return id;
177 }
178
179 bool ReceivedIceCandidate(int peer_connection_id, const char* ice_candidate) {
180 if (!g_peer_connection_map.count(peer_connection_id))
181 return false;
182
183 return g_peer_connection_map[peer_connection_id]->ReceivedIceCandidate(
184 ice_candidate);
185 }
OLDNEW
« no previous file with comments | « webrtc/examples/unityplugin/unity_plugin_apis.h ('k') | webrtc/examples/unityplugin/video_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698