Commit e7e53d1d73618019bf8ef3e12d014d69b5fcd733

Authored by 王军波
1 parent 12f615a1

直播播放,添加聊天SDK

Showing 17 changed files with 1235 additions and 51 deletions
LiveVideoCloud/LiveVideoCloud.xcodeproj/project.pbxproj
... ... @@ -22,8 +22,6 @@
22 22 810B650A1E77B39D00133E15 /* LVCFullScreenPlayerController.m in Sources */ = {isa = PBXBuildFile; fileRef = 810B65091E77B39D00133E15 /* LVCFullScreenPlayerController.m */; };
23 23 8112D4311E7927A5002E00F6 /* LVCPlayerLoadingView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8112D4301E7927A5002E00F6 /* LVCPlayerLoadingView.m */; };
24 24 812E50531E7699DC004F5FCD /* CNLivePlayerSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 812E50501E7699DC004F5FCD /* CNLivePlayerSDK.framework */; };
25   - 812E50551E7699E9004F5FCD /* CNLiveMsgTools.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 812E504F1E7699DC004F5FCD /* CNLiveMsgTools.framework */; };
26   - 812E50561E7699E9004F5FCD /* CNLiveMsgTools.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 812E504F1E7699DC004F5FCD /* CNLiveMsgTools.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
27 25 812E50581E7699E9004F5FCD /* CNLivePlayerSDK.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 812E50501E7699DC004F5FCD /* CNLivePlayerSDK.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
28 26 81FB5B3C1E7A6FFC00F98E1D /* SevenSwitch.m in Sources */ = {isa = PBXBuildFile; fileRef = 81FB5B3B1E7A6FFC00F98E1D /* SevenSwitch.m */; };
29 27 D2029B861E6EAAA50027CD92 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D2029B851E6EAAA50027CD92 /* main.m */; };
... ... @@ -148,6 +146,15 @@
148 146 D25BF87B1E7B8A82007FB138 /* SliderView.m in Sources */ = {isa = PBXBuildFile; fileRef = D25BF8791E7B8A82007FB138 /* SliderView.m */; };
149 147 D25BF87D1E7B8C78007FB138 /* KSYGPUResource.bundle in Resources */ = {isa = PBXBuildFile; fileRef = D25BF87C1E7B8C78007FB138 /* KSYGPUResource.bundle */; };
150 148 D25BF8801E7BD266007FB138 /* LVCUGCLivePlayerController.m in Sources */ = {isa = PBXBuildFile; fileRef = D25BF87F1E7BD266007FB138 /* LVCUGCLivePlayerController.m */; };
  149 + D25BF8831E7F775F007FB138 /* LVCUGCPlayerLoadingView.m in Sources */ = {isa = PBXBuildFile; fileRef = D25BF8821E7F775F007FB138 /* LVCUGCPlayerLoadingView.m */; };
  150 + D25BF8901E7F7F8F007FB138 /* UGCLoading.jpeg in Resources */ = {isa = PBXBuildFile; fileRef = D25BF88F1E7F7F8F007FB138 /* UGCLoading.jpeg */; };
  151 + D25BF8931E7FBAEA007FB138 /* LVCUGCBackgroundView.m in Sources */ = {isa = PBXBuildFile; fileRef = D25BF8921E7FBAEA007FB138 /* LVCUGCBackgroundView.m */; };
  152 + D25BF8971E7FE01B007FB138 /* CNLiveMsgTools.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D25BF8961E7FE01B007FB138 /* CNLiveMsgTools.framework */; };
  153 + D25BF8991E7FE033007FB138 /* CNLiveChatManager.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D25BF8981E7FE033007FB138 /* CNLiveChatManager.framework */; };
  154 + D25BF89A1E7FE046007FB138 /* CNLiveChatManager.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D25BF8981E7FE033007FB138 /* CNLiveChatManager.framework */; };
  155 + D25BF89B1E7FE046007FB138 /* CNLiveChatManager.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D25BF8981E7FE033007FB138 /* CNLiveChatManager.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
  156 + D25BF89C1E7FE049007FB138 /* CNLiveMsgTools.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D25BF8961E7FE01B007FB138 /* CNLiveMsgTools.framework */; };
  157 + D25BF89D1E7FE049007FB138 /* CNLiveMsgTools.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D25BF8961E7FE01B007FB138 /* CNLiveMsgTools.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
151 158 D2888D941E6EB8B4003A77C8 /* LVCTabBar.m in Sources */ = {isa = PBXBuildFile; fileRef = D2888D931E6EB8B4003A77C8 /* LVCTabBar.m */; };
152 159 D2888D9E1E6EBF1B003A77C8 /* LVCLiveViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D2888D9B1E6EBF1B003A77C8 /* LVCLiveViewController.m */; };
153 160 D2888DB11E6EC05F003A77C8 /* TempViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D2888DB01E6EC05F003A77C8 /* TempViewController.m */; };
... ... @@ -179,8 +186,9 @@
179 186 dstPath = "";
180 187 dstSubfolderSpec = 10;
181 188 files = (
182   - 812E50561E7699E9004F5FCD /* CNLiveMsgTools.framework in Embed Frameworks */,
183 189 812E50581E7699E9004F5FCD /* CNLivePlayerSDK.framework in Embed Frameworks */,
  190 + D25BF89B1E7FE046007FB138 /* CNLiveChatManager.framework in Embed Frameworks */,
  191 + D25BF89D1E7FE049007FB138 /* CNLiveMsgTools.framework in Embed Frameworks */,
184 192 );
185 193 name = "Embed Frameworks";
186 194 runOnlyForDeploymentPostprocessing = 0;
... ... @@ -221,7 +229,6 @@
221 229 810B65091E77B39D00133E15 /* LVCFullScreenPlayerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCFullScreenPlayerController.m; sourceTree = "<group>"; };
222 230 8112D42F1E7927A5002E00F6 /* LVCPlayerLoadingView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCPlayerLoadingView.h; sourceTree = "<group>"; };
223 231 8112D4301E7927A5002E00F6 /* LVCPlayerLoadingView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCPlayerLoadingView.m; sourceTree = "<group>"; };
224   - 812E504F1E7699DC004F5FCD /* CNLiveMsgTools.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = CNLiveMsgTools.framework; sourceTree = "<group>"; };
225 232 812E50501E7699DC004F5FCD /* CNLivePlayerSDK.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = CNLivePlayerSDK.framework; sourceTree = "<group>"; };
226 233 81FB5B3A1E7A6FFC00F98E1D /* SevenSwitch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SevenSwitch.h; sourceTree = "<group>"; };
227 234 81FB5B3B1E7A6FFC00F98E1D /* SevenSwitch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SevenSwitch.m; sourceTree = "<group>"; };
... ... @@ -482,6 +489,13 @@
482 489 D25BF87C1E7B8C78007FB138 /* KSYGPUResource.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = KSYGPUResource.bundle; sourceTree = "<group>"; };
483 490 D25BF87E1E7BD266007FB138 /* LVCUGCLivePlayerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCUGCLivePlayerController.h; sourceTree = "<group>"; };
484 491 D25BF87F1E7BD266007FB138 /* LVCUGCLivePlayerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCUGCLivePlayerController.m; sourceTree = "<group>"; };
  492 + D25BF8811E7F775F007FB138 /* LVCUGCPlayerLoadingView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCUGCPlayerLoadingView.h; sourceTree = "<group>"; };
  493 + D25BF8821E7F775F007FB138 /* LVCUGCPlayerLoadingView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCUGCPlayerLoadingView.m; sourceTree = "<group>"; };
  494 + D25BF88F1E7F7F8F007FB138 /* UGCLoading.jpeg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = UGCLoading.jpeg; sourceTree = "<group>"; };
  495 + D25BF8911E7FBAEA007FB138 /* LVCUGCBackgroundView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCUGCBackgroundView.h; sourceTree = "<group>"; };
  496 + D25BF8921E7FBAEA007FB138 /* LVCUGCBackgroundView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCUGCBackgroundView.m; sourceTree = "<group>"; };
  497 + D25BF8961E7FE01B007FB138 /* CNLiveMsgTools.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = CNLiveMsgTools.framework; sourceTree = "<group>"; };
  498 + D25BF8981E7FE033007FB138 /* CNLiveChatManager.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = CNLiveChatManager.framework; sourceTree = "<group>"; };
485 499 D2888D921E6EB8B4003A77C8 /* LVCTabBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCTabBar.h; sourceTree = "<group>"; };
486 500 D2888D931E6EB8B4003A77C8 /* LVCTabBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCTabBar.m; sourceTree = "<group>"; };
487 501 D2888D9A1E6EBF1B003A77C8 /* LVCLiveViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCLiveViewController.h; sourceTree = "<group>"; };
... ... @@ -501,7 +515,10 @@
501 515 files = (
502 516 D2575C7D1E76A4F300E3A8FC /* NHGiftAnimtionSDK.a in Frameworks */,
503 517 812E50531E7699DC004F5FCD /* CNLivePlayerSDK.framework in Frameworks */,
504   - 812E50551E7699E9004F5FCD /* CNLiveMsgTools.framework in Frameworks */,
  518 + D25BF89A1E7FE046007FB138 /* CNLiveChatManager.framework in Frameworks */,
  519 + D25BF8971E7FE01B007FB138 /* CNLiveMsgTools.framework in Frameworks */,
  520 + D25BF8991E7FE033007FB138 /* CNLiveChatManager.framework in Frameworks */,
  521 + D25BF89C1E7FE049007FB138 /* CNLiveMsgTools.framework in Frameworks */,
505 522 );
506 523 runOnlyForDeploymentPostprocessing = 0;
507 524 };
... ... @@ -565,8 +582,9 @@
565 582 812E504E1E7699B9004F5FCD /* CNLiveSDK */ = {
566 583 isa = PBXGroup;
567 584 children = (
  585 + D25BF8981E7FE033007FB138 /* CNLiveChatManager.framework */,
  586 + D25BF8961E7FE01B007FB138 /* CNLiveMsgTools.framework */,
568 587 D25BF87C1E7B8C78007FB138 /* KSYGPUResource.bundle */,
569   - 812E504F1E7699DC004F5FCD /* CNLiveMsgTools.framework */,
570 588 812E50501E7699DC004F5FCD /* CNLivePlayerSDK.framework */,
571 589 );
572 590 path = CNLiveSDK;
... ... @@ -609,7 +627,7 @@
609 627 D2029CDC1E6EAE2E0027CD92 /* UtilKits */,
610 628 D2029BD01E6EADE10027CD92 /* Classes */,
611 629 D2029CD11E6EADE70027CD92 /* HttpService */,
612   - D2029CD71E6EAE140027CD92 /* Resource */,
  630 + D25BF88A1E7F7F77007FB138 /* Resource */,
613 631 D2029B901E6EAAA50027CD92 /* animation.xcassets */,
614 632 D2029CD61E6EADFB0027CD92 /* PrefixHeader.pch */,
615 633 D2029B841E6EAAA50027CD92 /* Supporting Files */,
... ... @@ -1063,45 +1081,6 @@
1063 1081 path = HttpService;
1064 1082 sourceTree = "<group>";
1065 1083 };
1066   - D2029CD71E6EAE140027CD92 /* Resource */ = {
1067   - isa = PBXGroup;
1068   - children = (
1069   - D2029CD81E6EAE140027CD92 /* Fonts */,
1070   - D2029CD91E6EAE140027CD92 /* Images */,
1071   - D2029CDA1E6EAE140027CD92 /* Sound */,
1072   - D2029CDB1E6EAE140027CD92 /* Videos */,
1073   - );
1074   - path = Resource;
1075   - sourceTree = "<group>";
1076   - };
1077   - D2029CD81E6EAE140027CD92 /* Fonts */ = {
1078   - isa = PBXGroup;
1079   - children = (
1080   - );
1081   - path = Fonts;
1082   - sourceTree = "<group>";
1083   - };
1084   - D2029CD91E6EAE140027CD92 /* Images */ = {
1085   - isa = PBXGroup;
1086   - children = (
1087   - );
1088   - path = Images;
1089   - sourceTree = "<group>";
1090   - };
1091   - D2029CDA1E6EAE140027CD92 /* Sound */ = {
1092   - isa = PBXGroup;
1093   - children = (
1094   - );
1095   - path = Sound;
1096   - sourceTree = "<group>";
1097   - };
1098   - D2029CDB1E6EAE140027CD92 /* Videos */ = {
1099   - isa = PBXGroup;
1100   - children = (
1101   - );
1102   - path = Videos;
1103   - sourceTree = "<group>";
1104   - };
1105 1084 D2029CDC1E6EAE2E0027CD92 /* UtilKits */ = {
1106 1085 isa = PBXGroup;
1107 1086 children = (
... ... @@ -1331,6 +1310,46 @@
1331 1310 path = View;
1332 1311 sourceTree = "<group>";
1333 1312 };
  1313 + D25BF88A1E7F7F77007FB138 /* Resource */ = {
  1314 + isa = PBXGroup;
  1315 + children = (
  1316 + D25BF88C1E7F7F77007FB138 /* Images */,
  1317 + D25BF88B1E7F7F77007FB138 /* Fonts */,
  1318 + D25BF88D1E7F7F77007FB138 /* Sound */,
  1319 + D25BF88E1E7F7F77007FB138 /* Videos */,
  1320 + );
  1321 + path = Resource;
  1322 + sourceTree = "<group>";
  1323 + };
  1324 + D25BF88B1E7F7F77007FB138 /* Fonts */ = {
  1325 + isa = PBXGroup;
  1326 + children = (
  1327 + );
  1328 + path = Fonts;
  1329 + sourceTree = "<group>";
  1330 + };
  1331 + D25BF88C1E7F7F77007FB138 /* Images */ = {
  1332 + isa = PBXGroup;
  1333 + children = (
  1334 + D25BF88F1E7F7F8F007FB138 /* UGCLoading.jpeg */,
  1335 + );
  1336 + path = Images;
  1337 + sourceTree = "<group>";
  1338 + };
  1339 + D25BF88D1E7F7F77007FB138 /* Sound */ = {
  1340 + isa = PBXGroup;
  1341 + children = (
  1342 + );
  1343 + path = Sound;
  1344 + sourceTree = "<group>";
  1345 + };
  1346 + D25BF88E1E7F7F77007FB138 /* Videos */ = {
  1347 + isa = PBXGroup;
  1348 + children = (
  1349 + );
  1350 + path = Videos;
  1351 + sourceTree = "<group>";
  1352 + };
1334 1353 D2888D911E6EB897003A77C8 /* View */ = {
1335 1354 isa = PBXGroup;
1336 1355 children = (
... ... @@ -1398,6 +1417,10 @@
1398 1417 810B64DF1E779AE900133E15 /* LVCPlayer.m */,
1399 1418 8112D42F1E7927A5002E00F6 /* LVCPlayerLoadingView.h */,
1400 1419 8112D4301E7927A5002E00F6 /* LVCPlayerLoadingView.m */,
  1420 + D25BF8811E7F775F007FB138 /* LVCUGCPlayerLoadingView.h */,
  1421 + D25BF8821E7F775F007FB138 /* LVCUGCPlayerLoadingView.m */,
  1422 + D25BF8911E7FBAEA007FB138 /* LVCUGCBackgroundView.h */,
  1423 + D25BF8921E7FBAEA007FB138 /* LVCUGCBackgroundView.m */,
1401 1424 );
1402 1425 path = View;
1403 1426 sourceTree = "<group>";
... ... @@ -1547,6 +1570,7 @@
1547 1570 D2029C971E6EADE10027CD92 /* Info.plist in Resources */,
1548 1571 D2575C7F1E76A4F300E3A8FC /* NHPlaneViews.xib in Resources */,
1549 1572 D2575C7B1E76A4F300E3A8FC /* NHCarViews.xib in Resources */,
  1573 + D25BF8901E7F7F8F007FB138 /* UGCLoading.jpeg in Resources */,
1550 1574 D2029CC91E6EADE10027CD92 /* SVProgressHUD.bundle in Resources */,
1551 1575 D2575C801E76A4F300E3A8FC /* resource.bundle in Resources */,
1552 1576 D2029B941E6EAAA50027CD92 /* LaunchScreen.storyboard in Resources */,
... ... @@ -1582,6 +1606,7 @@
1582 1606 D2029CC31E6EADE10027CD92 /* UIImageView+HighlightedWebCache.m in Sources */,
1583 1607 D22830FF1E77C69E00627701 /* GiftListView.m in Sources */,
1584 1608 D2029CC01E6EADE10027CD92 /* UIImage+GIF.m in Sources */,
  1609 + D25BF8831E7F775F007FB138 /* LVCUGCPlayerLoadingView.m in Sources */,
1585 1610 D2029BCF1E6EADD70027CD92 /* ZXTabBarController.m in Sources */,
1586 1611 D2029D071E6EAE2E0027CD92 /* ZXConst.m in Sources */,
1587 1612 D2029CB81E6EADE10027CD92 /* SDImageCache.m in Sources */,
... ... @@ -1589,6 +1614,7 @@
1589 1614 D2029CA71E6EADE10027CD92 /* MJRefreshAutoGifFooter.m in Sources */,
1590 1615 D2029CC11E6EADE10027CD92 /* UIImage+MultiFormat.m in Sources */,
1591 1616 D2029C861E6EADE10027CD92 /* Tools.m in Sources */,
  1617 + D25BF8931E7FBAEA007FB138 /* LVCUGCBackgroundView.m in Sources */,
1592 1618 D2029CA01E6EADE10027CD92 /* NSObject+MJProperty.m in Sources */,
1593 1619 D2029CB51E6EADE10027CD92 /* SDiOSVersion.m in Sources */,
1594 1620 D2029C9C1E6EADE10027CD92 /* MJPropertyType.m in Sources */,
... ...
LiveVideoCloud/LiveVideoCloud/Classes/CNLiveSDK/CNLiveChatManager.framework/CNLiveChatManager 0 → 100755
No preview for this file type
LiveVideoCloud/LiveVideoCloud/Classes/CNLiveSDK/CNLiveChatManager.framework/Headers/CNLiveChatManager.h 0 → 100644
  1 +//
  2 +// CNLiveChatManager.h
  3 +// CNLiveChatManager
  4 +//
  5 +// Created by cnliveJunBo on 17/2/27.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +#import "CNLiveChatUserInfo.h"
  11 +#import "CNLiveChatStatusDefine.h"
  12 +#import "CNLiveChatMessage.h"
  13 +
  14 +@protocol CNLiveChatManagerDelegate <NSObject>
  15 +
  16 +@optional
  17 +/**
  18 + 连接状态的的监听器
  19 +
  20 + @param status 网络连接状态码
  21 + */
  22 +- (void)onConnectionStatusChanged:(CNLiveConnectionStatus)status;
  23 +
  24 +
  25 +/**
  26 + 加入聊天室成功的监听
  27 + @param chatroomId 聊天室ID
  28 + */
  29 +- (void)onChatRoomJoined:(NSString *)chatroomId;
  30 +
  31 +
  32 +/*!
  33 + 加入聊天室失败的监听
  34 +
  35 + @param chatroomId 聊天室ID
  36 + @param errorCode 加入失败的错误码
  37 +
  38 + @discussion 如果错误码是CNLive_KICKED_FROM_CHATROOM或CNLive_CHATROOM_NOT_EXIST,则不会自动重新加入聊天室,App需要按照自己的逻辑处理。
  39 + */
  40 +- (void)onChatRoomJoinFailed:(NSString *)chatroomId
  41 + errorCode:(CNLiveChatErrorCode)errorCode;
  42 +
  43 +/**
  44 + 接收消息监听
  45 +
  46 + @param message 消息实体类型对象(包括消息内容,消息ID,会话类型,目标ID,发送者的用户信息)
  47 + */
  48 +- (void)onReceived:(CNLiveChatMessage *)message;
  49 +
  50 +
  51 +/**
  52 + 当前用户在其他设备上登录,此设备被踢下线。
  53 + */
  54 +- (void)kickedByAnotherDevice;
  55 +
  56 +@end
  57 +
  58 +@interface CNLiveChatManager : NSObject
  59 +
  60 +/**
  61 + 聊天SDK代理,设置代理后,实现代理方法。
  62 + */
  63 +@property (nonatomic, weak) id<CNLiveChatManagerDelegate> delegate;
  64 +
  65 +/**
  66 + 当前登录用户的用户信息
  67 +
  68 + @discussion 用于与融云服务器建立连接之后,获取&设置当前用户的用户信息。
  69 + 用户ID不允许重新设置,只能设置昵称&头像。
  70 + */
  71 +@property(nonatomic, strong) CNLiveChatUserInfo *currentUserInfo;
  72 +
  73 +/**
  74 + 获取SDK版本号
  75 +
  76 + @return SDK版本号
  77 + */
  78 ++ (NSString *)getVersion;
  79 +
  80 +
  81 +/**
  82 + 获取视讯聊天核心类单例
  83 +
  84 + @return 视讯聊天核心类单例
  85 +
  86 + @discussion 您可以通过此方法,获取视讯聊天的单例,访问对象中的属性和方法。
  87 + */
  88 ++ (instancetype)sharedCNLiveChatManager;
  89 +
  90 +
  91 +/**
  92 + 初始化SDK方法
  93 +
  94 + @param appKey 从视讯云平台获取到的appKey
  95 + @param appId 从视讯云平台获取到的appId
  96 + @warning 必传参数
  97 + @discussion 您在使用聊天SDK所有功能之前,您必须先调用此方法初始化SDK。
  98 + 在App整个生命周期中,您只需要执行一次初始化。
  99 + */
  100 +- (void)initWithAppKey:(NSString *)appKey appId:(NSString *)appId;
  101 +
  102 +
  103 +/**
  104 + 连接到视讯云服务器
  105 +
  106 + @param successBlock 连接建立成功的回调。
  107 + @param errorBlock 连接建立成功的回调,返回错误码。
  108 + 注:连接服务器成功后才能使用聊天功能(如:单聊、加入聊天室、聊天室内 聊天);
  109 + */
  110 +- (void)connectServerSuccess:(void (^)())successBlock
  111 + error:(void (^)(CNLiveChatConnectErrorCode errors))errorBlock;
  112 +
  113 +/**
  114 + 以用户信息登陆到视讯云服务器
  115 +
  116 + @param userInfo 用户信息
  117 + @param successBlock 登陆成功的回调,返回登陆成功的用户ID。
  118 + @param errorBlock 登陆失败的回调,返回错误码。
  119 + 注:连接服务器成功后才能使用聊天功能(如:单聊、加入聊天室、聊天室内 聊天);
  120 + */
  121 +- (void)loginServer:(CNLiveChatUserInfo *)userInfo
  122 + success:(void (^)(NSString *userId))successBlock
  123 + error:(void (^)(CNLiveChatConnectErrorCode errors))errorBlock;
  124 +
  125 +
  126 +/**
  127 + 当前用户登出服务器
  128 + */
  129 +- (void)logoutServer;
  130 +
  131 +
  132 +/**
  133 + 断开与服务器的连接
  134 +
  135 + @param isReceivePush 与服务器断开后,是否还接收远程推送
  136 + */
  137 +- (void)disconnectServer:(BOOL)isReceivePush;
  138 +
  139 +
  140 +/**
  141 + 加入已经存在的聊天室(如果不存在或超限会返回聊天室不存在错误23410 或 人数超限23411)
  142 +
  143 + @param targetId 要加入的聊天室ID
  144 + @param messageCount 进入聊天室时获取历史消息的数量,-1<=messageCount<=50
  145 + -1表示不获取任何历史消息,0表示不特殊设置而使用SDK默认的设置(默认为获取10条),0<messageCount<=50为具体获取的消息数量,最大值为50。
  146 + @param successBlock 加入聊天室成功的回调,返回成功加入的聊天室ID。
  147 + @param errorBlock 加入聊天室失败的回调,返回错误码以及加入失败的聊天室ID。
  148 + */
  149 +- (void)joinExistChatRoom:(NSString *)targetId
  150 + messageCount:(int)messageCount
  151 + success:(void (^)(NSString *targetId))successBlock
  152 + error:(void (^)(CNLiveChatErrorCode errors, NSString *targetId))errorBlock;
  153 +
  154 +
  155 +/**
  156 + 加入聊天室,若不存在自动创建聊天室
  157 +
  158 + @param targetId 要加入的聊天室ID
  159 + @param messageCount 进入聊天室时获取历史消息的数量,-1<=messageCount<=50
  160 + -1表示不获取任何历史消息,0表示不特殊设置而使用SDK默认的设置(默认为获取10条),0<messageCount<=50为具体获取的消息数量,最大值为50。
  161 + @param successBlock 加入聊天室成功的回调,返回成功加入的聊天室ID
  162 + @param errorBlock 加入聊天室失败的回调,返回错误码以及加入失败的聊天室ID
  163 + */
  164 +- (void)joinChatRoom:(NSString *)targetId
  165 + messageCount:(int)messageCount
  166 + success:(void (^)(NSString *targetId))successBlock
  167 + error:(void (^)(CNLiveChatErrorCode errors, NSString *targetId))errorBlock;
  168 +
  169 +
  170 +/**
  171 + 退出聊天室
  172 +
  173 + @param targetId 要退出的聊天室ID
  174 + @param successBlock 退出聊天室成功的回调,返回成功退出的聊天室ID
  175 + @param errorBlock 退出聊天室失败的回调,返回失败的错误码以及退出失败的聊天室的ID
  176 + */
  177 +- (void)quitChatRoom:(NSString *)targetId
  178 + success:(void (^)(NSString *targetId))successBlock
  179 + error:(void (^)(CNLiveChatErrorCode errors, NSString *targetId))errorBlock;
  180 +
  181 +
  182 +/**
  183 + 发送消息
  184 +
  185 + @param message 消息内容
  186 + @param type 会话类型(私聊 / 聊天室)
  187 + @param targetId 会话目标ID(私聊:用户ID / 聊天室:聊天室ID)
  188 + @param successBlock 发送消息成功的回调,消息实体类型对象(包括消息内容,消息ID,会话类型,目标ID,发送者的用户信息)
  189 + @param errorBlock 发送消息失败的回调,返回错误码,消息ID,目标ID
  190 + */
  191 +- (void)sendMessage:(NSString *)message
  192 + type:(CNLiveConversationType)type
  193 + targetId:(NSString *)targetId
  194 + success:(void (^)(CNLiveChatMessage *message))successBlock
  195 + error:(void (^)(CNLiveChatErrorCode errors, NSString *messageId, NSString *targetId))errorBlock;
  196 +
  197 +
  198 +/**
  199 + 获取当前SDK的连接状态
  200 +
  201 + @return 当前SDK的连接状态
  202 + */
  203 +- (CNLiveConnectionStatus)getConnectionStatus;
  204 +
  205 +
  206 +/**
  207 + 获取某个会话中指定数量的最新消息
  208 +
  209 + @param conversationType 会话类型(私聊 / 聊天室)
  210 + @param targetId 会话目标ID(私聊:用户ID / 聊天室:聊天室ID)
  211 + @param count 所要获取的消息数量
  212 +
  213 + @return 消息数组(CNLiveChatMessage类型)
  214 + @discussion
  215 + 此方法会获取该会话中指定数量的最新消息实体,返回的消息实体按照时间从新到旧排列。
  216 + 如果会话中的消息数量小于参数count的值,会将该会话中的所有消息返回。
  217 + */
  218 +- (NSArray *)getLatestMessages:(CNLiveConversationType)conversationType
  219 + targetId:(NSString *)targetId
  220 + count:(int)count;
  221 +
  222 +
  223 +@end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/CNLiveSDK/CNLiveChatManager.framework/Headers/CNLiveChatMessage.h 0 → 100644
  1 +//
  2 +// CNLiveChatMessage.h
  3 +// CNLiveChatManager
  4 +//
  5 +// Created by cnliveJunBo on 17/3/3.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +#import "CNLiveChatStatusDefine.h"
  11 +#import "CNLiveChatUserInfo.h"
  12 +
  13 +@interface CNLiveChatMessage : NSObject
  14 +
  15 +/**
  16 + 会话类型(私聊 / 聊天室)
  17 + */
  18 +@property (nonatomic, assign) CNLiveConversationType conversationType;
  19 +
  20 +/**
  21 + 目标ID(消息来自聊天室的ID / 接收者ID)
  22 + */
  23 +@property (nonatomic, assign) NSString *targetId;
  24 +
  25 +/**
  26 + 消息ID(本地存储的消息的唯一值(数据库索引唯一值))
  27 + */
  28 +@property (nonatomic, assign) NSString *messageId;
  29 +
  30 +/**
  31 + 消息内容
  32 + */
  33 +@property (nonatomic, strong) NSString *messageContent;
  34 +
  35 +/**
  36 + 发送者的用户信息(userId, name, portraitUri)
  37 + */
  38 +@property (nonatomic, strong) CNLiveChatUserInfo *userInfo;
  39 +
  40 +/**
  41 + 消息的接收时间(Unix时间戳、毫秒)
  42 + */
  43 +@property(nonatomic, assign) long long receivedTime;
  44 +
  45 +/**
  46 + 消息的发送时间(Unix时间戳、毫秒)
  47 + */
  48 +@property(nonatomic, assign) long long sentTime;
  49 +
  50 +@end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/CNLiveSDK/CNLiveChatManager.framework/Headers/CNLiveChatStatusDefine.h 0 → 100644
  1 +//
  2 +// CNLiveChatStatusDefine.h
  3 +// CNLiveChatManager
  4 +//
  5 +// Created by cnliveJunBo on 17/3/1.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +
  11 +#pragma mark - 错误码相关
  12 +
  13 +#pragma mark CNLiveChatConnectErrorCode - 建立连接返回的错误码
  14 +/*!
  15 + 建立连接返回的错误码
  16 +
  17 + @discussion
  18 + 开发者仅需要关注以下几种连接错误码,其余错误码SDK均会进行自动重连,开发者无须处理。
  19 + CNLive_CONN_ID_REJECT, CNLive_CONN_TOKEN_INCORRECT, CNLive_CONN_NOT_AUTHRORIZED,
  20 + CNLive_CONN_PACKAGE_NAME_INVALID, CNLive_CONN_APP_BLOCKED_OR_DELETED,
  21 + CNLive_CONN_USER_BLOCKED, CNLive_DISCONN_KICK, CNLive_CLIENT_NOT_INIT, CNLive_INVALID_PARAMETER, CNLive_INVALID_ARGUMENT
  22 + */
  23 +typedef NS_ENUM(NSInteger, CNLiveChatConnectErrorCode) {
  24 +
  25 + /*!
  26 + 连接已被释放
  27 +
  28 + @discussion 建立连接的临时错误码,SDK会做好自动重连,开发者无须处理。
  29 + */
  30 + CNLive_NET_CHANNEL_INVALID = 30001,
  31 +
  32 + /*!
  33 + 连接不可用
  34 +
  35 + @discussion 建立连接的临时错误码,SDK会做好自动重连,开发者无须处理。
  36 + */
  37 + CNLive_NET_UNAVAILABLE = 30002,
  38 +
  39 + /*!
  40 + 导航HTTP发送失败
  41 +
  42 + @discussion 建立连接的临时错误码,SDK会做好自动重连,开发者无须处理。
  43 + */
  44 + CNLive_NAVI_REQUEST_FAIL = 30004,
  45 +
  46 + /*!
  47 + 导航HTTP请求失败
  48 +
  49 + @discussion 建立连接的临时错误码,SDK会做好自动重连,开发者无须处理。
  50 + */
  51 + CNLive_NAVI_RESPONSE_ERROR = 30007,
  52 +
  53 + /*!
  54 + 导航HTTP返回数据格式错误
  55 +
  56 + @discussion 建立连接的临时错误码,SDK会做好自动重连,开发者无须处理。
  57 + */
  58 + CNLive_NODE_NOT_FOUND = 30008,
  59 +
  60 + /*!
  61 + 创建Socket连接失败
  62 +
  63 + @discussion 建立连接的临时错误码,SDK会做好自动重连,开发者无须处理。
  64 + */
  65 + CNLive_SOCKET_NOT_CONNECTED = 30010,
  66 +
  67 + /*!
  68 + Socket断开
  69 +
  70 + @discussion 建立连接的临时错误码,SDK会做好自动重连,开发者无须处理。
  71 + */
  72 + CNLive_SOCKET_DISCONNECTED = 30011,
  73 +
  74 + /*!
  75 + PING失败
  76 +
  77 + @discussion 建立连接的临时错误码,SDK会做好自动重连,开发者无须处理。
  78 + */
  79 + CNLive_PING_SEND_FAIL = 30012,
  80 +
  81 + /*!
  82 + PING超时
  83 +
  84 + @discussion 建立连接的临时错误码,SDK会做好自动重连,开发者无须处理。
  85 + */
  86 + CNLive_PONG_RECV_FAIL = 30013,
  87 +
  88 + /*!
  89 + 信令发送失败
  90 +
  91 + @discussion 建立连接的临时错误码,SDK会做好自动重连,开发者无须处理。
  92 + */
  93 + CNLive_MSG_SEND_FAIL = 30014,
  94 +
  95 + /*!
  96 + 连接过于频繁
  97 +
  98 + @discussion 建立连接的临时错误码,SDK会做好自动重连,开发者无须处理。
  99 + */
  100 + CNLive_CONN_OVERFREQUENCY = 30015,
  101 +
  102 + /*!
  103 + 连接ACK超时
  104 +
  105 + @discussion 建立连接的临时错误码,SDK会做好自动重连,开发者无须处理。
  106 + */
  107 + CNLive_CONN_ACK_TIMEOUT = 31000,
  108 +
  109 + /*!
  110 + 信令版本错误
  111 +
  112 + @discussion 建立连接的临时错误码,SDK会做好自动重连,开发者无须处理。
  113 + */
  114 + CNLive_CONN_PROTO_VERSION_ERROR = 31001,
  115 +
  116 + /*!
  117 + AppKey错误
  118 +
  119 + @discussion 请检查您使用的AppKey是否正确。(*自行处理)
  120 + */
  121 + CNLive_CONN_ID_REJECT = 31002,
  122 +
  123 + /*!
  124 + 服务器当前不可用(预留)
  125 +
  126 + @discussion 建立连接的临时错误码,SDK会做好自动重连,开发者无须处理。
  127 + */
  128 + CNLive_CONN_SERVER_UNAVAILABLE = 31003,
  129 +
  130 + /*!
  131 + Token无效
  132 +
  133 + @discussion Token无效一般有以下两种原因。(*自行处理)
  134 + 一是token错误,请您检查客户端初始化使用的AppKey和您服务器获取token使用的AppKey是否一致;
  135 + 二是token过期,是因为您在开发者后台设置了token过期时间,您需要请求您的服务器重新获取token并再次用新的token建立连接。
  136 + */
  137 + CNLive_CONN_TOKEN_INCORRECT = 31004,
  138 +
  139 + /*!
  140 + AppKey与Token不匹配
  141 +
  142 + @discussion
  143 + 请检查您使用的AppKey与Token是否正确,是否匹配。一般有以下两种原因。(*自行处理)
  144 + 一是token错误,请您检查客户端初始化使用的AppKey和您服务器获取token使用的AppKey是否一致;
  145 + 二是token过期,是因为您在开发者后台设置了token过期时间,您需要请求您的服务器重新获取token并再次用新的token建立连接。
  146 + */
  147 + CNLive_CONN_NOT_AUTHRORIZED = 31005,
  148 +
  149 + /*!
  150 + 连接重定向
  151 +
  152 + @discussion 建立连接的临时错误码,SDK会做好自动重连,开发者无须处理。
  153 + */
  154 + CNLive_CONN_REDIRECTED = 31006,
  155 +
  156 + /*!
  157 + BundleID不正确
  158 +
  159 + @discussion 请检查您App的BundleID是否正确。(*自行处理)
  160 + */
  161 + CNLive_CONN_PACKAGE_NAME_INVALID = 31007,
  162 +
  163 + /*!
  164 + AppKey被封禁或已删除
  165 +
  166 + @discussion 请检查您使用的AppKey是否正确。(*自行处理)
  167 + */
  168 + CNLive_CONN_APP_BLOCKED_OR_DELETED = 31008,
  169 +
  170 + /*!
  171 + 用户被封禁
  172 +
  173 + @discussion 请检查您使用的Token是否正确,以及对应的UserId是否被封禁。(*自行处理)
  174 + */
  175 + CNLive_CONN_USER_BLOCKED = 31009,
  176 +
  177 + /*!
  178 + Token请求失败
  179 +
  180 + @discussion 请检查连接服务器方法的参数是否正确,特别是用户信息中的用户ID。也可能是无网络。(*自行处理)
  181 + */
  182 + CNLive_CONN_TOKEN_NULL = 31012,
  183 +
  184 + /*!
  185 + 当前用户在其他设备上登陆,此设备被踢下线。(*自行处理)
  186 + */
  187 + CNLive_DISCONN_KICK = 31010,
  188 +
  189 + /*!
  190 + SDK没有初始化
  191 +
  192 + @discussion 在使用SDK任何功能之前,必须先Init。(*自行处理)
  193 + */
  194 + CNLive_CONN_CLIENT_NOT_INIT = 33001,
  195 +
  196 + /*!
  197 + 开发者接口调用时传入的参数错误
  198 +
  199 + @discussion 请检查接口调用时传入的参数类型和值。(*自行处理)
  200 + */
  201 + CNLive_CONN_INVALID_PARAMETER = 33003,
  202 +
  203 + /*!
  204 + Connection已经存在
  205 +
  206 + @discussion
  207 + 调用过connect之后,建议在token错误或者被踢下线或者用户logout的情况下才需要再次调用connect。SDK会自动重连,不需要应用多次调用connect来保证连接性。(*自行处理)
  208 + */
  209 + CNLive_CONNECTION_EXIST = 34001,
  210 +
  211 + /*!
  212 + Connection正在连接
  213 +
  214 + @discussion
  215 + Connection正在连接,此时不能再次做connect操作,稍后再做操作(*自行处理)
  216 + */
  217 + CNLive_CONNECTION_CONNING = 34002,
  218 +
  219 + /*!
  220 + 开发者接口调用时传入的参数错误
  221 +
  222 + @discussion 请检查接口调用时传入的参数类型和值。(*自行处理)
  223 + */
  224 + CNLive_INVALID_ARGUMENT = -1000
  225 +};
  226 +
  227 +#pragma mark CNLiveChatErrorCode - 具体业务错误码
  228 +/*!
  229 + 具体业务错误码
  230 + */
  231 +typedef NS_ENUM(NSInteger, CNLiveChatErrorCode) {
  232 + /*!
  233 + 未知错误(预留)
  234 + */
  235 + CNLive_ERRORCODE_UNKNOWN = -1,
  236 +
  237 + /*!
  238 + token错误
  239 + */
  240 + CNLive_ERRORCODE_BY_TOKENERROR = 302,
  241 +
  242 + /*!
  243 + 鉴权失败 此AppId无权加入此targetId的聊天室
  244 + */
  245 + CNLive_ERRORCODE_BY_AUTHENTICATIONERROR = 303,
  246 +
  247 + /*!
  248 + 不合法的 targetId
  249 + */
  250 + CNLive_ERRORCODE_BY_TARGETIDERROR = 304,
  251 +
  252 + /*!
  253 + 不合法的 会话类型 type
  254 + */
  255 + CNLive_ERRORCODE_BY_CONVERSATIONTYPEERROR = 305,
  256 +
  257 + /*!
  258 + 已被对方加入黑名单
  259 + */
  260 + CNLive_REJECTED_BY_BLACKLIST = 405,
  261 +
  262 + /*!
  263 + 超时
  264 + */
  265 + CNLive_ERRORCODE_TIMEOUT = 5004,
  266 +
  267 + /*!
  268 + 发送消息频率过高,1秒钟最多只允许发送5条消息
  269 + */
  270 + CNLive_SEND_MSG_FREQUENCY_OVERRUN = 20604,
  271 +
  272 + /*!
  273 + 不在该聊天室中
  274 + */
  275 + CNLive_NOT_IN_CHATROOM = 23406,
  276 +
  277 + /*!
  278 + 在该聊天室中已被禁言
  279 + */
  280 + CNLive_FORBIDDEN_IN_CHATROOM = 23408,
  281 +
  282 + /*!
  283 + 已被踢出聊天室
  284 + */
  285 + CNLive_KICKED_FROM_CHATROOM = 23409,
  286 +
  287 + /*!
  288 + 聊天室不存在
  289 + */
  290 + CNLive_CHATROOM_NOT_EXIST = 23410,
  291 +
  292 + /*!
  293 + 聊天室成员超限
  294 + */
  295 + CNLive_CHATROOM_IS_FULL = 23411,
  296 +
  297 + /*!
  298 + 聊天室接口参数无效
  299 + */
  300 + CNLive_PARAMETER_INVALID_CHATROOM = 23412,
  301 +
  302 + /*!
  303 + 聊天室云存储业务未开通
  304 + */
  305 + CNLive_ROAMING_SERVICE_UNAVAILABLE_CHATROOM = 23414,
  306 +
  307 + /*!
  308 + 当前连接不可用(连接已经被释放)
  309 + */
  310 + CNLive_CHANNEL_INVALID = 30001,
  311 +
  312 + /*!
  313 + 当前连接不可用
  314 + */
  315 + CNLive_NETWORK_UNAVAILABLE = 30002,
  316 +
  317 + /*!
  318 + 消息响应超时
  319 + */
  320 + CNLive_MSG_RESPONSE_TIMEOUT = 30003,
  321 +
  322 + /*!
  323 + SDK没有初始化
  324 +
  325 + @discussion 在使用SDK任何功能之前,必须先Init。
  326 + */
  327 + CNLive_CLIENT_NOT_INIT = 33001,
  328 +
  329 + /*!
  330 + 数据库错误
  331 +
  332 + @discussion 请检查您使用的Token和userId是否正确。
  333 + */
  334 + CNLive_DATABASE_ERROR = 33002,
  335 +
  336 + /*!
  337 + 开发者接口调用时传入的参数错误
  338 +
  339 + @discussion 请检查接口调用时传入的参数类型和值。
  340 + */
  341 + CNLive_INVALID_PARAMETER = 33003,
  342 +
  343 + /*!
  344 + 历史消息云存储业务未开通
  345 + */
  346 + CNLive_MSG_ROAMING_SERVICE_UNAVAILABLE = 33007,
  347 +
  348 + /*!
  349 + 消息大小超限,消息体(序列化成json格式之后的内容)最大128k bytes。
  350 + */
  351 + CNLive_MSG_SIZE_OUT_OF_LIMIT = 30016
  352 +};
  353 +
  354 +#pragma mark - 会话相关
  355 +
  356 +#pragma mark CNLiveConversationType - 会话类型
  357 +/*!
  358 + 会话类型
  359 + */
  360 +typedef NS_ENUM(NSUInteger, CNLiveConversationType) {
  361 + /*!
  362 + 私聊
  363 + */
  364 + CNLive_ConversationType_PRIVATE = 1,
  365 +
  366 + /*!
  367 + 聊天室
  368 + */
  369 + CNLive_ConversationType_CHATROOM = 4,
  370 +};
  371 +
  372 +#pragma mark - 线上状态
  373 +
  374 +#pragma mark CNLiveConnectionStatus - 网络连接状态码
  375 +/*!
  376 + 网络连接状态码
  377 +
  378 + @discussion 开发者仅需要关注以下几种连接状态,其余状态SDK均会进行自动重连。
  379 + CNLive_ConnectionStatus_Connected, CNLive_ConnectionStatus_Connecting,
  380 + CNLive_ConnectionStatus_Unconnected,
  381 + CNLive_ConnectionStatus_SignUp, CNLive_ConnectionStatus_KICKED_OFFLINE_BY_OTHER_CLIENT,
  382 + CNLive_ConnectionStatus_TOKEN_INCORRECT
  383 + */
  384 +typedef NS_ENUM(NSInteger, CNLiveConnectionStatus) {
  385 + /*!
  386 + 未知状态
  387 +
  388 + @discussion 建立连接中出现异常的临时状态,SDK会做好自动重连,开发者无须处理。
  389 + */
  390 + CNLive_ConnectionStatus_UNKNOWN = -1,
  391 +
  392 + /*!
  393 + 连接成功
  394 + */
  395 + CNLive_ConnectionStatus_Connected = 0,
  396 +
  397 + /*!
  398 + 当前设备网络不可用
  399 +
  400 + @discussion 建立连接的临时状态,SDK会做好自动重连,开发者无须处理。
  401 + */
  402 + CNLive_ConnectionStatus_NETWORK_UNAVAILABLE = 1,
  403 +
  404 + /*!
  405 + 当前设备切换到飞行模式
  406 +
  407 + @discussion 建立连接的临时状态,SDK会做好自动重连,开发者无须处理。
  408 + */
  409 + CNLive_ConnectionStatus_AIRPLANE_MODE = 2,
  410 +
  411 + /*!
  412 + 当前设备切换到 2G(GPRS、EDGE)低速网络
  413 +
  414 + @discussion 建立连接的临时状态,SDK会做好自动重连,开发者无须处理。
  415 + */
  416 + CNLive_ConnectionStatus_Cellular_2G = 3,
  417 +
  418 + /*!
  419 + 当前设备切换到 3G 或 4G 高速网络
  420 +
  421 + @discussion 建立连接的临时状态,SDK会做好自动重连,开发者无须处理。
  422 + */
  423 + CNLive_ConnectionStatus_Cellular_3G_4G = 4,
  424 +
  425 + /*!
  426 + 当前设备切换到 WIFI 网络
  427 +
  428 + @discussion 建立连接的临时状态,SDK会做好自动重连,开发者无须处理。
  429 + */
  430 + CNLive_ConnectionStatus_WIFI = 5,
  431 +
  432 + /*!
  433 + 当前用户在其他设备上登录,此设备被踢下线
  434 + */
  435 + CNLive_ConnectionStatus_KICKED_OFFLINE_BY_OTHER_CLIENT = 6,
  436 +
  437 + /*!
  438 + 当前用户在 Web 端登录
  439 +
  440 + @discussion 建立连接的临时状态,SDK会做好自动重连,开发者无须处理。
  441 + */
  442 + CNLive_ConnectionStatus_LOGIN_ON_WEB = 7,
  443 +
  444 + /*!
  445 + 服务器异常
  446 +
  447 + @discussion 建立连接的临时状态,SDK会做好自动重连,开发者无须处理。
  448 + */
  449 + CNLive_ConnectionStatus_SERVER_INVALID = 8,
  450 +
  451 + /*!
  452 + 连接验证异常
  453 +
  454 + @discussion 建立连接的临时状态,SDK会做好自动重连,开发者无须处理。
  455 + */
  456 + CNLive_ConnectionStatus_VALIDATE_INVALID = 9,
  457 +
  458 + /*!
  459 + 连接中
  460 + */
  461 + CNLive_ConnectionStatus_Connecting = 10,
  462 +
  463 + /*!
  464 + 连接失败或未连接
  465 + */
  466 + CNLive_ConnectionStatus_Unconnected = 11,
  467 +
  468 + /*!
  469 + 已注销
  470 + */
  471 + CNLive_ConnectionStatus_SignUp = 12,
  472 +
  473 + /*!
  474 + Token无效
  475 +
  476 + @discussion
  477 + Token无效一般有两种原因。一是token错误,请您检查客户端初始化使用的AppKey和您服务器获取token使用的AppKey是否一致;二是token过期,是因为您在开发者后台设置了token过期时间,您需要请求您的服务器重新获取token并再次用新的token建立连接。
  478 + */
  479 + CNLive_ConnectionStatus_TOKEN_INCORRECT = 31004,
  480 +
  481 + /*!
  482 + 与服务器的连接已断开
  483 +
  484 + @discussion 建立连接的临时状态,SDK会做好自动重连,开发者无须处理。
  485 + */
  486 + CNLive_ConnectionStatus_DISCONN_EXCEPTION = 31011,
  487 +
  488 + /*!
  489 + 与服务器的连接已断开
  490 +
  491 + @discussion 无法自动重连,需手动重新连接服务器connectServerSuccess:error:。
  492 + */
  493 + CNLive_ConnectionStatus_DISCONN_MANUALCONN = 32011
  494 +};
  495 +
  496 +
... ...
LiveVideoCloud/LiveVideoCloud/Classes/CNLiveSDK/CNLiveChatManager.framework/Headers/CNLiveChatUserInfo.h 0 → 100644
  1 +//
  2 +// CNLiveChatUserInfo.h
  3 +// CNLiveChatManager
  4 +//
  5 +// Created by cnliveJunBo on 17/3/1.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +
  11 +@interface CNLiveChatUserInfo : NSObject
  12 +
  13 +/*!
  14 + 用户ID(一旦以一个用户ID连接到服务器,就不能再修改用户ID了,如果修改也会被忽略)
  15 + */
  16 +@property(nonatomic, strong, readonly) NSString *userId;
  17 +
  18 +/*!
  19 + 用户名称
  20 + */
  21 +@property(nonatomic, strong) NSString *name;
  22 +
  23 +/*!
  24 + 用户头像的URL
  25 + */
  26 +@property(nonatomic, strong) NSString *portraitUri;
  27 +
  28 +/*!
  29 + 用户信息的初始化方法,
  30 +
  31 + @param userId 用户ID
  32 + @param username 用户名称
  33 + @param portrait 用户头像的URL
  34 + @return 用户信息对象
  35 + */
  36 +- (instancetype)initWithUserId:(NSString *)userId
  37 + name:(NSString *)username
  38 + portrait:(NSString *)portrait;
  39 +
  40 +@end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/CNLiveSDK/CNLiveChatManager.framework/Info.plist 0 → 100644
No preview for this file type
LiveVideoCloud/LiveVideoCloud/Classes/CNLiveSDK/CNLiveChatManager.framework/Modules/module.modulemap 0 → 100644
  1 +framework module CNLiveChatManager {
  2 + umbrella header "CNLiveChatManager.h"
  3 +
  4 + export *
  5 + module * { export * }
  6 +}
... ...
LiveVideoCloud/LiveVideoCloud/Classes/CNLiveSDK/CNLiveMsgTools.framework/CNLiveMsgTools
No preview for this file type
LiveVideoCloud/LiveVideoCloud/Classes/CNLiveSDK/CNLiveMsgTools.framework/Headers/CNLiveMsgManager.h
... ... @@ -17,9 +17,8 @@
17 17 + (instancetype)sharedCNLiveMsgManager;
18 18  
19 19  
20   -- (void)setToolsInfoWithInfoId:(NSString *)infoId
21   - infoName:(NSString *)infoName
22   - infoUrl:(NSString *)infoUrl;
  20 +- (void)setToolsInfoWithInfoName:(NSString *)infoName
  21 + infoUrl:(NSString *)infoUrl;
23 22  
24 23  
25 24 - (NSDictionary *)getToolsInfo;
... ... @@ -72,8 +71,8 @@
72 71 - (void)sendCarrier:(NSString *)carrier
73 72 type:(NSInteger)type
74 73 targetId:(NSString *)targetId
75   - success:(void (^)(NSString *carrier, NSString *targetId, NSInteger type, NSString *infoId, NSString *infoName, NSString *infoUrl))successBlock
76   - error:(void (^)(NSInteger errors, NSString *targetId, NSInteger type))errorBlock;
  74 + success:(void (^)(NSString *carrier, NSString *messageId, NSString *targetId, NSInteger type, NSString *infoId, NSString *infoName, NSString *infoUrl, long long goTime, long long comeTime))successBlock
  75 + error:(void (^)(NSInteger errors, NSString *messageId, NSString *targetId))errorBlock;
77 76  
78 77  
79 78 - (NSInteger)getOnLineStatus;
... ...
LiveVideoCloud/LiveVideoCloud/Classes/CNLiveSDK/CNLiveMsgTools.framework/Info.plist
No preview for this file type
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/Controller/LVCUGCLivePlayerController.m
... ... @@ -7,9 +7,21 @@
7 7 //
8 8  
9 9 #import "LVCUGCLivePlayerController.h"
  10 +#import <CNLivePlayerSDK/CNLiveWebcastManager.h>
  11 +#import "LVCUGCPlayerLoadingView.h"
  12 +#import "LVCUGCBackgroundView.h"
  13 +
  14 +#define KAppId @"60_irn9edco29"
  15 +#define KAppKey @"69fe70bda67e059286ad509d9f5377f815955645b52f94"
10 16  
11 17 @interface LVCUGCLivePlayerController ()
12 18  
  19 +@property (nonatomic, strong) CNLiveMoviePlayerController *player;// 播放器
  20 +
  21 +@property (nonatomic, strong) LVCUGCBackgroundView *bgView; // 背景视图
  22 +
  23 +@property (nonatomic, strong) LVCUGCPlayerLoadingView *loadingView; // 加载视图
  24 +
13 25 @end
14 26  
15 27 @implementation LVCUGCLivePlayerController
... ... @@ -32,8 +44,218 @@
32 44 [super viewDidLoad];
33 45  
34 46 self.view.backgroundColor = [UIColor whiteColor];
  47 +
  48 + [self.view addSubview:self.loadingView];
  49 +
  50 + //添加播放器通知
  51 + [self installMovieNotificationObservers];
  52 +
  53 + [[CNLiveWebcastManager manager] initWithAppId:KAppId appKey:KAppKey];
  54 +
  55 + //直播播放
  56 + _player = [[CNLiveMoviePlayerController alloc] initLivePlayWithChannelId:@"iOStest"
  57 + authSuccess:^{
  58 +
  59 + _player.videoDecoderMode = CNLiveMovieVideoDecoderMode_AUTO;
  60 + _player.view.frame = self.view.bounds;
  61 + _player.shouldAutoplay = YES;
  62 + [_player prepareToPlay];
  63 + [self.view addSubview:_player.view];
  64 + [self.view sendSubviewToBack:_player.view];
  65 +
  66 + } authFailed:^(NSDictionary *errorInfo) {
  67 + NSLog(@"初始化直播播放器失败:%@", errorInfo);
  68 +
  69 +
  70 + } getAnchorStatusResult:^(BOOL result) {
  71 +
  72 + NSLog(@"-------------获取主播状态%d", result ? YES : NO);
  73 +
  74 + }];
  75 +}
  76 +
  77 +#pragma mark - 添加通知监听 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  78 +-(void)installMovieNotificationObservers //添加视频播放通知
  79 +{
  80 + //视频加载状态改变
  81 + [[NSNotificationCenter defaultCenter] addObserver:self
  82 + selector:@selector(loadStateDidChange:)
  83 + name:MPMoviePlayerLoadStateDidChangeNotification
  84 + object:nil];
  85 +
  86 + //视频播放错误及结束原因
  87 + [[NSNotificationCenter defaultCenter] addObserver:self
  88 + selector:@selector(moviePlayBackDidFinish:)
  89 + name:MPMoviePlayerPlaybackDidFinishNotification
  90 + object:nil];
  91 +
  92 + //视频缓冲至可播放状态
  93 + [[NSNotificationCenter defaultCenter] addObserver:self
  94 + selector:@selector(mediaIsPreparedToPlayDidChange:)
  95 + name:MPMediaPlaybackIsPreparedToPlayDidChangeNotification
  96 + object:nil];
  97 +
  98 + //视频播放状态改变
  99 + [[NSNotificationCenter defaultCenter] addObserver:self
  100 + selector:@selector(moviePlayBackStateDidChange:)
  101 + name:MPMoviePlayerPlaybackStateDidChangeNotification
  102 + object:nil];
  103 +
  104 +
  105 + //获取主播状态通知(点播和普通播放不需要注册该通知)
  106 + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(anchorStatusChanged:)
  107 + name:CNLiveAnchorStatusChangedNotification
  108 + object:nil];
  109 +
  110 +}
  111 +
  112 +#pragma mark - 移除通知
  113 +- (void)removeMovieNotificationObservers
  114 +{
  115 + [[NSNotificationCenter defaultCenter]removeObserver:self
  116 + name:MPMoviePlayerLoadStateDidChangeNotification
  117 + object:nil];
  118 + [[NSNotificationCenter defaultCenter]removeObserver:self
  119 + name:MPMoviePlayerPlaybackDidFinishNotification
  120 + object:nil];
  121 + [[NSNotificationCenter defaultCenter]removeObserver:self
  122 + name:MPMediaPlaybackIsPreparedToPlayDidChangeNotification
  123 + object:nil];
  124 + [[NSNotificationCenter defaultCenter]removeObserver:self
  125 + name:MPMoviePlayerPlaybackStateDidChangeNotification
  126 + object:nil];
  127 +
  128 + [[NSNotificationCenter defaultCenter]removeObserver:self
  129 + name:CNLiveAnchorStatusChangedNotification
  130 + object:nil];
  131 +}
  132 +
  133 +#pragma mark - 通知 Action !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  134 +//视频加载状态改变
  135 +- (void)loadStateDidChange:(NSNotification *)notification
  136 +{
  137 + if (_player) {
  138 + MPMovieLoadState loadState = _player.loadState;
  139 + if ((loadState & MPMovieLoadStatePlaythroughOK) != 0) {
  140 +
  141 + NSLog(@"loadStateDidChange: MPMovieLoadStatePlaythroughOK: %d\n", (int)loadState);
  142 +
  143 + } else if ((loadState & MPMovieLoadStateStalled) != 0) {
  144 + NSLog(@"loadStateDidChange: MPMovieLoadStateStalled: %d\n", (int)loadState);
  145 +
  146 + } else {
  147 + NSLog(@"loadStateDidChange: ???: %d\n", (int)loadState);
  148 + }
  149 + }
  150 +}
  151 +
  152 +//视频播放错误及结束原因
  153 +- (void)moviePlayBackDidFinish:(NSNotification *)notification
  154 +{
  155 + if (_player) {
  156 + int reason = [[[notification userInfo] valueForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey] intValue];
  157 + if (MPMovieFinishReasonPlaybackError == reason) {
  158 +
  159 +
  160 + } else {
  161 +
  162 + }
  163 +
  164 + switch (reason)
  165 + {
  166 + case MPMovieFinishReasonPlaybackEnded:
  167 + NSLog(@"playbackStateDidChange: MPMovieFinishReasonPlaybackEnded: %d\n", reason);
  168 + break;
  169 +
  170 + case MPMovieFinishReasonUserExited:
  171 + NSLog(@"playbackStateDidChange: MPMovieFinishReasonUserExited: %d\n", reason);
  172 + break;
  173 +
  174 + case MPMovieFinishReasonPlaybackError:
  175 + NSLog(@"playbackStateDidChange: MPMovieFinishReasonPlaybackError: %d\n", reason);
  176 + break;
  177 +
  178 + default:
  179 + NSLog(@"playbackPlayBackDidFinish: ???: %d\n", reason);
  180 + break;
  181 + }
  182 + }
  183 +}
  184 +
  185 +//视频缓冲至可播放状态
  186 +- (void)mediaIsPreparedToPlayDidChange:(NSNotification *)notification
  187 +{
  188 + if (_player) {
  189 + NSLog(@"isPreparedToPlay");
  190 + }
  191 +}
  192 +
  193 +//视频播放状态改变
  194 +- (void)moviePlayBackStateDidChange:(NSNotification *)notification
  195 +{
  196 + if (_player) {
  197 +
  198 + switch (_player.playbackState) {
  199 + case MPMoviePlaybackStateStopped: {
  200 +
  201 + NSLog(@"moviePlayBackStateDidChange : MPMoviePlaybackStateStopped");
  202 + break;
  203 + }
  204 + case MPMoviePlaybackStatePlaying: {
  205 +
  206 + NSLog(@"moviePlayBackStateDidChange : MPMoviePlaybackStatePlaying");
  207 + break;
  208 + }
  209 + case MPMoviePlaybackStatePaused:
  210 +
  211 + NSLog(@"moviePlayBackStateDidChange : MPMoviePlaybackStatePaused");
  212 + break;
  213 + case MPMoviePlaybackStateInterrupted:
  214 +
  215 + NSLog(@"moviePlayBackStateDidChange : MPMoviePlaybackStateInterrupted");
  216 + break;
  217 + case MPMoviePlaybackStateSeekingForward:
  218 +
  219 + NSLog(@"moviePlayBackStateDidChange : MPMoviePlaybackStateSeekingForward");
  220 + break;
  221 + case MPMoviePlaybackStateSeekingBackward:
  222 +
  223 + NSLog(@"moviePlayBackStateDidChange : MPMoviePlaybackStateSeekingBackward");
  224 + break;
  225 + default:
  226 +
  227 + NSLog(@"moviePlayBackStateDidChange : %ld", (long)_player.playbackState);
  228 + break;
  229 + }
  230 + }
  231 +}
  232 +
  233 +
  234 +
  235 +// 获取主播状态通知
  236 +- (void)anchorStatusChanged:(NSNotification *)notification
  237 +{
  238 + if (_player.anchorStatus == 2) {
  239 +
  240 + }
  241 + _bgView.anchorStatus = _player.anchorStatus;
  242 +}
  243 +
  244 +//重新连接获取主播状态
  245 +- (void)anchorStatusConnectFailed
  246 +{
  247 +
  248 +}
  249 +
  250 +#pragma mark - getter
  251 +- (LVCUGCPlayerLoadingView *)loadingView {
  252 + if (!_loadingView) {
  253 + _loadingView = [[LVCUGCPlayerLoadingView alloc] initWithFrame:self.view.bounds bgImageURLStr:@""];
  254 + }
  255 + return _loadingView;
35 256 }
36 257  
  258 +#pragma mark - 内存警告 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
37 259 - (void)didReceiveMemoryWarning {
38 260 [super didReceiveMemoryWarning];
39 261 // Dispose of any resources that can be recreated.
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/View/LVCUGCBackgroundView.h 0 → 100644
  1 +//
  2 +// LVCUGCBackgroundView.h
  3 +// LiveVideoCloud
  4 +//
  5 +// Created by cnliveJunBo on 17/3/20.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +@interface LVCUGCBackgroundView : UIView
  12 +
  13 +@property (nonatomic, assign) int anchorStatus; //设置主播状态
  14 +
  15 +@end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/View/LVCUGCBackgroundView.m 0 → 100644
  1 +//
  2 +// LVCUGCBackgroundView.m
  3 +// LiveVideoCloud
  4 +//
  5 +// Created by cnliveJunBo on 17/3/20.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "LVCUGCBackgroundView.h"
  10 +
  11 +@implementation LVCUGCBackgroundView
  12 +
  13 +/*
  14 +// Only override drawRect: if you perform custom drawing.
  15 +// An empty implementation adversely affects performance during animation.
  16 +- (void)drawRect:(CGRect)rect {
  17 + // Drawing code
  18 +}
  19 +*/
  20 +
  21 +@end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/View/LVCUGCPlayerLoadingView.h 0 → 100644
  1 +//
  2 +// LVCUGCPlayerLoadingView.h
  3 +// LiveVideoCloud
  4 +//
  5 +// Created by cnliveJunBo on 17/3/20.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +@interface LVCUGCPlayerLoadingView : UIView
  12 +
  13 +- (instancetype)initWithFrame:(CGRect)frame bgImageURLStr:(NSString *)bgImageURLStr;
  14 +
  15 +@end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/View/LVCUGCPlayerLoadingView.m 0 → 100644
  1 +//
  2 +// LVCUGCPlayerLoadingView.m
  3 +// LiveVideoCloud
  4 +//
  5 +// Created by cnliveJunBo on 17/3/20.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "LVCUGCPlayerLoadingView.h"
  10 +
  11 +@interface LVCUGCPlayerLoadingView() {
  12 +
  13 + NSString *_bgImageURLStr;
  14 +}
  15 +
  16 +@property (nonatomic, strong) UIImageView *bgImageView;
  17 +
  18 +@end
  19 +
  20 +@implementation LVCUGCPlayerLoadingView
  21 +
  22 +- (instancetype)initWithFrame:(CGRect)frame bgImageURLStr:(NSString *)bgImageURLStr
  23 +{
  24 + self = [super initWithFrame:frame];
  25 + if (self) {
  26 + _bgImageURLStr = bgImageURLStr;
  27 + [self addSubview:self.bgImageView];
  28 + }
  29 + return self;
  30 +}
  31 +
  32 +- (UIImageView *)bgImageView {
  33 + if (!_bgImageView) {
  34 +
  35 + // 1、创建输入图像,CIImage类型,这里使用一个网上图片。
  36 + CIImage *inputImage = [CIImage imageWithContentsOfURL:[NSURL URLWithString:@"http://echo-image.qiniucdn.com/FtPAdyCH-SlO-5xEe009AFE-N0EF?imageMogr2/auto-orient/quality/100%7CimageView2/4/w/640/q/100"]];
  37 +
  38 + // 2、构建一个滤镜图表
  39 + CIColor *sepiaColor = [CIColor colorWithRed:0.76 green:0.65 blue:0.54];
  40 + // 2.1 先构建一个 CIColorMonochrome 滤镜,并配置输入图像与滤镜参数
  41 + CIFilter *monochromeFilter = [CIFilter filterWithName:@"CIColorMonochrome" withInputParameters:@{@"inputColor" : sepiaColor,@"inputIntensity":@1.0}];
  42 + [monochromeFilter setValue:inputImage forKey:@"inputImage"];// 通过KVC来设置输入图像
  43 + // 2.2 先构建一个 CIVignette 滤镜
  44 + CIFilter *vignetteFilter = [CIFilter filterWithName:@"CIVignette" withInputParameters:@{@"inputRadius" : @2.0,@"inputIntensity" :@1.0}];
  45 + [vignetteFilter setValue:monochromeFilter.outputImage forKey:@"inputImage"];// 以monochromeFilter的输出来作为输入
  46 +
  47 + // 3、得到一个滤镜处理后的图片,并转换至 UIImage
  48 + // 创建一个 CIContext
  49 + CIContext *ciContext = [CIContext contextWithOptions:nil];
  50 + // 将 CIImage 过渡到 CGImageRef 类型
  51 + CGImageRef cgImage = [ciContext createCGImage:vignetteFilter.outputImage fromRect:inputImage.extent];
  52 + // 最后转换为 UIImage 类型
  53 + UIImage *uiImage = [UIImage imageWithCGImage:cgImage];
  54 +
  55 +// NSString *path = [[NSBundle mainBundle] pathForResource:@"UGCLoading" ofType:@"jpeg"];
  56 +// UIImage *image = [UIImage imageWithContentsOfFile:path];
  57 + _bgImageView = [[UIImageView alloc] initWithImage:uiImage];
  58 + _bgImageView.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
  59 + _bgImageView.backgroundColor = [UIColor whiteColor];
  60 + _bgImageView.contentMode = UIViewContentModeScaleAspectFill;
  61 + _bgImageView.clipsToBounds = YES;
  62 +// UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
  63 +// UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
  64 +// effectView.frame = _bgImageView.bounds;
  65 +// [_bgImageView addSubview:effectView];
  66 +// effectView.alpha = .8f;
  67 + }
  68 + return _bgImageView;
  69 +}
  70 +
  71 +@end
... ...
LiveVideoCloud/LiveVideoCloud/Resource/Images/UGCLoading.jpeg 0 → 100644

876 KB