Skip to content

Commit ae9e3d7

Browse files
author
carolsuo
committed
Android/iOS:小直播:增加美颜面板模块;
1 parent 8cf2ad4 commit ae9e3d7

File tree

476 files changed

+14763
-11568
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

476 files changed

+14763
-11568
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Android/XiaoZhiBo/.idea
22
Android/XiaoZhiBo/.gradle
33
Android/XiaoZhiBo/app/build/
4+
Android/XiaoZhiBo/beauty/build/
45

56
.gradle
67
.idea

Android/XiaoZhiBo/app/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,7 @@ dependencies {
6666
compile 'com.android.support:multidex:1.0.0'
6767
// Demo 用于 crash 上报的 bugly 组件
6868
compile 'com.tencent.bugly:crashreport:3.0.0'
69+
// 美颜面板
70+
compile project(':beauty')
6971
}
7072

Android/XiaoZhiBo/app/src/main/java/com/tencent/liteav/demo/lvb/liveroom/MLVBLiveRoom.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import android.graphics.Bitmap;
55
import android.os.Handler;
66

7+
import com.tencent.liteav.beauty.TXBeautyManager;
78
import com.tencent.liteav.demo.lvb.liveroom.roomutil.commondef.LoginInfo;
89
import com.tencent.liteav.demo.lvb.liveroom.roomutil.commondef.AnchorInfo;
910
import com.tencent.liteav.demo.lvb.liveroom.roomutil.commondef.MLVBCommonDef;
@@ -466,6 +467,8 @@ public static void destroySharedInstance() {
466467
/// @name 美颜滤镜相关接口函数
467468
/// @{
468469

470+
public abstract TXBeautyManager getBeautyManager();
471+
469472
/**
470473
* 设置美颜、美白、红润效果级别
471474
*
@@ -474,6 +477,7 @@ public static void destroySharedInstance() {
474477
* @param whitenessLevel 美白级别,取值范围 0 - 9; 0 表示关闭, 1 - 9值越大,效果越明显
475478
* @param ruddinessLevel 红润级别,取值范围 0 - 9; 0 表示关闭, 1 - 9值越大,效果越明显
476479
*/
480+
@Deprecated
477481
public abstract boolean setBeautyStyle(int beautyStyle , int beautyLevel, int whitenessLevel, int ruddinessLevel);
478482

479483
/**
@@ -506,6 +510,7 @@ public static void destroySharedInstance() {
506510
*
507511
* @param filePaht 动态贴图文件路径
508512
*/
513+
@Deprecated
509514
public abstract void setMotionTmpl(String filePaht);
510515

511516
/**
@@ -527,41 +532,47 @@ public static void destroySharedInstance() {
527532
*
528533
* @param level 大眼等级取值为 0 ~ 9。取值为0时代表关闭美颜效果。默认值:0
529534
*/
535+
@Deprecated
530536
public abstract void setEyeScaleLevel(int level);
531537

532538
/**
533539
* 设置 V 脸(特权版本有效,普通版本设置此参数无效)
534540
*
535541
* @param level V 脸级别取值范围 0 ~ 9。数值越大,效果越明显。默认值:0
536542
*/
543+
@Deprecated
537544
public abstract void setFaceVLevel(int level);
538545

539546
/**
540547
* 设置瘦脸效果
541548
*
542549
* @param level 瘦脸等级取值为 0 ~ 9。取值为0时代表关闭美颜效果。默认值:0
543550
*/
551+
@Deprecated
544552
public abstract void setFaceSlimLevel(int level);
545553

546554
/**
547555
* 设置短脸(特权版本有效,普通版本设置此参数无效)
548556
*
549557
* @param level 短脸级别取值范围 0 ~ 9。 数值越大,效果越明显。默认值:0
550558
*/
559+
@Deprecated
551560
public abstract void setFaceShortLevel(int level);
552561

553562
/**
554563
* 设置下巴拉伸或收缩(特权版本有效,普通版本设置此参数无效)
555564
*
556565
* @param chinLevel 下巴拉伸或收缩级别取值范围 -9 ~ 9。数值越大,拉伸越明显。默认值:0
557566
*/
567+
@Deprecated
558568
public abstract void setChinLevel(int chinLevel);
559569

560570
/**
561571
* 设置瘦鼻(特权版本有效,普通版本设置此参数无效)
562572
*
563573
* @param noseSlimLevel 瘦鼻级别取值范围 0 ~ 9。数值越大,效果越明显。默认值:0
564574
*/
575+
@Deprecated
565576
public abstract void setNoseSlimLevel(int noseSlimLevel);
566577

567578
/**

Android/XiaoZhiBo/app/src/main/java/com/tencent/liteav/demo/lvb/liveroom/MLVBLiveRoomImpl.java

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import com.tencent.imsdk.TIMUserProfile;
1818
import com.tencent.imsdk.TIMValueCallBack;
1919
import com.tencent.liteav.basic.log.TXCLog;
20+
import com.tencent.liteav.beauty.TXBeautyManager;
2021
import com.tencent.liteav.demo.lvb.liveroom.roomutil.commondef.AnchorInfo;
2122
import com.tencent.liteav.demo.lvb.liveroom.roomutil.commondef.AudienceInfo;
2223
import com.tencent.liteav.demo.lvb.liveroom.roomutil.commondef.LoginInfo;
@@ -1542,6 +1543,14 @@ public void setCameraMuteImage(int id) {
15421543
}
15431544
}
15441545

1546+
@Override
1547+
public TXBeautyManager getBeautyManager() {
1548+
if (mTXLivePusher == null) {
1549+
mTXLivePusher = new TXLivePusher(mAppContext);
1550+
}
1551+
return mTXLivePusher.getBeautyManager();
1552+
}
1553+
15451554
/**
15461555
* 设置美颜、美白、红润效果级别
15471556
*
@@ -2288,16 +2297,16 @@ protected String getRoomCreator(String roomID) {
22882297

22892298
protected void initLivePusher(boolean frontCamera) {
22902299
if (mTXLivePusher == null) {
2291-
TXLivePushConfig config = new TXLivePushConfig();
2292-
config.setFrontCamera(frontCamera);
2293-
config.enableScreenCaptureAutoRotate(mScreenAutoEnable);// 是否开启屏幕自适应
2294-
config.setPauseFlag(TXLiveConstants.PAUSE_FLAG_PAUSE_VIDEO | TXLiveConstants.PAUSE_FLAG_PAUSE_AUDIO);
22952300
mTXLivePusher = new TXLivePusher(mAppContext);
2296-
mTXLivePusher.setConfig(config);
2297-
mTXLivePusher.setBeautyFilter(TXLiveConstants.BEAUTY_STYLE_SMOOTH, 5, 3, 2);
2298-
mTXLivePushListener = new TXLivePushListenerImpl();
2299-
mTXLivePusher.setPushListener(mTXLivePushListener);
23002301
}
2302+
TXLivePushConfig config = new TXLivePushConfig();
2303+
config.setFrontCamera(frontCamera);
2304+
config.enableScreenCaptureAutoRotate(mScreenAutoEnable);// 是否开启屏幕自适应
2305+
config.setPauseFlag(TXLiveConstants.PAUSE_FLAG_PAUSE_VIDEO | TXLiveConstants.PAUSE_FLAG_PAUSE_AUDIO);
2306+
mTXLivePusher.setConfig(config);
2307+
mTXLivePusher.setBeautyFilter(TXLiveConstants.BEAUTY_STYLE_SMOOTH, 5, 3, 2);
2308+
mTXLivePushListener = new TXLivePushListenerImpl();
2309+
mTXLivePusher.setPushListener(mTXLivePushListener);
23012310
}
23022311

23032312
protected void unInitLivePusher() {

Android/XiaoZhiBo/app/src/main/java/com/tencent/liteav/demo/lvb/liveroom/roomutil/im/IMMessageMgr.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public class IMMessageMgr implements TIMMessageListener {
6868
*/
6969
public interface Callback{
7070
void onError(int code, String errInfo);
71-
void onSuccess(Object... args);
71+
void onSuccess(Object ...args);
7272
}
7373

7474
/**

Android/XiaoZhiBo/app/src/main/java/com/tencent/qcloud/xiaozhibo/anchor/TCCameraAnchorActivity.java

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,18 @@
1919
import android.widget.TextView;
2020
import android.widget.Toast;
2121

22+
import com.tencent.liteav.demo.beauty.BeautyPanel;
23+
import com.tencent.liteav.demo.beauty.BeautyParams;
2224
import com.tencent.liteav.demo.lvb.liveroom.IMLVBLiveRoomListener;
2325
import com.tencent.liteav.demo.lvb.liveroom.roomutil.commondef.AnchorInfo;
2426
import com.tencent.qcloud.xiaozhibo.R;
2527
import com.tencent.qcloud.xiaozhibo.common.report.TCELKReportMgr;
26-
import com.tencent.qcloud.xiaozhibo.common.widget.beauty.TCBeautyControl;
2728
import com.tencent.qcloud.xiaozhibo.common.utils.TCConstants;
2829
import com.tencent.qcloud.xiaozhibo.common.utils.TCUtils;
2930
import com.tencent.qcloud.xiaozhibo.common.widget.TCUserAvatarListAdapter;
31+
import com.tencent.qcloud.xiaozhibo.common.widget.beauty.LiveRoomBeautyKit;
3032
import com.tencent.qcloud.xiaozhibo.common.widget.video.TCVideoView;
3133
import com.tencent.qcloud.xiaozhibo.common.widget.video.TCVideoViewMgr;
32-
import com.tencent.qcloud.xiaozhibo.common.widget.beauty.TCBeautyDialogFragment;
3334
import com.tencent.qcloud.xiaozhibo.common.msg.TCSimpleUserInfo;
3435
import com.tencent.qcloud.xiaozhibo.login.TCUserMgr;
3536
import com.tencent.qcloud.xiaozhibo.anchor.music.TCAudioControl;
@@ -52,7 +53,7 @@
5253
*
5354
* 3. 音效控制面板类 {@link TCAudioControl}
5455
*
55-
* 4. 美颜特效控制类 {@link TCBeautyControl}
56+
* 4. 美颜特效控制类 {@link BeautyPanel}
5657
*/
5758
public class TCCameraAnchorActivity extends TCBaseAnchorActivity {
5859
private static final String TAG = TCCameraAnchorActivity.class.getSimpleName();
@@ -74,7 +75,7 @@ public class TCCameraAnchorActivity extends TCBaseAnchorActivity {
7475
private TCAudioControl mAudioCtrl; // 音效控制面板
7576
private LinearLayout mAudioPluginLayout;
7677

77-
private TCBeautyControl mBeautyControl; // 美颜设置的控制类
78+
private BeautyPanel mBeautyControl; // 美颜设置的控制类
7879

7980
// log相关
8081
private boolean mShowLog; // 是否打开 log 面板
@@ -90,9 +91,13 @@ public class TCCameraAnchorActivity extends TCBaseAnchorActivity {
9091

9192
@Override
9293
protected void onCreate(Bundle savedInstanceState) {
94+
setTheme(R.style.BeautyTheme);
9395
super.onCreate(savedInstanceState);
9496
TCELKReportMgr.getInstance().reportELK(TCConstants.ELK_ACTION_CAMERA_PUSH, TCUserMgr.getInstance().getUserId(), 0, "摄像头推流", null);
9597
mPusherList = new ArrayList<>();
98+
99+
LiveRoomBeautyKit manager = new LiveRoomBeautyKit(mLiveRoom);
100+
mBeautyControl.setProxy(manager);
96101
}
97102

98103
@Override
@@ -124,7 +129,7 @@ protected void initView() {
124129
mAudioCtrl = (TCAudioControl) findViewById(R.id.anchor_audio_control);
125130
mAudioPluginLayout = (LinearLayout) findViewById(R.id.anchor_ll_audio_plugin);
126131

127-
mBeautyControl = new TCBeautyControl(mLiveRoom);
132+
mBeautyControl = (BeautyPanel) findViewById(R.id.beauty_panel);
128133

129134
// 监听踢出的回调
130135
mPlayerVideoViewList = new TCVideoViewMgr(this, new TCVideoView.OnRoomViewListener() {
@@ -181,15 +186,19 @@ protected void onDestroy() {
181186
protected void startPublish() {
182187
mAudioCtrl.setPusher(mLiveRoom);
183188
mTXCloudVideoView.setVisibility(View.VISIBLE);
184-
TCBeautyDialogFragment.BeautyParams beautyParams = mBeautyControl.getParams();
189+
185190
// 打开本地预览,传入预览的 View
186191
mLiveRoom.startLocalPreview(true, mTXCloudVideoView);
187192
// 设置美颜参数
188-
mLiveRoom.setBeautyStyle(beautyParams.mBeautyStyle, beautyParams.mBeautyProgress, beautyParams.mWhiteProgress, beautyParams.mRuddyProgress);
193+
BeautyParams beautyParams = new BeautyParams();
194+
mLiveRoom.getBeautyManager().setBeautyStyle(beautyParams.mBeautyStyle);
195+
mLiveRoom.getBeautyManager().setBeautyLevel(beautyParams.mBeautyLevel);
196+
mLiveRoom.getBeautyManager().setWhitenessLevel(beautyParams.mWhiteLevel);
197+
mLiveRoom.getBeautyManager().setRuddyLevel(beautyParams.mRuddyLevel);
189198
// 设置瘦脸参数
190-
mLiveRoom.setFaceSlimLevel(beautyParams.mFaceLiftProgress);
199+
mLiveRoom.getBeautyManager().setFaceSlimLevel(beautyParams.mFaceSlimLevel);
191200
// 设置大眼参数
192-
mLiveRoom.setEyeScaleLevel(beautyParams.mBigEyeProgress);
201+
mLiveRoom.getBeautyManager().setEyeScaleLevel(beautyParams.mBigEyeLevel);
193202
if (TCUtils.checkRecordPermission(this)) {
194203
super.startPublish();
195204
}
@@ -433,10 +442,11 @@ public void onClick(View v) {
433442

434443
break;
435444
case R.id.beauty_btn:
436-
if (mBeautyControl.isAdded())
437-
mBeautyControl.dismiss();
438-
else
439-
mBeautyControl.show(getFragmentManager(), "");
445+
if (mBeautyControl.isShown()) {
446+
mBeautyControl.setVisibility(View.GONE);
447+
} else {
448+
mBeautyControl.setVisibility(View.VISIBLE);
449+
}
440450
break;
441451
case R.id.btn_close:
442452
showExitInfoDialog("当前正在直播,是否退出直播?", false);
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
package com.tencent.qcloud.xiaozhibo.anchor.music;
2+
3+
import android.net.Uri;
4+
import android.os.Parcel;
5+
import android.os.Parcelable;
6+
import android.support.annotation.NonNull;
7+
8+
public class MusicEntity implements Parcelable {
9+
//id标识
10+
public int id;
11+
// 显示名称
12+
public String title;
13+
// 文件名称
14+
public String display_name;
15+
// 音乐文件的路径
16+
public String path;
17+
// 媒体播放总时间
18+
public int duration;
19+
// 专辑
20+
public String albums;
21+
// 艺术家
22+
public String artist;
23+
//歌手
24+
public String singer;
25+
public String durationStr;
26+
public long size;
27+
//0:idle 1:playing
28+
public char state = 0;
29+
public Uri fileUri;
30+
31+
MusicEntity() {
32+
}
33+
34+
protected MusicEntity(Parcel in) {
35+
id = in.readInt();
36+
title = in.readString();
37+
display_name = in.readString();
38+
path = in.readString();
39+
duration = in.readInt();
40+
albums = in.readString();
41+
artist = in.readString();
42+
singer = in.readString();
43+
durationStr = in.readString();
44+
size = in.readLong();
45+
state = (char) in.readInt();
46+
fileUri = in.readParcelable(Uri.class.getClassLoader());
47+
}
48+
49+
public static final Creator<MusicEntity> CREATOR = new Creator<MusicEntity>() {
50+
@Override
51+
public MusicEntity createFromParcel(Parcel in) {
52+
return new MusicEntity(in);
53+
}
54+
55+
@Override
56+
public MusicEntity[] newArray(int size) {
57+
return new MusicEntity[size];
58+
}
59+
};
60+
61+
@Override
62+
public int describeContents() {
63+
return 0;
64+
}
65+
66+
@Override
67+
public void writeToParcel(Parcel dest, int flags) {
68+
dest.writeInt(id);
69+
dest.writeString(title);
70+
dest.writeString(display_name);
71+
dest.writeString(path);
72+
dest.writeInt(duration);
73+
dest.writeString(albums);
74+
dest.writeString(artist);
75+
dest.writeString(singer);
76+
dest.writeString(durationStr);
77+
dest.writeLong(size);
78+
dest.writeInt(state);
79+
dest.writeParcelable(fileUri, flags);
80+
}
81+
82+
@NonNull
83+
@Override
84+
public String toString() {
85+
return "MusicEntity{" +
86+
"id=" + id +
87+
", title='" + title + '\'' +
88+
", display_name='" + display_name + '\'' +
89+
", path='" + path + '\'' +
90+
", duration='" + duration + '\'' +
91+
", albums=" + albums +
92+
", artist=" + artist +
93+
", singer=" + singer +
94+
", durationStr=" + durationStr +
95+
", size=" + size +
96+
", state=" + state +
97+
", fileUri=" + fileUri +
98+
'}';
99+
}
100+
}

Android/XiaoZhiBo/app/src/main/java/com/tencent/qcloud/xiaozhibo/anchor/music/MusicListAdapter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
* Function: 音乐列表的 Adapter
1818
*/
1919
class MusicListAdapter extends BaseAdapter {
20-
private List<TCAudioControl.MediaEntity> mData;
20+
private List<MusicEntity> mData;
2121
private LayoutInflater mInflater;
2222

23-
MusicListAdapter(LayoutInflater inflater, List<TCAudioControl.MediaEntity> list) {
23+
MusicListAdapter(LayoutInflater inflater, List<MusicEntity> list) {
2424
mInflater = inflater;
2525
mData = list;
2626
}

Android/XiaoZhiBo/app/src/main/java/com/tencent/qcloud/xiaozhibo/anchor/music/MusicListView.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* Function: 音乐列表的 ListView
1515
*/
1616
public class MusicListView extends ListView {
17-
private List<TCAudioControl.MediaEntity> mData;
17+
private List<MusicEntity> mData;
1818
private BaseAdapter mAdapter;
1919

2020
public BaseAdapter getAdapter() {
@@ -31,13 +31,13 @@ public MusicListView(Context context, AttributeSet attrs) {
3131
this.setChoiceMode(CHOICE_MODE_SINGLE);
3232
}
3333

34-
public void setupList(LayoutInflater inflater, List<TCAudioControl.MediaEntity> data) {
34+
public void setupList(LayoutInflater inflater, List<MusicEntity> data) {
3535
mData = data;
3636
mAdapter = new MusicListAdapter(inflater, data);
3737
setAdapter(mAdapter);
3838
}
3939

40-
public void setData(List<TCAudioControl.MediaEntity> data) {
40+
public void setData(List<MusicEntity> data) {
4141
mData = data;
4242
}
4343
@Override

0 commit comments

Comments
 (0)