Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objectVersion = 51;
objects = {

/* Begin PBXBuildFile section */
2B8A448B584670D41EC78EFE /* libPods-Group-Video.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CE872D1AFA3EB9FFF5CEC338 /* libPods-Group-Video.a */; };
AAF5A3BE28619F8B00EBCBB6 /* libiconv.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = AAF5A3BD28619F8B00EBCBB6 /* libiconv.tbd */; };
AAF5A3C028619F9200EBCBB6 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = AAF5A3BF28619F9200EBCBB6 /* libz.tbd */; };
AAF5A3C228619F9D00EBCBB6 /* libbz2.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = AAF5A3C128619F9D00EBCBB6 /* libbz2.tbd */; };
C3BD41DE224090AB006EAC1D /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = C3BD41DD224090AB006EAC1D /* AppDelegate.m */; };
C3BD41E1224090AB006EAC1D /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C3BD41E0224090AB006EAC1D /* ViewController.m */; };
C3BD41E4224090AB006EAC1D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C3BD41E2224090AB006EAC1D /* Main.storyboard */; };
Expand All @@ -20,6 +23,9 @@

/* Begin PBXFileReference section */
8FA14B1D56E6549125A95329 /* Pods-Group-Video.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Group-Video.release.xcconfig"; path = "Target Support Files/Pods-Group-Video/Pods-Group-Video.release.xcconfig"; sourceTree = "<group>"; };
AAF5A3BD28619F8B00EBCBB6 /* libiconv.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libiconv.tbd; path = usr/lib/libiconv.tbd; sourceTree = SDKROOT; };
AAF5A3BF28619F9200EBCBB6 /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; };
AAF5A3C128619F9D00EBCBB6 /* libbz2.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libbz2.tbd; path = usr/lib/libbz2.tbd; sourceTree = SDKROOT; };
C3BD41D9224090AB006EAC1D /* Group-Video.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Group-Video.app"; sourceTree = BUILT_PRODUCTS_DIR; };
C3BD41DC224090AB006EAC1D /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
C3BD41DD224090AB006EAC1D /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
Expand All @@ -43,6 +49,9 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
AAF5A3C228619F9D00EBCBB6 /* libbz2.tbd in Frameworks */,
AAF5A3C028619F9200EBCBB6 /* libz.tbd in Frameworks */,
AAF5A3BE28619F8B00EBCBB6 /* libiconv.tbd in Frameworks */,
2B8A448B584670D41EC78EFE /* libPods-Group-Video.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -100,6 +109,9 @@
F253F524D67D91D54AE36D00 /* Frameworks */ = {
isa = PBXGroup;
children = (
AAF5A3C128619F9D00EBCBB6 /* libbz2.tbd */,
AAF5A3BF28619F9200EBCBB6 /* libz.tbd */,
AAF5A3BD28619F8B00EBCBB6 /* libiconv.tbd */,
CE872D1AFA3EB9FFF5CEC338 /* libPods-Group-Video.a */,
);
name = Frameworks;
Expand Down
Binary file not shown.
18 changes: 9 additions & 9 deletions Group-Video/Group-Video-iOS/Group-Video/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>NSMicrophoneUsageDescription</key>
<string>请允许访问麦克风权限</string>
<key>NSCameraUsageDescription</key>
<string>请允许访问相机权限</string>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
Expand All @@ -29,6 +20,15 @@
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>NSCameraUsageDescription</key>
<string>请允许访问相机权限</string>
<key>NSMicrophoneUsageDescription</key>
<string>请允许访问麦克风权限</string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
Expand Down
65 changes: 34 additions & 31 deletions Group-Video/Group-Video-iOS/Group-Video/RoomViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@

#import "RoomViewController.h"
#import <QNRTCKit/QNRTCKit.h>

#warning 请到 Podifle 下,重新执行 pod install,确认 Pods/QNRTCKit-iOS/Pod/iphoneos 文件夹下,存在 FFmpeg.framework、QNRTCKit.framework 文件后可运行。

@interface RoomViewController ()
<
QNRTCClientDelegate,
QNMicrophoneAudioTrackDataDelegate,
QNCameraTrackVideoDataDelegate,
QNRemoteTrackVideoDataDelegate,
QNRemoteTrackAudioDataDelegate
QNLocalAudioTrackDelegate,
QNLocalVideoTrackDelegate,
QNRemoteVideoTrackDelegate,
QNRemoteAudioTrackDelegate
>
@property (nonatomic, assign) CGFloat screenWidth;
@property (nonatomic, assign) CGFloat screenHeight;
Expand All @@ -32,7 +35,7 @@ @interface RoomViewController ()
@property (nonatomic, strong) QNMicrophoneAudioTrack *audioTrack;
@property (nonatomic, strong) QNCameraVideoTrack *cameraTrack;

@property (nonatomic, strong) QNGLKView *preview;
@property (nonatomic, strong) QNVideoGLView *preview;
@property (nonatomic, strong) UIScrollView *scrollView;
@property (nonatomic, strong) NSMutableArray *viewsArray;
@end
Expand Down Expand Up @@ -72,37 +75,38 @@ - (void)viewDidLoad {
#pragma mark - settings

- (NSDictionary *)settingsArrayAtIndex:(NSInteger)index {
NSArray *settingsArray = @[@{@"VideoSize":NSStringFromCGSize(CGSizeMake(288, 352)), @"FrameRate":@15, @"Bitrate":@(300*1000)},
@{@"VideoSize":NSStringFromCGSize(CGSizeMake(480, 640)), @"FrameRate":@15, @"Bitrate":@(400*1000) },
@{@"VideoSize":NSStringFromCGSize(CGSizeMake(544, 960)), @"FrameRate":@15, @"Bitrate":@(700*1000)},
@{@"VideoSize":NSStringFromCGSize(CGSizeMake(720, 1280)), @"FrameRate":@20, @"Bitrate":@(1000*1000)}];
NSArray *settingsArray = @[@{@"VideoSize":NSStringFromCGSize(CGSizeMake(288, 352)), @"FrameRate":@15, @"Bitrate":@(300)},
@{@"VideoSize":NSStringFromCGSize(CGSizeMake(480, 640)), @"FrameRate":@15, @"Bitrate":@(400) },
@{@"VideoSize":NSStringFromCGSize(CGSizeMake(544, 960)), @"FrameRate":@15, @"Bitrate":@(700)},
@{@"VideoSize":NSStringFromCGSize(CGSizeMake(720, 1280)), @"FrameRate":@20, @"Bitrate":@(1000)}];
return settingsArray[index];
}

#pragma mark - QNRTCKit 核心类

- (void)configureRTCEngine {
// QNRTC 初始化
[QNRTC configRTC:[QNRTCConfiguration defaultConfiguration]];
[QNRTC initRTC:[QNRTCConfiguration defaultConfiguration]];

// QNRTCClient 初始化
self.rtcClient = [QNRTC createRTCClient];
self.rtcClient.delegate = self;

// 设置本地预览视图 显示在排列第一个
self.preview = [[QNGLKView alloc] init];
self.preview = [[QNVideoGLView alloc] init];
self.preview.frame = CGRectMake(0, 0, self.screenWidth/2, self.screenHeight/2);
[self.scrollView addSubview:self.preview];

// 视频
QNCameraVideoTrackConfig * cameraConfig = [[QNCameraVideoTrackConfig alloc] initWithSourceTag:@"camera" bitrate:self.kBitrate videoEncodeSize:self.videoEncodeSize];
QNVideoEncoderConfig *videoConfig = [[QNVideoEncoderConfig alloc] initWithBitrate:self.kBitrate videoEncodeSize:self.videoEncodeSize];
QNCameraVideoTrackConfig * cameraConfig = [[QNCameraVideoTrackConfig alloc] initWithSourceTag:@"camera" config:videoConfig];
self.cameraTrack = [QNRTC createCameraVideoTrackWithConfig:cameraConfig];
// 设置本地预览视图
[self.cameraTrack play:self.preview];

// 设置采集视频的帧率
self.cameraTrack.videoFrameRate = [self.settingsDic[@"FrameRate"] integerValue];
self.cameraTrack.videoDelegate = self;
self.cameraTrack.delegate = self;

// 加入房间
[self.rtcClient join:self.token];
Expand All @@ -114,7 +118,7 @@ - (void)configureRTCEngine {
房间内状态变化的回调
*/
- (void)RTCClient:(QNRTCClient *)client didConnectionStateChanged:(QNConnectionState)state disconnectedInfo:(QNConnectionDisconnectedInfo *)info {
NSDictionary *connectionStateDictionary = @{@(QNConnectionStateIdle) : @"Idle",
NSDictionary *connectionStateDictionary = @{@(QNConnectionStateDisconnected) : @"Disconnected",
@(QNConnectionStateConnecting) : @"Connecting",
@(QNConnectionStateConnected): @"Connected",
@(QNConnectionStateReconnecting) : @"Reconnecting",
Expand All @@ -127,7 +131,7 @@ - (void)RTCClient:(QNRTCClient *)client didConnectionStateChanged:(QNConnectionS
self.microphoneButton.selected = YES;
// 音频
self.audioTrack = [QNRTC createMicrophoneAudioTrack];
self.audioTrack.audioDelegate = self;
self.audioTrack.delegate = self;
// [self.audioTrack setVolume:0.5];

// 发布音视频
Expand All @@ -142,7 +146,7 @@ - (void)RTCClient:(QNRTCClient *)client didConnectionStateChanged:(QNConnectionS
NSLog(@"publish error: %@",error);
}
}];
} else if (QNConnectionStateIdle == state) {
} else if (QNConnectionStateDisconnected == state) {
self.videoButton.enabled = NO;
self.videoButton.selected = NO;
} else if (QNConnectionStateReconnecting == state) {
Expand Down Expand Up @@ -175,11 +179,11 @@ - (void)RTCClient:(QNRTCClient *)client didSubscribedRemoteVideoTracks:(NSArray<
NSLog(@"didSubscribedRemoteTracks - %d,%d userTd %@", audioTracks.count, videoTracks.count, userID);
dispatch_async(dispatch_get_main_queue(), ^{
for (QNRemoteAudioTrack * audioTrack in audioTracks) {
audioTrack.audioDelegate = self;
audioTrack.delegate = self;
}
for (QNRemoteVideoTrack * videoTrack in videoTracks) {
[videoTrack play:[self remoteUserView:userID]];
videoTrack.videoDelegate = self;
videoTrack.delegate = self;
}
});

Expand Down Expand Up @@ -217,25 +221,24 @@ - (void)RTCClient:(QNRTCClient *)client didReconnectedOfUserID:(NSString *)userI
NSLog(@"didReconnectedOfUserID - %@",userID);
}


#pragma mark - QNRemoteTrackVideoDataDelegate
#pragma mark - QNRemoteVideoTrackDelegate
- (void)remoteVideoTrack:(QNRemoteVideoTrack *)remoteVideoTrack didGetPixelBuffer:(CVPixelBufferRef)pixelBuffer {
NSLog(@"remoteVideoTrack: %@ tag: %@ didGetPixelBuffer",remoteVideoTrack.trackID,remoteVideoTrack.tag);
}

#pragma mark - QNRemoteTrackAudioDataDelegate
#pragma mark - QNRemoteAudioTrackDelegate
- (void)remoteAudioTrack:(QNRemoteAudioTrack *)remoteAudioTrack didGetAudioBuffer:(AudioBuffer *)audioBuffer bitsPerSample:(NSUInteger)bitsPerSample sampleRate:(NSUInteger)sampleRate {
NSLog(@"remoteAudioTrack: %@ tag: %@ didGetAudioBuffer",remoteAudioTrack.trackID,remoteAudioTrack.tag);
}

#pragma mark - QNCameraTrackVideoDataDelegate
- (void)cameraVideoTrack:(QNCameraVideoTrack *)cameraVideoTrack didGetPixelBuffer:(CVPixelBufferRef)pixelBuffer {
#pragma mark - QNLocalVideoTrackDelegate
- (void)localVideoTrack:(QNLocalVideoTrack *)localVideoTrack didGetPixelBuffer:(CVPixelBufferRef)pixelBuffer {
// NSLog(@"cameraVideoTrack: %@ tag: %@ didGetPixelBuffer",cameraVideoTrack.trackID,track.tag);

}

#pragma mark - QNMicrophoneAudioTrackDataDelegate
- (void)microphoneAudioTrack:(QNMicrophoneAudioTrack *)microphoneAudioTrack didGetAudioBuffer:(AudioBuffer *)audioBuffer bitsPerSample:(NSUInteger)bitsPerSample sampleRate:(NSUInteger)sampleRate {
#pragma mark - QNLocalAudioTrackDelegate
- (void)localAudioTrack:(QNLocalAudioTrack *)localAudioTrack didGetAudioBuffer:(AudioBuffer *)audioBuffer bitsPerSample:(NSUInteger)bitsPerSample sampleRate:(NSUInteger)sampleRate {
// NSLog(@"microphoneAudioTrack: %@ tag: %@ didGetAudioBuffer",track.trackID,track.tag);
}

Expand All @@ -253,9 +256,9 @@ - (void)layoutScrollView {
#pragma mark - 远端用户画面
#warning 考虑多个远端排列显示

- (QNVideoView *)remoteUserView:(NSString *)userId {
- (QNVideoGLView *)remoteUserView:(NSString *)userId {
NSInteger count = self.viewsArray.count + 1;
QNVideoView *remoteView = [[QNVideoView alloc] initWithFrame:CGRectMake(self.screenWidth/2 * (count%2), self.screenWidth/2 * (count/2), self.screenWidth/2, self.screenWidth/2)];
QNVideoGLView *remoteView = [[QNVideoGLView alloc] initWithFrame:CGRectMake(self.screenWidth/2 * (count%2), self.screenWidth/2 * (count/2), self.screenWidth/2, self.screenWidth/2)];
[self.scrollView addSubview:remoteView];

UILabel *nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, self.screenWidth/4 - 30, self.screenWidth/2, 60)];
Expand All @@ -281,7 +284,7 @@ - (QNVideoView *)remoteUserView:(NSString *)userId {
- (void)removeRemoteRenderView:(NSString *)userId {
NSInteger index = -1;
for (NSInteger i = 0; i < self.viewsArray.count; i++) {
QNVideoView *remoteView = self.viewsArray[i];
QNVideoGLView *remoteView = self.viewsArray[i];
UILabel *label = remoteView.subviews.lastObject;
if ([label.text isEqualToString:userId]) {
[remoteView removeFromSuperview];
Expand All @@ -292,7 +295,7 @@ - (void)removeRemoteRenderView:(NSString *)userId {

// 剔除离开的远端用户画面后,重新调整布局
for (NSInteger i = 0; i < self.viewsArray.count; i++) {
QNVideoView *remoteView = self.viewsArray[i];
QNVideoGLView *remoteView = self.viewsArray[i];
NSInteger count = i + 1;
remoteView.frame = CGRectMake(self.screenWidth/2 * (count%2), self.screenWidth/2 * (count/2), self.screenWidth/2, self.screenWidth/2);
}
Expand All @@ -319,12 +322,12 @@ - (void)closePublishAndBack:(UIButton *)button {

- (void)videoButtonAction:(UIButton *)button {
button.selected = !button.isSelected;
[self.cameraTrack updataMute:!button.isSelected];
[self.cameraTrack updateMute:!button.isSelected];
}

- (void)microphoneButtonAction:(UIButton *)button {
button.selected = !button.isSelected;
[self.audioTrack updataMute:!button.isSelected];
[self.audioTrack updateMute:!button.isSelected];
}

- (void)cameraButtonAction:(UIButton *)button {
Expand Down
2 changes: 1 addition & 1 deletion Group-Video/Group-Video-iOS/Group-Video/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ - (void)layoutView {
// 版本 label
UILabel *versionLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, screenHeight - 130, screenWidth - 80, 60)];
NSArray *infoArray = [[QNRTC versionInfo] componentsSeparatedByString:@"-"];
versionLabel.text = [NSString stringWithFormat:@"版本:v%@\n\n更新时间:%@-%@-%@", infoArray[0], infoArray[1], infoArray[2], infoArray[3]];
versionLabel.text = [NSString stringWithFormat:@"版本:v%@\n\n更新 id:%@", infoArray[0], infoArray[1]];
versionLabel.textColor = [UIColor colorWithRed:155/255.0 green:155/255.0 blue:155/255.0 alpha:1.0];
versionLabel.font = [UIFont fontWithName:@"HelveticaNeue-Light" size:13.0];
versionLabel.textAlignment = NSTextAlignmentRight;
Expand Down
2 changes: 1 addition & 1 deletion Group-Video/Group-Video-iOS/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ target 'Group-Video' do

# Pods for Group-Video

pod 'QNRTCKit-iOS'
pod 'QNRTCKit-iOS', '= 5.0.0'

end
12 changes: 6 additions & 6 deletions Group-Video/Group-Video-iOS/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
PODS:
- QNRTCKit-iOS (4.0.4):
- QNRTCKit-iOS/Core (= 4.0.4)
- QNRTCKit-iOS/Core (4.0.4)
- QNRTCKit-iOS (5.0.0):
- QNRTCKit-iOS/Core (= 5.0.0)
- QNRTCKit-iOS/Core (5.0.0)

DEPENDENCIES:
- QNRTCKit-iOS
- QNRTCKit-iOS (= 5.0.0)

SPEC REPOS:
trunk:
- QNRTCKit-iOS

SPEC CHECKSUMS:
QNRTCKit-iOS: 96d5a8cb090d026059ab860aa8341eeaac88ac10
QNRTCKit-iOS: 02b624c22c604127414152424beae31c1139830c

PODFILE CHECKSUM: 5559821512f68ab61852a15e056ce1df8d3735cf
PODFILE CHECKSUM: e259bd583f92b27a6f12c29756ff08a09d466040

COCOAPODS: 1.11.3
12 changes: 6 additions & 6 deletions Group-Video/Group-Video-iOS/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading