Authored by 盖剑秋

直播通过密码获取房间详情。

... ... @@ -26,7 +26,6 @@
2E2E2D7C1D0E8BD90067D118 /* NSString+M16String.m in Sources */ = {isa = PBXBuildFile; fileRef = 2E2E2D7B1D0E8BD90067D118 /* NSString+M16String.m */; };
2E3F97D31D767A0800DCB96B /* YH_EndViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2E3F97D21D767A0800DCB96B /* YH_EndViewController.m */; };
2E487ACC1D66AA5D009DBB6D /* UIView+YOHO.m in Sources */ = {isa = PBXBuildFile; fileRef = 2E487ACB1D66AA5D009DBB6D /* UIView+YOHO.m */; };
2E487AD71D66AA94009DBB6D /* NSMutableArray+QueueAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 2E487ACE1D66AA94009DBB6D /* NSMutableArray+QueueAdditions.m */; };
2E487AD81D66AA94009DBB6D /* NSString+LIVE.m in Sources */ = {isa = PBXBuildFile; fileRef = 2E487AD01D66AA94009DBB6D /* NSString+LIVE.m */; };
2E487AD91D66AA94009DBB6D /* NSString+M16String.m in Sources */ = {isa = PBXBuildFile; fileRef = 2E487AD21D66AA94009DBB6D /* NSString+M16String.m */; };
2E487ADA1D66AA94009DBB6D /* UIColor+YOHO.m in Sources */ = {isa = PBXBuildFile; fileRef = 2E487AD41D66AA94009DBB6D /* UIColor+YOHO.m */; };
... ... @@ -1015,6 +1014,7 @@
TargetAttributes = {
EF14E52A1C884C71002F1BEF = {
CreatedOnToolsVersion = 7.2.1;
DevelopmentTeam = 6U82P566A4;
SystemCapabilities = {
com.apple.BackgroundModes = {
enabled = 1;
... ... @@ -1246,7 +1246,6 @@
2E487B0D1D66B05F009DBB6D /* YH_H5URLProtocol.m in Sources */,
2EB66FFB1D18EF2F00E91AAE /* MTLReflection.m in Sources */,
2EFAE0AA1D740EDD00D489BD /* YH_RoomSecretViewController.m in Sources */,
2E487AD71D66AA94009DBB6D /* NSMutableArray+QueueAdditions.m in Sources */,
2EB66FA71D18EEB100E91AAE /* YH_BarrageModel.m in Sources */,
2EB66FB71D18EEC700E91AAE /* YH_BarrageTableView.m in Sources */,
2E487AD81D66AA94009DBB6D /* NSString+LIVE.m in Sources */,
... ... @@ -1402,9 +1401,9 @@
"$(PROJECT_DIR)/YohoLive/yoho/Vendors/Zine",
"$(PROJECT_DIR)/YohoLive/yoho/Vendors/Zipzap",
);
PRODUCT_BUNDLE_IDENTIFIER = com.kennaki.live;
PRODUCT_BUNDLE_IDENTIFIER = cn.yoho.live.ent;
PRODUCT_NAME = YohoLive;
PROVISIONING_PROFILE = "";
PROVISIONING_PROFILE = "a054e3fc-ce5a-4cd0-a13b-21f70ebeab79";
USER_HEADER_SEARCH_PATHS = ./YohoLive/TXRTMPSDK.framework/Headers;
VALID_ARCHS = "arm64 armv7 armv7s i386";
};
... ... @@ -1553,9 +1552,9 @@
"$(PROJECT_DIR)/YohoLive/yoho/Vendors/Zine",
"$(PROJECT_DIR)/YohoLive/yoho/Vendors/Zipzap",
);
PRODUCT_BUNDLE_IDENTIFIER = com.kennaki.live;
PRODUCT_BUNDLE_IDENTIFIER = cn.yoho.live.ent;
PRODUCT_NAME = YohoLive;
PROVISIONING_PROFILE = "";
PROVISIONING_PROFILE = "a054e3fc-ce5a-4cd0-a13b-21f70ebeab79";
USER_HEADER_SEARCH_PATHS = ./YohoLive/TXRTMPSDK.framework/Headers;
VALID_ARCHS = "arm64 armv7 armv7s i386";
};
... ... @@ -1615,9 +1614,9 @@
"$(PROJECT_DIR)/YohoLive/yoho/Vendors/Zine",
"$(PROJECT_DIR)/YohoLive/yoho/Vendors/Zipzap",
);
PRODUCT_BUNDLE_IDENTIFIER = com.kennaki.live;
PRODUCT_BUNDLE_IDENTIFIER = cn.yoho.live.ent;
PRODUCT_NAME = YohoLive;
PROVISIONING_PROFILE = "";
PROVISIONING_PROFILE = "a054e3fc-ce5a-4cd0-a13b-21f70ebeab79";
USER_HEADER_SEARCH_PATHS = ./YohoLive/TXRTMPSDK.framework/Headers;
VALID_ARCHS = "arm64 armv7 armv7s i386";
};
... ...
... ... @@ -2,70 +2,4 @@
<Bucket
type = "0"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "YohoLive/Classes/YH_SocketService.m"
timestampString = "493980931.071469"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "342"
endingLineNumber = "342"
landmarkName = "-logout"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "YohoLive/Classes/YH_SocketService.m"
timestampString = "493980931.071469"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "347"
endingLineNumber = "347"
landmarkName = "-logout"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "YohoLive/Classes/YH_SocketService.m"
timestampString = "493980931.071469"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "350"
endingLineNumber = "350"
landmarkName = "-logout"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "YohoLive/Classes/YH_SocketService.m"
timestampString = "493980917.098365"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "200"
endingLineNumber = "200"
landmarkName = "-socket:didConnectToHost:port:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
... ...
... ... @@ -18,7 +18,7 @@
{
void (^completionBlock)(NSDictionary *dic, BOOL success);
UITextField *textField;
UIButton *startButton;
UIButton *endButton;
UILabel *secretLabel;
}
... ... @@ -64,14 +64,14 @@
secretLabel.textAlignment = NSTextAlignmentCenter;
[bg addSubview:secretLabel];
startButton = [UIButton buttonWithType:UIButtonTypeCustom];
startButton.frame = CGRectMake(15, CGRectGetMaxY(secretLabel.frame)+ 40, 250, 40);
startButton.titleLabel.font = [UIFont boldSystemFontOfSize:17];
[startButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
startButton.backgroundColor = [UIColor blackColor];
[bg addSubview:startButton];
[startButton addTarget:self action:@selector(startButtonPressed) forControlEvents:UIControlEventTouchUpInside];
[startButton setTitle:@"结束直播" forState:UIControlStateNormal];
endButton = [UIButton buttonWithType:UIButtonTypeCustom];
endButton.frame = CGRectMake(15, CGRectGetMaxY(secretLabel.frame)+ 40, 250, 40);
endButton.titleLabel.font = [UIFont boldSystemFontOfSize:17];
[endButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
endButton.backgroundColor = [UIColor blackColor];
[bg addSubview:endButton];
[endButton addTarget:self action:@selector(endButtonPressed) forControlEvents:UIControlEventTouchUpInside];
[endButton setTitle:@"结束直播" forState:UIControlStateNormal];
UIButton *closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
closeButton.frame = CGRectMake(280-18-8, 8, 18, 18);
... ... @@ -80,7 +80,7 @@
[closeButton addTarget:self action:@selector(closeButtonPressed) forControlEvents:UIControlEventTouchUpInside];
}
- (void)startButtonPressed {
- (void)endButtonPressed {
if (completionBlock) {
completionBlock(nil,YES);
}
... ...
... ... @@ -26,6 +26,8 @@
+ (instancetype)manager;
+ (instancetype)roomEngine;
+ (instancetype)validateAnchorEngine;
/**
... ...
... ... @@ -510,27 +510,34 @@ static NSString *const kIdentifier_live_three = @"threePicture";
return [[self alloc] init];
}
+ (instancetype)roomEngine {
YH_HttpEngine *manager = [YH_HttpEngine manager];
[manager setHttpURLString:@"http://api.live.yoho.cn/v1/room/getpushroom"];
return manager;
}
+ (instancetype)validateAnchorEngine {
YH_HttpEngine *manager = [YH_HttpEngine manager];
[manager setHttpURLString:@"http://testapi.live.yohops.com:9999/v1/room/validmaster"];
[manager setHttpURLString:@"http://api.live.yoho.cn/v1/room/validmaster"];
return manager;
}
+ (instancetype)pushStatusEngine {
YH_HttpEngine *manager = [YH_HttpEngine manager];
[manager setHttpURLString:@"http://testapi.live.yohops.com:9999/v1/room/setstat"];
[manager setHttpURLString:@"http://api.live.yoho.cn/v1/room/setstat"];
return manager;
}
+ (instancetype)roomListEngine {
YH_HttpEngine *manager = [YH_HttpEngine manager];
[manager setHttpURLString:@"http://testapi.live.yohops.com:9999/v1/room/getpushflow"];
[manager setHttpURLString:@"http://api.live.yoho.cn/v1/room/getpushflow"];
return manager;
}
+ (instancetype)socketAddrEngine {
YH_HttpEngine *manager = [YH_HttpEngine manager];
[manager setHttpURLString:@"http://testapi.live.yohops.com:9999/v1/system/gethosts"];
[manager setHttpURLString:@"http://api.live.yoho.cn/v1/system/gethosts"];
return manager;
}
... ...
... ... @@ -21,6 +21,8 @@ typedef NS_ENUM(NSInteger, PushStatus) {
@interface YH_NetworkAdapter (Live)
- (void)getRoomWithSecret:(NSString *)secret completion:(DictionaryBlock)finishBlock;
/**
* @author Kennaki Kai, 16-08-19 13:08:08
*
... ...
... ... @@ -11,6 +11,24 @@
@implementation YH_NetworkAdapter (Live)
- (void)getRoomWithSecret:(NSString *)secret completion:(DictionaryBlock)finishBlock {
NSDictionary *param = @{
@"secret":secret,
};
[[YH_HttpEngine roomEngine] get:param success:^(AFHTTPRequestOperation *operation, id responseObject) {
if ([responseObject[@"code"] integerValue] != 200) {
NSError *anError = [NSError errorWithDomain:@"live" code:[responseObject[@"code"] integerValue] userInfo:@{}];
BLOCK_EXEC(finishBlock, nil, anError);
}else{
BLOCK_EXEC(finishBlock, responseObject[@"data"],nil);
}
DLog(@"%@",responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
BLOCK_EXEC(finishBlock, nil,error);
DLog(@"%@",error);
}];
}
- (void)getPushListFinished:(DictionaryBlock)finishBlock {
[[YH_HttpEngine roomListEngine] get:@{} success:^(AFHTTPRequestOperation *operation, id responseObject) {
... ... @@ -29,7 +47,7 @@
- (void)setStatusWithStat:(PushStatus)status andRoomId:(NSString *)room completion:(BoolBlock)block {
NSDictionary *param = @{
@"room_id":room,
@"room_id":room?:@"",
@"living_stat":@(status),
};
[[YH_HttpEngine pushStatusEngine] get:param success:^(AFHTTPRequestOperation *operation, id responseObject) {
... ...
... ... @@ -7,6 +7,8 @@
//
#import "YH_RoomSecretViewController.h"
#import "YH_NetworkAdapter+Live.h"
#import "YH_Tool.h"
@interface YH_RoomSecretViewController()
... ... @@ -99,6 +101,18 @@
if (!textField.text.length) {
return;
}
[[YH_NetworkAdapter adapter] getRoomWithSecret:textField.text completion:^(NSMutableDictionary *infoDict, NSError *error) {
if (error) {
[YH_Tool alertMessage:@"密码无效,请重输"];
textField.text = @"";
} else {
if (completionBlock) {
completionBlock(infoDict, YES);
}
[self closeButtonPressed];
}
}];
}
- (void)viewDidAppear:(BOOL)animated {
... ...
... ... @@ -150,7 +150,7 @@
AFNetworkReachabilityManager *manager = [AFNetworkReachabilityManager sharedManager];
[manager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
if (status == AFNetworkReachabilityStatusNotReachable) {
[YH_Tool alert:@"网络已断开" type:YHBAlertTypeMessage autoHide:NO];
[YH_Tool alert:@"网络已断开" type:YHBAlertTypeMessage autoHide:YES];
} else {
[YH_Tool hideAlert];
}
... ... @@ -182,9 +182,10 @@
if (error) {
[self toastTip:[NSString stringWithFormat:@"开始失败,原因:%@",error.localizedDescription]];
[[NSUserDefaults standardUserDefaults] removeObjectForKey:kPushging];
_currentChannel = nil;
}else {
if ([self startRtmp]) {
[self toastTip:@"开始直播"];
[YH_Tool alertMessage:@"直播开始"];
_switchLock = NO;
_totalTime = _currentChannel.totalTime.integerValue;
_timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(updateInfoView) userInfo:nil repeats:YES];
... ... @@ -198,10 +199,10 @@
self.socketService.userName = @"";
[self.socketService connect];
_switchLock=NO;
} else {
[self toastTip:@"直播开始失败"];
[[NSUserDefaults standardUserDefaults] removeObjectForKey:kPushging];
_currentChannel = nil;
}
}
[_liveButton addTarget:self action:@selector(liveButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
... ... @@ -530,9 +531,11 @@
dispatch_async(dispatch_get_main_queue(), ^{
DLog(@"通知结束成功");
[self toastTip:@"通知结束成功"];
[YH_Tool alertMessage:@"直播结束"];
[sock disconnect];
_socket = nil;
[self loadChannelData];//防止主播再次进入同一间房间。
// [self loadChannelData];//防止主播再次进入同一间房间。
_inPushing = NO;
[_socketTimer invalidate];
_socketTimer = nil;
... ... @@ -541,7 +544,7 @@
_liveButton.selected = !_liveButton.selected;
[[YH_NetworkAdapter adapter] setStatusWithStat:PushStatusEnd andRoomId:_currentChannel.room completion:^(BOOL flag, NSError *error) {
_currentChannel = nil;
}];
[_socketService logout];
_socketService=nil;
... ... @@ -619,19 +622,58 @@
- (void)channelPressed:(UIButton *)sender {
if (!_channels.count) {
[self loadChannelData];
[self toastTip:@"暂无可用直播间,稍后再试!"];
return;
}
if (!_inPushing) {
[self loadChannelData];
[self toastTip:@"房间列表更新中!"];
if (_currentChannel) {
if (_totalTime<122) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"直播时间小于2分钟,不可以结束直播。" delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil, nil];
[alert show];
} else {
[YH_EndViewController showInController:self secret:_currentChannel.secret completionBlock:^(NSDictionary *dic, BOOL success) {
[_timer invalidate];
[self socketSendEndNotify];//通知结束。
}];
}
}else {
[YH_RoomSecretViewController showInController:self completionBlock:^(NSDictionary *dic, BOOL success) {
if (success) {
YH_ChannelModel *model = [YH_ChannelModel new];
model.roomTitle = dic[@"name"];
model.roomURL = dic[@"url"];
model.channel_id = dic[@"channel_id"];
model.cid = dic[@"cid"];
model.app = dic[@"app"];
model.type = dic[@"type"];
model.room = dic[@"id"];
model.title = dic[@"title"];
model.secret = dic[@"secret"];
_currentChannel = model;
[[YH_NetworkAdapter adapter] setStatusWithStat:PushStatusStart andRoomId:_currentChannel.room completion:^(BOOL flag, NSError *error) {
if (error) {
[YH_Tool alertMessage:[NSString stringWithFormat:@"开始失败,原因:%@",error.localizedDescription]];
}else {
if ([self startRtmp]) {
[YH_Tool alertMessage:@"开始直播"];
_totalTime = 0;
_timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(updateInfoView) userInfo:nil repeats:YES];
[_timer fire];
[self clearLog];
}else {
[self toastTip:@"直播开始失败"];
}
}
}];
}else {
[YH_Tool alertMessage:@"开始失败"];
}
}];
}
[self hideAllToolView];
_channelPannel.hidden = sender.selected;
sender.selected = !sender.selected;
}
- (void)fullScreenPressed:(UIButton *)sender {
... ... @@ -652,16 +694,12 @@
}
- (void)torchPressed:(UIButton *)sender {
[YH_EndViewController showInController:self secret:@"9527" completionBlock:^(NSDictionary *dic, BOOL success) {
}];
// if (_livePush.frontCamera) {//前置摄像头的AVcapturesession会与后置摄像头的闪光灯冲突,所以前置摄像头的情况下不允许开启闪光灯。
// [self toastTip:@"前置摄像头不存在闪光灯。"];
// return;
// }
// [_livePush toggleTorch:!sender.selected];
// sender.selected = !sender.selected;
if (_livePush.frontCamera) {//前置摄像头的AVcapturesession会与后置摄像头的闪光灯冲突,所以前置摄像头的情况下不允许开启闪光灯。
[self toastTip:@"前置摄像头不存在闪光灯。"];
return;
}
[_livePush toggleTorch:!sender.selected];
sender.selected = !sender.selected;
}
- (void)liveButtonPressed:(UIButton *)sender {
... ... @@ -700,7 +738,8 @@
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (alertView.tag == ContinueAlertTag && buttonIndex == 0) {
[self liveButtonPressed:_liveButton];
[self continueRTMP];
// [self liveButtonPressed:_liveButton];
} else if (alertView.tag == ValidateAlertTag && alertView.firstOtherButtonIndex == buttonIndex) {
UITextField *txtField = [alertView textFieldAtIndex:0];
if ([txtField.text isEqualToString:_currentChannel.secret]) {
... ... @@ -1236,7 +1275,7 @@
_channelButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_channelButton addTarget:self action:@selector(channelPressed:) forControlEvents:UIControlEventTouchUpInside];
[_channelButton setTitle:@"频道" forState:UIControlStateNormal];
[_channelButton setTitle:@"房间" forState:UIControlStateNormal];
[bottomToolView addSubview:_channelButton];
_beautyButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_beautyButton addTarget:self action:@selector(beautyPressed:) forControlEvents:UIControlEventTouchUpInside];
... ...