提交 d2cefae1 编写于 作者: Z Zhang Rui

ios/player: compare ijkplayer version

上级 a9ff2d6c
......@@ -21,8 +21,8 @@
*/
#include "ijkplayer.h"
#include "ijkplayer_internal.h"
#include "version.h"
#define MP_RET_IF_FAILED(ret) \
do { \
......@@ -81,6 +81,16 @@ void ijkmp_global_set_log_level(int log_level)
ffp_global_set_log_level(log_level);
}
const char *ijkmp_version_ident()
{
return LIBIJKPLAYER_IDENT;
}
unsigned int ijkmp_version_int()
{
return LIBIJKPLAYER_VERSION_INT;
}
void ijkmp_io_stat_register(void (*cb)(const char *url, int type, int bytes))
{
ffp_io_stat_register(cb);
......
......@@ -153,6 +153,8 @@ void ijkmp_global_init();
void ijkmp_global_uninit();
void ijkmp_global_set_log_report(int use_report);
void ijkmp_global_set_log_level(int log_level); // log_level = AV_LOG_xxx
const char *ijkmp_version_ident();
unsigned int ijkmp_version_int();
void ijkmp_io_stat_register(void (*cb)(const char *url, int type, int bytes));
void ijkmp_io_stat_complete_register(void (*cb)(const char *url,
int64_t read_bytes, int64_t total_size,
......
/*
* Copyright (c) 2015 Zhang Rui <bbcallen@gmail.com>
*
* This file is part of ijkPlayer.
*
* ijkPlayer is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* ijkPlayer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with ijkPlayer; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef FFPLAY__VERSION_H
#define FFPLAY__VERSION_H
#include "libavutil/version.h"
#define LIBIJKPLAYER_VERSION_MAJOR 1
#define LIBIJKPLAYER_VERSION_MINOR 0
#define LIBIJKPLAYER_VERSION_MICRO 0
#define LIBIJKPLAYER_VERSION_INT AV_VERSION_INT(LIBIJKPLAYER_VERSION_MAJOR, \
LIBIJKPLAYER_VERSION_MINOR, \
LIBIJKPLAYER_VERSION_MICRO)
#define LIBIJKPLAYER_VERSION AV_VERSION(LIBIJKPLAYER_VERSION_MAJOR, \
LIBIJKPLAYER_VERSION_MINOR, \
LIBIJKPLAYER_VERSION_MICRO)
#define LIBIJKPLAYER_BUILD LIBIJKPLAYER_VERSION_INT
#define LIBIJKPLAYER_IDENT "ijkplayer " AV_STRINGIFY(LIBIJKPLAYER_VERSION)
#define IJKVERSION_GET_MAJOR(x) ((x >> 16) & 0xFF)
#define IJKVERSION_GET_MINOR(x) ((x >> 8) & 0xFF)
#define IJKVERSION_GET_MICRO(x) ((x ) & 0xFF)
#endif//FFPLAY__VERSION_H
......@@ -52,6 +52,7 @@
return self;
}
#define EXPECTED_IJKPLAYER_VERSION (1 << 16) & 0xFF) |
- (void)viewDidLoad
{
[super viewDidLoad];
......@@ -69,6 +70,7 @@
#endif
[IJKFFMoviePlayerController checkIfFFmpegVersionMatch:YES];
// [IJKFFMoviePlayerController checkIfPlayerVersionMatch:YES major:1 minor:0 micro:0];
self.player = [[IJKFFMoviePlayerController alloc] initWithContentURL:self.url withOptions:nil];
self.player.view.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
......
......@@ -193,6 +193,7 @@
E654EADD1B6B291A00B0F2D0 /* libavutil.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libavutil.a; path = "../../../FFmpeg-ios-bin/lib/libavutil.a"; sourceTree = "<group>"; };
E654EADE1B6B291A00B0F2D0 /* libswresample.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libswresample.a; path = "../../../FFmpeg-ios-bin/lib/libswresample.a"; sourceTree = "<group>"; };
E654EADF1B6B291A00B0F2D0 /* libswscale.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libswscale.a; path = "../../../FFmpeg-ios-bin/lib/libswscale.a"; sourceTree = "<group>"; };
E654EAFB1B6B503A00B0F2D0 /* version.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = version.h; sourceTree = "<group>"; };
E65DC3B719D93D5F004F8A08 /* IJKKVOController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IJKKVOController.h; path = IJKMediaPlayer/IJKKVOController.h; sourceTree = "<group>"; };
E65DC3B819D93D5F004F8A08 /* IJKKVOController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = IJKKVOController.m; path = IJKMediaPlayer/IJKKVOController.m; sourceTree = "<group>"; };
E66F8DBF17EEC65200354D80 /* IJKMPMoviePlayerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IJKMPMoviePlayerController.h; path = IJKMediaPlayer/IJKMPMoviePlayerController.h; sourceTree = "<group>"; };
......@@ -575,6 +576,7 @@
E66F8DF017EFEA9400354D80 /* ijkplayer.h */,
E66F8DF817EFEC1300354D80 /* ios */,
E67B91B11A3801E600717EA9 /* pipeline */,
E654EAFB1B6B503A00B0F2D0 /* version.h */,
);
path = ijkplayer;
sourceTree = "<group>";
......
......@@ -92,6 +92,10 @@ typedef enum IJKLogLevel {
+ (void)setLogReport:(BOOL)preferLogReport;
+ (void)setLogLevel:(IJKLogLevel)logLevel;
+ (BOOL)checkIfFFmpegVersionMatch:(BOOL)showAlert;
+ (BOOL)checkIfPlayerVersionMatch:(BOOL)showAlert
major:(unsigned int)major
minor:(unsigned int)minor
micro:(unsigned int)micro;
@property(nonatomic, readonly) CGFloat fpsInMeta;
@property(nonatomic, readonly) CGFloat fpsAtOutput;
......
......@@ -30,8 +30,9 @@
#import "IJKAudioKit.h"
#include "string.h"
#include "ijkplayer/version.h"
NSString *const kIJKFFRequiredFFmpegVersion = @"n2.7-24-g58b28fc";
static const char *kIJKFFRequiredFFmpegVersion = "n2.7-24-g58b28fc";
@interface IJKFFMoviePlayerController()
......@@ -367,13 +368,13 @@ inline static int getPlayerOption(IJKFFOptionCategory category)
+ (BOOL)checkIfFFmpegVersionMatch:(BOOL)showAlert;
{
NSString *actualVersion = [NSString stringWithUTF8String:av_version_info()];
NSString *expectVersion = kIJKFFRequiredFFmpegVersion;
if ([actualVersion isEqualToString:expectVersion]) {
const char *actualVersion = av_version_info();
const char *expectVersion = kIJKFFRequiredFFmpegVersion;
if (0 == strcmp(actualVersion, expectVersion)) {
return YES;
} else {
if (showAlert) {
NSString *message = [NSString stringWithFormat:@"actual: %@\n expect: %@\n", actualVersion, expectVersion];
NSString *message = [NSString stringWithFormat:@"actual: %s\n expect: %s\n", actualVersion, expectVersion];
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Unexpected FFmpeg version"
message:message
delegate:nil
......@@ -385,6 +386,29 @@ inline static int getPlayerOption(IJKFFOptionCategory category)
}
}
+ (BOOL)checkIfPlayerVersionMatch:(BOOL)showAlert
major:(unsigned int)major
minor:(unsigned int)minor
micro:(unsigned int)micro
{
unsigned int actualVersion = ijkmp_version_int();
if (actualVersion == AV_VERSION_INT(major, minor, micro)) {
return YES;
} else {
if (showAlert) {
NSString *message = [NSString stringWithFormat:@"actual: %s\n expect: %d.%d.%d\n",
ijkmp_version_ident(), major, minor, micro];
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Unexpected ijkplayer version"
message:message
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
}
return NO;
}
}
- (void)shutdown
{
if (!_mediaPlayer)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册