Skip to content

Commit

Permalink
V73-1
Browse files Browse the repository at this point in the history
  • Loading branch information
cpluser09 committed Jul 24, 2018
1 parent 9ffb0c1 commit 7a8b429
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 56 deletions.
Binary file modified ios/lib/libqcPlayEng.a
Binary file not shown.
20 changes: 11 additions & 9 deletions ios/sample/TestCode.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
A01B66F01F20FBAD0058D8D8 /* libssl.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libssl.a; path = ../../../../bin/ios/libssl.a; sourceTree = "<group>"; };
A01B66F11F20FBAD0058D8D8 /* libswresample.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libswresample.a; path = ../../../../bin/ios/libswresample.a; sourceTree = "<group>"; };
A01B670F1F2110100058D8D8 /* libspeex.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libspeex.a; path = ../../../../bin/ios/libspeex.a; sourceTree = "<group>"; };
A020A46920D3AAFC00B27E4F /* qcErr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = qcErr.h; path = ../../../../include/qcErr.h; sourceTree = "<group>"; };
A060DC8B1F972DA700E2F792 /* CoreTelephony.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreTelephony.framework; path = System/Library/Frameworks/CoreTelephony.framework; sourceTree = SDKROOT; };
A0914134205A491100D0F2E6 /* libyuv.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libyuv.a; path = ../../../../bin/ios/libyuv.a; sourceTree = "<group>"; };
A09DCC981E91F0CB00DC855E /* export.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = export.plist; sourceTree = "<group>"; };
Expand All @@ -86,28 +87,28 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
A0914135205A491100D0F2E6 /* libyuv.a in Frameworks */,
A060DC8C1F972DA700E2F792 /* CoreTelephony.framework in Frameworks */,
A01503701E72488500B6093E /* libiconv.tbd in Frameworks */,
A01B67101F2110100058D8D8 /* libspeex.a in Frameworks */,
A015036E1E72482300B6093E /* libz.tbd in Frameworks */,
A060DC8C1F972DA700E2F792 /* CoreTelephony.framework in Frameworks */,
2741A0B81E55A9ED009F87FA /* VideoToolbox.framework in Frameworks */,
A01B66F31F20FBAD0058D8D8 /* libavformat.a in Frameworks */,
A01B66F51F20FBAD0058D8D8 /* libcrypto.a in Frameworks */,
27CCC17D1E3A3ADE00AEDA22 /* CoreVideo.framework in Frameworks */,
27CCC17B1E3A3AA100AEDA22 /* OpenGLES.framework in Frameworks */,
A01B66F41F20FBAD0058D8D8 /* libavutil.a in Frameworks */,
A01B66F21F20FBAD0058D8D8 /* libavcodec.a in Frameworks */,
27648E351E37A34F005C1A20 /* Foundation.framework in Frameworks */,
27648E331E37A336005C1A20 /* AVKit.framework in Frameworks */,
27648E291E3723EB005C1A20 /* QuartzCore.framework in Frameworks */,
27648E271E371F86005C1A20 /* MediaPlayer.framework in Frameworks */,
27648E251E371F7C005C1A20 /* CoreMedia.framework in Frameworks */,
27648E231E37184A005C1A20 /* AVFoundation.framework in Frameworks */,
A01B66F81F20FBAD0058D8D8 /* libswresample.a in Frameworks */,
27C98B291E3515DF0018DFA1 /* AudioToolbox.framework in Frameworks */,
A01B66F71F20FBAD0058D8D8 /* libssl.a in Frameworks */,
27C98B221E35008C0018DFA1 /* libqcPlayEng.a in Frameworks */,
A0914135205A491100D0F2E6 /* libyuv.a in Frameworks */,
A01B67101F2110100058D8D8 /* libspeex.a in Frameworks */,
A01B66F71F20FBAD0058D8D8 /* libssl.a in Frameworks */,
A01B66F51F20FBAD0058D8D8 /* libcrypto.a in Frameworks */,
A01B66F21F20FBAD0058D8D8 /* libavcodec.a in Frameworks */,
A01B66F81F20FBAD0058D8D8 /* libswresample.a in Frameworks */,
A01B66F41F20FBAD0058D8D8 /* libavutil.a in Frameworks */,
A01B66F31F20FBAD0058D8D8 /* libavformat.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -200,6 +201,7 @@
A0DBD2681E6E60C200EBF5B8 /* inc */ = {
isa = PBXGroup;
children = (
A020A46920D3AAFC00B27E4F /* qcErr.h */,
A0DBD2671E6E60B600EBF5B8 /* qcPlayer.h */,
A0DBD2661E6E60B600EBF5B8 /* qcMsg.h */,
);
Expand Down
136 changes: 89 additions & 47 deletions ios/sample/TestCode/ViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ @interface ViewController () <UITableViewDataSource, UITableViewDelegate>
QC_VIDEO_FORMAT _fmtVideo;
long long _lastPlaybackPos;
BOOL _playbackFromLastPos;
BOOL _useHW;
}
@end

Expand All @@ -65,10 +66,16 @@ -(void)prepareURL
_currURL = 0;
_clipboardURL = nil;

[_urlList addObject:@"http://nclive.grtn.cn/zjpd/playlist.m3u8?_upt=6eac0a671527759000&token=c739022aba5e40029ebbc71047bb9510"];
[_urlList addObject:@"-------------------------------------------------------------------------------"];
[_urlList addObject:@"MP4"];
[_urlList addObject:@"http://op053v693.bkt.clouddn.com/IMG_3376.MP4"];
[_urlList addObject:@"http://demo-videos.qnsdk.com/movies/qiniu.mp4"];
[_urlList addObject:@"http://op053v693.bkt.clouddn.com/qiniu_960x540.mp4"];
[_urlList addObject:@"http://op053v693.bkt.clouddn.com/qiniu_480x270.mp4"];
[_urlList addObject:@"ROTATE"];
[_urlList addObject:@"http://static.zhibojie.tv/1502826524711_1_record.mp4"];
[_urlList addObject:@"HLS"];
[_urlList addObject:@"http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"];
[_urlList addObject:@"HKS"];
[_urlList addObject:@"rtmp://live.hkstv.hk.lxdns.com/live/hks"];
[_urlList addObject:@"http://fms.cntv.lxdns.com/live/flv/channel84.flv"];
Expand All @@ -78,8 +85,6 @@ -(void)prepareURL
[_urlList addObject:@"HD Live"];
[_urlList addObject:@"http://stream1.hnntv.cn/lywsgq/sd/live.m3u8"];
[_urlList addObject:@"http://skydvn-nowtv-atv-prod.skydvn.com/atv/skynews/1404/live/07.m3u8"];
[_urlList addObject:@"HLS"];
[_urlList addObject:@"http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"];
[_urlList addObject:@""];

NSString* docPathDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
Expand All @@ -104,7 +109,6 @@ -(void)prepareURL
//[self parseDemoLive];
}


#pragma mark Player event callback
void NotifyEvent (void * pUserData, int nID, void * pValue1)
{
Expand Down Expand Up @@ -143,6 +147,8 @@ - (void)onPlayerEvent:(int)nID withParam:(void*)pParam
NSLog(@"Open use time %d. %d", [self getSysTime]-_openStartTime, [self getSysTime]);
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
[self showMessage:@"Open fail" duration:2.0];
[_switchCache setHidden:NO];
[_labelCache setHidden:NO];
[self loopPlayback];
}];
}
Expand All @@ -161,8 +167,7 @@ - (void)onPlayerEvent:(int)nID withParam:(void*)pParam
[[NSOperationQueue mainQueue] addOperationWithBlock:^{

if(![self loopPlayback])
//[self onStop: _btnStart];
_player.Run(_player.hPlayer);
[self onStop: _btnStart];
}];
}
else if (nID == QC_MSG_PLAY_SEEK_DONE)
Expand All @@ -187,7 +192,11 @@ - (void)onPlayerEvent:(int)nID withParam:(void*)pParam
}
else if(nID == QC_MSG_RTMP_CONNECT_START || nID == QC_MSG_HTTP_CONNECT_START)
{
NSLog(@"[EVT]Connect start, %x", nID);
NSLog(@"[EVT]Connect start, %x\n", nID);
}
else if (nID == QC_MSG_HTTP_CONNECT_SUCESS || nID == QC_MSG_RTMP_CONNECT_SUCESS)
{
NSLog(@"[EVT]Connect success, %x\n", nID);
}
else if (nID == QC_MSG_HTTP_RECONNECT_SUCESS || nID == QC_MSG_RTMP_RECONNECT_SUCESS)
{
Expand All @@ -198,10 +207,6 @@ - (void)onPlayerEvent:(int)nID withParam:(void*)pParam
[self showMessage:@"Reconnect success" duration:5.0];
}];
}
else if (nID == QC_MSG_HTTP_CONNECT_SUCESS || nID == QC_MSG_RTMP_CONNECT_SUCESS)
{
NSLog(@"[EVT]Connect success, %x\n", nID);
}
else if(nID == QC_MSG_SNKV_FIRST_FRAME)
{
NSLog(@"[EVT]First video frame rendered\n");
Expand Down Expand Up @@ -322,6 +327,12 @@ -(void) createPlayer
return;

qcCreatePlayer(&_player, NULL);

#if 0
int log = 5;
_player.SetParam(_player.hPlayer, QCPLAY_PID_Log_Level, (void*)&log);
#endif

_player.SetNotify(_player.hPlayer, NotifyEvent, (__bridge void*)self);

#if 0
Expand All @@ -345,11 +356,6 @@ -(void) createPlayer
#if 0
_player.SetParam(_player.hPlayer, QCPLAY_PID_DNS_DETECT, (void*)"live.hkstv.hk.lxdns.com");
#endif

#if 0
int log = 5;
_player.SetParam(_player.hPlayer, QCPLAY_PID_Log_Level, (void*)&log);
#endif

#if 0
int preLoadTime = 8000*10000;
Expand All @@ -366,6 +372,17 @@ -(void) createPlayer
char* key = (char*)"dH8jqShxWCJNpwlx";
_player.SetParam(_player.hPlayer, QCPLAY_PID_DRM_KeyText, (void*)key);
#endif

#if 0
char* url = (char*)"http://op053v693.bkt.clouddn.com/IMG_3376.MP4";
_player.SetParam(_player.hPlayer, QCPLAY_PID_ADD_Cache, (void*)url);
url = (char*)"http://demo-videos.qnsdk.com/movies/qiniu.mp4";
_player.SetParam(_player.hPlayer, QCPLAY_PID_ADD_Cache, (void*)url);
url = (char*)"http://op053v693.bkt.clouddn.com/qiniu_960x540.mp4";
_player.SetParam(_player.hPlayer, QCPLAY_PID_ADD_Cache, (void*)url);
url = (char*)"http://op053v693.bkt.clouddn.com/qiniu_480x270.mp4";
_player.SetParam(_player.hPlayer, QCPLAY_PID_ADD_Cache, (void*)url);
#endif
}


Expand Down Expand Up @@ -611,6 +628,7 @@ - (void)viewDidLoad
[super viewDidLoad];

//
_useHW = NO;
_lastPlaybackPos = -1;
_playbackFromLastPos = YES;
_loopPlayback = NO;
Expand Down Expand Up @@ -647,6 +665,9 @@ -(IBAction)onStart:(id)sender
}
else
{
if(_waitView)
[_waitView stopAnimating];

[btn setTitle:@"PAUSE" forState:UIControlStateNormal];
_timer = [NSTimer scheduledTimerWithTimeInterval:100.0/100.0 target:self selector:@selector(onTimer:) userInfo:nil repeats:YES];

Expand All @@ -656,8 +677,7 @@ -(IBAction)onStart:(id)sender
url = [_clipboardURL UTF8String];

// update options
if(_switchCache.on)
[self enableFileCacheMode];
[self updateFileCacheMode];
int loop = _switchLoop.on?1:0;
_player.SetParam(_player.hPlayer, QCPLAY_PID_Playback_Loop, &loop);

Expand All @@ -667,11 +687,9 @@ -(IBAction)onStart:(id)sender
_openStartTime = [self getSysTime];
_firstFrameTime = -1;
NSLog(@"Open start time %d. %d", _openStartTime, [self getSysTime]);
#if 1
_player.Open(_player.hPlayer, url, 0);
#else
_player.Open(_player.hPlayer, url, QCPLAY_OPEN_VIDDEC_HW);
#endif

_player.Open(_player.hPlayer, url, _useHW?QCPLAY_OPEN_VIDDEC_HW:0);

if(_clipboardURL)
{
_clipboardURL = nil;
Expand All @@ -691,6 +709,9 @@ -(IBAction)onStop:(id)sender
int useTime = [self getSysTime];
NSLog(@"+Stop[KPI]");

if(_waitView)
[_waitView stopAnimating];

[((UIButton*)sender) setTitle:@"START" forState:UIControlStateNormal];

[_timer invalidate];
Expand Down Expand Up @@ -731,7 +752,6 @@ - (IBAction)onTimer:(id)sender
{
if(!_player.hPlayer)
return;

long long pos = _player.GetPos(_player.hPlayer) / 1000;
long long dur = _player.GetDur(_player.hPlayer) / 1000;
static long long lastPos = 0;
Expand All @@ -750,7 +770,7 @@ - (IBAction)onTimer:(id)sender
NSString* strPos = [NSString stringWithFormat:@"%02lld:%02lld:%02lld", pos / 3600, pos % 3600 / 60, pos % 3600 % 60];
NSString* strDur = [NSString stringWithFormat:@"%02lld:%02lld:%02lld", dur / 3600, dur % 3600 / 60, dur % 3600 % 60];

_labelPlayingTime.text = [NSString stringWithFormat: @"%d - %dx%d - %@%@%@", _firstFrameTime, _fmtVideo.nWidth, _fmtVideo.nHeight, strPos, @" / " , strDur];
_labelPlayingTime.text = [NSString stringWithFormat: @"%s - %d - %dx%d - %@%@%@", _useHW?"HW":"SW", _firstFrameTime, _fmtVideo.nWidth, _fmtVideo.nHeight, strPos, @" / " , strDur];
}

-(void)onAppActive:(BOOL)active
Expand Down Expand Up @@ -796,30 +816,40 @@ -(IBAction)onFullScreen:(id)sender
if(!_isFullScreen)
{
_isFullScreen = YES;
//[[UIDevice currentDevice]setValue:[NSNumber numberWithInteger:UIDeviceOrientationPortrait] forKey:@"orientation"];
[[UIDevice currentDevice]setValue:[NSNumber numberWithInteger:UIDeviceOrientationLandscapeLeft] forKey:@"orientation"];
if([self isLandscape])
{
[[UIDevice currentDevice]setValue:[NSNumber numberWithInteger:UIDeviceOrientationLandscapeLeft] forKey:@"orientation"];
}
else
{
}
}
else
{
_isFullScreen = NO;
//[[UIDevice currentDevice]setValue:[NSNumber numberWithInteger:UIDeviceOrientationLandscapeLeft] forKey:@"orientation"];
[[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationPortrait] forKey:@"orientation"];

if([self isLandscape])
[[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationPortrait] forKey:@"orientation"];
else
{

}
}

[_tableViewURL setHidden:_isFullScreen?YES:NO];

// [UIView animateWithDuration:1.0 animations:^{

if(_player.hPlayer)
if(_player.hPlayer)
{
if([self isLandscape])
_viewVideo.frame = _isFullScreen?_rectFullScreen:_rectSmallScreen;
else
{
_viewVideo.frame = _isFullScreen?_rectFullScreen:_rectSmallScreen;
CGRect r = _viewVideo.bounds;
RECT drawRect = {(int)r.origin.x, (int)r.origin.y, (int)r.size.width, (int)r.size.height};
_player.SetView(_player.hPlayer, (__bridge void*)_viewVideo, &drawRect);
_viewVideo.frame = _isFullScreen?self.view.bounds:_rectSmallScreen;
}

// } completion:^(BOOL finished) {
// }];
CGRect r = _viewVideo.bounds;
RECT drawRect = {(int)r.origin.x, (int)r.origin.y, (int)r.size.width, (int)r.size.height};
_player.SetView(_player.hPlayer, (__bridge void*)_viewVideo, &drawRect);
}
}

-(IBAction)onSelectStreamEnd:(id)sender
Expand Down Expand Up @@ -1140,8 +1170,7 @@ -(BOOL)fastOpen:(const char*)newURL
{
NSLog(@"+Fast open, %s", newURL);
int flag = 0;//_switchHW.on?QCPLAY_OPEN_VIDDEC_HW:0;
if(_switchCache.on)
[self enableFileCacheMode];
[self updateFileCacheMode];
_openStartTime = [self getSysTime];
NSLog(@"Open start time %d. %d", _openStartTime, [self getSysTime]);
[self enablePlaybackFromPosition];
Expand All @@ -1155,13 +1184,21 @@ -(BOOL)fastOpen:(const char*)newURL
return NO;
}

-(void)enableFileCacheMode
-(void)updateFileCacheMode
{
NSString* docPathDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
docPathDir = [docPathDir stringByAppendingString:@"/cache/"];
_player.SetParam(_player.hPlayer, QCPLAY_PID_PD_Save_Path, (void*)[docPathDir UTF8String]);
int nProtocol = QC_IOPROTOCOL_HTTPPD;
_player.SetParam(_player.hPlayer, QCPLAY_PID_Prefer_Protocol, &nProtocol);
if(_switchCache.on)
{
NSString* docPathDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
docPathDir = [docPathDir stringByAppendingString:@"/cache/"];
_player.SetParam(_player.hPlayer, QCPLAY_PID_PD_Save_Path, (void*)[docPathDir UTF8String]);
int nProtocol = QC_IOPROTOCOL_HTTPPD;
_player.SetParam(_player.hPlayer, QCPLAY_PID_Prefer_Protocol, &nProtocol);
}
else
{
int nProtocol = QC_IOPROTOCOL_NONE;
_player.SetParam(_player.hPlayer, QCPLAY_PID_Prefer_Protocol, &nProtocol);
}
}

-(bool)loopPlayback
Expand Down Expand Up @@ -1230,6 +1267,11 @@ - (void)enablePlaybackFromPosition
#endif
}

- (BOOL)isLandscape
{
return _fmtVideo.nWidth >= _fmtVideo.nHeight;
}



-(NSString*)getVersion
Expand Down

0 comments on commit 7a8b429

Please sign in to comment.