Skip to content

Commit

Permalink
Fix bug, update sdk.
Browse files Browse the repository at this point in the history
  • Loading branch information
borryzhang committed Oct 26, 2020
1 parent 4f3e455 commit ffcc7e4
Show file tree
Hide file tree
Showing 43 changed files with 424 additions and 142 deletions.
4 changes: 2 additions & 2 deletions Demo/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "com.tencent.liteav.demo"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 9
versionName "7.8.588"
versionCode 10
versionName "7.9.607"

multiDexEnabled true
ndk {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_main);

mTvVersion = (TextView) findViewById(R.id.main_tv_version);
mTvVersion.setText("视频云工具包 v" + TXLiveBase.getSDKVersionStr()+"(7.8.588)");
mTvVersion.setText("视频云工具包 v" + TXLiveBase.getSDKVersionStr()+"(7.9.607)");

mMainTitle = (TextView) findViewById(R.id.main_title);
mMainTitle.setOnLongClickListener(new View.OnLongClickListener() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"tab_item_level_value_size": 14,
"tab_item_level_progress_drawable": "@beauty_progress_drawable",
"tab_item_level_progress_thumb": "@beauty_thumb",
"tab_item_list_default_selected_index": 2,
"tab_item_list": [
{
"item_id": 1,
Expand Down Expand Up @@ -255,6 +256,7 @@
"tab_item_level_value_size": 14,
"tab_item_level_progress_drawable": "@beauty_progress_drawable",
"tab_item_level_progress_thumb": "@beauty_thumb",
"tab_item_list_default_selected_index": 1,
"tab_item_list": [
{
"item_id": 1,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class TabInfo {
private String tab_item_level_progress_drawable;// string, 进度条背景颜色
private String tab_item_level_progress_thumb; // string, 进度条 bar 颜色

private int tab_item_list_default_selected_index; // int, 默认选中的item

private List<ItemInfo> tab_item_list;

public long getTabId() {
Expand Down Expand Up @@ -83,6 +85,10 @@ public String getTabItemLevelProgressThumb() {
return tab_item_level_progress_thumb;
}

public int getTabItemListDefaultSelectedIndex() {
return tab_item_list_default_selected_index;
}

public List<ItemInfo> getTabItemList() {
return tab_item_list;
}
Expand All @@ -103,6 +109,7 @@ public String toString() {
", tab_item_level_value_size=" + tab_item_level_value_size +
", tab_item_level_progress_drawable='" + tab_item_level_progress_drawable + '\'' +
", tab_item_level_progress_thumb='" + tab_item_level_progress_thumb + '\'' +
", tab_item_list_default_selected_index='" + tab_item_list_default_selected_index + '\'' +
", tab_item_list=" + tab_item_list +
'}';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,10 @@ public void setVisibility(int visibility) {
*/
public void setBeautyInfo(@NonNull BeautyInfo beautyInfo) {
mBeautyInfo = beautyInfo;
int tabSize = beautyInfo.getBeautyTabList().size();
mCurrentItemPosition = new int[tabSize];
mCurrentItemInfo = new ItemInfo[tabSize];

//根据配置文件选择默认选中项
setCurrentBeautyInfo(beautyInfo);

mBeauty.fillingMaterialPath(beautyInfo);
setBackground(ResourceUtils.getLinearDrawable(ResourceUtils.getColor(beautyInfo.getBeautyBg())));
refresh();
Expand Down Expand Up @@ -156,9 +157,11 @@ public BeautyInfo getDefaultBeautyInfo() {
public void setBeautyManager(TXBeautyManager beautyManager) {
mBeauty.setBeautyManager(beautyManager);
clear();
// 滤镜默认选中白皙
setCurrentFilterIndex(1);
setCurrentBeautyIndex(2);

if (mBeautyInfo != null) {
//根据配置文件选择默认选中项
setCurrentBeautyInfo(mBeautyInfo);
}
}

public void setMotionTmplEnable(boolean enable) {
Expand Down Expand Up @@ -221,6 +224,19 @@ private void initData() {
setBeautyInfo(getDefaultBeautyInfo());
}

private void setCurrentBeautyInfo(@NonNull BeautyInfo beautyInfo) {
int tabSize = beautyInfo.getBeautyTabList().size();
mCurrentItemPosition = new int[tabSize];
mCurrentItemInfo = new ItemInfo[tabSize];

for (int i = 0; i < tabSize; i++) {
TabInfo tabInfo = beautyInfo.getBeautyTabList().get(i);
mCurrentItemPosition[i] = tabInfo.getTabItemListDefaultSelectedIndex();
mCurrentItemInfo[i] = tabInfo.getTabItemList().get(tabInfo.getTabItemListDefaultSelectedIndex());
mBeauty.setBeautySpecialEffects(tabInfo, i, mCurrentItemInfo[i], mCurrentItemPosition[i]);
}
}

private void refresh() {
createTabList();
}
Expand Down Expand Up @@ -248,15 +264,7 @@ public void onTabChange(TabInfo tabInfo, int position) {
private void createItemList(@NonNull final TabInfo tabInfo, @NonNull final int tabPosition) {
setBeautyTitle(tabInfo.getTabName());
ItemAdapter itemAdapter = new ItemAdapter(mContext);
if (tabInfo.getTabType() == BeautyConstants.TAB_TYPE_FILTER) {
// 滤镜默认选中白皙
itemAdapter.setData(tabInfo, mCurrentItemPosition[1]);
} else if(tabInfo.getTabType() == BeautyConstants.TAB_TYPE_BEAUTY) {
// 美颜默认选中P图
itemAdapter.setData(tabInfo, mCurrentItemPosition[0]);
} else {
itemAdapter.setData(tabInfo);
}
itemAdapter.setData(tabInfo, mCurrentItemPosition[tabPosition]);
mScrollItemView.setAdapter(itemAdapter);
mScrollItemView.setClicked(mCurrentItemPosition[tabPosition]);
itemAdapter.setOnItemClickListener(new ItemAdapter.OnItemClickListener() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,6 @@ public void startPush() {
// 设置推流分辨率
mLivePushConfig.setVideoResolution(mVideoResolution);

// 设置美颜
mLivePusher.setBeautyFilter(mBeautyStyle, mBeautyLevel, mWhiteningLevel, mRuddyLevel);

// 如果当前Activity可以自动旋转的话,那么需要进行设置
if (isActivityCanRotation(mContext)) {
setRotationForActivity();
Expand Down Expand Up @@ -474,6 +471,8 @@ private void initialize(Context context, TXCloudVideoView pusherView) {
mLivePushConfig = new TXLivePushConfig();
mLivePushConfig.setVideoEncodeGop(5);
mLivePusher.setConfig(mLivePushConfig);
// 设置美颜
mLivePusher.setBeautyFilter(mBeautyStyle, mBeautyLevel, mWhiteningLevel, mRuddyLevel);
mWaterMarkBitmap = decodeResource(mContext.getResources(), R.drawable.livepusher_watermark);
initListener();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ public boolean onDown(MotionEvent e) {
public void onBrightnessGesture(float newBrightness) {
if (mGestureVolumeBrightnessProgressLayout != null) {
mGestureVolumeBrightnessProgressLayout.setProgress((int) (newBrightness * 100));
mVodMoreView.setBrightProgress((int) (newBrightness * 100));
mGestureVolumeBrightnessProgressLayout.setImageResource(R.drawable.superplayer_ic_light_max);
mGestureVolumeBrightnessProgressLayout.show();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.tencent.liteav.demo.play.view;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.media.AudioManager;
import android.util.AttributeSet;
import android.view.LayoutInflater;
Expand Down Expand Up @@ -35,6 +38,10 @@
*/

public class TCVodMoreView extends RelativeLayout implements RadioGroup.OnCheckedChangeListener, CompoundButton.OnCheckedChangeListener {

private static final String VOLUME_CHANGED_ACTION = "android.media.VOLUME_CHANGED_ACTION";
private static final String EXTRA_VOLUME_STREAM_TYPE = "android.media.EXTRA_VOLUME_STREAM_TYPE";

private Context mContext;

private SeekBar mSeekBarVolume; // 音量seekBar
Expand All @@ -51,6 +58,8 @@ public class TCVodMoreView extends RelativeLayout implements RadioGroup.OnChecke
private LinearLayout mLayoutSpeed; // 倍速按钮所在布局
private LinearLayout mLayoutMirror; // 镜像按钮所在布局

private VolumeBroadcastReceiver mVolumeBroadcastReceiver;

public TCVodMoreView(Context context) {
super(context);
init(context);
Expand Down Expand Up @@ -114,15 +123,13 @@ private void updateCurrentLight() {
Window window = activity.getWindow();

WindowManager.LayoutParams params = window.getAttributes();
if (params.screenBrightness == WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE) {
params.screenBrightness = getActivityBrightness((Activity) mContext);
window.setAttributes(params);
if (params.screenBrightness == -1) {
mSeekBarLight.setProgress(100);
return;
}
mSeekBarLight.setProgress((int) (params.screenBrightness * 100));
params.screenBrightness = getActivityBrightness((Activity) mContext);
window.setAttributes(params);
if (params.screenBrightness == -1) {
mSeekBarLight.setProgress(100);
return;
}
mSeekBarLight.setProgress((int) (params.screenBrightness * 100));
}

/**
Expand All @@ -139,8 +146,10 @@ public static float getActivityBrightness(Activity activity) {

private SeekBar.OnSeekBarChangeListener mVolumeChangeListener = new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean b) {
updateVolumeProgress(progress);
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if (fromUser) {
updateVolumeProgress(progress);
}
}

@Override
Expand Down Expand Up @@ -169,8 +178,10 @@ private void updateVolumeProgress(int progress) {

private SeekBar.OnSeekBarChangeListener mLightChangeListener = new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean b) {
updateBrightProgress(progress);
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if (fromUser) {
updateBrightProgress(progress);
}
}

@Override
Expand Down Expand Up @@ -266,6 +277,27 @@ public void onCheckedChanged(RadioGroup radioGroup, int checkedId) {
}
}

@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
}

@Override
public void setVisibility(int visibility) {
super.setVisibility(visibility);
if (visibility == View.VISIBLE) {
updateCurrentVolume();
updateCurrentLight();
registerReceiver();
}else {
unregisterReceiver();
}
}

public void setBrightProgress(int progress) {
updateBrightProgress(progress);
}

/**
* 更新播放视频类型
*
Expand All @@ -281,6 +313,39 @@ public void updatePlayType(int playType) {
}
}

private class VolumeBroadcastReceiver extends BroadcastReceiver {

public void onReceive(Context context, Intent intent) {
//媒体音量改变才通知
if (VOLUME_CHANGED_ACTION.equals(intent.getAction())
&& (intent.getIntExtra(EXTRA_VOLUME_STREAM_TYPE, -1) == AudioManager.STREAM_MUSIC)) {
updateCurrentVolume();
}
}
}

/**
* 注册音量广播接收器
* @return
*/
public void registerReceiver() {
mVolumeBroadcastReceiver = new VolumeBroadcastReceiver();
IntentFilter filter = new IntentFilter();
filter.addAction(VOLUME_CHANGED_ACTION);
mContext.registerReceiver(mVolumeBroadcastReceiver, filter);
}

/**
* 反注册音量广播监听器,需要与 registerReceiver 成对使用
*/
public void unregisterReceiver() {
try {
mContext.unregisterReceiver(mVolumeBroadcastReceiver);
} catch (Exception e) {
e.printStackTrace();
}
}

/**
* 回调
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,6 @@ private boolean isCallingData(String data) {
}

private void processInvite(String inviteID, String inviter, String groupID, List<String> inviteeList, String data) {
// 收到来电,开始监听 trtc 的消息
mTRTCCloud.setListener(mTRTCCloudListener);
CallModel callModel = new CallModel();
callModel.callId = inviteID;
callModel.groupId = groupID;
Expand Down Expand Up @@ -575,8 +573,6 @@ public void groupCall(final List<String> userIdList, int type, String groupId) {
* @param groupId 群组通话的group id,如果是C2C需要传 ""
*/
private void internalCall(final List<String> userIdList, int type, String groupId) {
// 主动拨打电话,开始监听trtc的消息
mTRTCCloud.setListener(mTRTCCloudListener);
final boolean isGroupCall = !TextUtils.isEmpty(groupId);
if (!isOnCalling) {
// 首次拨打电话,生成id,并进入trtc房间
Expand Down Expand Up @@ -689,6 +685,8 @@ private void enterTRTCRoom() {
mTRTCCloud.enableAudioVolumeEvaluation(300);
mTRTCCloud.setAudioRoute(TRTCCloudDef.TRTC_AUDIO_ROUTE_SPEAKER);
mTRTCCloud.startLocalAudio();
// 收到来电,开始监听 trtc 的消息
mTRTCCloud.setListener(mTRTCCloudListener);
mTRTCCloud.enterRoom(TRTCParams, mCurCallType == TRTCCalling.TYPE_VIDEO_CALL ? TRTCCloudDef.TRTC_APP_SCENE_VIDEOCALL : TRTCCloudDef.TRTC_APP_SCENE_AUDIOCALL);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,10 @@ public void startPublish(String streamId, TXCallback callback) {
} else if (mOriginRole == TRTCCloudDef.TRTCRoleAnchor) {
// 大主播的时候切换分辨率
TRTCCloudDef.TRTCVideoEncParam param = new TRTCCloudDef.TRTCVideoEncParam();
param.videoResolution = TRTCCloudDef.TRTC_VIDEO_RESOLUTION_960_540;
param.videoBitrate = 1200;
param.videoResolution = TRTCCloudDef.TRTC_VIDEO_RESOLUTION_1280_720;
param.videoBitrate = 1800;
param.videoFps = 15;
param.enableAdjustRes = true;
param.videoResolutionMode = TRTCCloudDef.TRTC_VIDEO_RESOLUTION_MODE_PORTRAIT;
mTRTCCloud.setVideoEncoderParam(param);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ protected void onDestroy() {
mVideoViewMgr.recycleVideoView();
mVideoViewMgr = null;
if (mPanelAudioControl != null) {
mPanelAudioControl.reset();
mPanelAudioControl.unInit();
mPanelAudioControl = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,12 @@ public static void destroySharedInstance() {
*/
public abstract void setLocalViewMirror(int type);

/**
* 设置网络qos参数
* @param qosParam
*/
public abstract void setNetworkQosParam(TRTCCloudDef.TRTCNetworkQosParam qosParam);

//////////////////////////////////////////////////////////
//
// 本地音频操作接口
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,16 @@ public void run() {
});
}

@Override
public void setNetworkQosParam(final TRTCCloudDef.TRTCNetworkQosParam qosParam) {
runOnMainThread(new Runnable() {
@Override
public void run() {
TXTRTCMeeting.getInstance().setNetworkQosParam(qosParam);
}
});
}

@Override
public void startMicrophone() {
runOnMainThread(new Runnable() {
Expand Down
Loading

0 comments on commit ffcc7e4

Please sign in to comment.