1
0
mirror of https://git.FreeBSD.org/ports.git synced 2025-01-20 08:27:15 +00:00

Add omxplayer, a command line media player originally developed for the RPi

PR:		204392
Submitted by:	mikael.urankar@gmail.com (maintainer)
This commit is contained in:
Thomas Zander 2015-12-06 07:19:40 +00:00
parent 0a3561889b
commit c542dfb08c
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=403092
10 changed files with 254 additions and 0 deletions

View File

@ -267,6 +267,7 @@
SUBDIR += oggvideotools
SUBDIR += ogmrip
SUBDIR += ogmtools
SUBDIR += omxplayer
SUBDIR += opencinematools
SUBDIR += openh264
SUBDIR += openquicktime

View File

@ -0,0 +1,54 @@
# Created by: mikael.urankar@gmail.com
# $FreeBSD$
PORTNAME= omxplayer
PORTVERSION= 20151109
CATEGORIES= multimedia
MAINTAINER= mikael.urankar@gmail.com
COMMENT= Raspberry Pi video player
LICENSE= GPLv2
LIB_DEPENDS= libboost_thread.so:${PORTSDIR}/devel/boost-libs \
libdbus-1.so:${PORTSDIR}/devel/dbus \
libpcre.so:${PORTSDIR}/devel/pcre \
libEGL.so:${PORTSDIR}/misc/raspberrypi-userland \
libavcodec.so:${PORTSDIR}/multimedia/ffmpeg \
libfreetype.so:${PORTSDIR}/print/freetype2
RUN_DEPENDS= bash:${PORTSDIR}/shells/bash \
${LOCALBASE}/share/fonts/freefont-ttf/FreeSans.ttf:${PORTSDIR}/x11-fonts/freefont-ttf
ONLY_FOR_ARCHS= armv6
CFLAGS+= -Dfopen64=fopen -Dfseeko64=fseeko -Dftello64=ftello
ALL_TARGET= omxplayer.bin
USE_GITHUB= yes
GH_ACCOUNT= popcornmix
GH_TAGNAME= 6f073c9
USES= gmake shebangfix
USE_GCC= yes
SHEBANG_FILES= omxplayer
PLIST_FILES= bin/omxplayer bin/omxplayer.bin
PORTDOCS= README.md
OPTIONS_DEFINE= DOCS
post-patch:
@${REINPLACE_CMD} -e \
's|LOCALBASE|${LOCALBASE}|g' ${WRKSRC}/omxplayer.cpp
do-install:
${INSTALL_PROGRAM} ${WRKSRC}/omxplayer.bin ${STAGEDIR}${PREFIX}/bin
${INSTALL_SCRIPT} ${WRKSRC}/omxplayer ${STAGEDIR}${PREFIX}/bin
do-install-DOCS-on:
@${MKDIR} ${STAGEDIR}${DOCSDIR}
.for i in ${PORTDOCS}
${INSTALL_DATA} -p ${WRKSRC}/${i} ${STAGEDIR}${DOCSDIR}
.endfor
.include <bsd.port.mk>

View File

@ -0,0 +1,2 @@
SHA256 (popcornmix-omxplayer-20151109-6f073c9_GH0.tar.gz) = a88723f7f854386b53fb601b4f57cbad33a702556de83122661cc6cd5d877ff2
SIZE (popcornmix-omxplayer-20151109-6f073c9_GH0.tar.gz) = 1203829

View File

@ -0,0 +1,64 @@
--- Keyboard.cpp.orig 2015-10-24 12:09:14 UTC
+++ Keyboard.cpp
@@ -23,7 +23,6 @@ Keyboard::Keyboard()
new_termios = orig_termios;
new_termios.c_lflag &= ~(ICANON | ECHO | ECHOCTL | ECHONL);
new_termios.c_cflag |= HUPCL;
- new_termios.c_cc[VMIN] = 0;
tcsetattr(STDIN_FILENO, TCSANOW, &new_termios);
}
@@ -74,13 +73,20 @@ void Keyboard::restore_term()
}
}
-void Keyboard::Sleep(unsigned int dwMilliSeconds)
+int Keyboard::Hit()
{
- struct timespec req;
- req.tv_sec = dwMilliSeconds / 1000;
- req.tv_nsec = (dwMilliSeconds % 1000) * 1000000;
+ struct timeval timeo;
+ fd_set fds;
- while ( nanosleep(&req, &req) == -1 && errno == EINTR && (req.tv_nsec > 0 || req.tv_sec > 0));
+ timeo.tv_sec = 0;
+ timeo.tv_usec = 200000;
+
+ FD_ZERO(&fds);
+ FD_SET(STDIN_FILENO, &fds);
+
+ select(FD_SETSIZE, &fds, NULL, NULL, &timeo);
+
+ return FD_ISSET(STDIN_FILENO, &fds);
}
void Keyboard::Process()
@@ -90,9 +96,16 @@ void Keyboard::Process()
if (conn)
dbus_connection_read_write_dispatch(conn, 0);
int ch[8];
- int chnum = 0;
+ int chnum, nb;
- while ((ch[chnum] = getchar()) != EOF) chnum++;
+ if (Hit() == 0)
+ continue;
+
+ ioctl(STDIN_FILENO, FIONREAD, &nb);
+
+ for (chnum = 0; chnum < nb && chnum < 8; chnum++) {
+ ch[chnum] = getchar();
+ }
if (chnum > 1) ch[0] = ch[chnum - 1] | (ch[chnum - 2] << 8);
@@ -101,8 +114,6 @@ void Keyboard::Process()
if (m_keymap[ch[0]] != 0)
send_action(m_keymap[ch[0]]);
- else
- Sleep(20);
}
}

View File

@ -0,0 +1,11 @@
--- Keyboard.h.orig 2015-10-24 12:09:14 UTC
+++ Keyboard.h
@@ -21,7 +21,7 @@
void Process();
void setKeymap(std::map<int,int> keymap);
void setDbusName(std::string dbus_name);
- void Sleep(unsigned int dwMilliSeconds);
+ int Hit();
int getEvent();
private:
void restore_term();

View File

@ -0,0 +1,28 @@
--- Makefile.orig 2015-10-24 12:09:14 UTC
+++ Makefile
@@ -2,9 +2,9 @@ include Makefile.include
CFLAGS+=-std=c++0x -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -DTARGET_POSIX -DTARGET_LINUX -fPIC -DPIC -D_REENTRANT -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -DHAVE_CMAKE_CONFIG -D__VIDEOCORE4__ -U_FORTIFY_SOURCE -Wall -DHAVE_OMXLIB -DUSE_EXTERNAL_FFMPEG -DHAVE_LIBAVCODEC_AVCODEC_H -DHAVE_LIBAVUTIL_OPT_H -DHAVE_LIBAVUTIL_MEM_H -DHAVE_LIBAVUTIL_AVUTIL_H -DHAVE_LIBAVFORMAT_AVFORMAT_H -DHAVE_LIBAVFILTER_AVFILTER_H -DHAVE_LIBSWRESAMPLE_SWRESAMPLE_H -DOMX -DOMX_SKIP64BIT -ftree-vectorize -DUSE_EXTERNAL_OMX -DTARGET_RASPBERRY_PI -DUSE_EXTERNAL_LIBBCM_HOST
-LDFLAGS+=-L./ -Lffmpeg_compiled/usr/local/lib/ -lc -lWFC -lGLESv2 -lEGL -lbcm_host -lopenmaxil -lfreetype -lz
+LDFLAGS+=-L./ -lWFC -lGLESv2 -lEGL -lbcm_host -lopenmaxil -lfreetype -lz
-INCLUDES+=-I./ -Ilinux -Iffmpeg_compiled/usr/local/include/ -I /usr/include/dbus-1.0 -I /usr/lib/arm-linux-gnueabihf/dbus-1.0/include
+INCLUDES+=-I./ -Ilinux -I$(LOCALBASE)/include/dbus-1.0 -I$(LOCALBASE)/include/dbus-1.0/include -I$(LOCALBASE)/include/freetype2 -I$(LOCALBASE)/include/ffmpeg
DIST ?= omxplayer-dist
@@ -48,11 +48,10 @@ all: dist
omxplayer.o: help.h keys.h
version:
- bash gen_version.sh > version.h
+ sh gen_version.sh > version.h
omxplayer.bin: version $(OBJS)
- $(CXX) $(LDFLAGS) -o omxplayer.bin $(OBJS) -lvchiq_arm -lvcos -ldbus-1 -lrt -lpthread -lavutil -lavcodec -lavformat -lswscale -lswresample -lpcre
- $(STRIP) omxplayer.bin
+ $(CXX) $(CFLAGS) $(LDFLAGS) -o omxplayer.bin $(OBJS) -lvchiq_arm -lvcos -ldbus-1 -lrt -lthr -lavutil -lavcodec -lavformat -lswscale -lswresample -lpcre
help.h: README.md Makefile
awk '/SYNOPSIS/{p=1;print;next} p&&/KEY BINDINGS/{p=0};p' $< \

View File

@ -0,0 +1,47 @@
--- Makefile.include.orig 2015-10-24 12:09:14 UTC
+++ Makefile.include
@@ -1,40 +1,7 @@
-USE_BUILDROOT=0
-FLOAT=hard
-
-ifeq ($(USE_BUILDROOT), 1)
-BUILDROOT :=/opt/xbmc-bcm/buildroot
-SDKSTAGE :=$(BUILDROOT)/output/staging
-TARGETFS :=$(BUILDROOT)/output/target
-TOOLCHAIN :=$(BUILDROOT)/output/host/usr/
-HOST :=arm-unknown-linux-gnueabi
-SYSROOT :=$(BUILDROOT)/output/host/usr/arm-unknown-linux-gnueabi/sysroot
-else
-BUILDROOT :=/opt/bcm-rootfs
-SDKSTAGE :=/opt/bcm-rootfs
-TARGETFS :=/opt/bcm-rootfs
-TOOLCHAIN :=/home/dc4/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/
-HOST :=arm-linux-gnueabihf
-#SYSROOT :=$(TOOLCHAIN)/arm-bcm2708hardfp-linux-gnueabi/sysroot
-SYSROOT :=/opt/bcm-rootfs
-endif
-
-JOBS=7
-
-CFLAGS := -isystem$(PREFIX)/include
-CXXFLAGS := $(CFLAGS)
-CPPFLAGS := $(CFLAGS)
-LDFLAGS := -L$(BUILDROOT)/lib
-LD := $(TOOLCHAIN)/bin/$(HOST)-ld --sysroot=$(SYSROOT)
-CC := $(TOOLCHAIN)/bin/$(HOST)-gcc --sysroot=$(SYSROOT)
-CXX := $(TOOLCHAIN)/bin/$(HOST)-g++ --sysroot=$(SYSROOT)
-OBJDUMP := $(TOOLCHAIN)/bin/$(HOST)-objdump
-RANLIB := $(TOOLCHAIN)/bin/$(HOST)-ranlib
-STRIP := $(TOOLCHAIN)/bin/$(HOST)-strip
-AR := $(TOOLCHAIN)/bin/$(HOST)-ar
+LDFLAGS := -L$(LOCALBASE)/lib -L$(LOCALBASE)/lib/ffmpeg
CXXCP := $(CXX) -E
-PATH := $(PREFIX)/bin:$(BUILDROOT)/output/host/usr/bin:$(PATH)
+STRIP := strip
+FLOAT := softfp
CFLAGS += -pipe -mfloat-abi=$(FLOAT) -mcpu=arm1176jzf-s -fomit-frame-pointer -mabi=aapcs-linux -mtune=arm1176jzf-s -mfpu=vfp -Wno-psabi -mno-apcs-stack-check -g -mstructure-size-boundary=32 -mno-sched-prolog
-LDFLAGS += -L$(SDKSTAGE)/lib -L$(SDKSTAGE)/usr/lib -L$(SDKSTAGE)/opt/vc/lib/ -Lpcre/build
-#INCLUDES += -isystem$(SDKSTAGE)/usr/include -isystem$(SDKSTAGE)/opt/vc/include -isystem$(SYSROOT)/usr/include -isystem$(SDKSTAGE)/opt/vc/include/interface/vcos/pthreads -isystem$(SDKSTAGE)/usr/include/freetype2
-INCLUDES += -isystem$(SDKSTAGE)/opt/vc/include -isystem$(SYSROOT)/usr/include -isystem$(SDKSTAGE)/opt/vc/include/interface/vcos/pthreads -Ipcre/build -Iboost-trunk -Ifreetype2/include
+INCLUDES += -I$(LOCALBASE)/include -I$(LOCALBASE)/include/interface/vcos/pthreads -I$(LOCALBASE)/include/interface/vmcs_host/linux -I$(LOCALBASE)/lib/dbus-1.0/include

View File

@ -0,0 +1,29 @@
--- linux/PlatformDefs.h.orig 2015-10-24 12:09:14 UTC
+++ linux/PlatformDefs.h
@@ -39,11 +39,11 @@
#include <unistd.h>
#include <pthread.h>
#include <string.h>
-#ifdef __APPLE__
+#if defined(__APPLE__)
#include <stdio.h>
#include <sys/sysctl.h>
#include <mach/mach.h>
-#else
+#elif defined(__linux__)
#include <sys/sysinfo.h>
#endif
#include <sys/time.h>
@@ -416,8 +416,12 @@ typedef struct _SECURITY_ATTRIBUTES {
#define FILE_CURRENT 1
#define FILE_END 2
+#ifndef _S_IFREG
#define _S_IFREG S_IFREG
+#endif
+#ifndef _S_IFDIR
#define _S_IFDIR S_IFDIR
+#endif
#define MAX_PATH PATH_MAX
#define _stat stat

View File

@ -0,0 +1,13 @@
--- omxplayer.cpp.orig 2015-10-24 12:09:14 UTC
+++ omxplayer.cpp
@@ -84,8 +86,8 @@ bool m_osd
bool m_no_keys = false;
std::string m_external_subtitles_path;
bool m_has_external_subtitles = false;
-std::string m_font_path = "/usr/share/fonts/truetype/freefont/FreeSans.ttf";
-std::string m_italic_font_path = "/usr/share/fonts/truetype/freefont/FreeSansOblique.ttf";
+std::string m_font_path = "/usr/local/share/fonts/freefont-ttf/FreeSans.ttf";
+std::string m_italic_font_path = "/usr/local/share/fonts/freefont-ttf/FreeSansOblique.ttf";
std::string m_dbus_name = "org.mpris.MediaPlayer2.omxplayer";
bool m_asked_for_font = false;
bool m_asked_for_italic_font = false;

View File

@ -0,0 +1,5 @@
OMXPlayer is a commandline OMX player for the Raspberry Pi. It was developed
as a testbed for the XBMC Raspberry PI implementation and is quite handy to
use standalone.
WWW: https://github.com/popcornmix/omxplayer