Skip to content

Commit

Permalink
ff_ffplay: add ijk version info
Browse files Browse the repository at this point in the history
Signed-off-by: Xinzheng Zhang <zhangxzheng@gmail.com>
  • Loading branch information
zhenghanchao authored and xinzhengzhang committed Sep 22, 2016
1 parent a3da39a commit 0d75e47
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ bin/
gen/
libs/
obj/
ijkmedia/ijkplayer/ijkversion.h

# Local configuration file (sdk path, etc)
local.properties
Expand Down
4 changes: 4 additions & 0 deletions ijkmedia/ijkplayer/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,8 @@ LOCAL_SHARED_LIBRARIES := ijkffmpeg ijksdl
LOCAL_STATIC_LIBRARIES := android-ndk-profiler

LOCAL_MODULE := ijkplayer

VERSION_SH = $(LOCAL_PATH)/version.sh
VERSION_H = ijkversion.h
$(info $(shell ($(VERSION_SH) $(LOCAL_PATH) $(VERSION_H))))
include $(BUILD_SHARED_LIBRARY)
8 changes: 8 additions & 0 deletions ijkmedia/ijkplayer/ff_ffplay.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
#include "ff_ffplay_debug.h"
#include "version.h"
#include "ijkmeta.h"
#include "ijkversion.h"

#ifndef AV_CODEC_FLAG2_FAST
#define AV_CODEC_FLAG2_FAST CODEC_FLAG2_FAST
Expand Down Expand Up @@ -3231,9 +3232,15 @@ const AVClass ffp_context_class = {
.child_class_next = ffp_context_child_class_next,
};

const char *ijk_version_info()
{
return IJKPLAYER_VERSION;
}

FFPlayer *ffp_create()
{
av_log(NULL, AV_LOG_INFO, "av_version_info: %s\n", av_version_info());
av_log(NULL, AV_LOG_INFO, "ijk_version_info: %s\n", ijk_version_info());

FFPlayer* ffp = (FFPlayer*) av_mallocz(sizeof(FFPlayer));
if (!ffp)
Expand Down Expand Up @@ -3455,6 +3462,7 @@ int ffp_prepare_async_l(FFPlayer *ffp, const char *file_name)
}

av_log(NULL, AV_LOG_INFO, "===== versions =====\n");
ffp_show_version_str(ffp, "ijkplayer", ijk_version_info());
ffp_show_version_str(ffp, "FFmpeg", av_version_info());
ffp_show_version_int(ffp, "libavutil", avutil_version());
ffp_show_version_int(ffp, "libavcodec", avcodec_version());
Expand Down
64 changes: 64 additions & 0 deletions ijkmedia/ijkplayer/version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/sh

# Usage: version.sh <ijplayer-root-dir> <output-version.h>

# check for git short hash

if ! test "$revision"; then
if (cd "$1" && grep git RELEASE 2> /dev/null >/dev/null) ; then
revision=$(cd "$1" && git describe --tags --match N 2> /dev/null)
else
revision=$(cd "$1" && git describe --tags --always 2> /dev/null)
fi
fi

# Shallow Git clones (--depth) do not have the N tag:
# use 'git-YYYY-MM-DD-hhhhhhh'.
test "$revision" || revision=$(cd "$1" &&
git log -1 --pretty=format:"git-%cd-%h" --date=short 2> /dev/null)

# Snapshots from gitweb are in a directory called ijkplayer-hhhhhhh or
# ijkplayer-HEAD-hhhhhhh.
if [ -z "$revision" ]; then
srcdir=$(cd "$1" && pwd)
case "$srcdir" in
*/ijkplayer-[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f])
git_hash="${srcdir##*-}";;
*/ijkplayer-HEAD-[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f])
git_hash="${srcdir##*-}";;
esac
fi

# no revision number found
test "$revision" || revision=$(cd "$1" && cat RELEASE 2> /dev/null)

# Append the Git hash if we have one
test "$revision" && test "$git_hash" && revision="$revision-$git_hash"

# releases extract the version number from the VERSION file
version=$(cd "$1" && cat VERSION 2> /dev/null)
test "$version" || version=$revision

if [ -z "$2" ]; then
echo "$version"
exit
fi

cd $1

NEW_REVISION="#define IJKPLAYER_VERSION \"$version\""
OLD_REVISION=$(cat "$2" 2> /dev/null | head -4 | tail -1)

# String used for preprocessor guard
GUARD=$(echo "$2" | sed 's/\//_/' | sed 's/\./_/' | tr '[:lower:]' '[:upper:]' | sed 's/LIB//')

# Update version header only on revision changes to avoid spurious rebuilds
if test "$NEW_REVISION" != "$OLD_REVISION"; then
cat << EOF > "$2"
/* Automatically generated by version.sh, do not manually edit! */
#ifndef $GUARD
#define $GUARD
$NEW_REVISION
#endif /* $GUARD */
EOF
fi
18 changes: 18 additions & 0 deletions ios/IJKMediaPlayer/IJKMediaPlayer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,7 @@
isa = PBXNativeTarget;
buildConfigurationList = E654EAA11B6B27E600B0F2D0 /* Build configuration list for PBXNativeTarget "IJKMediaFramework" */;
buildPhases = (
544E73271D93DEF4005CA5D9 /* ijkversion.h */,
E654EA851B6B27E600B0F2D0 /* Sources */,
E654EA861B6B27E600B0F2D0 /* Frameworks */,
E654EA871B6B27E600B0F2D0 /* Headers */,
Expand Down Expand Up @@ -828,6 +829,23 @@
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
544E73271D93DEF4005CA5D9 /* ijkversion.h */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = ijkversion.h;
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "sh \"${PROJECT_DIR}/../../ijkmedia/ijkplayer/version.sh\" \"${PROJECT_DIR}/../../ijkmedia/ijkplayer\" \"ijkversion.h\"";
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
E654EA851B6B27E600B0F2D0 /* Sources */ = {
isa = PBXSourcesBuildPhase;
Expand Down

0 comments on commit 0d75e47

Please sign in to comment.