Skip to content

Commit

Permalink
refactor(las): simplify the ios end code
Browse files Browse the repository at this point in the history
  • Loading branch information
yangdan07 committed Sep 9, 2020
1 parent d5c3da5 commit 1d29db8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 31 deletions.
5 changes: 1 addition & 4 deletions ijkmedia/ijkplayer/ijkavformat/allformats.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@
#include "libavformat/avformat.h"
#include "libavformat/url.h"
#include "libavformat/version.h"
#include "ijklas.h"

#define IJK_REGISTER_DEMUXER(x) \
{ \
av_log(NULL, AV_LOG_INFO, "===== regiseter =====\n"); \
extern AVInputFormat ijkff_##x##_demuxer; \
ijkav_register_input_format(&ijkff_##x##_demuxer); \
}

#define IJK_REGISTER_PROTOCOL(x) \
{ \
extern URLProtocol ijkimp_ff_##x##_protocol; \
Expand Down Expand Up @@ -88,6 +86,5 @@ void ijkav_register_all(void)
IJK_REGISTER_PROTOCOL(ijksegment);
/* demuxers */
IJK_REGISTER_DEMUXER(ijklivehook);
IJK_REGISTER_DEMUXER(las);
av_log(NULL, AV_LOG_INFO, "===== custom modules end =====\n");
}
32 changes: 7 additions & 25 deletions ios/IJKMediaDemo/IJKMediaDemo/IJKDemoSampleViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,6 @@ @interface IJKDemoSampleViewController () <UITableViewDataSource, UITableViewDel

@implementation IJKDemoSampleViewController

NSDictionary *_nameAddrMap;
NSDictionary *_nameHostMap;

typedef NS_ENUM(NSInteger, KwaiplayerInputType) {
KwaiplayerInputType_Default = 0,
KwaiplayerInputType_AVPlayer, //普通单url
KwaiplayerInputType_AVPlayer_Manifest, //私有json
};


- (void)viewDidLoad {
[super viewDidLoad];

Expand All @@ -47,8 +37,7 @@ - (void)viewDidLoad {
NSMutableArray *sampleList = [[NSMutableArray alloc] init];

[sampleList addObject:@[@"las url",
@"{\"version\":\"1.0.0\",\"adaptationSet\":[{\"duration\":1000,\"id\":1,\"representation\":[{\"id\":1,\"codec\":\"avc1.64001e,mp4a.40.5\",\"url\":\"http://las-tech.org.cn/kwai/las-test_ld500d.flv\",\"backupUrl\":[],\"host\":\"las-tech.org.cn\",\"maxBitrate\":700,\"width\":640,\"height\":360,\"frameRate\":25,\"qualityType\":\"SMOOTH\",\"qualityTypeName\":\"流畅\",\"hidden\":false,\"disabledFromAdaptive\":false,\"defaultSelected\":false},{\"id\":2,\"codec\":\"avc1.64001f,mp4a.40.5\",\"url\":\"http://las-tech.org.cn/kwai/las-test_sd1000d.flv\",\"backupUrl\":[],\"host\":\"las-tech.org.cn\",\"maxBitrate\":1300,\"width\":960,\"height\":540,\"frameRate\":25,\"qualityType\":\"STANDARD\",\"qualityTypeName\":\"标清\",\"hidden\":false,\"disabledFromAdaptive\":false,\"defaultSelected\":false},{\"id\":3,\"codec\":\"avc1.64001f,mp4a.40.5\",\"url\":\"http://las-tech.org.cn/kwai/las-test.flv\",\"backupUrl\":[],\"host\":\"las-tech.org.cn\",\"maxBitrate\":2300,\"width\":1280,\"height\":720,\"frameRate\":30,\"qualityType\":\"HIGH\",\"qualityTypeName\":\"高清\",\"hidden\":false,\"disabledFromAdaptive\":false,\"defaultSelected\":true}]}]}"]];

@"{\"version\":\"1.0.0\",\"adaptationSet\":[{\"duration\":1000,\"id\":1,\"representation\":[{\"id\":1,\"codec\":\"avc1.64001e,mp4a.40.5\",\"url\":\"http://las-tech.org.cn/kwai/las-test_ld500d.flv\",\"backupUrl\":[],\"host\":\"las-tech.org.cn\",\"maxBitrate\":700,\"width\":640,\"height\":360,\"frameRate\":25,\"qualityType\":\"SMOOTH\",\"qualityTypeName\":\"流畅\",\"hidden\":false,\"disabledFromAdaptive\":false,\"defaultSelected\":false},{\"id\":2,\"codec\":\"avc1.64001f,mp4a.40.5\",\"url\":\"http://las-tech.org.cn/kwai/las-test_sd1000d.flv\",\"backupUrl\":[],\"host\":\"las-tech.org.cn\",\"maxBitrate\":1300,\"width\":960,\"height\":540,\"frameRate\":25,\"qualityType\":\"STANDARD\",\"qualityTypeName\":\"标清\",\"hidden\":false,\"disabledFromAdaptive\":false,\"defaultSelected\":false},{\"id\":3,\"codec\":\"avc1.64001f,mp4a.40.5\",\"url\":\"http://las-tech.org.cn/kwai/las-test.flv\",\"backupUrl\":[],\"host\":\"las-tech.org.cn\",\"maxBitrate\":2300,\"width\":1280,\"height\":720,\"frameRate\":30,\"qualityType\":\"HIGH\",\"qualityTypeName\":\"高清\",\"hidden\":false,\"disabledFromAdaptive\":false,\"defaultSelected\":true}]}]}"]];
[sampleList addObject:@[@"bipbop basic master playlist",
@"http://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/bipbop_4x3_variant.m3u8"]];
[sampleList addObject:@[@"bipbop basic 400x300 @ 232 kbps",
Expand All @@ -74,7 +63,9 @@ - (void)viewDidLoad {
@"http://devimages.apple.com.edgekey.net/streaming/examples/bipbop_16x9/gear4/prog_index.m3u8"]];
[sampleList addObject:@[@"bipbop advanced 1920x1080 @ 2 Mbps",
@"http://devimages.apple.com.edgekey.net/streaming/examples/bipbop_16x9/gear5/prog_index.m3u8"]];

[sampleList addObject:@[@"bipbop advanced 22.050Hz stereo @ 40 kbps",
@"http://devimages.apple.com.edgekey.net/streaming/examples/bipbop_16x9/gear0/prog_index.m3u8"]];

self.sampleList = sampleList;
}

Expand Down Expand Up @@ -117,24 +108,15 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath

NSArray *item = self.sampleList[indexPath.row];
NSString *url_str = item[1];
NSString *host = [_nameHostMap objectForKey:url_str];
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];

if (host != nil) {
[dict setObject:host forKey:@"Host"];
}

if ([url_str containsString:@"adaptationSet"]) {
NSString *mainfest_url = @"http://100.100.100.100/manifest";
NSURL *url = [NSURL URLWithString:mainfest_url];
[dict setObject:url_str forKey:@"manifest_string"];
[self.navigationController presentViewController:[[IJKVideoViewController alloc] initWithURL:url headers:dict] animated:YES completion:^{}];
NSString *fake_url = @"http://100.100.100.100/manifest";
NSURL *url = [NSURL URLWithString:fake_url];
[self.navigationController presentViewController:[[IJKVideoViewController alloc] initWithURL:url manifest_string:url_str] animated:YES completion:^{}];
} else{
NSURL *url = [NSURL URLWithString:item[1]];
[self.navigationController presentViewController:[[IJKVideoViewController alloc] initWithURL:url] animated:YES completion:^{}];
}


}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
@property(strong,nonatomic) NSString* manifest;
@property(atomic, retain) id<IJKMediaPlayback> player;

- (id)initWithURL:(NSURL *)url headers:(NSDictionary*) headers;
- (id)initWithURL:(NSURL *)url manifest_string:(NSString*)manifest_string;
- (id)initWithURL:(NSURL *)url;

+ (void)presentFromViewController:(UIViewController *)viewController withTitle:(NSString *)title URL:(NSURL *)url completion:(void(^)())completion;
Expand Down
6 changes: 5 additions & 1 deletion ios/IJKMediaDemo/IJKMediaDemo/IJKMoviePlayerViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,15 @@ + (void)presentFromViewController:(UIViewController *)viewController withTitle:(

[viewController presentViewController:[[IJKVideoViewController alloc] initWithURL:url] animated:YES completion:completion];
}
- (instancetype)initWithURL:(NSURL *)url headers:(NSDictionary*)headers {

- (instancetype)initWithURL:(NSURL *)url manifest_string:(NSString*)manifest_string {
self = [self initWithNibName:@"IJKMoviePlayerViewController" bundle:nil];
if (self) {
self.url = url;
}
NSMutableDictionary *headers = [[NSMutableDictionary alloc] init];
[headers setObject:manifest_string forKey:@"manifest_string"];

self.headers = headers;
return self;
}
Expand Down

0 comments on commit 1d29db8

Please sign in to comment.