android-emulator-webrtc 1.0.17 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +93 -204
- package/dist/components/emulator/emulator.d.ts +64 -0
- package/dist/components/emulator/emulator.js +161 -173
- package/dist/components/emulator/net/emulator_status.d.ts +45 -0
- package/dist/components/emulator/net/emulator_status.js +35 -42
- package/dist/components/emulator/net/logcat.js +37 -54
- package/dist/components/emulator/net/logger.d.ts +7 -0
- package/dist/components/emulator/net/logger.js +20 -0
- package/dist/components/emulator/net/ws_jsep_protocol_driver.d.ts +213 -0
- package/dist/components/emulator/net/ws_jsep_protocol_driver.js +640 -0
- package/dist/components/emulator/views/event_handler.d.ts +37 -0
- package/dist/components/emulator/views/event_handler.js +274 -260
- package/dist/components/emulator/views/webrtc_view.d.ts +27 -0
- package/dist/components/emulator/views/webrtc_view.js +42 -25
- package/dist/index.d.ts +8 -0
- package/dist/index.js +0 -7
- package/dist/proto/emulator_controller_pb.d.ts +1 -0
- package/dist/proto/emulator_controller_pb.js +146 -287
- package/dist/src/components/emulator/emulator.d.ts +64 -0
- package/dist/src/components/emulator/net/emulator_status.d.ts +45 -0
- package/dist/src/components/emulator/net/logger.d.ts +7 -0
- package/dist/src/components/emulator/net/ws_jsep_protocol_driver.d.ts +213 -0
- package/dist/src/components/emulator/views/event_handler.d.ts +37 -0
- package/dist/src/components/emulator/views/webrtc_view.d.ts +27 -0
- package/dist/src/index.d.ts +8 -0
- package/dist/src/proto/emulator_controller_pb.d.ts +1 -0
- package/package.json +17 -18
- package/proto/emulator_controller.proto +746 -181
- package/.vscode/launch.json +0 -21
- package/.vscode/settings.json +0 -3
- package/CONTRIBUTING.md +0 -28
- package/Makefile +0 -123
- package/android-emulator-webrtc.code-workspace +0 -7
- package/api_descriptor.pb +0 -0
- package/babel.config.js +0 -16
- package/cloudbuild.yaml +0 -41
- package/cloudbuilders/.gcloudignore +0 -1
- package/cloudbuilders/Dockerfile +0 -20
- package/cloudbuilders/README.md +0 -29
- package/cloudbuilders/cloudbuild.yaml +0 -19
- package/dist/components/emulator/net/jsep_protocol_driver.js +0 -365
- package/dist/components/emulator/views/resizing_component.js +0 -86
- package/dist/components/emulator/views/simple_png_view.js +0 -111
- package/dist/proto/emulator_controller_grpc_web_pb.js +0 -1601
- package/dist/proto/emulator_web_client.js +0 -176
- package/dist/proto/rtc_service_grpc_web_pb.js +0 -231
- package/dist/proto/rtc_service_pb.js +0 -338
- package/emulator/index.js +0 -1
- package/eslint_prefix.py +0 -37
- package/gen_md_doc.js +0 -40
- package/npmrc.enc +0 -0
- package/proto/rtc_service.proto +0 -117
- package/protoc-plugin/Makefile +0 -31
- package/protoc-plugin/grpc_generator.cc +0 -1755
- package/src/components/emulator/emulator.js +0 -217
- package/src/components/emulator/net/emulator_status.js +0 -94
- package/src/components/emulator/net/jsep_protocol_driver.js +0 -364
- package/src/components/emulator/net/logcat.js +0 -155
- package/src/components/emulator/views/event_handler.js +0 -268
- package/src/components/emulator/views/resizing_component.js +0 -65
- package/src/components/emulator/views/simple_png_view.js +0 -106
- package/src/components/emulator/views/webrtc_view.js +0 -146
- package/src/index.js +0 -20
- package/src/proto/emulator_web_client.js +0 -140
- package/test/cloudbuild.yaml +0 -41
- package/test/emulator.test.js +0 -125
- package/test/event_handler.test.js +0 -91
- package/test/fake_events.js +0 -50
- package/test/jsep_protocol_driver.test.js +0 -228
- package/test/resizing_component.test.js +0 -37
- package/test/simple_png_view.test.js +0 -145
- package/test/touch_event_handler.test.js +0 -118
|
@@ -9,6 +9,7 @@ exports["default"] = void 0;
|
|
|
9
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _logger = _interopRequireDefault(require("../net/logger"));
|
|
12
13
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
14
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
14
15
|
/*
|
|
@@ -27,13 +28,35 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
27
28
|
* limitations under the License.
|
|
28
29
|
*/
|
|
29
30
|
|
|
31
|
+
/**
|
|
32
|
+
* A React component that renders the WebRTC video stream of the emulator.
|
|
33
|
+
* Handles establishing the stream via the JSEP protocol driver and managing
|
|
34
|
+
* local playback (including handling autoplay constraints).
|
|
35
|
+
*
|
|
36
|
+
* @param {Object} props Component properties.
|
|
37
|
+
* @param {Object} props.jsep The JSEP protocol driver instance.
|
|
38
|
+
* @param {function(string): void} [props.onStateChange] Callback for connection state changes ("connecting", "connected", "disconnected").
|
|
39
|
+
* @param {function(boolean): void} [props.onAudioStateChange] Callback when audio track status changes.
|
|
40
|
+
* @param {boolean} [props.muted=true] Whether the audio should be muted.
|
|
41
|
+
* @param {number} [props.volume=1.0] Audio volume (between 0.0 and 1.0).
|
|
42
|
+
* @param {function(Error): void} props.onError Callback invoked on signaling or playback errors.
|
|
43
|
+
* @param {number} [props.width] Component width.
|
|
44
|
+
* @param {number} [props.height] Component height.
|
|
45
|
+
*/
|
|
30
46
|
var EmulatorWebrtcView = function EmulatorWebrtcView(_ref) {
|
|
31
47
|
var jsep = _ref.jsep,
|
|
32
48
|
onStateChange = _ref.onStateChange,
|
|
33
49
|
onAudioStateChange = _ref.onAudioStateChange,
|
|
34
|
-
muted = _ref.muted,
|
|
35
|
-
|
|
36
|
-
|
|
50
|
+
_ref$muted = _ref.muted,
|
|
51
|
+
muted = _ref$muted === void 0 ? true : _ref$muted,
|
|
52
|
+
_ref$volume = _ref.volume,
|
|
53
|
+
volume = _ref$volume === void 0 ? 1.0 : _ref$volume,
|
|
54
|
+
_ref$onError = _ref.onError,
|
|
55
|
+
onError = _ref$onError === void 0 ? function (e) {
|
|
56
|
+
return _logger["default"].error("WebRTC error: " + e);
|
|
57
|
+
} : _ref$onError,
|
|
58
|
+
width = _ref.width,
|
|
59
|
+
height = _ref.height;
|
|
37
60
|
var _useState = (0, _react.useState)(false),
|
|
38
61
|
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
39
62
|
audio = _useState2[0],
|
|
@@ -44,13 +67,11 @@ var EmulatorWebrtcView = function EmulatorWebrtcView(_ref) {
|
|
|
44
67
|
connect = _useState4[0],
|
|
45
68
|
setConnect = _useState4[1];
|
|
46
69
|
(0, _react.useEffect)(function () {
|
|
47
|
-
console.log("Webrtc state changed to: " + connect);
|
|
48
70
|
if (onStateChange) {
|
|
49
71
|
onStateChange(connect);
|
|
50
72
|
}
|
|
51
73
|
}, [connect]);
|
|
52
74
|
(0, _react.useEffect)(function () {
|
|
53
|
-
console.log("Webrtc audio state changed to: " + audio);
|
|
54
75
|
if (onAudioStateChange) {
|
|
55
76
|
onAudioStateChange(audio);
|
|
56
77
|
}
|
|
@@ -83,7 +104,7 @@ var EmulatorWebrtcView = function EmulatorWebrtcView(_ref) {
|
|
|
83
104
|
var possiblePromise = video.play();
|
|
84
105
|
if (possiblePromise) {
|
|
85
106
|
possiblePromise.then(function (_) {
|
|
86
|
-
|
|
107
|
+
_logger["default"].debug("Automatic playback started!");
|
|
87
108
|
})["catch"](function (error) {
|
|
88
109
|
// Notify listeners that we cannot start.
|
|
89
110
|
onError(error);
|
|
@@ -97,25 +118,30 @@ var EmulatorWebrtcView = function EmulatorWebrtcView(_ref) {
|
|
|
97
118
|
e.preventDefault();
|
|
98
119
|
};
|
|
99
120
|
(0, _react.useEffect)(function () {
|
|
100
|
-
jsep.
|
|
101
|
-
|
|
102
|
-
|
|
121
|
+
jsep.startStream({
|
|
122
|
+
onConnected: onConnect,
|
|
123
|
+
onDisconnected: onDisconnect
|
|
124
|
+
});
|
|
103
125
|
setConnect("connecting");
|
|
104
126
|
return function () {
|
|
105
127
|
jsep.disconnect();
|
|
106
128
|
};
|
|
107
129
|
}, []);
|
|
130
|
+
(0, _react.useEffect)(function () {
|
|
131
|
+
if (videoRef.current) {
|
|
132
|
+
videoRef.current.volume = volume;
|
|
133
|
+
}
|
|
134
|
+
}, [volume]);
|
|
108
135
|
return /*#__PURE__*/_react["default"].createElement("video", {
|
|
109
136
|
ref: videoRef,
|
|
110
137
|
style: {
|
|
111
138
|
display: "block",
|
|
112
139
|
position: "relative",
|
|
113
|
-
width: "100%",
|
|
114
|
-
height: "100%",
|
|
140
|
+
width: width ? "".concat(width, "px") : "100%",
|
|
141
|
+
height: height ? "".concat(height, "px") : "100%",
|
|
115
142
|
objectFit: "contain",
|
|
116
143
|
objectPosition: "center"
|
|
117
144
|
},
|
|
118
|
-
volume: volume,
|
|
119
145
|
muted: muted,
|
|
120
146
|
onContextMenu: onContextMenu,
|
|
121
147
|
onCanPlay: onCanPlay
|
|
@@ -127,17 +153,8 @@ EmulatorWebrtcView.propTypes = {
|
|
|
127
153
|
onAudioStateChange: _propTypes["default"].func,
|
|
128
154
|
muted: _propTypes["default"].bool,
|
|
129
155
|
volume: _propTypes["default"].number,
|
|
130
|
-
onError: _propTypes["default"].func
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
muted: true,
|
|
134
|
-
volume: 1.0,
|
|
135
|
-
onError: function onError(e) {
|
|
136
|
-
return console.error("WebRTC error: " + e);
|
|
137
|
-
},
|
|
138
|
-
onAudioStateChange: function onAudioStateChange(e) {
|
|
139
|
-
return console.log("Webrtc audio became available: " + e);
|
|
140
|
-
}
|
|
156
|
+
onError: _propTypes["default"].func,
|
|
157
|
+
width: _propTypes["default"].number,
|
|
158
|
+
height: _propTypes["default"].number
|
|
141
159
|
};
|
|
142
|
-
var _default = EmulatorWebrtcView;
|
|
143
|
-
exports["default"] = _default;
|
|
160
|
+
var _default = exports["default"] = EmulatorWebrtcView;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Main entry point for the android-emulator-webrtc package.
|
|
3
|
+
* Exports the primary Emulator React component and the EmulatorStatus utility.
|
|
4
|
+
*/
|
|
5
|
+
import Emulator from "./components/emulator/emulator";
|
|
6
|
+
import EmulatorStatus from "./components/emulator/net/emulator_status";
|
|
7
|
+
import logger from "./components/emulator/net/logger";
|
|
8
|
+
export { Emulator, EmulatorStatus, logger };
|
package/dist/index.js
CHANGED
|
@@ -16,12 +16,5 @@ Object.defineProperty(exports, "EmulatorStatus", {
|
|
|
16
16
|
return _emulator_status["default"];
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
|
-
Object.defineProperty(exports, "Logcat", {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
get: function get() {
|
|
22
|
-
return _logcat["default"];
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
19
|
var _emulator = _interopRequireDefault(require("./components/emulator/emulator"));
|
|
26
|
-
var _logcat = _interopRequireDefault(require("./components/emulator/net/logcat"));
|
|
27
20
|
var _emulator_status = _interopRequireDefault(require("./components/emulator/net/emulator_status"));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|