//
//  PlayerViewController.h
//  VclustersGemini
//
//  Created by APPLE on 2019/6/13.
//  Copyright © 2019 APPLE. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "BaseViewController.h"
#import "PlayerView.h"
#import <RCCloudPhoneSDK/RCAudioPlayer.h>
#import <RCCloudPhoneSDK/RCCommandChannel.h>
#import "PlayerControlButTipView.h"
#import "Const.h"
#import "playerShowSecretkeyView.h"
#import "uploadFileDataModel.h"

@protocol PlayerViewControllerDelegate <NSObject>

@optional
- (void)playerViewControllerBackWithPhoneIndex:(NSInteger)phoneIndex;
- (void)shortcutBackWithPhoneID:(NSInteger)phoneID phoneVaild:(BOOL)phoneVaild; // 快捷方式 云手机已过期
// 激活码试用云手机续费
- (void)playerViewControllerActiveCodeRenewBackWithPhoneIndex:(NSInteger)phoneIndex;

@end

@class AdvertItemModel;
@class PlayerControlView;


@interface PlayerViewController : BaseViewController
{
    __block NSInteger deviceShareStates;/*设备状态*/
    PlayerControlView *controlView;
    /**
     * @brief 标记是否有返回上一级
     */
    BOOL haveBack;
    
    PlayerView *mPlayerView;
    NSLock  *connectLock;
    CIImage *saveCIImage;    //保存流，取最后一张图片

    RCMAACPlayer *aacPlayer;
    
    UIView *wattingView;
}

@property(copy,nonatomic)NSString * _Nullable internetVideoPort;
@property(copy,nonatomic)NSString *ip;
@property(copy,nonatomic)NSString *deviceId;
@property(nonatomic,assign)BOOL canControl;/*是否可以控制设备*/

@property(strong,nonatomic)PlayerControlButTipView *PlayerControlButTipV;
/**
* @brief vpnStatus 1：开启    0：关闭
*/
@property (nonatomic, assign) NSInteger vpnStatus;

/**
* @brief internetHttp websocket指令通道连接
*/
@property (nonatomic, copy) NSString *internetHttp;

@property (nonatomic, strong) RCCommandChannelManager *commandChannelManager;//指令通道
@property (nonatomic, strong) RCCommandChannelManager *businessCommandChannelManager;//业务通道


/**是否延迟发送打开app指令*/
@property (nonatomic, assign) BOOL               delayPostOpenAppOrder;

/**
 * @brief 编码类型是否支持h265
 */
@property(nonatomic, assign) BOOL isSupportH265Type;

/**页面跳转-需不需要回收资源*/
@property (nonatomic, assign) BOOL               isNeedRecyclResource;
/**音视频是否连接成功*/
@property (nonatomic, assign) BOOL               isConnectSuccess;

/**0:初始状态  1:切换云手机超分  2:token失效超分*/
@property (nonatomic, assign) NSInteger         rbdNotification;

//第一次链接设备 要发送指令信息 实现单点登录
@property (nonatomic, assign)BOOL didSendfristMsg;

@property (nonatomic, assign) BOOL isPwdVCShow;//当前是否有密码页面
//第一次链接设备 要发送指令信息 实现单点登录
@property (nonatomic, assign)BOOL isLoginAgainType;

//主动断开链接  后台之类的
@property (nonatomic, assign)BOOL needToDissconnectType;

//上传文件用到
@property (nonatomic, copy) NSString * _Nullable taskUid;
@property (nonatomic, copy) NSString * _Nullable fileName;
@property (nonatomic, strong) NSData * _Nullable AllFileData;
@property (nonatomic, strong) NSMutableArray * _Nullable cutFileDataArr;
@property (nonatomic, assign) NSInteger indexOfUploadFlie;
@property (nonatomic, assign) NSInteger cutFileEachPieceSzie;
@property (nonatomic, strong) uploadFileDataModel *curUploadFileDataMod;
@property (nonatomic, assign) BOOL isSuspendUploadType;

/**
 * @brief 云手机类型  VIP星动云手机  SVIP星曜云手机  STAR 唔即云手机
 */
//@property(copy,nonatomic)NSString *buyVipType;

//最后一帧回调
@property (nonatomic, copy) void (^block)(void);   //saveCIImageAction
//返回回传 最后一帧
@property (nonatomic, copy) void (^LastImageblock)(UIImage *image,NSString *deviceId,NSArray *cloudPhones);   //saveCIImageAction
//弹窗广告点击
@property (nonatomic, copy) void (^AdvertBlock)(AdvertItemModel *model);

@property (nonatomic, weak) id<PlayerViewControllerDelegate> delegate;

@property (nonatomic, strong) UIAlertController  *alertController;
typedef void(^sureActionBlock)(UIAlertController *alertView);
typedef void(^cancelActionBlock)(UIAlertController *alertController);
typedef void(^completiongeBlock) (int stats , NSString *backData);

/*更新云手机分辨率*/
- (void)updatePhoneReslotings;

- (void)addLoadingWithTipsView:(NSString *)tipsStr;
-(void)showNewIndicator;
-(void)removeNewIndicator;
- (void)removeLoadingWithTipsView;
-(void)initAlertWithTitle:(NSString *_Nullable)title message:(NSString *)message sureActionBlock:(sureActionBlock)sureActionBlock;
- (void)saveCIImageAction:(NSString *)deviceId;
- (void)toStopRecoder;
- (void)toStopAudioRecoder;
- (void)removeNSNotification;
- (void)addNSNotification;
- (void)initData;
- (BOOL)initVideoServer;
- (void)connectVideoServer;
- (NSArray *)getAllIvar:(id)object;
- (void)updatemPlayerView;
- (void)tryAgain;
- (void)requestIFrame;
- (void)disconnectVideoServer;
- (void)send_data:(NSString *)dataStr;
- (void)toUpdateDeviceUse;
- (void)phoneSelectWithIndex:(NSInteger)index;
- (void)exitPlayerView;/*退出推拉流*/

/**清除试用广告*/
- (void)extensionClearTrialAD;

- (void)showYearCardNoTime;
- (void)showChangPhoneTipsWithPhone:(NSInteger)index;

#pragma mark - 提示框
- (void)showAlertWithTitle:(NSAttributedString*_Nullable)atbTitle
                   message:(NSAttributedString*_Nullable)atbmessage
            tilteAlignment:(NSTextAlignment)tilteAlignment
          messageAlignment:(NSTextAlignment)messageAlignment
                sureAction:(UIAlertAction*_Nullable)sureAction
              cancelAction:(UIAlertAction*_Nullable)cancelAction;

- (void)openbusinessCommandChannelManagerrc_openURL;
- (void)opencommandChannelManagerrc_openURL;

#pragma mark - 设置是否可以播放声音和动画
-(void)setShowImgAndVoiceTypeFun:(bool)isCan;

#pragma mark - 显示秘钥 后续忘记密码要
-(void)showSecretkeyFun;

- (void)recyclResource;
@end
