6 package com.netease.nimlib.sdk.avchat.model;
8 import android.view.Surface;
25 import com.
netease.yunxin.base.annotation.IntDef;
26 import com.
netease.yunxin.base.annotation.Runtime;
27 import com.
netease.yunxin.base.annotation.StringDef;
28 import com.
netease.yunxin.base.annotation.Writable;
30 import com.
netease.nrtc.engine.rawapi.RtcParameters;
31 import com.
netease.nrtc.sdk.common.VideoFilterParameter;
34 import java.io.Serializable;
35 import java.util.HashSet;
36 import java.util.List;
77 public static class Key<T>
implements Serializable {
79 private final RtcKey<T> mKey;
80 private final boolean mWritable;
81 private final boolean mRuntime;
94 Key(
final String name, Class<T> clazz) {
95 mKey =
new RtcKey<>(name, clazz);
96 mWritable = RtcParameters.writeSupported(name);
97 mRuntime = RtcParameters.runtimeSupported(name);
101 private static class SpecializedKey<T>
extends Key<T> {
102 SpecializedKey(String name, Class<T> clazz) {
114 public static Key<?> createSpecializedKey(
final String name) {
115 Class<?> clazz = RtcParameters.getKeyType(name);
117 throw new IllegalArgumentException(
118 "Key " + name +
" unsupported!");
120 return new SpecializedKey<>(name, clazz);
128 public String name() {
129 return mKey.getName();
137 public boolean runtime() {
146 public boolean writable() {
156 public final Class<T> type() {
157 return mKey.getType();
164 public final int hashCode() {
165 return mKey.hashCode();
171 @SuppressWarnings(
"unchecked")
173 public final boolean equals(Object o) {
174 return o instanceof Key && ((Key<T>) o).mKey.equals(mKey);
181 public String toString() {
182 return String.format(
"Key(Name:%s, Type:%s, Writable:%s, Runtime:%s)", name(), type(), writable(), runtime());
210 @IntDef({Surface.ROTATION_0,
212 Surface.ROTATION_180,
213 Surface.ROTATION_270})
239 @IntDef({Surface.ROTATION_0,
241 Surface.ROTATION_180,
242 Surface.ROTATION_270})
268 @StringDef({MEDIA_CODEC_AUTO,
269 MEDIA_CODEC_HARDWARE,
270 MEDIA_CODEC_SOFTWARE})
296 @StringDef({MEDIA_CODEC_AUTO,
297 MEDIA_CODEC_HARDWARE,
298 MEDIA_CODEC_SOFTWARE})
453 public static final Key<Integer>
KEY_VIDEO_QUALITY =
new Key<>(RtcParameters.KEY_VIDEO_QUALITY, Integer.class);
543 public static final Key<Boolean>
KEY_VIDEO_FPS_REPORTED =
new Key<>(RtcParameters.KEY_VIDEO_FPS_REPORTED, Boolean.class);
558 public static final Key<Integer>
KEY_VIDEO_MAX_BITRATE =
new Key<>(RtcParameters.KEY_VIDEO_MAX_BITRATE, Integer.class);
585 @IntDef({FRAME_RATE_5,
590 public static final Key<Integer>
KEY_VIDEO_FRAME_RATE =
new Key<>(RtcParameters.KEY_VIDEO_FRAME_RATE, Integer.class);
608 public static final Key<Boolean>
KEY_VIDEO_FRAME_FILTER =
new Key<>(RtcParameters.KEY_VIDEO_FRAME_FILTER, Boolean.class);
668 public static final Key<Boolean>
KEY_AUDIO_FRAME_FILTER =
new Key<>(RtcParameters.KEY_AUDIO_FRAME_FILTER, Boolean.class);
685 public static final Key<String>
KEY_SESSION_LIVE_URL =
new Key<>(RtcParameters.KEY_SESSION_LIVE_URL, String.class);
715 public static final Key<Boolean>
KEY_AUDIO_HIGH_QUALITY =
new Key<>(RtcParameters.KEY_AUDIO_HIGH_QUALITY, Boolean.class);
848 @IntDef({MIX_AND_SINGLE,
851 public static final Key<Integer>
KEY_SERVER_RECORD_MODE =
new Key<>(RtcParameters.KEY_SERVER_RECORD_MODE, Integer.class);
878 public static final Key<Boolean>
KEY_SERVER_LIVE_RECORD =
new Key<>(RtcParameters.KEY_SERVER_LIVE_RECORD, Boolean.class);
912 public static final Key<Boolean>
KEY_SESSION_LIVE_MODE =
new Key<>(RtcParameters.KEY_SESSION_LIVE_MODE, Boolean.class);
927 new Key<>(RtcParameters.KEY_COMPATIBILITY_CONFIG_SERVER, String.class);
940 new Key<>(RtcParameters.KEY_COMPATIBILITY_CONFIG_LOCAL, String.class);
957 new Key<>(RtcParameters.KEY_AUDIO_EXTERNAL_CAPTURE, Boolean.class);
964 new Key<>(RtcParameters.KEY_AUDIO_PROCESS_DUMP_FLAG_DEBUG, Integer.class);
973 new Key<>(RtcParameters.KEY_PROFILE_TRACE_FLAG_DEBUG, Boolean.class);
985 new Key<>(RtcParameters.KEY_AUDIO_PLAYBACK_DEFAULT_SAMPLE_RATE, Integer.class);
988 private RtcParameters mRawParams;
991 mRawParams =
new RtcParameters();
1003 mRawParams =
new RtcParameters();
1005 Set<String> keys = parameters.keys();
1008 for (String key : keys) {
1009 mRawParams.setObject(key, parameters.getObject(key));
1017 Set<String> keyName =
new HashSet<>(keys.size());
1018 for (Key key : keys) {
1019 keyName.add(key.name());
1021 mRawParams.setRequestKeys(keyName);
1028 mRawParams.setRequestKey(key.name());
1053 public final void setString(Key<String> key, String value) {
1059 return mRawParams.containsKey(key.name());
1062 public final <T>
void set(Key<T> key, T value) {
1064 mRawParams.setObject(key.name(), value);
1067 public final <T> T
get(Key<T> key) {
1069 T value = (T) mRawParams.getObject(key.name());
1073 public final void setFloat(Key<Float> key,
float value) {
1083 mRawParams.removeParameters(key.name());
1087 private static <T> T checkNotNull(T reference) {
1088 if (reference == null) {
1089 throw new NullPointerException();
static final Key< String > KEY_SESSION_LIVE_URL
final AVChatParameters setRequestKey(Key key)
String SDK_BUILTIN
优先使用SDK内置的语音处理
static final Key< Integer > KEY_VIDEO_FRAME_RATE
static final Key< String > KEY_AUDIO_EFFECT_AUTOMATIC_GAIN_CONTROL
static final Key< Boolean > KEY_AUDIO_FRAME_FILTER
static final Key< Integer > KEY_DEVICE_DEFAULT_ROTATION
static final Key< Boolean > KEY_SESSION_LIVE_MODE
int CROP_RATIO_1_1
画面 1:1 裁剪
String PLATFORM_BUILTIN
如果平台内置了语音处理, 优先使用平台内置语音处理
static final Key< Integer > KEY_SESSION_MULTI_MODE_USER_ROLE
static final Key< String > KEY_COMPATIBILITY_CONFIG_LOCAL
int ORIENTATION_LANDSCAPE_LEFT
Indicates that video should be oriented horizontally, home button on the left.
final void setBoolean(Key< Boolean > key, boolean value)
static final Key< Boolean > KEY_AUDIO_HIGH_QUALITY
void setRawParameters(RtcParameters parameters)
final void setFloat(Key< Float > key, float value)
static final Key< Boolean > KEY_VIDEO_FRAME_FILTER_NEW
static final Key< Integer > KEY_VIDEO_MAX_BITRATE
final int getInteger(Key< Integer > key)
int ORIENTATION_PORTRAIT_UPSIDEDOWN
Indicates that video should be oriented vertically, home button on the top.
static final Key< Integer > KEY_AUDIO_PROCESS_DUMP_FLAG_DEBUG
语音播放采样率设置
int CROP_RATIO_16_9
画面 16:9 裁剪
static final Key< String > KEY_AUDIO_EFFECT_NOISE_SUPPRESSOR
static final Key< Boolean > KEY_SERVER_AUDIO_RECORD
static final Key< Boolean > KEY_AUDIO_EXTERNAL_CAPTURE
final void removeParameters(Key key)
final AVChatParameters setRequestKeys(Set< Key > keys)
static final Key< Boolean > KEY_VIDEO_TRANSPORT_MIRROR
static final Key< Boolean > KEY_SERVER_RECORD_SPEAKER
static final Key< Integer > KEY_SERVER_RECORD_MODE
final boolean getBoolean(Key< Boolean > key)
static final Key< String > KEY_COMPATIBILITY_CONFIG_SERVER
final float getFloat(Key< Float > key)
static final Key< Integer > KEY_VIDEO_PREVIEW_QUALITY
static final Key< Boolean > KEY_AUDIO_REPORT_SPEAKER
final void setString(Key< String > key, String value)
static final Key< Boolean > KEY_VIDEO_LOCAL_PREVIEW_MIRROR
static final Key< Integer > KEY_DEVICE_ROTATION_FIXED_OFFSET
static final Key< Boolean > KEY_VIDEO_FRAME_FILTER
static final Key< Boolean > KEY_AUDIO_CALL_PROXIMITY
static final Key< Boolean > KEY_VIDEO_ROTATE_IN_RENDING
static final Key< Integer > KEY_VIDEO_CAPTURE_ORIENTATION
static final Key< Boolean > KEY_VIDEO_SUPPORTED_HW_DECODER
static final Key< Integer > KEY_VIDEO_FRAME_FILTER_FORMAT
static final Key< Boolean > KEY_VIDEO_FPS_REPORTED
static final Key< String > KEY_VIDEO_ENCODER_MODE
int ORIENTATION_PORTRAIT
Indicates that video should be oriented vertically, home button on the bottom.
static final Key< Integer > KEY_VIDEO_FIXED_CROP_RATIO
final String getString(Key< String > key)
int CROP_RATIO_4_3
画面 4:3 裁剪
final boolean containsKey(Key key)
static final Key< AVChatLiveCompositingLayout > KEY_SESSION_LIVE_COMPOSITING_LAYOUT
int MIX_AND_SINGLE
混合与单人一起录制
static final Key< Boolean > KEY_PROFILE_TRACE_FLAG_DEBUG
设置是否打印 kTraceProfile 日志
static final Key< Boolean > KEY_SERVER_LIVE_RECORD
RtcParameters getRawParameters()
static final Key< String > KEY_VIDEO_DECODER_MODE
static final Key< Integer > KEY_VIDEO_QUALITY
static final Key< Boolean > KEY_SERVER_VIDEO_RECORD
static final Key< Boolean > KEY_VIDEO_SUPPORTED_HW_ENCODER
static final Key< Integer > KEY_AUDIO_PLAYBACK_DEFAULT_SAMPLE_RATE
语音播放采样率设置
final void setInteger(Key< Integer > key, int value)
static final Key< String > KEY_AUDIO_EFFECT_ACOUSTIC_ECHO_CANCELER
int ORIENTATION_LANDSCAPE_RIGHT
Indicates that video should be oriented horizontally, home button on the right.