summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhaibinlu@chromium.org <haibinlu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-08 00:24:28 +0000
committerhaibinlu@chromium.org <haibinlu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-08 00:24:28 +0000
commit0071ca0accdc5300f3d664280a7963a1bfcb3e6d (patch)
treeb065fddd92db8316037687526fd3d33e6445169c
parent8e398d50a76ebaa7d37ff62f06fc65a307718b29 (diff)
downloadchromium_src-0071ca0accdc5300f3d664280a7963a1bfcb3e6d.zip
chromium_src-0071ca0accdc5300f3d664280a7963a1bfcb3e6d.tar.gz
chromium_src-0071ca0accdc5300f3d664280a7963a1bfcb3e6d.tar.bz2
Add cast transport API skeleton.
BUG=301920 TBR=sky Review URL: https://codereview.chromium.org/23892027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@227401 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/common/extensions/api/_api_features.json8
-rw-r--r--chrome/common/extensions/api/_permission_features.json4
-rw-r--r--chrome/common/extensions/api/api.gyp2
-rw-r--r--chrome/common/extensions/api/webrtc_cast_send_transport.idl144
-rw-r--r--chrome/common/extensions/api/webrtc_udp_transport.idl44
-rw-r--r--chrome/common/extensions/permissions/api_permission.h1
-rw-r--r--chrome/common/extensions/permissions/chrome_api_permissions.cc1
-rw-r--r--chrome/common/extensions/permissions/permission_set_unittest.cc1
-rw-r--r--chrome/renderer/extensions/dispatcher.cc4
-rw-r--r--chrome/renderer/resources/extensions/webrtc_cast_send_transport_custom_bindings.js18
-rw-r--r--chrome/renderer/resources/extensions/webrtc_udp_transport_custom_bindings.js18
-rw-r--r--chrome/renderer/resources/renderer_resources.grd2
-rw-r--r--extensions/common/manifest_constants.cc1
13 files changed, 248 insertions, 0 deletions
diff --git a/chrome/common/extensions/api/_api_features.json b/chrome/common/extensions/api/_api_features.json
index 03d9593..94a616a 100644
--- a/chrome/common/extensions/api/_api_features.json
+++ b/chrome/common/extensions/api/_api_features.json
@@ -641,6 +641,14 @@
"dependencies": ["permission:webstorePrivate"],
"contexts": ["blessed_extension"]
},
+ "webrtc.castSendTransport": {
+ "dependencies": ["permission:webrtc"],
+ "contexts": ["blessed_extension"]
+ },
+ "webrtc.udpTransport": {
+ "dependencies": ["permission:webrtc"],
+ "contexts": ["blessed_extension"]
+ },
"webview": {
"internal": true,
"dependencies": ["permission:webview"],
diff --git a/chrome/common/extensions/api/_permission_features.json b/chrome/common/extensions/api/_permission_features.json
index 1fd9853..b0531ec 100644
--- a/chrome/common/extensions/api/_permission_features.json
+++ b/chrome/common/extensions/api/_permission_features.json
@@ -777,6 +777,10 @@
"channel": "stable",
"extension_types": ["extension", "legacy_packaged_app"]
},
+ "webrtc": {
+ "channel": "trunk",
+ "extension_types": ["extension"]
+ },
"webrtcLoggingPrivate": {
"channel": "stable",
"extension_types": ["extension"],
diff --git a/chrome/common/extensions/api/api.gyp b/chrome/common/extensions/api/api.gyp
index b1b256d..8a14555 100644
--- a/chrome/common/extensions/api/api.gyp
+++ b/chrome/common/extensions/api/api.gyp
@@ -113,7 +113,9 @@
'wallpaper_private.json',
'web_navigation.json',
'web_request.json',
+ 'webrtc_cast_send_transport.idl',
'webrtc_logging_private.idl',
+ 'webrtc_udp_transport.idl',
'webstore_private.json',
'webview.json',
'windows.json',
diff --git a/chrome/common/extensions/api/webrtc_cast_send_transport.idl b/chrome/common/extensions/api/webrtc_cast_send_transport.idl
new file mode 100644
index 0000000..1a851fd
--- /dev/null
+++ b/chrome/common/extensions/api/webrtc_cast_send_transport.idl
@@ -0,0 +1,144 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// The <code>chrome.webrtc.castSendTransport</code> API takes a track as
+// a source of media, and sends that media on the inner transport according to
+// the given RtpParams.
+namespace webrtc.castSendTransport {
+ // Params for audio and video codec.
+ dictionary CodecSpecificParam {
+ DOMString key;
+ DOMString value;
+ };
+
+ // RTP payload param.
+ dictionary RtpPayloadParam {
+ long payloadType;
+
+ DOMString codecName;
+
+ // Synchronization source identifier.
+ long? ssrc;
+
+ long? clockRate;
+
+ long? minBitrate;
+
+ long? maxBitrate;
+
+ // The number of channels.
+ long? channels;
+
+ // Video width in pixels.
+ long? width;
+
+ // Video height in pixels.
+ long? height;
+
+ // A list of codec specific params.
+ CodecSpecificParam[] codecSpecficParams;
+ };
+
+ // Cast transport capabilities
+ dictionary CastTransportCaps {
+ // RTP payload params.
+ RtpPayloadParam[] payloads;
+
+ DOMString[] rtcpFeatures;
+
+ DOMString[] fecMechanisms;
+ };
+
+ // Cast transport params.
+ dictionary CastTransportParams {
+ // RTP payload params.
+ RtpPayloadParam[] payloads;
+
+ DOMString[] rtcpFeatures;
+
+ DOMString[] fecMechanisms;
+ };
+
+ // Result of <code>create</code> call.
+ dictionary CreateInfo {
+ // The ID of the newly created transport.
+ long id;
+ };
+
+ // Callback from the <code>create</code> method.
+ // |id| : The transport id.
+ // A null value indicates an error.
+ callback CreateCallback = void (CreateInfo id);
+
+ // Callback from the <code>createParams</code> method.
+ // |params| : The cast transport params.
+ // A null value indicates an error.
+ callback CreateParamsCallback = void (CastTransportParams params);
+
+ interface Functions {
+ // Creates a cast send transport.
+ // |innerTransportId| : the ID of the inner transport. The transport to be
+ // created will send data on the inner transport.
+ // |callback| : Called when the transport has been created.
+ [nocompile] static void create(long innerTransportId,
+ CreateCallback callback);
+
+ // Creates suitable params given the capabilities.
+ // |caps| : the capabilities.
+ // |callback| : Called when the params has been created.
+ [nocompile] static void createParams(CastTransportCaps caps,
+ CreateParamsCallback callback);
+
+ // Set the source of media.
+ // |transportId| : the transport ID.
+ // |track| : A media stream track.
+ [nocompile] static void setTrack(long transportId,
+ [instanceOf=MediaStreamTrack] object track);
+
+ // Starts to use the transport by providing remote params info.
+ // |transportId| : The transport ID.
+ // |remoteParams| : The remote params.
+ [nocompile] static void start(long transportId,
+ CastTransportParams remoteParams);
+
+ // Stops using the transport.
+ // |transportId| : The transport ID.
+ [nocompile] static void stop(long transportId);
+
+ // Mutes the media track.
+ // |transportId| : The transport ID.
+ [nocompile] static void mute(long transportId);
+
+ // Unmute the media track.
+ // |transportId| : The transport ID.
+ [nocompile] static void unmute(long transportId);
+ };
+
+ interface Events {
+ // Event fired when a cast send transport has started.
+ // |transportId| : The ID of the transport.
+ static void onStarted(long transportId);
+
+ // Event fired when a cast send transport has connected.
+ // After this event, the transport is ready to send the track.
+ // |transportId| : The ID of the transport.
+ static void onConnected(long transportId);
+
+ // Event fired when a cast send transport has stopped.
+ // |transportId| : The ID of the transport.
+ static void onStopped(long transportId);
+
+ // Event fired when a cast send transport has timeout.
+ // This happens when network has been congested for a while, or one side
+ // left.
+ // |transportId| : The ID of the transport.
+ static void onTimeout(long transportId);
+
+ // Event fired when a cast send transport has error.
+ // |transportId| : The ID of the transport.
+ // |errorString| : The error info.
+ static void onError(long transportId, DOMString errorString);
+ };
+};
+
diff --git a/chrome/common/extensions/api/webrtc_udp_transport.idl b/chrome/common/extensions/api/webrtc_udp_transport.idl
new file mode 100644
index 0000000..f118671
--- /dev/null
+++ b/chrome/common/extensions/api/webrtc_udp_transport.idl
@@ -0,0 +1,44 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// The <code>chrome.webrtc.udpTransport</code> API creates a UDP transport
+// for outer transport to send and receive data. This API is not useful when
+// standalone since it does not have send and receive methods. It should be
+// used as an inner transport for other transports such as castSendTransport.
+namespace webrtc.udpTransport {
+ // The UDP socket address and port.
+ dictionary UdpParams {
+ DOMString address;
+ long port;
+ };
+
+ // Result of <code>create</code> call.
+ dictionary CreateInfo {
+ // The ID of the newly created UDP transport.
+ long id;
+
+ // The transport params.
+ UdpParams params;
+ };
+
+ // Callback from the <code>create</code> method.
+ // |createInfo| : The transport info.
+ // A null value indicates an error.
+ callback CreateCallback = void (CreateInfo createInfo);
+
+ interface Functions {
+ // Creates a UDP transport.
+ // |callback| : Called when the transport has been created.
+ [nocompile] static void create(CreateCallback callback);
+
+ // Starts to use the transport by providing remote UDP info.
+ // |transportId| : The transport ID.
+ // |remoteParams| : The address and port to send packets to.
+ [nocompile] static void start(long transportId, UdpParams remoteParams);
+
+ // Stops using the transport.
+ // |transportId| : The transport ID.
+ [nocompile] static void stop(long transportId);
+ };
+};
diff --git a/chrome/common/extensions/permissions/api_permission.h b/chrome/common/extensions/permissions/api_permission.h
index 10e3e8d..1debe6e 100644
--- a/chrome/common/extensions/permissions/api_permission.h
+++ b/chrome/common/extensions/permissions/api_permission.h
@@ -153,6 +153,7 @@ class APIPermission {
kWebRequest,
kWebRequestBlocking,
kWebRequestInternal,
+ kWebRtc,
kWebrtcLoggingPrivate,
kWebstorePrivate,
kWebView,
diff --git a/chrome/common/extensions/permissions/chrome_api_permissions.cc b/chrome/common/extensions/permissions/chrome_api_permissions.cc
index 05ee590..55b10a9 100644
--- a/chrome/common/extensions/permissions/chrome_api_permissions.cc
+++ b/chrome/common/extensions/permissions/chrome_api_permissions.cc
@@ -345,6 +345,7 @@ std::vector<APIPermissionInfo*> ChromeAPIPermissions::GetAllPermissions()
{ APIPermission::kPointerLock, "pointerLock" },
{ APIPermission::kFullscreen, "fullscreen" },
{ APIPermission::kAudio, "audio" },
+ { APIPermission::kWebRtc, "webrtc" },
};
std::vector<APIPermissionInfo*> permissions;
diff --git a/chrome/common/extensions/permissions/permission_set_unittest.cc b/chrome/common/extensions/permissions/permission_set_unittest.cc
index c4cbfa3..9cbd689 100644
--- a/chrome/common/extensions/permissions/permission_set_unittest.cc
+++ b/chrome/common/extensions/permissions/permission_set_unittest.cc
@@ -663,6 +663,7 @@ TEST(PermissionsTest, PermissionMessages) {
skip.insert(APIPermission::kSystemStorage);
skip.insert(APIPermission::kTts);
skip.insert(APIPermission::kUnlimitedStorage);
+ skip.insert(APIPermission::kWebRtc);
skip.insert(APIPermission::kWebView);
// TODO(erikkay) add a string for this permission.
diff --git a/chrome/renderer/extensions/dispatcher.cc b/chrome/renderer/extensions/dispatcher.cc
index 822d5e5..a4f98f6 100644
--- a/chrome/renderer/extensions/dispatcher.cc
+++ b/chrome/renderer/extensions/dispatcher.cc
@@ -960,6 +960,10 @@ void Dispatcher::PopulateSourceMap() {
source_map_.RegisterSource("webRequest", IDR_WEB_REQUEST_CUSTOM_BINDINGS_JS);
source_map_.RegisterSource("webRequestInternal",
IDR_WEB_REQUEST_INTERNAL_CUSTOM_BINDINGS_JS);
+ source_map_.RegisterSource("webrtc.castSendTransport",
+ IDR_WEBRTC_CAST_SEND_TRANSPORT_CUSTOM_BINDINGS_JS);
+ source_map_.RegisterSource("webrtc.udpTransport",
+ IDR_WEBRTC_UDP_TRANSPORT_CUSTOM_BINDINGS_JS);
source_map_.RegisterSource("webstore", IDR_WEBSTORE_CUSTOM_BINDINGS_JS);
source_map_.RegisterSource("windowControls", IDR_WINDOW_CONTROLS_JS);
source_map_.RegisterSource("binding", IDR_BINDING_JS);
diff --git a/chrome/renderer/resources/extensions/webrtc_cast_send_transport_custom_bindings.js b/chrome/renderer/resources/extensions/webrtc_cast_send_transport_custom_bindings.js
new file mode 100644
index 0000000..6ba4c6f
--- /dev/null
+++ b/chrome/renderer/resources/extensions/webrtc_cast_send_transport_custom_bindings.js
@@ -0,0 +1,18 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Custom binding for the webrtc custom transport API.
+
+var binding = require('binding').Binding.create('webrtc.castSendTransport');
+
+binding.registerCustomHook(function(bindingsAPI, extensionId) {
+ var apiFunctions = bindingsAPI.apiFunctions;
+
+ apiFunctions.setHandleRequest('create',
+ function(innerTransportId, callback) {
+ // invoke impl here.
+ });
+});
+
+exports.binding = binding.generate();
diff --git a/chrome/renderer/resources/extensions/webrtc_udp_transport_custom_bindings.js b/chrome/renderer/resources/extensions/webrtc_udp_transport_custom_bindings.js
new file mode 100644
index 0000000..3b0b42f
--- /dev/null
+++ b/chrome/renderer/resources/extensions/webrtc_udp_transport_custom_bindings.js
@@ -0,0 +1,18 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Custom binding for the webrtc custom transport API.
+
+var binding = require('binding').Binding.create('webrtc.udpTransport');
+
+binding.registerCustomHook(function(bindingsAPI, extensionId) {
+ var apiFunctions = bindingsAPI.apiFunctions;
+
+ apiFunctions.setHandleRequest('create',
+ function(callback) {
+ // invoke impl here.
+ });
+});
+
+exports.binding = binding.generate();
diff --git a/chrome/renderer/resources/renderer_resources.grd b/chrome/renderer/resources/renderer_resources.grd
index 2c1673f..fc0db75 100644
--- a/chrome/renderer/resources/renderer_resources.grd
+++ b/chrome/renderer/resources/renderer_resources.grd
@@ -89,6 +89,8 @@ without changes to the corresponding grd file. fb9 -->
<include name="IDR_WINDOW_CONTROLS_TEMPLATE_HTML" file="extensions\window_controls_template.html" type="BINDATA" />
<include name="IDR_WEB_REQUEST_CUSTOM_BINDINGS_JS" file="extensions\web_request_custom_bindings.js" type="BINDATA" />
<include name="IDR_WEB_REQUEST_INTERNAL_CUSTOM_BINDINGS_JS" file="extensions\web_request_internal_custom_bindings.js" type="BINDATA" />
+ <include name="IDR_WEBRTC_CAST_SEND_TRANSPORT_CUSTOM_BINDINGS_JS" file="extensions\webrtc_cast_send_transport_custom_bindings.js" type="BINDATA" />
+ <include name="IDR_WEBRTC_UDP_TRANSPORT_CUSTOM_BINDINGS_JS" file="extensions\webrtc_udp_transport_custom_bindings.js" type="BINDATA" />
<include name="IDR_WEBSTORE_CUSTOM_BINDINGS_JS" file="extensions\webstore_custom_bindings.js" type="BINDATA" />
<include name="IDR_WEB_VIEW_DENY_JS" file="extensions\web_view_deny.js" type="BINDATA" />
<include name="IDR_WEB_VIEW_EXPERIMENTAL_JS" file="extensions\web_view_experimental.js" type="BINDATA" />
diff --git a/extensions/common/manifest_constants.cc b/extensions/common/manifest_constants.cc
index fce206e..dccf628 100644
--- a/extensions/common/manifest_constants.cc
+++ b/extensions/common/manifest_constants.cc
@@ -148,6 +148,7 @@ const char kUrlHandlers[] = "url_handlers";
const char kUrlHandlerTitle[] = "title";
const char kVersion[] = "version";
const char kWebAccessibleResources[] = "web_accessible_resources";
+const char kWebRtc[] = "webrtc";
const char kWebURLs[] = "app.urls";
const char kWebview[] = "webview";
const char kWebviewAccessibleResources[] = "accessible_resources";