Browse Source

更新版本到 2.0.0-alpha.8

ChangeLog
1. 修复华为微信浏览器声音异常的问题
2. 增加错误码 3020, 3021
3. 新增 snapshot 方法
4. 其他内部优化
kevin.song 4 years ago
parent
commit
5316b4961e

File diff suppressed because it is too large
+ 1 - 1
docs/assets/js/search.js


File diff suppressed because it is too large
+ 45 - 0
docs/classes/localstream.html


File diff suppressed because it is too large
+ 45 - 0
docs/classes/remotestream.html


+ 32 - 0
docs/classes/rtcerror.html

@@ -134,6 +134,8 @@
 								<li class="tsd-kind-property tsd-parent-kind-class tsd-is-static"><a href="rtcerror.html#over_constrained_error" class="tsd-kind-icon">OVER_<wbr>CONSTRAINED_<wbr>ERROR</a></li>
 								<li class="tsd-kind-property tsd-parent-kind-class tsd-is-static"><a href="rtcerror.html#peerconnection_failed" class="tsd-kind-icon">PEERCONNECTION_<wbr>FAILED</a></li>
 								<li class="tsd-kind-property tsd-parent-kind-class tsd-is-static"><a href="rtcerror.html#play_not_allowed" class="tsd-kind-icon">PLAY_<wbr>NOT_<wbr>ALLOWED</a></li>
+								<li class="tsd-kind-property tsd-parent-kind-class tsd-is-static"><a href="rtcerror.html#play_pending" class="tsd-kind-icon">PLAY_<wbr>PENDING</a></li>
+								<li class="tsd-kind-property tsd-parent-kind-class tsd-is-static"><a href="rtcerror.html#resume_not_allowed" class="tsd-kind-icon">RESUME_<wbr>NOT_<wbr>ALLOWED</a></li>
 								<li class="tsd-kind-property tsd-parent-kind-class tsd-is-static"><a href="rtcerror.html#role_type_not_match" class="tsd-kind-icon">ROLE_<wbr>TYPE_<wbr>NOT_<wbr>MATCH</a></li>
 								<li class="tsd-kind-property tsd-parent-kind-class tsd-is-static"><a href="rtcerror.html#signal_address_invalid" class="tsd-kind-icon">SIGNAL_<wbr>ADDRESS_<wbr>INVALID</a></li>
 								<li class="tsd-kind-property tsd-parent-kind-class tsd-is-static"><a href="rtcerror.html#stream_exists" class="tsd-kind-icon">STREAM_<wbr>EXISTS</a></li>
@@ -586,6 +588,30 @@
 					</div>
 				</section>
 				<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-static">
+					<a name="play_pending" class="tsd-anchor"></a>
+					<h3><span class="tsd-flag ts-flagStatic">Static</span> <span class="tsd-flag ts-flagReadonly">Readonly</span> PLAY_<wbr>PENDING</h3>
+					<div class="tsd-signature tsd-kind-icon">PLAY_<wbr>PENDING<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">&quot;3020&quot;</span><span class="tsd-signature-symbol"> = &#x27;3020&#x27;</span></div>
+					<aside class="tsd-sources">
+					</aside>
+					<div class="tsd-comment tsd-typography">
+						<div class="lead">
+							<p>3020 - 视频数据异常,未成功播放</p>
+						</div>
+					</div>
+				</section>
+				<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-static">
+					<a name="resume_not_allowed" class="tsd-anchor"></a>
+					<h3><span class="tsd-flag ts-flagStatic">Static</span> <span class="tsd-flag ts-flagReadonly">Readonly</span> RESUME_<wbr>NOT_<wbr>ALLOWED</h3>
+					<div class="tsd-signature tsd-kind-icon">RESUME_<wbr>NOT_<wbr>ALLOWED<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">&quot;3021&quot;</span><span class="tsd-signature-symbol"> = &#x27;3021&#x27;</span></div>
+					<aside class="tsd-sources">
+					</aside>
+					<div class="tsd-comment tsd-typography">
+						<div class="lead">
+							<p>3021 - 因未曾调用或调用 play 方法失败,故不可恢复播放</p>
+						</div>
+					</div>
+				</section>
+				<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-static">
 					<a name="role_type_not_match" class="tsd-anchor"></a>
 					<h3><span class="tsd-flag ts-flagStatic">Static</span> <span class="tsd-flag ts-flagReadonly">Readonly</span> ROLE_<wbr>TYPE_<wbr>NOT_<wbr>MATCH</h3>
 					<div class="tsd-signature tsd-kind-icon">ROLE_<wbr>TYPE_<wbr>NOT_<wbr>MATCH<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">&quot;2008&quot;</span><span class="tsd-signature-symbol"> = &#x27;2008&#x27;</span></div>
@@ -867,6 +893,12 @@
 								<a href="rtcerror.html#play_not_allowed" class="tsd-kind-icon">PLAY_<wbr>NOT_<wbr>ALLOWED</a>
 							</li>
 							<li class=" tsd-kind-property tsd-parent-kind-class tsd-is-static">
+								<a href="rtcerror.html#play_pending" class="tsd-kind-icon">PLAY_<wbr>PENDING</a>
+							</li>
+							<li class=" tsd-kind-property tsd-parent-kind-class tsd-is-static">
+								<a href="rtcerror.html#resume_not_allowed" class="tsd-kind-icon">RESUME_<wbr>NOT_<wbr>ALLOWED</a>
+							</li>
+							<li class=" tsd-kind-property tsd-parent-kind-class tsd-is-static">
 								<a href="rtcerror.html#role_type_not_match" class="tsd-kind-icon">ROLE_<wbr>TYPE_<wbr>NOT_<wbr>MATCH</a>
 							</li>
 							<li class=" tsd-kind-property tsd-parent-kind-class tsd-is-static">

File diff suppressed because it is too large
+ 44 - 0
docs/classes/stream.html


+ 6 - 0
docs/index.html

@@ -86,6 +86,7 @@
 								<li class="tsd-kind-interface"><a href="interfaces/playoptions.html" class="tsd-kind-icon">Play<wbr>Options</a></li>
 								<li class="tsd-kind-interface tsd-has-type-parameter"><a href="interfaces/rtcevent.html" class="tsd-kind-icon">Rtc<wbr>Event</a></li>
 								<li class="tsd-kind-interface"><a href="interfaces/serverconfig.html" class="tsd-kind-icon">Server<wbr>Config</a></li>
+								<li class="tsd-kind-interface"><a href="interfaces/snapshotoptions.html" class="tsd-kind-icon">Snapshot<wbr>Options</a></li>
 								<li class="tsd-kind-interface"><a href="interfaces/streamplugin.html" class="tsd-kind-icon">Stream<wbr>Plugin</a></li>
 								<li class="tsd-kind-interface"><a href="interfaces/streamstats.html" class="tsd-kind-icon">Stream<wbr>Stats</a></li>
 								<li class="tsd-kind-interface"><a href="interfaces/videostats.html" class="tsd-kind-icon">Video<wbr>Stats</a></li>
@@ -213,6 +214,8 @@
 							<li>3017 - 流正在取消订阅</li>
 							<li>3018 - 流已经订阅</li>
 							<li>3019 - 自动播放被禁止错误</li>
+							<li>3020 - 视频数据异常,未成功播放</li>
+							<li>3021 - 因未曾调用或调用 play 方法失败,故不可恢复播放</li>
 						</ul>
 					</div>
 				</section>
@@ -1304,6 +1307,9 @@
 						<a href="interfaces/serverconfig.html" class="tsd-kind-icon">Server<wbr>Config</a>
 					</li>
 					<li class=" tsd-kind-interface">
+						<a href="interfaces/snapshotoptions.html" class="tsd-kind-icon">Snapshot<wbr>Options</a>
+					</li>
+					<li class=" tsd-kind-interface">
 						<a href="interfaces/streamplugin.html" class="tsd-kind-icon">Stream<wbr>Plugin</a>
 					</li>
 					<li class=" tsd-kind-interface">

+ 186 - 0
docs/interfaces/snapshotoptions.html

@@ -0,0 +1,186 @@
+<!doctype html>
+<html class="default no-js">
+<head>
+	<meta charset="utf-8">
+	<meta http-equiv="X-UA-Compatible" content="IE=edge">
+	<title>SnapshotOptions | @urtc/sdk-web</title>
+	<meta name="description" content="Documentation for @urtc/sdk-web">
+	<meta name="viewport" content="width=device-width, initial-scale=1">
+	<link rel="stylesheet" href="../assets/css/main.css">
+	<script async src="../assets/js/search.js" id="search-script"></script>
+</head>
+<body>
+<header>
+	<div class="tsd-page-toolbar">
+		<div class="container">
+			<div class="table-wrap">
+				<div class="table-cell" id="tsd-search" data-index="../assets/js/search.json" data-base="..">
+					<div class="field">
+						<label for="tsd-search-field" class="tsd-widget search no-caption">Search</label>
+						<input id="tsd-search-field" type="text" />
+					</div>
+					<ul class="results">
+						<li class="state loading">Preparing search index...</li>
+						<li class="state failure">The search index is not available</li>
+					</ul>
+					<a href="../index.html" class="title">@urtc/sdk-web</a>
+				</div>
+				<div class="table-cell" id="tsd-widgets">
+					<div id="tsd-filter">
+						<a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a>
+						<div class="tsd-filter-group">
+							<div class="tsd-select" id="tsd-filter-visibility">
+								<span class="tsd-select-label">All</span>
+								<ul class="tsd-select-list">
+									<li data-value="public">Public</li>
+									<li data-value="protected">Public/Protected</li>
+									<li data-value="private" class="selected">All</li>
+								</ul>
+							</div>
+							<input type="checkbox" id="tsd-filter-inherited" checked />
+							<label class="tsd-widget" for="tsd-filter-inherited">Inherited</label>
+							<input type="checkbox" id="tsd-filter-externals" checked />
+							<label class="tsd-widget" for="tsd-filter-externals">Externals</label>
+						</div>
+					</div>
+					<a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a>
+				</div>
+			</div>
+		</div>
+	</div>
+	<div class="tsd-page-title">
+		<div class="container">
+			<ul class="tsd-breadcrumb">
+				<li>
+					<a href="../index.html">@urtc/sdk-web</a>
+				</li>
+				<li>
+					<a href="snapshotoptions.html">SnapshotOptions</a>
+				</li>
+			</ul>
+			<h1>Interface SnapshotOptions</h1>
+		</div>
+	</div>
+</header>
+<div class="container container-main">
+	<div class="row">
+		<div class="col-8 col-content">
+			<section class="tsd-panel tsd-comment">
+				<div class="tsd-comment tsd-typography">
+					<div class="lead">
+						<p>截屏参数</p>
+					</div>
+				</div>
+			</section>
+			<section class="tsd-panel tsd-hierarchy">
+				<h3>Hierarchy</h3>
+				<ul class="tsd-hierarchy">
+					<li>
+						<span class="target">SnapshotOptions</span>
+					</li>
+				</ul>
+			</section>
+			<section class="tsd-panel-group tsd-index-group">
+				<h2>Index</h2>
+				<section class="tsd-panel tsd-index-panel">
+					<div class="tsd-index-content">
+						<section class="tsd-index-section ">
+							<h3>Properties</h3>
+							<ul class="tsd-index-list">
+								<li class="tsd-kind-property tsd-parent-kind-interface"><a href="snapshotoptions.html#download" class="tsd-kind-icon">download</a></li>
+								<li class="tsd-kind-property tsd-parent-kind-interface"><a href="snapshotoptions.html#filename" class="tsd-kind-icon">filename</a></li>
+							</ul>
+						</section>
+					</div>
+				</section>
+			</section>
+			<section class="tsd-panel-group tsd-member-group ">
+				<h2>Properties</h2>
+				<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface">
+					<a name="download" class="tsd-anchor"></a>
+					<h3><span class="tsd-flag ts-flagOptional">Optional</span> download</h3>
+					<div class="tsd-signature tsd-kind-icon">download<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">boolean</span></div>
+					<aside class="tsd-sources">
+					</aside>
+					<div class="tsd-comment tsd-typography">
+						<div class="lead">
+							<p>选填,是否将截屏保存为图片并下载,默认 false</p>
+						</div>
+					</div>
+				</section>
+				<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface">
+					<a name="filename" class="tsd-anchor"></a>
+					<h3><span class="tsd-flag ts-flagOptional">Optional</span> filename</h3>
+					<div class="tsd-signature tsd-kind-icon">filename<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div>
+					<aside class="tsd-sources">
+					</aside>
+					<div class="tsd-comment tsd-typography">
+						<div class="lead">
+							<p>选填,将截屏保存为图片时指定的文件名
+								当传入文件名时,将按指定的文件名保存图片,否则文件名将自动生成
+							特别地,当传入文件名时,即使 download 指定为 false,也将按指定的文件名保存图片并下载</p>
+						</div>
+					</div>
+				</section>
+			</section>
+		</div>
+		<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
+			<nav class="tsd-navigation primary">
+				<ul>
+					<li class=" ">
+						<a href="../index.html">Exports</a>
+					</li>
+				</ul>
+			</nav>
+			<nav class="tsd-navigation secondary menu-sticky">
+				<ul class="before-current">
+				</ul>
+				<ul class="current">
+					<li class="current tsd-kind-interface">
+						<a href="snapshotoptions.html" class="tsd-kind-icon">Snapshot<wbr>Options</a>
+						<ul>
+							<li class=" tsd-kind-property tsd-parent-kind-interface">
+								<a href="snapshotoptions.html#download" class="tsd-kind-icon">download</a>
+							</li>
+							<li class=" tsd-kind-property tsd-parent-kind-interface">
+								<a href="snapshotoptions.html#filename" class="tsd-kind-icon">filename</a>
+							</li>
+						</ul>
+					</li>
+				</ul>
+				<ul class="after-current">
+				</ul>
+			</nav>
+		</div>
+	</div>
+</div>
+<footer class="with-border-bottom">
+	<div class="container">
+		<h2>Legend</h2>
+		<div class="tsd-legend-group">
+			<ul class="tsd-legend">
+				<li class="tsd-kind-constructor tsd-parent-kind-class"><span class="tsd-kind-icon">Constructor</span></li>
+				<li class="tsd-kind-property tsd-parent-kind-class"><span class="tsd-kind-icon">Property</span></li>
+				<li class="tsd-kind-method tsd-parent-kind-class"><span class="tsd-kind-icon">Method</span></li>
+			</ul>
+			<ul class="tsd-legend">
+				<li class="tsd-kind-property tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited property</span></li>
+				<li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited method</span></li>
+			</ul>
+			<ul class="tsd-legend">
+				<li class="tsd-kind-property tsd-parent-kind-class tsd-is-static"><span class="tsd-kind-icon">Static property</span></li>
+				<li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><span class="tsd-kind-icon">Static method</span></li>
+			</ul>
+			<ul class="tsd-legend">
+				<li class="tsd-kind-property tsd-parent-kind-interface"><span class="tsd-kind-icon">Property</span></li>
+			</ul>
+		</div>
+	</div>
+</footer>
+<div class="container tsd-generator">
+	<p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p>
+</div>
+<div class="overlay"></div>
+<script src="../assets/js/main.js"></script>
+</body>
+</html>

+ 42 - 1
lib/index.d.ts

@@ -601,6 +601,22 @@ declare module '__@urtc/sdk-web/types' {
         */
       video: VideoCodec[];
   }
+  /**
+    * 截屏参数
+    * @public
+    */
+  export interface SnapshotOptions {
+      /**
+        * 选填,是否将截屏保存为图片并下载,默认 false
+        */
+      download?: boolean;
+      /**
+        * 选填,将截屏保存为图片时指定的文件名
+        * 当传入文件名时,将按指定的文件名保存图片,否则文件名将自动生成
+        * 特别地,当传入文件名时,即使 download 指定为 false,也将按指定的文件名保存图片并下载
+        */
+      filename?: string;
+  }
 }
 
 declare module '__@urtc/sdk-web/logger' {
@@ -1058,6 +1074,14 @@ declare module '__@urtc/sdk-web/error' {
         * 3019 - 自动播放被禁止错误
         */
       static readonly PLAY_NOT_ALLOWED = "3019";
+      /**
+        * 3020 - 视频数据异常,未成功播放
+        */
+      static readonly PLAY_PENDING = "3020";
+      /**
+        * 3021 - 因未曾调用或调用 play 方法失败,故不可恢复播放
+        */
+      static readonly RESUME_NOT_ALLOWED = "3021";
   }
   /**
     * RTC 错误代码
@@ -1103,6 +1127,8 @@ declare module '__@urtc/sdk-web/error' {
     * - 3017 - 流正在取消订阅
     * - 3018 - 流已经订阅
     * - 3019 - 自动播放被禁止错误
+    * - 3020 - 视频数据异常,未成功播放
+    * - 3021 - 因未曾调用或调用 play 方法失败,故不可恢复播放
     * @public
     */
   export type ErrorCode = typeof RtcError[Exclude<keyof typeof RtcError, 'prototype' | 'getCode' | 'stackTraceLimit' | 'prepareStackTrace' | 'captureStackTrace'>];
@@ -1226,7 +1252,7 @@ declare module '__@urtc/sdk-web/stream/types' {
 
 declare module '__@urtc/sdk-web/stream/stream' {
   import { EventEmitter } from '__@urtc/sdk-web/event-emitter';
-  import { PlayOptions } from '__@urtc/sdk-web/types';
+  import { PlayOptions, SnapshotOptions } from '__@urtc/sdk-web/types';
   import { MediaType, StreamStats } from '__@urtc/sdk-web/stream/types';
   /**
     * LocalStream 和 RemoteStream 的基类
@@ -1396,6 +1422,21 @@ declare module '__@urtc/sdk-web/stream/stream' {
         * ```
         */
       getStats(): Promise<StreamStats>;
+      /**
+        * 对当前流进行截屏,可用于页面展示或下载保存
+        * @param opts - 截屏参数,选传,参见{@link SnapshotOptions}
+        * @example
+        * ```js
+        * stream.snapshot({filename: 'xxx.jpg'})
+        *   .then((pic) => {
+        *     console.log('截屏图像', pic);
+        *   })
+        *   .catch((err) => {
+        *     console.log('截屏失败', err);
+        *   });
+        * ```
+        */
+      snapshot(opts?: SnapshotOptions): Promise<string>;
   }
 }
 

File diff suppressed because it is too large
+ 6 - 6
lib/index.js


+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "@urtc/sdk-web",
-  "version": "2.0.0-alpha.7",
+  "version": "2.0.0-alpha.8",
   "description": "UCloud RTC javascript SDK",
   "main": "lib/index.js",
   "types": "lib/index.d.ts",