123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- //
- // LivePrepareViewController.m
- // KulexiuForTeacher
- //
- // Created by Kyle on 2022/3/30.
- //
- #import "LivePrepareViewController.h"
- #import "LivePreviewBodyView.h"
- #import <RongRTCLib/RongRTCLib.h>
- #import "KSEnterLiveroomManager.h"
- #import <RongFaceBeautifier/RongFaceBeautifier.h>
- @interface LivePrepareViewController ()
- @property (nonatomic, strong) LivePreviewBodyView *bodyView;
- // 音频配置
- @property(strong, nonatomic) RCRTCEngine *engine;
- @end
- @implementation LivePrepareViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- self.ks_prefersNavigationBarHidden = YES;
- [self configUI];
- [self configEngine];
- }
- - (void)configUI {
- self.bodyView = [LivePreviewBodyView shareInstance];
- [self.view addSubview:self.bodyView];
- [self.bodyView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.bottom.top.mas_equalTo(self.view);
- }];
- MJWeakSelf;
- [self.bodyView previewOperationCallback:^(PREVIEWLIVEACTION action) {
- [weakSelf previewOperationAction:action];
- }];
-
- }
- - (void)configEngine {
- self.engine = [RCRTCEngine sharedInstance];
- RCRTCVideoView *videoView = [[RCRTCVideoView alloc] init];
- videoView.fillMode = RCRTCVideoFillModeAspectFill;
-
- videoView.frameAnimated = NO;
- [self.bodyView.videoView addSubview:videoView];
- [videoView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.top.bottom.right.mas_equalTo(self.bodyView.videoView);
- }];
- [self.engine.defaultVideoStream setVideoView:videoView];
- [self.engine.defaultVideoStream startCapture];
-
- }
- - (void)previewOperationAction:(PREVIEWLIVEACTION)action {
- switch (action) {
- case PREVIEWLIVEACTION_BACK: // 返回
- {
- [self.navigationController dismissViewControllerAnimated:YES completion:nil];
- }
- break;
- case PREVIEWLIVEACTION_SWITCH: // 切换
- {
- [[RCRTCEngine sharedInstance].defaultVideoStream switchCamera];
- }
- break;
- case PREVIEWLIVEACTION_BEAUTY: // 美颜
- {
- [self displayBeautyView];
- }
- break;
- case PREVIEWLIVEACTION_SHARE: // 分享
- {
-
- }
- break;
- case PREVIEWLIVEACTION_OPEN: // 进入直播间
- {
- [self joinLiveRoom];
- }
- break;
- default:
- break;
- }
- }
- - (void)displayBeautyView {
- [self configSettingBeauty:YES white:8 smoothLevel:5 ruddyLevel:8 brightLevel:7 filter:RCRTCBeautyFilterEsthetic filterLevel:80];
- }
- - (void)configSettingBeauty:(BOOL)isOn white:(NSInteger)whitenessLevel smoothLevel:(NSInteger)smoothLevel ruddyLevel:(NSInteger)ruddyLevel brightLevel:(NSInteger)brightLevel filter:(RCRTCBeautyFilter)filter filterLevel:(int)filterLevel {
- if (isOn) {
- // 获取当前美颜参数
- RCRTCBeautyOption *option = [[RCRTCBeautyEngine sharedInstance] getCurrentBeautyOption];
- // 修改参数
- option.whitenessLevel = whitenessLevel;
- option.smoothLevel = smoothLevel;
- option.ruddyLevel = ruddyLevel;
- option.brightLevel = brightLevel;
- // 设置美颜
- [[RCRTCBeautyEngine sharedInstance] setBeautyOption:YES option:option];
- // 设置滤镜
- [[RCRTCBeautyEngine sharedInstance] setBeautyFilter:filter];
- // 设置滤镜强度
- [[RCRTCBeautyEngine sharedInstance] setFilterIntensity:filterLevel];
- }
- else {
- [[RCRTCBeautyEngine sharedInstance] reset];
- }
- }
- - (void)joinLiveRoom {
- [self showhud];
- MJWeakSelf;
- [KSEnterLiveroomManager joinLiveWithRoomId:self.roomId inController:(CustomNavViewController *)self.navigationController callback:^{
- [weakSelf removehub];
- }];
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|