WebRTC技术详解:从0到1构建多人视频会议系统
上QQ阅读APP看书,第一时间看更新

2.8 录制媒体流

WebRTC的应用经常会用到媒体流录制,下面进行详细介绍。MediaRecorder接口提供了录制相关的API,其定义如代码清单2-45所示。

代码清单2-45 MediaRecorder接口定义

interface MediaRecorder : EventTarget {
  readonly attribute MediaStream stream;
  readonly attribute DOMString mimeType;
  readonly attribute RecordingState state;
  attribute EventHandler onstart;
  attribute EventHandler onstop;
  attribute EventHandler ondataavailable;
  attribute EventHandler onpause;
  attribute EventHandler onresume;
  attribute EventHandler onerror;
  readonly attribute unsigned long videoBitsPerSecond;
  readonly attribute unsigned long audioBitsPerSecond;
  readonly attribute BitrateMode audioBitrateMode;
  void start(optional unsigned long timeslice);
  void stop();
  void pause();
  void resume();
  void requestData();
  static boolean isTypeSupported(DOMString type);
};