Merge commit 'gst-player/merge'

All gst-player example applications from https://github.com/sdroege/gst-player
This commit is contained in:
Sebastian Dröge 2016-08-26 18:28:43 +03:00
commit 7b9b4b15da
71 changed files with 10943 additions and 0 deletions

View file

@ -0,0 +1,15 @@
EXTRA_DIST = \
build.gradle \
gradle.properties \
settings.gradle \
app/build.gradle \
app/proguard-rules.pro \
app/src/main/AndroidManifest.xml \
app/src/main/java/org/freedesktop/gstreamer/Player.java \
app/src/main/java/org/freedesktop/gstreamer/player/GStreamerSurfaceView.java \
app/src/main/java/org/freedesktop/gstreamer/player/Play.java \
app/src/main/jni/Android.mk \
app/src/main/jni/Application.mk \
app/src/main/jni/player.c \
app/src/main/res/layout/main.xml \
app/src/main/res/values/strings.xml

View file

@ -0,0 +1,73 @@
apply plugin: 'com.android.application'
def getNdkCommandLine(ndkRoot, target) {
def gstRoot
if (project.hasProperty('gstAndroidRoot'))
gstRoot = project.gstAndroidRoot
else
gstRoot = System.properties['user.home'] + '/cerbero/dist/android_arm'
if (ndkRoot == null)
throw new GradleException('NDK not configured')
return ["$ndkRoot/ndk-build",
'NDK_PROJECT_PATH=build',
'APP_BUILD_SCRIPT=src/main/jni/Android.mk',
'NDK_APPLICATION_MK=src/main/jni/Application.mk',
'GSTREAMER_JAVA_SRC_DIR=src/main/java',
"GSTREAMER_ROOT_ANDROID=$gstRoot",
target]
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
sourceSets {
main {
// Avoid using the built in JNI generation plugin
jni.srcDirs = []
jniLibs.srcDirs = ['build/libs']
}
}
defaultConfig {
applicationId "org.freedesktop.gstreamer.play"
minSdkVersion 15
targetSdkVersion 15
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
// Before compiling our app, prepare NDK code
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn ndkBuild
}
// Need to call clean on NDK ourselves too
clean.dependsOn 'ndkClean'
// Build native code using mk files like on Eclipse
task ndkBuild(type: Exec, description: 'Compile JNI source via NDK') {
commandLine getNdkCommandLine(android.ndkDirectory, 'all')
}
task ndkClean(type: Exec, description: 'Clean JNI code built via NDK') {
commandLine getNdkCommandLine(android.ndkDirectory, 'clean')
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
}

View file

@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /home/arun/code/android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

View file

@ -0,0 +1,344 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.freedesktop.gstreamer.play">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-feature android:glEsVersion="0x00020000"/>
<application android:label="@string/app_name">
<activity android:name=".Play"
android:label="@string/app_name">
<!-- Files whose MIME type is known to Android -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:mimeType="audio/*" />
<data android:mimeType="video/*" />
<data android:mimeType="image/*" />
<data android:mimeType="*/rmvb" />
<data android:mimeType="*/avi" />
<data android:mimeType="*/mkv" />
<data android:mimeType="application/3gpp*" />
<data android:mimeType="application/mp4" />
<data android:mimeType="application/mpeg*" />
<data android:mimeType="application/ogg" />
<data android:mimeType="application/sdp" />
<data android:mimeType="application/vnd.3gp*" />
<data android:mimeType="application/vnd.apple.mpegurl" />
<data android:mimeType="application/vnd.rn-realmedia*" />
<data android:mimeType="application/x-iso9660-image" />
<data android:mimeType="application/x-extension-mp4" />
<data android:mimeType="application/x-flac" />
<data android:mimeType="application/x-matroska" />
<data android:mimeType="application/x-mpegURL" />
<data android:mimeType="application/x-ogg" />
<data android:mimeType="application/x-quicktimeplayer" />
</intent-filter>
<!-- Files with unknown MIME type.
The list of extensions and supported protocols can certainly be extended. -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="file" />
<data android:scheme="http" />
<data android:scheme="https" />
<!-- video -->
<data android:pathPattern=".*\\.3g2" />
<data android:pathPattern=".*\\.3gp" />
<data android:pathPattern=".*\\.3gp2" />
<data android:pathPattern=".*\\.3gpp" />
<data android:pathPattern=".*\\.amv" />
<data android:pathPattern=".*\\.asf" />
<data android:pathPattern=".*\\.avi" />
<data android:pathPattern=".*\\.divx" />
<data android:pathPattern=".*\\.drc" />
<data android:pathPattern=".*\\.dv" />
<data android:pathPattern=".*\\.f4v" />
<data android:pathPattern=".*\\.flv" />
<data android:pathPattern=".*\\.gvi" />
<data android:pathPattern=".*\\.gxf" />
<data android:pathPattern=".*\\.ismv" />
<data android:pathPattern=".*\\.iso" />
<data android:pathPattern=".*\\.m1v" />
<data android:pathPattern=".*\\.m2v" />
<data android:pathPattern=".*\\.m2t" />
<data android:pathPattern=".*\\.m2ts" />
<!-- <data android:pathPattern=".*\\.m3u" /> -->
<data android:pathPattern=".*\\.m3u8" />
<data android:pathPattern=".*\\.mkv" />
<data android:pathPattern=".*\\.mov" />
<data android:pathPattern=".*\\.mp2" />
<data android:pathPattern=".*\\.mp2v" />
<data android:pathPattern=".*\\.mp4" />
<data android:pathPattern=".*\\.mp4v" />
<data android:pathPattern=".*\\.mpe" />
<data android:pathPattern=".*\\.mpeg" />
<data android:pathPattern=".*\\.mpeg1" />
<data android:pathPattern=".*\\.mpeg2" />
<data android:pathPattern=".*\\.mpeg4" />
<data android:pathPattern=".*\\.mpg" />
<data android:pathPattern=".*\\.mpv2" />
<data android:pathPattern=".*\\.mts" />
<data android:pathPattern=".*\\.mtv" />
<data android:pathPattern=".*\\.mxf" />
<data android:pathPattern=".*\\.mxg" />
<data android:pathPattern=".*\\.nsv" />
<data android:pathPattern=".*\\.nut" />
<data android:pathPattern=".*\\.nuv" />
<data android:pathPattern=".*\\.ogm" />
<data android:pathPattern=".*\\.ogv" />
<data android:pathPattern=".*\\.ogx" />
<data android:pathPattern=".*\\.ps" />
<data android:pathPattern=".*\\.rec" />
<data android:pathPattern=".*\\.rm" />
<data android:pathPattern=".*\\.rmvb" />
<data android:pathPattern=".*\\.tod" />
<data android:pathPattern=".*\\.ts" />
<data android:pathPattern=".*\\.tts" />
<data android:pathPattern=".*\\.vob" />
<data android:pathPattern=".*\\.vro" />
<data android:pathPattern=".*\\.webm" />
<data android:pathPattern=".*\\.wm" />
<data android:pathPattern=".*\\.wmv" />
<data android:pathPattern=".*\\.wtv" />
<data android:pathPattern=".*\\.xesc" />
<data android:pathPattern=".*\\.3G2" />
<data android:pathPattern=".*\\.3GP" />
<data android:pathPattern=".*\\.3GP2" />
<data android:pathPattern=".*\\.3GPP" />
<data android:pathPattern=".*\\.AMV" />
<data android:pathPattern=".*\\.ASF" />
<data android:pathPattern=".*\\.AVI" />
<data android:pathPattern=".*\\.DIVX" />
<data android:pathPattern=".*\\.DRC" />
<data android:pathPattern=".*\\.DV" />
<data android:pathPattern=".*\\.F4V" />
<data android:pathPattern=".*\\.FLV" />
<data android:pathPattern=".*\\.GVI" />
<data android:pathPattern=".*\\.GXF" />
<data android:pathPattern=".*\\.ISMV" />
<data android:pathPattern=".*\\.ISO" />
<data android:pathPattern=".*\\.M1V" />
<data android:pathPattern=".*\\.M2V" />
<data android:pathPattern=".*\\.M2T" />
<data android:pathPattern=".*\\.M2TS" />
<!-- <data android:pathPattern=".*\\.M3U" /> -->
<data android:pathPattern=".*\\.M3U8" />
<data android:pathPattern=".*\\.MKV" />
<data android:pathPattern=".*\\.MOV" />
<data android:pathPattern=".*\\.MP2" />
<data android:pathPattern=".*\\.MP2V" />
<data android:pathPattern=".*\\.MP4" />
<data android:pathPattern=".*\\.MP4V" />
<data android:pathPattern=".*\\.MPE" />
<data android:pathPattern=".*\\.MPEG" />
<data android:pathPattern=".*\\.MPEG1" />
<data android:pathPattern=".*\\.MPEG2" />
<data android:pathPattern=".*\\.MPEG4" />
<data android:pathPattern=".*\\.MPG" />
<data android:pathPattern=".*\\.MPV2" />
<data android:pathPattern=".*\\.MTS" />
<data android:pathPattern=".*\\.MTV" />
<data android:pathPattern=".*\\.MXF" />
<data android:pathPattern=".*\\.MXG" />
<data android:pathPattern=".*\\.NSV" />
<data android:pathPattern=".*\\.NUT" />
<data android:pathPattern=".*\\.NUV" />
<data android:pathPattern=".*\\.OGM" />
<data android:pathPattern=".*\\.OGV" />
<data android:pathPattern=".*\\.OGX" />
<data android:pathPattern=".*\\.PS" />
<data android:pathPattern=".*\\.REC" />
<data android:pathPattern=".*\\.RM" />
<data android:pathPattern=".*\\.RMVB" />
<data android:pathPattern=".*\\.TOD" />
<data android:pathPattern=".*\\.TS" />
<data android:pathPattern=".*\\.TTS" />
<data android:pathPattern=".*\\.VOB" />
<data android:pathPattern=".*\\.VRO" />
<data android:pathPattern=".*\\.WEBM" />
<data android:pathPattern=".*\\.WM" />
<data android:pathPattern=".*\\.WMV" />
<data android:pathPattern=".*\\.WTV" />
<data android:pathPattern=".*\\.XESC" />
<!-- audio -->
<data android:pathPattern=".*\\.3ga" />
<data android:pathPattern=".*\\.a52" />
<data android:pathPattern=".*\\.aac" />
<data android:pathPattern=".*\\.ac3" />
<data android:pathPattern=".*\\.adt" />
<data android:pathPattern=".*\\.adts" />
<data android:pathPattern=".*\\.aif" />
<data android:pathPattern=".*\\.aifc" />
<data android:pathPattern=".*\\.aiff" />
<data android:pathPattern=".*\\.amr" />
<data android:pathPattern=".*\\.aob" />
<data android:pathPattern=".*\\.ape" />
<data android:pathPattern=".*\\.awb" />
<data android:pathPattern=".*\\.caf" />
<data android:pathPattern=".*\\.dts" />
<data android:pathPattern=".*\\.flac" />
<data android:pathPattern=".*\\.it" />
<data android:pathPattern=".*\\.m4a" />
<data android:pathPattern=".*\\.m4b" />
<data android:pathPattern=".*\\.m4p" />
<data android:pathPattern=".*\\.mid" />
<data android:pathPattern=".*\\.mka" />
<data android:pathPattern=".*\\.mlp" />
<data android:pathPattern=".*\\.mod" />
<data android:pathPattern=".*\\.mpa" />
<data android:pathPattern=".*\\.mp1" />
<data android:pathPattern=".*\\.mp2" />
<data android:pathPattern=".*\\.mp3" />
<data android:pathPattern=".*\\.mpc" />
<data android:pathPattern=".*\\.mpga" />
<data android:pathPattern=".*\\.oga" />
<data android:pathPattern=".*\\.ogg" />
<data android:pathPattern=".*\\.oma" />
<data android:pathPattern=".*\\.opus" />
<data android:pathPattern=".*\\.ra" />
<data android:pathPattern=".*\\.ram" />
<data android:pathPattern=".*\\.rmi" />
<data android:pathPattern=".*\\.s3m" />
<data android:pathPattern=".*\\.spx" />
<data android:pathPattern=".*\\.tta" />
<data android:pathPattern=".*\\.voc" />
<data android:pathPattern=".*\\.vqf" />
<data android:pathPattern=".*\\.w64" />
<data android:pathPattern=".*\\.wav" />
<data android:pathPattern=".*\\.wma" />
<data android:pathPattern=".*\\.wv" />
<data android:pathPattern=".*\\.xa" />
<data android:pathPattern=".*\\.xm" />
<data android:pathPattern=".*\\.3GA" />
<data android:pathPattern=".*\\.A52" />
<data android:pathPattern=".*\\.AAC" />
<data android:pathPattern=".*\\.AC3" />
<data android:pathPattern=".*\\.ADT" />
<data android:pathPattern=".*\\.ADTS" />
<data android:pathPattern=".*\\.AIF" />
<data android:pathPattern=".*\\.AIFC" />
<data android:pathPattern=".*\\.AIFF" />
<data android:pathPattern=".*\\.AMR" />
<data android:pathPattern=".*\\.AOB" />
<data android:pathPattern=".*\\.APE" />
<data android:pathPattern=".*\\.AWB" />
<data android:pathPattern=".*\\.CAF" />
<data android:pathPattern=".*\\.DTS" />
<data android:pathPattern=".*\\.FLAC" />
<data android:pathPattern=".*\\.IT" />
<data android:pathPattern=".*\\.M4A" />
<data android:pathPattern=".*\\.M4B" />
<data android:pathPattern=".*\\.M4P" />
<data android:pathPattern=".*\\.MID" />
<data android:pathPattern=".*\\.MKA" />
<data android:pathPattern=".*\\.MLP" />
<data android:pathPattern=".*\\.MOD" />
<data android:pathPattern=".*\\.MPA" />
<data android:pathPattern=".*\\.MP1" />
<data android:pathPattern=".*\\.MP2" />
<data android:pathPattern=".*\\.MP3" />
<data android:pathPattern=".*\\.MPC" />
<data android:pathPattern=".*\\.MPGA" />
<data android:pathPattern=".*\\.OGA" />
<data android:pathPattern=".*\\.OGG" />
<data android:pathPattern=".*\\.OMA" />
<data android:pathPattern=".*\\.OPUS" />
<data android:pathPattern=".*\\.RA" />
<data android:pathPattern=".*\\.RAM" />
<data android:pathPattern=".*\\.RMI" />
<data android:pathPattern=".*\\.S3M" />
<data android:pathPattern=".*\\.SPX" />
<data android:pathPattern=".*\\.TTA" />
<data android:pathPattern=".*\\.VOC" />
<data android:pathPattern=".*\\.VQF" />
<data android:pathPattern=".*\\.W64" />
<data android:pathPattern=".*\\.WAV" />
<data android:pathPattern=".*\\.WMA" />
<data android:pathPattern=".*\\.WV" />
<data android:pathPattern=".*\\.XA" />
<data android:pathPattern=".*\\.XM" />
</intent-filter>
<!-- Remote URI schemes without types -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="rtmp" />
<data android:scheme="rtmpt" />
<data android:scheme="rtmps" />
<data android:scheme="rtmpe" />
<data android:scheme="rtmfp" />
<data android:scheme="rtmpte" />
<data android:scheme="rtmpts" />
<data android:scheme="rtsp" />
<data android:scheme="rtspu" />
<data android:scheme="rtspt" />
<data android:scheme="rtsph" />
<data android:scheme="rtsp-sdp" />
<data android:scheme="rtsps" />
<data android:scheme="rtspsu" />
<data android:scheme="rtspst" />
<data android:scheme="rtspsh" />
<data android:scheme="mms" />
<data android:scheme="mmsh" />
<data android:scheme="mmst" />
<data android:scheme="mmsu" />
<data android:scheme="icy" />
<data android:scheme="icyx" />
<data android:scheme="udp" />
</intent-filter>
<!-- Remote URI schemes with types -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:mimeType="audio/*" />
<data android:mimeType="video/*" />
<data android:mimeType="image/*" />
<data android:scheme="rtmp" />
<data android:scheme="rtmpt" />
<data android:scheme="rtmps" />
<data android:scheme="rtmpe" />
<data android:scheme="rtmfp" />
<data android:scheme="rtmpte" />
<data android:scheme="rtmpts" />
<data android:scheme="rtsp" />
<data android:scheme="rtspu" />
<data android:scheme="rtspt" />
<data android:scheme="rtsph" />
<data android:scheme="rtsp-sdp" />
<data android:scheme="rtsps" />
<data android:scheme="rtspsu" />
<data android:scheme="rtspst" />
<data android:scheme="rtspsh" />
<data android:scheme="mms" />
<data android:scheme="mmsh" />
<data android:scheme="mmst" />
<data android:scheme="mmsu" />
<data android:scheme="icy" />
<data android:scheme="icyx" />
<data android:scheme="udp" />
</intent-filter>
</activity>
</application>
</manifest>

View file

@ -0,0 +1,241 @@
/* GStreamer
*
* Copyright (C) 2014-2015 Sebastian Dröge <sebastian@centricular.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
package org.freedesktop.gstreamer;
import java.io.Closeable;
import android.view.Surface;
import android.content.Context;
import org.freedesktop.gstreamer.GStreamer;
public class Player implements Closeable {
private static native void nativeClassInit();
public static void init(Context context) throws Exception {
System.loadLibrary("gstreamer_android");
GStreamer.init(context);
System.loadLibrary("gstplayer");
nativeClassInit();
}
private long native_player;
private native void nativeNew();
public Player() {
nativeNew();
}
private native void nativeFree();
@Override
public void close() {
nativeFree();
}
private native void nativePlay();
public void play() {
nativePlay();
}
private native void nativePause();
public void pause() {
nativePause();
}
private native void nativeStop();
public void stop() {
nativeStop();
}
private native void nativeSeek(long position);
public void seek(long position) {
nativeSeek(position);
}
private native String nativeGetUri();
public String getUri() {
return nativeGetUri();
}
private native void nativeSetUri(String uri);
public void setUri(String uri) {
nativeSetUri(uri);
}
private native long nativeGetPosition();
public long getPosition() {
return nativeGetPosition();
}
private native long nativeGetDuration();
public long getDuration() {
return nativeGetDuration();
}
private native double nativeGetVolume();
public double getVolume() {
return nativeGetVolume();
}
private native void nativeSetVolume(double volume);
public void setVolume(double volume) {
nativeSetVolume(volume);
}
private native boolean nativeGetMute();
public boolean getMute() {
return nativeGetMute();
}
private native void nativeSetMute(boolean mute);
public void setMute(boolean mute) {
nativeSetMute(mute);
}
private Surface surface;
private native void nativeSetSurface(Surface surface);
public void setSurface(Surface surface) {
this.surface = surface;
nativeSetSurface(surface);
}
public Surface getSurface() {
return surface;
}
public static interface PositionUpdatedListener {
abstract void positionUpdated(Player player, long position);
}
private PositionUpdatedListener positionUpdatedListener;
public void setPositionUpdatedListener(PositionUpdatedListener listener) {
positionUpdatedListener = listener;
}
private void onPositionUpdated(long position) {
if (positionUpdatedListener != null) {
positionUpdatedListener.positionUpdated(this, position);
}
}
public static interface DurationChangedListener {
abstract void durationChanged(Player player, long duration);
}
private DurationChangedListener durationChangedListener;
public void setDurationChangedListener(DurationChangedListener listener) {
durationChangedListener = listener;
}
private void onDurationChanged(long duration) {
if (durationChangedListener != null) {
durationChangedListener.durationChanged(this, duration);
}
}
private static final State[] stateMap = {State.STOPPED, State.BUFFERING, State.PAUSED, State.PLAYING};
public enum State {
STOPPED,
BUFFERING,
PAUSED,
PLAYING
}
public static interface StateChangedListener {
abstract void stateChanged(Player player, State state);
}
private StateChangedListener stateChangedListener;
public void setStateChangedListener(StateChangedListener listener) {
stateChangedListener = listener;
}
private void onStateChanged(int stateIdx) {
if (stateChangedListener != null) {
State state = stateMap[stateIdx];
stateChangedListener.stateChanged(this, state);
}
}
public static interface BufferingListener {
abstract void buffering(Player player, int percent);
}
private BufferingListener bufferingListener;
public void setBufferingListener(BufferingListener listener) {
bufferingListener = listener;
}
private void onBuffering(int percent) {
if (bufferingListener != null) {
bufferingListener.buffering(this, percent);
}
}
public static interface EndOfStreamListener {
abstract void endOfStream(Player player);
}
private EndOfStreamListener endOfStreamListener;
public void setEndOfStreamListener(EndOfStreamListener listener) {
endOfStreamListener = listener;
}
private void onEndOfStream() {
if (endOfStreamListener != null) {
endOfStreamListener.endOfStream(this);
}
}
// Keep these in sync with gstplayer.h
private static final Error[] errorMap = {Error.FAILED};
public enum Error {
FAILED
}
public static interface ErrorListener {
abstract void error(Player player, Error error, String errorMessage);
}
private ErrorListener errorListener;
public void setErrorListener(ErrorListener listener) {
errorListener = listener;
}
private void onError(int errorCode, String errorMessage) {
if (errorListener != null) {
Error error = errorMap[errorCode];
errorListener.error(this, error, errorMessage);
}
}
public static interface VideoDimensionsChangedListener {
abstract void videoDimensionsChanged(Player player, int width, int height);
}
private VideoDimensionsChangedListener videoDimensionsChangedListener;
public void setVideoDimensionsChangedListener(VideoDimensionsChangedListener listener) {
videoDimensionsChangedListener = listener;
}
private void onVideoDimensionsChanged(int width, int height) {
if (videoDimensionsChangedListener != null) {
videoDimensionsChangedListener.videoDimensionsChanged(this, width, height);
}
}
}

View file

@ -0,0 +1,110 @@
/* GStreamer
*
* Copyright (C) 2014 Sebastian Dröge <sebastian@centricular.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
package org.freedesktop.gstreamer.play;
import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.SurfaceView;
import android.view.View;
// A simple SurfaceView whose width and height can be set from the outside
public class GStreamerSurfaceView extends SurfaceView {
public int media_width = 320;
public int media_height = 240;
// Mandatory constructors, they do not do much
public GStreamerSurfaceView(Context context, AttributeSet attrs,
int defStyle) {
super(context, attrs, defStyle);
}
public GStreamerSurfaceView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public GStreamerSurfaceView (Context context) {
super(context);
}
// Called by the layout manager to find out our size and give us some rules.
// We will try to maximize our size, and preserve the media's aspect ratio if
// we are given the freedom to do so.
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (media_width == 0 || media_height == 0) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
return;
}
int width = 0, height = 0;
int wmode = View.MeasureSpec.getMode(widthMeasureSpec);
int hmode = View.MeasureSpec.getMode(heightMeasureSpec);
int wsize = View.MeasureSpec.getSize(widthMeasureSpec);
int hsize = View.MeasureSpec.getSize(heightMeasureSpec);
Log.i ("GStreamer", "onMeasure called with " + media_width + "x" + media_height);
// Obey width rules
switch (wmode) {
case View.MeasureSpec.AT_MOST:
if (hmode == View.MeasureSpec.EXACTLY) {
width = Math.min(hsize * media_width / media_height, wsize);
break;
}
case View.MeasureSpec.EXACTLY:
width = wsize;
break;
case View.MeasureSpec.UNSPECIFIED:
width = media_width;
}
// Obey height rules
switch (hmode) {
case View.MeasureSpec.AT_MOST:
if (wmode == View.MeasureSpec.EXACTLY) {
height = Math.min(wsize * media_height / media_width, hsize);
break;
}
case View.MeasureSpec.EXACTLY:
height = hsize;
break;
case View.MeasureSpec.UNSPECIFIED:
height = media_height;
}
// Finally, calculate best size when both axis are free
if (hmode == View.MeasureSpec.AT_MOST && wmode == View.MeasureSpec.AT_MOST) {
int correct_height = width * media_height / media_width;
int correct_width = height * media_width / media_height;
if (correct_height < height)
height = correct_height;
else
width = correct_width;
}
// Obey minimum size
width = Math.max (getSuggestedMinimumWidth(), width);
height = Math.max (getSuggestedMinimumHeight(), height);
setMeasuredDimension(width, height);
}
}

View file

@ -0,0 +1,196 @@
/* GStreamer
*
* Copyright (C) 2014 Sebastian Dröge <sebastian@centricular.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
package org.freedesktop.gstreamer.play;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.PowerManager;
import android.util.Log;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
import android.widget.Toast;
import org.freedesktop.gstreamer.Player;
public class Play extends Activity implements SurfaceHolder.Callback, OnSeekBarChangeListener {
private PowerManager.WakeLock wake_lock;
private Player player;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
try {
Player.init(this);
} catch (Exception e) {
Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
finish();
return;
}
setContentView(R.layout.main);
player = new Player();
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
wake_lock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "GStreamer Play");
wake_lock.setReferenceCounted(false);
ImageButton play = (ImageButton) this.findViewById(R.id.button_play);
play.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
player.play();
wake_lock.acquire();
}
});
ImageButton pause = (ImageButton) this.findViewById(R.id.button_pause);
pause.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
player.pause();
wake_lock.release();
}
});
final SeekBar sb = (SeekBar) this.findViewById(R.id.seek_bar);
sb.setOnSeekBarChangeListener(this);
player.setPositionUpdatedListener(new Player.PositionUpdatedListener() {
public void positionUpdated(Player player, final long position) {
runOnUiThread (new Runnable() {
public void run() {
sb.setProgress((int) (position / 1000000));
updateTimeWidget();
}
});
}
});
player.setDurationChangedListener(new Player.DurationChangedListener() {
public void durationChanged(Player player, final long duration) {
runOnUiThread (new Runnable() {
public void run() {
sb.setMax((int) (duration / 1000000));
updateTimeWidget();
}
});
}
});
final GStreamerSurfaceView gsv = (GStreamerSurfaceView) this.findViewById(R.id.surface_video);
player.setVideoDimensionsChangedListener(new Player.VideoDimensionsChangedListener() {
public void videoDimensionsChanged(Player player, final int width, final int height) {
runOnUiThread (new Runnable() {
public void run() {
Log.i ("GStreamer", "Media size changed to " + width + "x" + height);
gsv.media_width = width;
gsv.media_height = height;
runOnUiThread(new Runnable() {
public void run() {
gsv.requestLayout();
}
});
}
});
}
});
SurfaceView sv = (SurfaceView) this.findViewById(R.id.surface_video);
SurfaceHolder sh = sv.getHolder();
sh.addCallback(this);
String mediaUri = null;
Intent intent = getIntent();
android.net.Uri uri = intent.getData();
Log.i ("GStreamer", "Received URI: " + uri);
if (uri.getScheme().equals("content")) {
android.database.Cursor cursor = getContentResolver().query(uri, null, null, null, null);
cursor.moveToFirst();
mediaUri = "file://" + cursor.getString(cursor.getColumnIndex(android.provider.MediaStore.Video.Media.DATA));
cursor.close();
} else {
mediaUri = uri.toString();
}
player.setUri(mediaUri);
updateTimeWidget();
}
protected void onDestroy() {
player.close();
super.onDestroy();
}
private void updateTimeWidget () {
final TextView tv = (TextView) this.findViewById(R.id.textview_time);
final SeekBar sb = (SeekBar) this.findViewById(R.id.seek_bar);
final int pos = sb.getProgress();
final int max = sb.getMax();
SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss");
df.setTimeZone(TimeZone.getTimeZone("UTC"));
final String message = df.format(new Date (pos)) + " / " + df.format(new Date (max));
tv.setText(message);
}
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
Log.d("GStreamer", "Surface changed to format " + format + " width "
+ width + " height " + height);
player.setSurface(holder.getSurface());
}
public void surfaceCreated(SurfaceHolder holder) {
Log.d("GStreamer", "Surface created: " + holder.getSurface());
}
public void surfaceDestroyed(SurfaceHolder holder) {
Log.d("GStreamer", "Surface destroyed");
player.setSurface(null);
}
public void onProgressChanged(SeekBar sb, int progress, boolean fromUser) {
if (!fromUser) return;
updateTimeWidget();
}
public void onStartTrackingTouch(SeekBar sb) {
}
public void onStopTrackingTouch(SeekBar sb) {
Log.d("GStreamer", "Seek to " + sb.getProgress());
player.seek(((long) sb.getProgress()) * 1000000);
}
}

View file

@ -0,0 +1,39 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := gstplayer
LOCAL_SRC_FILES := player.c
LOCAL_SHARED_LIBRARIES := gstreamer_android
LOCAL_LDLIBS := -llog -landroid
include $(BUILD_SHARED_LIBRARY)
ifeq ($(TARGET_ARCH_ABI),armeabi)
GSTREAMER_ROOT := $(GSTREAMER_ROOT_ARM)
else ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
GSTREAMER_ROOT := $(GSTREAMER_ROOT_ARMV7)
else ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
GSTREAMER_ROOT := $(GSTREAMER_ROOT_ARM64)
else ifeq ($(TARGET_ARCH_ABI),x86)
GSTREAMER_ROOT := $(GSTREAMER_ROOT_X86)
else ifeq ($(TARGET_ARCH_ABI),x86_64)
GSTREAMER_ROOT := $(GSTREAMER_ROOT_X86_64)
else
$(error Target arch ABI not supported)
endif
ifndef GSTREAMER_ROOT
ifndef GSTREAMER_ROOT_ANDROID
$(error GSTREAMER_ROOT_ANDROID is not defined!)
endif
GSTREAMER_ROOT := $(GSTREAMER_ROOT_ANDROID)
endif
GSTREAMER_NDK_BUILD_PATH := $(GSTREAMER_ROOT)/share/gst-android/ndk-build/
include $(GSTREAMER_NDK_BUILD_PATH)/plugins.mk
GSTREAMER_PLUGINS := $(GSTREAMER_PLUGINS_CORE) $(GSTREAMER_PLUGINS_PLAYBACK) $(GSTREAMER_PLUGINS_CODECS) $(GSTREAMER_PLUGINS_NET) $(GSTREAMER_PLUGINS_SYS) $(GSTREAMER_PLUGINS_CODECS_RESTRICTED) $(GSTREAMER_CODECS_GPL) $(GSTREAMER_PLUGINS_ENCODING) $(GSTREAMER_PLUGINS_VIS) $(GSTREAMER_PLUGINS_EFFECTS) $(GSTREAMER_PLUGINS_NET_RESTRICTED)
GSTREAMER_EXTRA_DEPS := gstreamer-player-1.0 gstreamer-video-1.0 glib-2.0
include $(GSTREAMER_NDK_BUILD_PATH)/gstreamer-1.0.mk

View file

@ -0,0 +1 @@
APP_PLATFORM = 15

View file

@ -0,0 +1,497 @@
/* GStreamer
*
* Copyright (C) 2014 Sebastian Dröge <sebastian@centricular.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include <string.h>
#include <stdint.h>
#include <jni.h>
#include <android/log.h>
#include <android/native_window.h>
#include <android/native_window_jni.h>
#include <gst/player/player.h>
GST_DEBUG_CATEGORY_STATIC (debug_category);
#define GST_CAT_DEFAULT debug_category
#define GET_CUSTOM_DATA(env, thiz, fieldID) (Player *)(gintptr)(*env)->GetLongField (env, thiz, fieldID)
#define SET_CUSTOM_DATA(env, thiz, fieldID, data) (*env)->SetLongField (env, thiz, fieldID, (jlong)(gintptr)data)
typedef struct _Player
{
jobject java_player;
GstPlayer *player;
GstPlayerVideoRenderer *renderer;
ANativeWindow *native_window;
} Player;
static pthread_key_t current_jni_env;
static JavaVM *java_vm;
static jfieldID native_player_field_id;
static jmethodID on_position_updated_method_id;
static jmethodID on_duration_changed_method_id;
static jmethodID on_state_changed_method_id;
static jmethodID on_buffering_method_id;
static jmethodID on_end_of_stream_method_id;
static jmethodID on_error_method_id;
static jmethodID on_video_dimensions_changed_method_id;
/* Register this thread with the VM */
static JNIEnv *
attach_current_thread (void)
{
JNIEnv *env;
JavaVMAttachArgs args;
GST_DEBUG ("Attaching thread %p", g_thread_self ());
args.version = JNI_VERSION_1_4;
args.name = NULL;
args.group = NULL;
if ((*java_vm)->AttachCurrentThread (java_vm, &env, &args) < 0) {
GST_ERROR ("Failed to attach current thread");
return NULL;
}
return env;
}
/* Unregister this thread from the VM */
static void
detach_current_thread (void *env)
{
GST_DEBUG ("Detaching thread %p", g_thread_self ());
(*java_vm)->DetachCurrentThread (java_vm);
}
/* Retrieve the JNI environment for this thread */
static JNIEnv *
get_jni_env (void)
{
JNIEnv *env;
if ((env = pthread_getspecific (current_jni_env)) == NULL) {
env = attach_current_thread ();
pthread_setspecific (current_jni_env, env);
}
return env;
}
/*
* Java Bindings
*/
static void
on_position_updated (GstPlayer * unused, GstClockTime position, Player * player)
{
JNIEnv *env = get_jni_env ();
(*env)->CallVoidMethod (env, player->java_player,
on_position_updated_method_id, position);
if ((*env)->ExceptionCheck (env)) {
(*env)->ExceptionDescribe (env);
(*env)->ExceptionClear (env);
}
}
static void
on_duration_changed (GstPlayer * unused, GstClockTime duration, Player * player)
{
JNIEnv *env = get_jni_env ();
(*env)->CallVoidMethod (env, player->java_player,
on_duration_changed_method_id, duration);
if ((*env)->ExceptionCheck (env)) {
(*env)->ExceptionDescribe (env);
(*env)->ExceptionClear (env);
}
}
static void
on_state_changed (GstPlayer * unused, GstPlayerState state, Player * player)
{
JNIEnv *env = get_jni_env ();
(*env)->CallVoidMethod (env, player->java_player,
on_state_changed_method_id, state);
if ((*env)->ExceptionCheck (env)) {
(*env)->ExceptionDescribe (env);
(*env)->ExceptionClear (env);
}
}
static void
on_buffering (GstPlayer * unused, gint percent, Player * player)
{
JNIEnv *env = get_jni_env ();
(*env)->CallVoidMethod (env, player->java_player,
on_buffering_method_id, percent);
if ((*env)->ExceptionCheck (env)) {
(*env)->ExceptionDescribe (env);
(*env)->ExceptionClear (env);
}
}
static void
on_end_of_stream (GstPlayer * unused, Player * player)
{
JNIEnv *env = get_jni_env ();
(*env)->CallVoidMethod (env, player->java_player, on_end_of_stream_method_id);
if ((*env)->ExceptionCheck (env)) {
(*env)->ExceptionDescribe (env);
(*env)->ExceptionClear (env);
}
}
static void
on_error (GstPlayer * unused, GError * err, Player * player)
{
JNIEnv *env = get_jni_env ();
jstring error_msg;
error_msg = (*env)->NewStringUTF (env, err->message);
(*env)->CallVoidMethod (env, player->java_player, on_error_method_id,
err->code, error_msg);
if ((*env)->ExceptionCheck (env)) {
(*env)->ExceptionDescribe (env);
(*env)->ExceptionClear (env);
}
(*env)->DeleteLocalRef (env, error_msg);
}
static void
on_video_dimensions_changed (GstPlayer * unused, gint width, gint height,
Player * player)
{
JNIEnv *env = get_jni_env ();
(*env)->CallVoidMethod (env, player->java_player,
on_video_dimensions_changed_method_id, width, height);
if ((*env)->ExceptionCheck (env)) {
(*env)->ExceptionDescribe (env);
(*env)->ExceptionClear (env);
}
}
static void
native_new (JNIEnv * env, jobject thiz)
{
Player *player = g_new0 (Player, 1);
player->renderer = gst_player_video_overlay_video_renderer_new (NULL);
player->player = gst_player_new (player->renderer, NULL);
SET_CUSTOM_DATA (env, thiz, native_player_field_id, player);
player->java_player = (*env)->NewGlobalRef (env, thiz);
g_signal_connect (player->player, "position-updated",
G_CALLBACK (on_position_updated), player);
g_signal_connect (player->player, "duration-changed",
G_CALLBACK (on_duration_changed), player);
g_signal_connect (player->player, "state-changed",
G_CALLBACK (on_state_changed), player);
g_signal_connect (player->player, "buffering",
G_CALLBACK (on_buffering), player);
g_signal_connect (player->player, "end-of-stream",
G_CALLBACK (on_end_of_stream), player);
g_signal_connect (player->player, "error", G_CALLBACK (on_error), player);
g_signal_connect (player->player, "video-dimensions-changed",
G_CALLBACK (on_video_dimensions_changed), player);
}
static void
native_free (JNIEnv * env, jobject thiz)
{
Player *player = GET_CUSTOM_DATA (env, thiz, native_player_field_id);
if (!player)
return;
g_object_unref (player->player);
(*env)->DeleteGlobalRef (env, player->java_player);
g_free (player);
SET_CUSTOM_DATA (env, thiz, native_player_field_id, NULL);
}
static void
native_play (JNIEnv * env, jobject thiz)
{
Player *player = GET_CUSTOM_DATA (env, thiz, native_player_field_id);
if (!player)
return;
gst_player_play (player->player);
}
static void
native_pause (JNIEnv * env, jobject thiz)
{
Player *player = GET_CUSTOM_DATA (env, thiz, native_player_field_id);
if (!player)
return;
gst_player_pause (player->player);
}
static void
native_stop (JNIEnv * env, jobject thiz)
{
Player *player = GET_CUSTOM_DATA (env, thiz, native_player_field_id);
if (!player)
return;
gst_player_stop (player->player);
}
static void
native_seek (JNIEnv * env, jobject thiz, jlong position)
{
Player *player = GET_CUSTOM_DATA (env, thiz, native_player_field_id);
if (!player)
return;
gst_player_seek (player->player, position);
}
static void
native_set_uri (JNIEnv * env, jobject thiz, jobject uri)
{
Player *player = GET_CUSTOM_DATA (env, thiz, native_player_field_id);
const gchar *uri_str;
if (!player)
return;
uri_str = (*env)->GetStringUTFChars (env, uri, NULL);
g_object_set (player->player, "uri", uri_str, NULL);
(*env)->ReleaseStringUTFChars (env, uri, uri_str);
}
static jobject
native_get_uri (JNIEnv * env, jobject thiz)
{
Player *player = GET_CUSTOM_DATA (env, thiz, native_player_field_id);
jobject uri;
gchar *uri_str;
if (!player)
return NULL;
g_object_get (player->player, "uri", &uri_str, NULL);
uri = (*env)->NewStringUTF (env, uri_str);
g_free (uri_str);
return uri;
}
static jlong
native_get_position (JNIEnv * env, jobject thiz)
{
Player *player = GET_CUSTOM_DATA (env, thiz, native_player_field_id);
jdouble position;
if (!player)
return -1;
g_object_get (player->player, "position", &position, NULL);
return position;
}
static jlong
native_get_duration (JNIEnv * env, jobject thiz)
{
Player *player = GET_CUSTOM_DATA (env, thiz, native_player_field_id);
jlong duration;
if (!player)
return -1;
g_object_get (player->player, "duration", &duration, NULL);
return duration;
}
static jdouble
native_get_volume (JNIEnv * env, jobject thiz)
{
Player *player = GET_CUSTOM_DATA (env, thiz, native_player_field_id);
jdouble volume;
if (!player)
return 1.0;
g_object_get (player->player, "volume", &volume, NULL);
return volume;
}
static void
native_set_volume (JNIEnv * env, jobject thiz, jdouble volume)
{
Player *player = GET_CUSTOM_DATA (env, thiz, native_player_field_id);
if (!player)
return;
g_object_set (player->player, "volume", volume, NULL);
}
static jboolean
native_get_mute (JNIEnv * env, jobject thiz)
{
Player *player = GET_CUSTOM_DATA (env, thiz, native_player_field_id);
jboolean mute;
if (!player)
return FALSE;
g_object_get (player->player, "mute", &mute, NULL);
return mute;
}
static void
native_set_mute (JNIEnv * env, jobject thiz, jboolean mute)
{
Player *player = GET_CUSTOM_DATA (env, thiz, native_player_field_id);
if (!player)
return;
g_object_set (player->player, "mute", mute, NULL);
}
static void
native_set_surface (JNIEnv * env, jobject thiz, jobject surface)
{
Player *player = GET_CUSTOM_DATA (env, thiz, native_player_field_id);
ANativeWindow *new_native_window;
if (!player)
return;
new_native_window = surface ? ANativeWindow_fromSurface (env, surface) : NULL;
GST_DEBUG ("Received surface %p (native window %p)", surface,
new_native_window);
if (player->native_window) {
ANativeWindow_release (player->native_window);
}
player->native_window = new_native_window;
gst_player_video_overlay_video_renderer_set_window_handle
(GST_PLAYER_VIDEO_OVERLAY_VIDEO_RENDERER (player->renderer),
(gpointer) new_native_window);
}
static void
native_class_init (JNIEnv * env, jclass klass)
{
native_player_field_id =
(*env)->GetFieldID (env, klass, "native_player", "J");
on_position_updated_method_id =
(*env)->GetMethodID (env, klass, "onPositionUpdated", "(J)V");
on_duration_changed_method_id =
(*env)->GetMethodID (env, klass, "onDurationChanged", "(J)V");
on_state_changed_method_id =
(*env)->GetMethodID (env, klass, "onStateChanged", "(I)V");
on_buffering_method_id =
(*env)->GetMethodID (env, klass, "onBuffering", "(I)V");
on_end_of_stream_method_id =
(*env)->GetMethodID (env, klass, "onEndOfStream", "()V");
on_error_method_id =
(*env)->GetMethodID (env, klass, "onError", "(ILjava/lang/String;)V");
on_video_dimensions_changed_method_id =
(*env)->GetMethodID (env, klass, "onVideoDimensionsChanged", "(II)V");
if (!native_player_field_id ||
!on_position_updated_method_id || !on_duration_changed_method_id ||
!on_state_changed_method_id || !on_buffering_method_id ||
!on_end_of_stream_method_id ||
!on_error_method_id || !on_video_dimensions_changed_method_id) {
static const gchar *message =
"The calling class does not implement all necessary interface methods";
jclass exception_class = (*env)->FindClass (env, "java/lang/Exception");
__android_log_print (ANDROID_LOG_ERROR, "GstPlayer", "%s", message);
(*env)->ThrowNew (env, exception_class, message);
}
gst_debug_set_threshold_for_name ("gst-player", GST_LEVEL_TRACE);
}
/* List of implemented native methods */
static JNINativeMethod native_methods[] = {
{"nativeClassInit", "()V", (void *) native_class_init},
{"nativeNew", "()V", (void *) native_new},
{"nativePlay", "()V", (void *) native_play},
{"nativePause", "()V", (void *) native_pause},
{"nativeStop", "()V", (void *) native_stop},
{"nativeSeek", "(J)V", (void *) native_seek},
{"nativeFree", "()V", (void *) native_free},
{"nativeGetUri", "()Ljava/lang/String;", (void *) native_get_uri},
{"nativeSetUri", "(Ljava/lang/String;)V", (void *) native_set_uri},
{"nativeGetPosition", "()J", (void *) native_get_position},
{"nativeGetDuration", "()J", (void *) native_get_duration},
{"nativeGetVolume", "()D", (void *) native_get_volume},
{"nativeSetVolume", "(D)V", (void *) native_set_volume},
{"nativeGetMute", "()Z", (void *) native_get_mute},
{"nativeSetMute", "(Z)V", (void *) native_set_mute},
{"nativeSetSurface", "(Landroid/view/Surface;)V",
(void *) native_set_surface}
};
/* Library initializer */
jint
JNI_OnLoad (JavaVM * vm, void *reserved)
{
JNIEnv *env = NULL;
java_vm = vm;
if ((*vm)->GetEnv (vm, (void **) &env, JNI_VERSION_1_4) != JNI_OK) {
__android_log_print (ANDROID_LOG_ERROR, "GstPlayer",
"Could not retrieve JNIEnv");
return 0;
}
jclass klass = (*env)->FindClass (env, "org/freedesktop/gstreamer/Player");
if (!klass) {
__android_log_print (ANDROID_LOG_ERROR, "GstPlayer",
"Could not retrieve class org.freedesktop.gstreamer.Player");
return 0;
}
if ((*env)->RegisterNatives (env, klass, native_methods,
G_N_ELEMENTS (native_methods))) {
__android_log_print (ANDROID_LOG_ERROR, "GstPlayer",
"Could not register native methods for org.freedesktop.gstreamer.Player");
return 0;
}
pthread_key_create (&current_jni_env, detach_current_thread);
return JNI_VERSION_1_4;
}

View file

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dip"
android:gravity="center_horizontal"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/button_play"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/button_play"
android:src="@android:drawable/ic_media_play"
android:text="@string/button_play" />
<ImageButton
android:id="@+id/button_pause"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/button_pause"
android:src="@android:drawable/ic_media_pause"
android:text="@string/button_pause" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dip"
android:gravity="center_horizontal"
android:orientation="horizontal" >
<TextView
android:id="@+id/textview_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip" />
<SeekBar
android:id="@+id/seek_bar"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:indeterminate="false" />
</LinearLayout>
<org.freedesktop.gstreamer.play.GStreamerSurfaceView
android:id="@+id/surface_video"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal" />
</LinearLayout>

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">GStreamer Play</string>
<string name="button_play">Play</string>
<string name="button_pause">Pause</string>
</resources>

View file

@ -0,0 +1,23 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

View file

@ -0,0 +1,18 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

Binary file not shown.

View file

@ -0,0 +1,6 @@
#Tue Aug 23 11:07:06 IST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip

160
playback/player/android/gradlew vendored Executable file
View file

@ -0,0 +1,160 @@
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"

90
playback/player/android/gradlew.bat vendored Normal file
View file

@ -0,0 +1,90 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View file

@ -0,0 +1 @@
include ':app'

View file

@ -0,0 +1,9 @@
bin_PROGRAMS = gst-play
gst_play_SOURCES = gst-play.c gst-play-kb.c gst-play-kb.h
LDADD = $(GSTREAMER_LIBS) $(GLIB_LIBS) $(LIBM)
AM_CFLAGS = $(GSTREAMER_CFLAGS) $(GLIB_CFLAGS) $(WARNING_CFLAGS)
noinst_HEADERS = gst-play-kb.h

View file

@ -0,0 +1,143 @@
/* GStreamer command line playback testing utility - keyboard handling helpers
*
* Copyright (C) 2013 Tim-Philipp Müller <tim centricular net>
* Copyright (C) 2013 Centricular Ltd
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gst-play-kb.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#ifdef G_OS_UNIX
#include <unistd.h>
#include <termios.h>
#endif
#include <gst/gst.h>
/* This is all not thread-safe, but doesn't have to be really */
#ifdef G_OS_UNIX
static struct termios term_settings;
static gboolean term_settings_saved = FALSE;
static GstPlayKbFunc kb_callback;
static gpointer kb_callback_data;
static gulong io_watch_id;
static gboolean
gst_play_kb_io_cb (GIOChannel * ioc, GIOCondition cond, gpointer user_data)
{
GIOStatus status;
if (cond & G_IO_IN) {
gchar buf[16] = { 0, };
gsize read;
status = g_io_channel_read_chars (ioc, buf, sizeof (buf) - 1, &read, NULL);
if (status == G_IO_STATUS_ERROR)
return FALSE;
if (status == G_IO_STATUS_NORMAL) {
if (kb_callback)
kb_callback (buf, kb_callback_data);
}
}
return TRUE; /* call us again */
}
gboolean
gst_play_kb_set_key_handler (GstPlayKbFunc kb_func, gpointer user_data)
{
GIOChannel *ioc;
int flags;
if (!isatty (STDIN_FILENO)) {
GST_INFO ("stdin is not connected to a terminal");
return FALSE;
}
if (io_watch_id > 0) {
g_source_remove (io_watch_id);
io_watch_id = 0;
}
if (kb_func == NULL && term_settings_saved) {
/* restore terminal settings */
if (tcsetattr (STDIN_FILENO, TCSAFLUSH, &term_settings) == 0)
term_settings_saved = FALSE;
else
g_warning ("could not restore terminal attributes");
setvbuf (stdin, NULL, _IOLBF, 0);
}
if (kb_func != NULL) {
struct termios new_settings;
if (!term_settings_saved) {
if (tcgetattr (STDIN_FILENO, &term_settings) != 0) {
g_warning ("could not save terminal attributes");
return FALSE;
}
term_settings_saved = TRUE;
/* Echo off, canonical mode off, extended input processing off */
new_settings = term_settings;
new_settings.c_lflag &= ~(ECHO | ICANON | IEXTEN);
if (tcsetattr (STDIN_FILENO, TCSAFLUSH, &new_settings) != 0) {
g_warning ("Could not set terminal state");
return FALSE;
}
setvbuf (stdin, NULL, _IONBF, 0);
}
}
ioc = g_io_channel_unix_new (STDIN_FILENO);
/* make non-blocking */
flags = g_io_channel_get_flags (ioc);
g_io_channel_set_flags (ioc, flags | G_IO_FLAG_NONBLOCK, NULL);
io_watch_id = g_io_add_watch_full (ioc, G_PRIORITY_DEFAULT, G_IO_IN,
(GIOFunc) gst_play_kb_io_cb, user_data, NULL);
g_io_channel_unref (ioc);
kb_callback = kb_func;
kb_callback_data = user_data;
return TRUE;
}
#else /* !G_OS_UNIX */
gboolean
gst_play_kb_set_key_handler (GstPlayKbFunc key_func, gpointer user_data)
{
GST_FIXME ("Keyboard handling for this OS needs to be implemented");
return FALSE;
}
#endif /* !G_OS_UNIX */

View file

@ -0,0 +1,35 @@
/* GStreamer command line playback testing utility - keyboard handling helpers
*
* Copyright (C) 2013 Tim-Philipp Müller <tim centricular net>
* Copyright (C) 2013 Centricular Ltd
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_PLAY_KB_INCLUDED__
#define __GST_PLAY_KB_INCLUDED__
#include <glib.h>
#define GST_PLAY_KB_ARROW_UP "\033[A"
#define GST_PLAY_KB_ARROW_DOWN "\033[B"
#define GST_PLAY_KB_ARROW_RIGHT "\033[C"
#define GST_PLAY_KB_ARROW_LEFT "\033[D"
typedef void (*GstPlayKbFunc) (const gchar * kb_input, gpointer user_data);
gboolean gst_play_kb_set_key_handler (GstPlayKbFunc kb_func, gpointer user_data);
#endif /* __GST_PLAY_KB_INCLUDED__ */

View file

@ -0,0 +1,773 @@
/* GStreamer command line playback testing utility
*
* Copyright (C) 2013-2014 Tim-Philipp Müller <tim centricular net>
* Copyright (C) 2013 Collabora Ltd.
* Copyright (C) 2014 Sebastian Dröge <sebastian@centricular.com>
* Copyright (C) 2015 Brijesh Singh <brijesh.ksingh@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include <locale.h>
#include <gst/gst.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "gst-play-kb.h"
#include <gst/player/player.h>
#define VOLUME_STEPS 20
GST_DEBUG_CATEGORY (play_debug);
#define GST_CAT_DEFAULT play_debug
typedef struct
{
gchar **uris;
guint num_uris;
gint cur_idx;
GstPlayer *player;
GstState desired_state;
gboolean repeat;
GMainLoop *loop;
} GstPlay;
static gboolean play_next (GstPlay * play);
static gboolean play_prev (GstPlay * play);
static void play_reset (GstPlay * play);
static void play_set_relative_volume (GstPlay * play, gdouble volume_step);
static void
end_of_stream_cb (GstPlayer * player, GstPlay * play)
{
g_print ("\n");
/* and switch to next item in list */
if (!play_next (play)) {
g_print ("Reached end of play list.\n");
g_main_loop_quit (play->loop);
}
}
static void
error_cb (GstPlayer * player, GError * err, GstPlay * play)
{
g_printerr ("ERROR %s for %s\n", err->message, play->uris[play->cur_idx]);
/* if looping is enabled, then disable it else will keep looping forever */
play->repeat = FALSE;
/* try next item in list then */
if (!play_next (play)) {
g_print ("Reached end of play list.\n");
g_main_loop_quit (play->loop);
}
}
static void
position_updated_cb (GstPlayer * player, GstClockTime pos, GstPlay * play)
{
GstClockTime dur = -1;
gchar status[64] = { 0, };
g_object_get (play->player, "duration", &dur, NULL);
memset (status, ' ', sizeof (status) - 1);
if (pos != -1 && dur > 0 && dur != -1) {
gchar dstr[32], pstr[32];
/* FIXME: pretty print in nicer format */
g_snprintf (pstr, 32, "%" GST_TIME_FORMAT, GST_TIME_ARGS (pos));
pstr[9] = '\0';
g_snprintf (dstr, 32, "%" GST_TIME_FORMAT, GST_TIME_ARGS (dur));
dstr[9] = '\0';
g_print ("%s / %s %s\r", pstr, dstr, status);
}
}
static void
state_changed_cb (GstPlayer * player, GstPlayerState state, GstPlay * play)
{
g_print ("State changed: %s\n", gst_player_state_get_name (state));
}
static void
buffering_cb (GstPlayer * player, gint percent, GstPlay * play)
{
g_print ("Buffering: %d\n", percent);
}
static void
print_one_tag (const GstTagList * list, const gchar * tag, gpointer user_data)
{
gint i, num;
num = gst_tag_list_get_tag_size (list, tag);
for (i = 0; i < num; ++i) {
const GValue *val;
val = gst_tag_list_get_value_index (list, tag, i);
if (G_VALUE_HOLDS_STRING (val)) {
g_print (" %s : %s \n", tag, g_value_get_string (val));
} else if (G_VALUE_HOLDS_UINT (val)) {
g_print (" %s : %u \n", tag, g_value_get_uint (val));
} else if (G_VALUE_HOLDS_DOUBLE (val)) {
g_print (" %s : %g \n", tag, g_value_get_double (val));
} else if (G_VALUE_HOLDS_BOOLEAN (val)) {
g_print (" %s : %s \n", tag,
g_value_get_boolean (val) ? "true" : "false");
} else if (GST_VALUE_HOLDS_DATE_TIME (val)) {
GstDateTime *dt = g_value_get_boxed (val);
gchar *dt_str = gst_date_time_to_iso8601_string (dt);
g_print (" %s : %s \n", tag, dt_str);
g_free (dt_str);
} else {
g_print (" %s : tag of type '%s' \n", tag, G_VALUE_TYPE_NAME (val));
}
}
}
static void
print_video_info (GstPlayerVideoInfo * info)
{
gint fps_n, fps_d;
guint par_n, par_d;
if (info == NULL)
return;
g_print (" width : %d\n", gst_player_video_info_get_width (info));
g_print (" height : %d\n", gst_player_video_info_get_height (info));
g_print (" max_bitrate : %d\n",
gst_player_video_info_get_max_bitrate (info));
g_print (" bitrate : %d\n", gst_player_video_info_get_bitrate (info));
gst_player_video_info_get_framerate (info, &fps_n, &fps_d);
g_print (" framerate : %.2f\n", (gdouble) fps_n / fps_d);
gst_player_video_info_get_pixel_aspect_ratio (info, &par_n, &par_d);
g_print (" pixel-aspect-ratio %u:%u\n", par_n, par_d);
}
static void
print_audio_info (GstPlayerAudioInfo * info)
{
if (info == NULL)
return;
g_print (" sample rate : %d\n",
gst_player_audio_info_get_sample_rate (info));
g_print (" channels : %d\n", gst_player_audio_info_get_channels (info));
g_print (" max_bitrate : %d\n",
gst_player_audio_info_get_max_bitrate (info));
g_print (" bitrate : %d\n", gst_player_audio_info_get_bitrate (info));
g_print (" language : %s\n", gst_player_audio_info_get_language (info));
}
static void
print_subtitle_info (GstPlayerSubtitleInfo * info)
{
if (info == NULL)
return;
g_print (" language : %s\n", gst_player_subtitle_info_get_language (info));
}
static void
print_all_stream_info (GstPlayerMediaInfo * media_info)
{
guint count = 0;
GList *list, *l;
g_print ("URI : %s\n", gst_player_media_info_get_uri (media_info));
g_print ("Duration: %" GST_TIME_FORMAT "\n",
GST_TIME_ARGS (gst_player_media_info_get_duration (media_info)));
g_print ("Global taglist:\n");
if (gst_player_media_info_get_tags (media_info))
gst_tag_list_foreach (gst_player_media_info_get_tags (media_info),
print_one_tag, NULL);
else
g_print (" (nil) \n");
list = gst_player_media_info_get_stream_list (media_info);
if (!list)
return;
g_print ("All Stream information\n");
for (l = list; l != NULL; l = l->next) {
GstTagList *tags = NULL;
GstPlayerStreamInfo *stream = (GstPlayerStreamInfo *) l->data;
g_print (" Stream # %u \n", count++);
g_print (" type : %s_%u\n",
gst_player_stream_info_get_stream_type (stream),
gst_player_stream_info_get_index (stream));
tags = gst_player_stream_info_get_tags (stream);
g_print (" taglist : \n");
if (tags) {
gst_tag_list_foreach (tags, print_one_tag, NULL);
}
if (GST_IS_PLAYER_VIDEO_INFO (stream))
print_video_info ((GstPlayerVideoInfo *) stream);
else if (GST_IS_PLAYER_AUDIO_INFO (stream))
print_audio_info ((GstPlayerAudioInfo *) stream);
else
print_subtitle_info ((GstPlayerSubtitleInfo *) stream);
}
}
static void
print_all_video_stream (GstPlayerMediaInfo * media_info)
{
GList *list, *l;
list = gst_player_get_video_streams (media_info);
if (!list)
return;
g_print ("All video streams\n");
for (l = list; l != NULL; l = l->next) {
GstPlayerVideoInfo *info = (GstPlayerVideoInfo *) l->data;
GstPlayerStreamInfo *sinfo = (GstPlayerStreamInfo *) info;
g_print (" %s_%d #\n", gst_player_stream_info_get_stream_type (sinfo),
gst_player_stream_info_get_index (sinfo));
print_video_info (info);
}
}
static void
print_all_subtitle_stream (GstPlayerMediaInfo * media_info)
{
GList *list, *l;
list = gst_player_get_subtitle_streams (media_info);
if (!list)
return;
g_print ("All subtitle streams:\n");
for (l = list; l != NULL; l = l->next) {
GstPlayerSubtitleInfo *info = (GstPlayerSubtitleInfo *) l->data;
GstPlayerStreamInfo *sinfo = (GstPlayerStreamInfo *) info;
g_print (" %s_%d #\n", gst_player_stream_info_get_stream_type (sinfo),
gst_player_stream_info_get_index (sinfo));
print_subtitle_info (info);
}
}
static void
print_all_audio_stream (GstPlayerMediaInfo * media_info)
{
GList *list, *l;
list = gst_player_get_audio_streams (media_info);
if (!list)
return;
g_print ("All audio streams: \n");
for (l = list; l != NULL; l = l->next) {
GstPlayerAudioInfo *info = (GstPlayerAudioInfo *) l->data;
GstPlayerStreamInfo *sinfo = (GstPlayerStreamInfo *) info;
g_print (" %s_%d #\n", gst_player_stream_info_get_stream_type (sinfo),
gst_player_stream_info_get_index (sinfo));
print_audio_info (info);
}
}
static void
print_current_tracks (GstPlay * play)
{
GstPlayerAudioInfo *audio = NULL;
GstPlayerVideoInfo *video = NULL;
GstPlayerSubtitleInfo *subtitle = NULL;
g_print ("Current video track: \n");
video = gst_player_get_current_video_track (play->player);
print_video_info (video);
g_print ("Current audio track: \n");
audio = gst_player_get_current_audio_track (play->player);
print_audio_info (audio);
g_print ("Current subtitle track: \n");
subtitle = gst_player_get_current_subtitle_track (play->player);
print_subtitle_info (subtitle);
if (audio)
g_object_unref (audio);
if (video)
g_object_unref (video);
if (subtitle)
g_object_unref (subtitle);
}
static void
print_media_info (GstPlayerMediaInfo * media_info)
{
print_all_stream_info (media_info);
g_print ("\n");
print_all_video_stream (media_info);
g_print ("\n");
print_all_audio_stream (media_info);
g_print ("\n");
print_all_subtitle_stream (media_info);
}
static void
media_info_cb (GstPlayer * player, GstPlayerMediaInfo * info, GstPlay * play)
{
static int once = 0;
if (!once) {
print_media_info (info);
print_current_tracks (play);
once = 1;
}
}
static GstPlay *
play_new (gchar ** uris, gdouble initial_volume)
{
GstPlay *play;
play = g_new0 (GstPlay, 1);
play->uris = uris;
play->num_uris = g_strv_length (uris);
play->cur_idx = -1;
play->player =
gst_player_new (NULL, gst_player_g_main_context_signal_dispatcher_new
(NULL));
g_signal_connect (play->player, "position-updated",
G_CALLBACK (position_updated_cb), play);
g_signal_connect (play->player, "state-changed",
G_CALLBACK (state_changed_cb), play);
g_signal_connect (play->player, "buffering", G_CALLBACK (buffering_cb), play);
g_signal_connect (play->player, "end-of-stream",
G_CALLBACK (end_of_stream_cb), play);
g_signal_connect (play->player, "error", G_CALLBACK (error_cb), play);
g_signal_connect (play->player, "media-info-updated",
G_CALLBACK (media_info_cb), play);
play->loop = g_main_loop_new (NULL, FALSE);
play->desired_state = GST_STATE_PLAYING;
play_set_relative_volume (play, initial_volume - 1.0);
return play;
}
static void
play_free (GstPlay * play)
{
play_reset (play);
gst_object_unref (play->player);
g_main_loop_unref (play->loop);
g_strfreev (play->uris);
g_free (play);
}
/* reset for new file/stream */
static void
play_reset (GstPlay * play)
{
}
static void
play_set_relative_volume (GstPlay * play, gdouble volume_step)
{
gdouble volume;
g_object_get (play->player, "volume", &volume, NULL);
volume = round ((volume + volume_step) * VOLUME_STEPS) / VOLUME_STEPS;
volume = CLAMP (volume, 0.0, 10.0);
g_object_set (play->player, "volume", volume, NULL);
g_print ("Volume: %.0f%% \n", volume * 100);
}
static gchar *
play_uri_get_display_name (GstPlay * play, const gchar * uri)
{
gchar *loc;
if (gst_uri_has_protocol (uri, "file")) {
loc = g_filename_from_uri (uri, NULL, NULL);
} else if (gst_uri_has_protocol (uri, "pushfile")) {
loc = g_filename_from_uri (uri + 4, NULL, NULL);
} else {
loc = g_strdup (uri);
}
/* Maybe additionally use glib's filename to display name function */
return loc;
}
static void
play_uri (GstPlay * play, const gchar * next_uri)
{
gchar *loc;
play_reset (play);
loc = play_uri_get_display_name (play, next_uri);
g_print ("Now playing %s\n", loc);
g_free (loc);
g_object_set (play->player, "uri", next_uri, NULL);
gst_player_play (play->player);
}
/* returns FALSE if we have reached the end of the playlist */
static gboolean
play_next (GstPlay * play)
{
if ((play->cur_idx + 1) >= play->num_uris) {
if (play->repeat) {
g_print ("Looping playlist \n");
play->cur_idx = -1;
} else
return FALSE;
}
play_uri (play, play->uris[++play->cur_idx]);
return TRUE;
}
/* returns FALSE if we have reached the beginning of the playlist */
static gboolean
play_prev (GstPlay * play)
{
if (play->cur_idx == 0 || play->num_uris <= 1)
return FALSE;
play_uri (play, play->uris[--play->cur_idx]);
return TRUE;
}
static void
do_play (GstPlay * play)
{
gint i;
/* dump playlist */
for (i = 0; i < play->num_uris; ++i)
GST_INFO ("%4u : %s", i, play->uris[i]);
if (!play_next (play))
return;
g_main_loop_run (play->loop);
}
static void
add_to_playlist (GPtrArray * playlist, const gchar * filename)
{
GDir *dir;
gchar *uri;
if (gst_uri_is_valid (filename)) {
g_ptr_array_add (playlist, g_strdup (filename));
return;
}
if ((dir = g_dir_open (filename, 0, NULL))) {
const gchar *entry;
/* FIXME: sort entries for each directory? */
while ((entry = g_dir_read_name (dir))) {
gchar *path;
path = g_strconcat (filename, G_DIR_SEPARATOR_S, entry, NULL);
add_to_playlist (playlist, path);
g_free (path);
}
g_dir_close (dir);
return;
}
uri = gst_filename_to_uri (filename, NULL);
if (uri != NULL)
g_ptr_array_add (playlist, uri);
else
g_warning ("Could not make URI out of filename '%s'", filename);
}
static void
shuffle_uris (gchar ** uris, guint num)
{
gchar *tmp;
guint i, j;
if (num < 2)
return;
for (i = 0; i < num; i++) {
/* gets equally distributed random number in 0..num-1 [0;num[ */
j = g_random_int_range (0, num);
tmp = uris[j];
uris[j] = uris[i];
uris[i] = tmp;
}
}
static void
restore_terminal (void)
{
gst_play_kb_set_key_handler (NULL, NULL);
}
static void
toggle_paused (GstPlay * play)
{
if (play->desired_state == GST_STATE_PLAYING) {
play->desired_state = GST_STATE_PAUSED;
gst_player_pause (play->player);
} else {
play->desired_state = GST_STATE_PLAYING;
gst_player_play (play->player);
}
}
static void
relative_seek (GstPlay * play, gdouble percent)
{
gint64 dur = -1, pos = -1;
g_return_if_fail (percent >= -1.0 && percent <= 1.0);
g_object_get (play->player, "position", &pos, "duration", &dur, NULL);
if (dur <= 0) {
g_print ("\nCould not seek.\n");
return;
}
pos = pos + dur * percent;
if (pos < 0)
pos = 0;
gst_player_seek (play->player, pos);
}
static void
keyboard_cb (const gchar * key_input, gpointer user_data)
{
GstPlay *play = (GstPlay *) user_data;
switch (g_ascii_tolower (key_input[0])) {
case 'i':
{
GstPlayerMediaInfo *media_info = gst_player_get_media_info (play->player);
if (media_info) {
print_media_info (media_info);
g_object_unref (media_info);
print_current_tracks (play);
}
break;
}
case ' ':
toggle_paused (play);
break;
case 'q':
case 'Q':
g_main_loop_quit (play->loop);
break;
case '>':
if (!play_next (play)) {
g_print ("\nReached end of play list.\n");
g_main_loop_quit (play->loop);
}
break;
case '<':
play_prev (play);
break;
case 27: /* ESC */
if (key_input[1] == '\0') {
g_main_loop_quit (play->loop);
break;
}
/* fall through */
default:
if (strcmp (key_input, GST_PLAY_KB_ARROW_RIGHT) == 0) {
relative_seek (play, +0.08);
} else if (strcmp (key_input, GST_PLAY_KB_ARROW_LEFT) == 0) {
relative_seek (play, -0.01);
} else if (strcmp (key_input, GST_PLAY_KB_ARROW_UP) == 0) {
play_set_relative_volume (play, +1.0 / VOLUME_STEPS);
} else if (strcmp (key_input, GST_PLAY_KB_ARROW_DOWN) == 0) {
play_set_relative_volume (play, -1.0 / VOLUME_STEPS);
} else {
GST_INFO ("keyboard input:");
for (; *key_input != '\0'; ++key_input)
GST_INFO (" code %3d", *key_input);
}
break;
}
}
int
main (int argc, char **argv)
{
GstPlay *play;
GPtrArray *playlist;
gboolean print_version = FALSE;
gboolean interactive = FALSE; /* FIXME: maybe enable by default? */
gboolean shuffle = FALSE;
gboolean repeat = FALSE;
gdouble volume = 1.0;
gchar **filenames = NULL;
gchar **uris;
guint num, i;
GError *err = NULL;
GOptionContext *ctx;
gchar *playlist_file = NULL;
GOptionEntry options[] = {
{"version", 0, 0, G_OPTION_ARG_NONE, &print_version,
"Print version information and exit", NULL},
{"shuffle", 0, 0, G_OPTION_ARG_NONE, &shuffle,
"Shuffle playlist", NULL},
{"interactive", 0, 0, G_OPTION_ARG_NONE, &interactive,
"Interactive control via keyboard", NULL},
{"volume", 0, 0, G_OPTION_ARG_DOUBLE, &volume,
"Volume", NULL},
{"playlist", 0, 0, G_OPTION_ARG_FILENAME, &playlist_file,
"Playlist file containing input media files", NULL},
{"loop", 0, 0, G_OPTION_ARG_NONE, &repeat, "Repeat all", NULL},
{G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames, NULL},
{NULL}
};
g_set_prgname ("gst-play");
ctx = g_option_context_new ("FILE1|URI1 [FILE2|URI2] [FILE3|URI3] ...");
g_option_context_add_main_entries (ctx, options, NULL);
g_option_context_add_group (ctx, gst_init_get_option_group ());
if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
g_print ("Error initializing: %s\n", GST_STR_NULL (err->message));
g_clear_error (&err);
g_option_context_free (ctx);
return 1;
}
g_option_context_free (ctx);
GST_DEBUG_CATEGORY_INIT (play_debug, "play", 0, "gst-play");
if (print_version) {
gchar *version_str;
version_str = gst_version_string ();
g_print ("%s version %s\n", g_get_prgname (), "1.0");
g_print ("%s\n", version_str);
g_free (version_str);
g_free (playlist_file);
return 0;
}
playlist = g_ptr_array_new ();
if (playlist_file != NULL) {
gchar *playlist_contents = NULL;
gchar **lines = NULL;
if (g_file_get_contents (playlist_file, &playlist_contents, NULL, &err)) {
lines = g_strsplit (playlist_contents, "\n", 0);
num = g_strv_length (lines);
for (i = 0; i < num; i++) {
if (lines[i][0] != '\0') {
GST_LOG ("Playlist[%d]: %s", i + 1, lines[i]);
add_to_playlist (playlist, lines[i]);
}
}
g_strfreev (lines);
g_free (playlist_contents);
} else {
g_printerr ("Could not read playlist: %s\n", err->message);
g_clear_error (&err);
}
g_free (playlist_file);
playlist_file = NULL;
}
if (playlist->len == 0 && (filenames == NULL || *filenames == NULL)) {
g_printerr ("Usage: %s FILE1|URI1 [FILE2|URI2] [FILE3|URI3] ...",
"gst-play");
g_printerr ("\n\n"),
g_printerr ("%s\n\n",
"You must provide at least one filename or URI to play.");
/* No input provided. Free array */
g_ptr_array_free (playlist, TRUE);
return 1;
}
/* fill playlist */
if (filenames != NULL && *filenames != NULL) {
num = g_strv_length (filenames);
for (i = 0; i < num; ++i) {
GST_LOG ("command line argument: %s", filenames[i]);
add_to_playlist (playlist, filenames[i]);
}
g_strfreev (filenames);
}
num = playlist->len;
g_ptr_array_add (playlist, NULL);
uris = (gchar **) g_ptr_array_free (playlist, FALSE);
if (shuffle)
shuffle_uris (uris, num);
/* prepare */
play = play_new (uris, volume);
play->repeat = repeat;
if (interactive) {
if (gst_play_kb_set_key_handler (keyboard_cb, play)) {
atexit (restore_terminal);
} else {
g_print ("Interactive keyboard handling in terminal not available.\n");
}
}
/* play */
do_play (play);
/* clean up */
play_free (play);
g_print ("\n");
gst_deinit ();
return 0;
}

View file

@ -0,0 +1,35 @@
bin_PROGRAMS = gtk-play
gtk-play-resources.c: resources/gresources.xml \
resources/media_info_dialog.ui \
resources/toolbar.css \
resources/toolbar.ui
$(AM_V_GEN) \
glib-compile-resources \
--sourcedir=$(srcdir)/resources \
--target=$@ \
--generate-source \
--c-name as \
$(srcdir)/resources/gresources.xml
gtk-play-resources.h: resources/gresources.xml \
resources/media_info_dialog.ui \
resources/toolbar.css \
resources/toolbar.ui
$(AM_V_GEN) \
glib-compile-resources \
--sourcedir=$(srcdir)/resources \
--target=$@ \
--generate-header \
--c-name as \
$(srcdir)/resources/gresources.xml
BUILT_SOURCES: gtk-play-resources.c gtk-play-resources.h
gtk_play_SOURCES = gtk-play.c gtk-play-resources.c gtk-video-renderer.c
LDADD = $(GSTREAMER_LIBS) $(GTK_LIBS) $(GTK_X11_LIBS) $(GLIB_LIBS) $(LIBM) $(GMODULE_LIBS)
AM_CFLAGS = $(GSTREAMER_CFLAGS) $(GTK_CFLAGS) $(GTK_X11_CFLAGS) $(GLIB_CFLAGS) $(GMODULE_CFLAGS) $(WARNING_CFLAGS)
noinst_HEADERS = gtk-play-resources.h gtk-video-renderer.h

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,178 @@
/* GStreamer
*
* Copyright (C) 2015 Sebastian Dröge <sebastian@centricular.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "gtk-video-renderer.h"
struct _GstPlayerGtkVideoRenderer
{
GObject parent;
GstElement *sink;
GtkWidget *widget;
};
struct _GstPlayerGtkVideoRendererClass
{
GObjectClass parent_class;
};
static void
gst_player_gtk_video_renderer_interface_init
(GstPlayerVideoRendererInterface * iface);
enum
{
GTK_VIDEO_RENDERER_PROP_0,
GTK_VIDEO_RENDERER_PROP_WIDGET,
GTK_VIDEO_RENDERER_PROP_LAST
};
G_DEFINE_TYPE_WITH_CODE (GstPlayerGtkVideoRenderer,
gst_player_gtk_video_renderer, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GST_TYPE_PLAYER_VIDEO_RENDERER,
gst_player_gtk_video_renderer_interface_init));
static GParamSpec
* gtk_video_renderer_param_specs[GTK_VIDEO_RENDERER_PROP_LAST] = { NULL, };
static void
gst_player_gtk_video_renderer_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec)
{
GstPlayerGtkVideoRenderer *self = GST_PLAYER_GTK_VIDEO_RENDERER (object);
switch (prop_id) {
case GTK_VIDEO_RENDERER_PROP_WIDGET:
g_value_set_object (value, self->widget);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_player_gtk_video_renderer_finalize (GObject * object)
{
GstPlayerGtkVideoRenderer *self = GST_PLAYER_GTK_VIDEO_RENDERER (object);
if (self->sink)
gst_object_unref (self->sink);
if (self->widget)
g_object_unref (self->widget);
G_OBJECT_CLASS
(gst_player_gtk_video_renderer_parent_class)->finalize (object);
}
static void
gst_player_gtk_video_renderer_class_init
(GstPlayerGtkVideoRendererClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->get_property = gst_player_gtk_video_renderer_get_property;
gobject_class->finalize = gst_player_gtk_video_renderer_finalize;
gtk_video_renderer_param_specs
[GTK_VIDEO_RENDERER_PROP_WIDGET] =
g_param_spec_object ("widget", "Widget",
"Widget to render the video into", GTK_TYPE_WIDGET,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (gobject_class,
GTK_VIDEO_RENDERER_PROP_LAST, gtk_video_renderer_param_specs);
}
static void
gst_player_gtk_video_renderer_init (GstPlayerGtkVideoRenderer * self)
{
GstElement *gtk_sink = gst_element_factory_make ("gtkglsink", NULL);
if (gtk_sink) {
GstElement *sink = gst_element_factory_make ("glsinkbin", NULL);
g_object_set (sink, "sink", gtk_sink, NULL);
self->sink = sink;
} else {
gtk_sink = gst_element_factory_make ("gtksink", NULL);
self->sink = gst_object_ref (gtk_sink);
}
g_assert (self->sink != NULL);
g_object_get (gtk_sink, "widget", &self->widget, NULL);
gst_object_unref (gtk_sink);
}
static GstElement *gst_player_gtk_video_renderer_create_video_sink
(GstPlayerVideoRenderer * iface, GstPlayer * player)
{
GstPlayerGtkVideoRenderer *self = GST_PLAYER_GTK_VIDEO_RENDERER (iface);
return gst_object_ref (self->sink);
}
static void
gst_player_gtk_video_renderer_interface_init
(GstPlayerVideoRendererInterface * iface)
{
iface->create_video_sink = gst_player_gtk_video_renderer_create_video_sink;
}
/**
* gst_player_gtk_video_renderer_new:
*
* Returns: (transfer full):
*/
GstPlayerVideoRenderer *
gst_player_gtk_video_renderer_new (void)
{
GstElementFactory *factory;
factory = gst_element_factory_find ("gtkglsink");
if (!factory)
factory = gst_element_factory_find ("gtksink");
if (!factory)
return NULL;
gst_object_unref (factory);
return g_object_new (GST_TYPE_PLAYER_GTK_VIDEO_RENDERER, NULL);
}
/**
* gst_player_gtk_video_renderer_get_widget:
* @self: #GstPlayerVideoRenderer instance
*
* Returns: (transfer full): The GtkWidget
*/
GtkWidget *gst_player_gtk_video_renderer_get_widget
(GstPlayerGtkVideoRenderer * self)
{
GtkWidget *widget;
g_return_val_if_fail (GST_IS_PLAYER_GTK_VIDEO_RENDERER (self), NULL);
g_object_get (self, "widget", &widget, NULL);
return widget;
}

View file

@ -0,0 +1,49 @@
/* GStreamer
*
* Copyright (C) 2015 Sebastian Dröge <sebastian@centricular.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GTK_VIDEO_RENDERER_H__
#define __GTK_VIDEO_RENDERER_H__
#include <gst/player/player.h>
#include <gtk/gtk.h>
G_BEGIN_DECLS
typedef struct _GstPlayerGtkVideoRenderer
GstPlayerGtkVideoRenderer;
typedef struct _GstPlayerGtkVideoRendererClass
GstPlayerGtkVideoRendererClass;
#define GST_TYPE_PLAYER_GTK_VIDEO_RENDERER (gst_player_gtk_video_renderer_get_type ())
#define GST_IS_PLAYER_GTK_VIDEO_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PLAYER_GTK_VIDEO_RENDERER))
#define GST_IS_PLAYER_GTK_VIDEO_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PLAYER_GTK_VIDEO_RENDERER))
#define GST_PLAYER_GTK_VIDEO_RENDERER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_PLAYER_GTK_VIDEO_RENDERER, GstPlayerGtkVideoRendererClass))
#define GST_PLAYER_GTK_VIDEO_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PLAYER_GTK_VIDEO_RENDERER, GstPlayerGtkVideoRenderer))
#define GST_PLAYER_GTK_VIDEO_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PLAYER_GTK_VIDEO_RENDERER, GstPlayerGtkVideoRendererClass))
#define GST_PLAYER_GTK_VIDEO_RENDERER_CAST(obj) ((GstPlayerGtkVideoRenderer*)(obj))
GType gst_player_gtk_video_renderer_get_type (void);
GstPlayerVideoRenderer * gst_player_gtk_video_renderer_new (void);
GtkWidget * gst_player_gtk_video_renderer_get_widget (GstPlayerGtkVideoRenderer * self);
G_END_DECLS
#endif /* __GTK_VIDEO_RENDERER_H__ */

View file

@ -0,0 +1,11 @@
<? xml version="1.0" encoding="UTF-8" ?>
<gresources>
<gresource prefix="/ui">
<file>toolbar.ui</file>
<file>media_info_dialog.ui</file>
</gresource>
<gresource prefix="/css">
<file>toolbar.css</file>
</gresource>
</gresources>

View file

@ -0,0 +1,108 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<interface>
<requires lib="gtk+" version="3.10"/>
<object class="GtkTreeStore" id="tree">
<columns>
<!-- column-name gchararray1 -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkDialog" id="media_info_dialog">
<property name="name">media_info_dialog</property>
<property name="can_focus">False</property>
<property name="window_position">center-on-parent</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox" id="dialog-action_area1">
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="media_info_dialog_button">
<property name="label" translatable="yes">Close</property>
<property name="name">media_info_dialog_button</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="media_info_dialog_button_clicked_cb" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_bottom">5</property>
<property name="label" translatable="yes">Information about all the streams contains in your media. </property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="sw">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="margin_top">5</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="view">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="model">tree</property>
<property name="headers_visible">False</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection2"/>
</child>
<child>
<object class="GtkTreeViewColumn" id="col">
<property name="sizing">autosize</property>
<property name="title" translatable="yes">col</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext1"/>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

View file

@ -0,0 +1,26 @@
* {
background-color: rgba(43,56,54,0.0);
padding: 0px;
}
GtkLabel {
font-size: 10px;
color: #ffffff;
}
#toolbar {
border-radius: 25px;
border: 3px solid #212B2A;
background: rgba(43,56,54,0.6);
}
GtkButton:hover {
border-radius: 45px;
background: rgba(43,56,54,1.0);
border: 1px solid #212B2A;
}
#title_label {
font-size: 12px;
}

View file

@ -0,0 +1,341 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<interface>
<requires lib="gtk+" version="3.12"/>
<!-- interface-css-provider-path controls.css -->
<object class="GtkImage" id="forward_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixel_size">30</property>
<property name="icon_name">media-seek-forward</property>
<property name="icon_size">0</property>
</object>
<object class="GtkImage" id="fullscreen_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixel_size">25</property>
<property name="icon_name">view-fullscreen</property>
<property name="icon_size">0</property>
</object>
<object class="GtkImage" id="next_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixel_size">30</property>
<property name="icon_name">media-skip-forward</property>
<property name="icon_size">0</property>
</object>
<object class="GtkImage" id="pause_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixel_size">35</property>
<property name="icon_name">media-playback-pause</property>
<property name="icon_size">0</property>
</object>
<object class="GtkImage" id="play_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<property name="pixel_size">35</property>
<property name="icon_name">media-playback-start</property>
<property name="icon_size">0</property>
</object>
<object class="GtkImage" id="prev_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixel_size">30</property>
<property name="icon_name">media-skip-backward</property>
</object>
<object class="GtkImage" id="restore_image">
<property name="name">restore_image</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixel_size">25</property>
<property name="icon_name">view-restore</property>
<property name="icon_size">0</property>
</object>
<object class="GtkImage" id="rewind_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixel_size">30</property>
<property name="icon_name">media-seek-backward</property>
</object>
<object class="GtkBox" id="toolbar">
<property name="name">toolbar</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_bottom">5</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">20</property>
<property name="margin_right">20</property>
<property name="spacing">9</property>
<child>
<object class="GtkLabel" id="elapshed_time">
<property name="name">elapshed_time</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
<property name="label" translatable="yes">00:00</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScale" id="seekbar">
<property name="name">seekbar</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="valign">center</property>
<property name="round_digits">1</property>
<property name="draw_value">False</property>
<signal name="value-changed" handler="seekbar_value_changed_cb" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="remain_time">
<property name="name">remain_time</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
<property name="label" translatable="yes">00:00</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkVolumeButton" id="volume_button">
<property name="name">volume_button</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="valign">center</property>
<property name="relief">none</property>
<property name="focus_on_click">False</property>
<property name="orientation">vertical</property>
<property name="icons">audio-volume-muted
audio-volume-high
audio-volume-low
audio-volume-medium</property>
<signal name="value-changed" handler="volume_button_value_changed_cb" swapped="no"/>
<child internal-child="plus_button">
<object class="GtkButton" id="volumebutton-plus_button1">
<property name="label" translatable="yes">+</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="relief">none</property>
</object>
</child>
<child internal-child="minus_button">
<object class="GtkButton" id="volumebutton-minus_button1">
<property name="label" translatable="yes">-</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="relief">none</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkToggleButton" id="fullscreen_button">
<property name="name">fullscreen_button</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="image">fullscreen_image</property>
<property name="relief">none</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<signal name="toggled" handler="fullscreen_button_toggled_cb" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">-1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="title_label">
<property name="name">title_label</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">5</property>
<property name="justify">center</property>
<property name="wrap">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
<property name="margin_left">20</property>
<property name="margin_right">20</property>
<property name="margin_bottom">10</property>
<child>
<object class="GtkBox" id="box4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="spacing">5</property>
<child>
<object class="GtkButton" id="prev_button">
<property name="name">prev_button</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="valign">center</property>
<property name="image">prev_image</property>
<property name="relief">none</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<signal name="clicked" handler="prev_button_clicked_cb" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="rewind_button">
<property name="name">rewind_button</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="image">rewind_image</property>
<property name="relief">none</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<signal name="clicked" handler="rewind_button_clicked_cb" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="play_pause_button">
<property name="name">play_pause_button</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="valign">center</property>
<property name="image">pause_image</property>
<property name="relief">none</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<signal name="clicked" handler="play_pause_button_clicked_cb" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="forward_button">
<property name="name">forward_button</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="valign">center</property>
<property name="image">forward_image</property>
<property name="relief">none</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<signal name="clicked" handler="forward_button_clicked_cb" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkButton" id="next_button">
<property name="name">next_button</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="valign">center</property>
<property name="image">next_image</property>
<property name="relief">none</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<signal name="clicked" handler="next_button_clicked_cb" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="rate_label">
<property name="name">rate_label</property>
<property name="width_request">40</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<property name="justify">right</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</interface>

View file

@ -0,0 +1,422 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
19A17EFC8D41A75E8D3DB72E /* OnlineMedia.plist in Resources */ = {isa = PBXBuildFile; fileRef = 19A176455D27298FE4041DC3 /* OnlineMedia.plist */; };
AD2B881F198D631B0070367B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD2B881E198D631B0070367B /* Foundation.framework */; };
AD2B8821198D631B0070367B /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD2B8820198D631B0070367B /* CoreGraphics.framework */; };
AD2B8823198D631B0070367B /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD2B8822198D631B0070367B /* UIKit.framework */; };
AD2B8825198D631B0070367B /* GStreamer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD2B8824198D631B0070367B /* GStreamer.framework */; };
AD2B882B198D631B0070367B /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = AD2B8829198D631B0070367B /* InfoPlist.strings */; };
AD2B882D198D631B0070367B /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = AD2B882C198D631B0070367B /* main.m */; };
AD2B8831198D631B0070367B /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = AD2B8830198D631B0070367B /* AppDelegate.m */; };
AD2B8833198D631B0070367B /* fonts.conf in Resources */ = {isa = PBXBuildFile; fileRef = AD2B8832198D631B0070367B /* fonts.conf */; };
AD2B8835198D631B0070367B /* Ubuntu-R.ttf in Resources */ = {isa = PBXBuildFile; fileRef = AD2B8834198D631B0070367B /* Ubuntu-R.ttf */; };
AD2B8837198D631B0070367B /* gst_ios_init.m in Sources */ = {isa = PBXBuildFile; fileRef = AD2B8836198D631B0070367B /* gst_ios_init.m */; };
AD2B8858198D637A0070367B /* EaglUIVIew.m in Sources */ = {isa = PBXBuildFile; fileRef = AD2B8857198D637A0070367B /* EaglUIVIew.m */; };
AD2B885B198D65470070367B /* MainStoryboard_iPhone.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AD2B8859198D65470070367B /* MainStoryboard_iPhone.storyboard */; };
AD2B885C198D65470070367B /* MainStoryboard_iPad.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AD2B885A198D65470070367B /* MainStoryboard_iPad.storyboard */; };
AD2B8861198D65780070367B /* LibraryViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = AD2B885E198D65780070367B /* LibraryViewController.m */; };
AD2B8862198D65780070367B /* VideoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = AD2B8860198D65780070367B /* VideoViewController.m */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
19A176455D27298FE4041DC3 /* OnlineMedia.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = OnlineMedia.plist; sourceTree = "<group>"; };
AD2B881B198D631B0070367B /* GstPlay.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GstPlay.app; sourceTree = BUILT_PRODUCTS_DIR; };
AD2B881E198D631B0070367B /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
AD2B8820198D631B0070367B /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
AD2B8822198D631B0070367B /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
AD2B8824198D631B0070367B /* GStreamer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GStreamer.framework; path = Library/Frameworks/GStreamer.framework; sourceTree = DEVELOPER_DIR; };
AD2B8828198D631B0070367B /* GstPlay-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "GstPlay-Info.plist"; sourceTree = "<group>"; };
AD2B882A198D631B0070367B /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
AD2B882C198D631B0070367B /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
AD2B882E198D631B0070367B /* GstPlay-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "GstPlay-Prefix.pch"; sourceTree = "<group>"; };
AD2B882F198D631B0070367B /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
AD2B8830198D631B0070367B /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
AD2B8832198D631B0070367B /* fonts.conf */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = fonts.conf; sourceTree = "<group>"; };
AD2B8834198D631B0070367B /* Ubuntu-R.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Ubuntu-R.ttf"; sourceTree = "<group>"; };
AD2B8836198D631B0070367B /* gst_ios_init.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = gst_ios_init.m; sourceTree = "<group>"; };
AD2B8838198D631B0070367B /* gst_ios_init.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = gst_ios_init.h; sourceTree = "<group>"; };
AD2B8840198D631B0070367B /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; };
AD2B8856198D637A0070367B /* EaglUIVIew.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EaglUIVIew.h; sourceTree = "<group>"; };
AD2B8857198D637A0070367B /* EaglUIVIew.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EaglUIVIew.m; sourceTree = "<group>"; };
AD2B8859198D65470070367B /* MainStoryboard_iPhone.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = MainStoryboard_iPhone.storyboard; sourceTree = "<group>"; };
AD2B885A198D65470070367B /* MainStoryboard_iPad.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = MainStoryboard_iPad.storyboard; sourceTree = "<group>"; };
AD2B885D198D65780070367B /* LibraryViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LibraryViewController.h; sourceTree = "<group>"; };
AD2B885E198D65780070367B /* LibraryViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LibraryViewController.m; sourceTree = "<group>"; };
AD2B885F198D65780070367B /* VideoViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideoViewController.h; sourceTree = "<group>"; };
AD2B8860198D65780070367B /* VideoViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VideoViewController.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
AD2B8818198D631B0070367B /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
AD2B8821198D631B0070367B /* CoreGraphics.framework in Frameworks */,
AD2B8825198D631B0070367B /* GStreamer.framework in Frameworks */,
AD2B8823198D631B0070367B /* UIKit.framework in Frameworks */,
AD2B881F198D631B0070367B /* Foundation.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
AD2B8812198D631B0070367B = {
isa = PBXGroup;
children = (
AD2B8826198D631B0070367B /* GstPlay */,
AD2B881D198D631B0070367B /* Frameworks */,
AD2B881C198D631B0070367B /* Products */,
);
sourceTree = "<group>";
};
AD2B881C198D631B0070367B /* Products */ = {
isa = PBXGroup;
children = (
AD2B881B198D631B0070367B /* GstPlay.app */,
);
name = Products;
sourceTree = "<group>";
};
AD2B881D198D631B0070367B /* Frameworks */ = {
isa = PBXGroup;
children = (
AD2B881E198D631B0070367B /* Foundation.framework */,
AD2B8820198D631B0070367B /* CoreGraphics.framework */,
AD2B8822198D631B0070367B /* UIKit.framework */,
AD2B8824198D631B0070367B /* GStreamer.framework */,
AD2B8840198D631B0070367B /* XCTest.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
AD2B8826198D631B0070367B /* GstPlay */ = {
isa = PBXGroup;
children = (
AD2B8856198D637A0070367B /* EaglUIVIew.h */,
AD2B8857198D637A0070367B /* EaglUIVIew.m */,
AD2B882F198D631B0070367B /* AppDelegate.h */,
AD2B8830198D631B0070367B /* AppDelegate.m */,
AD2B8859198D65470070367B /* MainStoryboard_iPhone.storyboard */,
AD2B885A198D65470070367B /* MainStoryboard_iPad.storyboard */,
AD2B885D198D65780070367B /* LibraryViewController.h */,
AD2B885E198D65780070367B /* LibraryViewController.m */,
AD2B885F198D65780070367B /* VideoViewController.h */,
AD2B8860198D65780070367B /* VideoViewController.m */,
AD2B8827198D631B0070367B /* Supporting Files */,
19A176455D27298FE4041DC3 /* OnlineMedia.plist */,
);
path = GstPlay;
sourceTree = "<group>";
};
AD2B8827198D631B0070367B /* Supporting Files */ = {
isa = PBXGroup;
children = (
AD2B8828198D631B0070367B /* GstPlay-Info.plist */,
AD2B8829198D631B0070367B /* InfoPlist.strings */,
AD2B882C198D631B0070367B /* main.m */,
AD2B882E198D631B0070367B /* GstPlay-Prefix.pch */,
AD2B8832198D631B0070367B /* fonts.conf */,
AD2B8834198D631B0070367B /* Ubuntu-R.ttf */,
AD2B8836198D631B0070367B /* gst_ios_init.m */,
AD2B8838198D631B0070367B /* gst_ios_init.h */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
AD2B881A198D631B0070367B /* GstPlay */ = {
isa = PBXNativeTarget;
buildConfigurationList = AD2B8850198D631B0070367B /* Build configuration list for PBXNativeTarget "GstPlay" */;
buildPhases = (
AD2B8817198D631B0070367B /* Sources */,
AD2B8818198D631B0070367B /* Frameworks */,
AD2B8819198D631B0070367B /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = GstPlay;
productName = GstPlay;
productReference = AD2B881B198D631B0070367B /* GstPlay.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
AD2B8813198D631B0070367B /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0510;
ORGANIZATIONNAME = "Sebastian Dröge";
};
buildConfigurationList = AD2B8816198D631B0070367B /* Build configuration list for PBXProject "GstPlay" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = AD2B8812198D631B0070367B;
productRefGroup = AD2B881C198D631B0070367B /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
AD2B881A198D631B0070367B /* GstPlay */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
AD2B8819198D631B0070367B /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
AD2B885C198D65470070367B /* MainStoryboard_iPad.storyboard in Resources */,
AD2B885B198D65470070367B /* MainStoryboard_iPhone.storyboard in Resources */,
AD2B8835198D631B0070367B /* Ubuntu-R.ttf in Resources */,
AD2B8833198D631B0070367B /* fonts.conf in Resources */,
AD2B882B198D631B0070367B /* InfoPlist.strings in Resources */,
19A17EFC8D41A75E8D3DB72E /* OnlineMedia.plist in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
AD2B8817198D631B0070367B /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
AD2B8861198D65780070367B /* LibraryViewController.m in Sources */,
AD2B8831198D631B0070367B /* AppDelegate.m in Sources */,
AD2B8862198D65780070367B /* VideoViewController.m in Sources */,
AD2B8858198D637A0070367B /* EaglUIVIew.m in Sources */,
AD2B882D198D631B0070367B /* main.m in Sources */,
AD2B8837198D631B0070367B /* gst_ios_init.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
AD2B8829198D631B0070367B /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (
AD2B882A198D631B0070367B /* en */,
);
name = InfoPlist.strings;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
AD2B884E198D631B0070367B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 6.1;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
AD2B884F198D631B0070367B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
ENABLE_NS_ASSERTIONS = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 6.1;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
AD2B8851198D631B0070367B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = armv7;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
FRAMEWORK_SEARCH_PATHS = (
"~/Library/Developer/GStreamer/iPhone.sdk",
"$(DEVELOPER_FRAMEWORKS_DIR)",
);
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "GstPlay/GstPlay-Prefix.pch";
HEADER_SEARCH_PATHS = (
"\"~/Library/Developer/GStreamer/iPhone.sdk/GStreamer.framework/Headers\"",
../lib,
);
INFOPLIST_FILE = "GstPlay/GstPlay-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 6.1;
OTHER_LDFLAGS = (
"-lresolv",
"-lstdc++",
"-framework",
CoreFoundation,
"-framework",
Foundation,
"-framework",
AVFoundation,
"-framework",
CoreMedia,
"-framework",
CoreVideo,
"-framework",
CoreAudio,
"-framework",
AudioToolbox,
"-weak_framework",
VideoToolbox,
"-framework",
OpenGLES,
"-framework",
AssetsLibrary,
"-framework",
QuartzCore,
"-framework",
AssetsLibrary,
);
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
name = Debug;
};
AD2B8852198D631B0070367B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = armv7;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
FRAMEWORK_SEARCH_PATHS = (
"~/Library/Developer/GStreamer/iPhone.sdk",
"$(DEVELOPER_FRAMEWORKS_DIR)",
);
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "GstPlay/GstPlay-Prefix.pch";
HEADER_SEARCH_PATHS = (
"\"~/Library/Developer/GStreamer/iPhone.sdk/GStreamer.framework/Headers\"",
../lib,
);
INFOPLIST_FILE = "GstPlay/GstPlay-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 6.1;
OTHER_LDFLAGS = (
"-lresolv",
"-lstdc++",
"-framework",
CoreFoundation,
"-framework",
Foundation,
"-framework",
AVFoundation,
"-framework",
CoreMedia,
"-framework",
CoreVideo,
"-framework",
CoreAudio,
"-framework",
AudioToolbox,
"-weak_framework",
VideoToolbox,
"-framework",
OpenGLES,
"-framework",
AssetsLibrary,
"-framework",
QuartzCore,
"-framework",
AssetsLibrary,
);
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
AD2B8816198D631B0070367B /* Build configuration list for PBXProject "GstPlay" */ = {
isa = XCConfigurationList;
buildConfigurations = (
AD2B884E198D631B0070367B /* Debug */,
AD2B884F198D631B0070367B /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
AD2B8850198D631B0070367B /* Build configuration list for PBXNativeTarget "GstPlay" */ = {
isa = XCConfigurationList;
buildConfigurations = (
AD2B8851198D631B0070367B /* Debug */,
AD2B8852198D631B0070367B /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = AD2B8813198D631B0070367B /* Project object */;
}

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:GstPlay.xcodeproj">
</FileRef>
</Workspace>

View file

@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AD2B881A198D631B0070367B"
BuildableName = "GstPlay.app"
BlueprintName = "GstPlay"
ReferencedContainer = "container:GstPlay.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AD2B883E198D631B0070367B"
BuildableName = "GstPlayTests.xctest"
BlueprintName = "GstPlayTests"
ReferencedContainer = "container:GstPlay.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AD2B881A198D631B0070367B"
BuildableName = "GstPlay.app"
BlueprintName = "GstPlay"
ReferencedContainer = "container:GstPlay.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AD2B881A198D631B0070367B"
BuildableName = "GstPlay.app"
BlueprintName = "GstPlay"
ReferencedContainer = "container:GstPlay.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AD2B881A198D631B0070367B"
BuildableName = "GstPlay.app"
BlueprintName = "GstPlay"
ReferencedContainer = "container:GstPlay.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View file

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>GstPlay.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>AD2B881A198D631B0070367B</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>AD2B883E198D631B0070367B</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>

View file

@ -0,0 +1,15 @@
//
// AppDelegate.h
// GstPlay
//
// Created by Sebastian Dröge on 02/08/14.
// Copyright (c) 2014 Sebastian Dröge. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end

View file

@ -0,0 +1,45 @@
//
// AppDelegate.m
// GstPlay
//
// Created by Sebastian Dröge on 02/08/14.
// Copyright (c) 2014 Sebastian Dröge. All rights reserved.
//
#import "AppDelegate.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application
{
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
@end

View file

@ -0,0 +1,11 @@
#import <Foundation/Foundation.h>
#import <QuartzCore/QuartzCore.h>
#include <OpenGLES/ES2/gl.h>
#include <OpenGLES/ES2/glext.h>
@interface EaglUIView : UIView
{
}
@end

View file

@ -0,0 +1,13 @@
#import "EaglUIVIew.h"
#import <QuartzCore/QuartzCore.h>
@implementation EaglUIView
+ (Class) layerClass
{
return [CAEAGLLayer class];
}
@end

View file

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>org.freedesktop.gstreamer.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIMainStoryboardFile</key>
<string>MainStoryboard_iPhone</string>
<key>UIMainStoryboardFile~ipad</key>
<string>MainStoryboard_iPad</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>

View file

@ -0,0 +1,16 @@
//
// Prefix header
//
// The contents of this file are implicitly included at the beginning of every source file.
//
#import <Availability.h>
#ifndef __IPHONE_3_0
#warning "This project uses features only available in iOS SDK 3.0 and later."
#endif
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif

View file

@ -0,0 +1,12 @@
#import <UIKit/UIKit.h>
@interface LibraryViewController : UITableViewController
{
NSArray *libraryEntries;
NSArray *mediaEntries;
NSArray *onlineEntries;
}
- (IBAction)refresh:(id)sender;
@end

View file

@ -0,0 +1,136 @@
#import "LibraryViewController.h"
#import "VideoViewController.h"
#import <AssetsLibrary/AssetsLibrary.h>
@interface LibraryViewController ()
@end
@implementation LibraryViewController
- (void)viewDidLoad
{
[super viewDidLoad];
[super setTitle:@"Library"];
[self refreshMediaItems];
}
- (IBAction)refresh:(id)sender
{
[self refreshMediaItems];
[self.tableView reloadData];
}
static NSString *CellIdentifier = @"CellIdentifier";
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 3;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
switch (section)
{
case 0: return @"Photo library";
case 1: return @"iTunes file sharing";
default: return @"Online files";
}
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
switch (section) {
case 0:
return [self->libraryEntries count];
case 1:
return [self->mediaEntries count];
case 2:
return [self->onlineEntries count];
default:
return 0;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// Configure Cell
UILabel *title = (UILabel *)[cell.contentView viewWithTag:10];
UILabel *subtitle = (UILabel *)[cell.contentView viewWithTag:11];
switch (indexPath.section) {
case 0: subtitle.text = [self->libraryEntries objectAtIndex:indexPath.item];
break;
case 1: subtitle.text = [self->mediaEntries objectAtIndex:indexPath.item];
break;
case 2: subtitle.text = [self->onlineEntries objectAtIndex:indexPath.item];
break;
default:
break;
}
NSArray *components = [subtitle.text pathComponents];
title.text = components.lastObject;
return cell;
}
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
return NO;
}
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
return NO;
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"playVideo"]) {
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
VideoViewController *destViewController = segue.destinationViewController;
UITableViewCell *cell = [[self tableView] cellForRowAtIndexPath:indexPath];
UILabel *label = (UILabel *)[cell.contentView viewWithTag:10];
destViewController.title = label.text;
label = (UILabel *)[cell.contentView viewWithTag:11];
destViewController.uri = label.text;
}
}
- (void)refreshMediaItems {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSAllDomainsMask, YES);
NSString *docsPath = [paths objectAtIndex:0];
/* Entries from the Photo Library */
NSMutableArray *entries = [[NSMutableArray alloc] init];
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library enumerateGroupsWithTypes:ALAssetsGroupAll
usingBlock:^(ALAssetsGroup *group, BOOL *stop)
{
if (group) {
[group enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop)
{
if(result) {
[entries addObject:[NSString stringWithFormat:@"%@",[result valueForProperty:ALAssetPropertyAssetURL]]];
*stop = NO;
}
}];
} else {
[self.tableView reloadData];
}
}
failureBlock:^(NSError *error)
{
NSLog(@"ERROR");
}
];
self->libraryEntries = entries;
/* Retrieve entries from iTunes file sharing */
entries = [[NSMutableArray alloc] init];
for (NSString *e in [[NSFileManager defaultManager] contentsOfDirectoryAtPath:docsPath error:nil])
{
[entries addObject:[NSString stringWithFormat:@"file://%@/%@", docsPath, e]];
}
self->mediaEntries = entries;
self->onlineEntries = [NSArray arrayWithContentsOfURL:[[NSBundle mainBundle] URLForResource:@"OnlineMedia" withExtension:@"plist"]];
}
@end

View file

@ -0,0 +1,180 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="5056" systemVersion="13E28" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none" useAutolayout="YES" initialViewController="b7k-ZL-0G1">
<dependencies>
<deployment defaultVersion="1552" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3733"/>
</dependencies>
<scenes>
<!--Navigation Controller-->
<scene sceneID="3gA-ZI-2k3">
<objects>
<navigationController definesPresentationContext="YES" id="b7k-ZL-0G1" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" id="zhK-zc-ohc">
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
<segue destination="VW0-ax-bPv" kind="relationship" relationship="rootViewController" id="bWs-EK-FdN"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Sqh-T0-zkr" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-1459" y="-199"/>
</scene>
<!--VideoViewController-->
<scene sceneID="P93-nn-HBJ">
<objects>
<viewController title="Playback" id="z7O-8l-Zeo" userLabel="VideoViewController" customClass="VideoViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="tYu-BR-4pC"/>
<viewControllerLayoutGuide type="bottom" id="gDN-cX-tzD"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="CqS-Gu-I1O">
<rect key="frame" x="0.0" y="0.0" width="768" height="1024"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="xWd-bg-0b6" userLabel="VideoContainer">
<rect key="frame" x="0.0" y="0.0" width="768" height="959"/>
<subviews>
<view contentMode="scaleToFill" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="6tN-97-YoQ" userLabel="Video" customClass="EaglUIView">
<rect key="frame" x="224" y="360" width="320" height="240"/>
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" constant="240" id="A9A-eK-7QX"/>
<constraint firstAttribute="width" constant="320" id="xcj-6M-2KJ"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="centerY" secondItem="6tN-97-YoQ" secondAttribute="centerY" id="UYa-oM-cdf"/>
<constraint firstAttribute="centerX" secondItem="6tN-97-YoQ" secondAttribute="centerX" id="w9H-W0-MfF"/>
</constraints>
</view>
<toolbar opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="MUi-CE-Ydy">
<rect key="frame" x="0.0" y="980" width="768" height="44"/>
<constraints>
<constraint firstAttribute="height" constant="44" id="EwL-Ma-A4v"/>
</constraints>
<items>
<barButtonItem systemItem="play" id="UlF-Ga-2VX">
<connections>
<action selector="play:" destination="z7O-8l-Zeo" id="5xC-uv-9lM"/>
</connections>
</barButtonItem>
<barButtonItem systemItem="pause" id="J3O-8j-Tkt">
<connections>
<action selector="pause:" destination="z7O-8l-Zeo" id="BYM-2X-Tel"/>
</connections>
</barButtonItem>
<barButtonItem style="plain" id="s39-nx-e0L">
<textField key="customView" opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="00:00:00 / 00:00:00" borderStyle="roundedRect" textAlignment="center" minimumFontSize="17" id="G8q-Tu-Qx0" userLabel="Time">
<rect key="frame" x="67" y="7" width="140" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
</barButtonItem>
<barButtonItem style="plain" id="2n0-TO-8Ss">
<slider key="customView" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" minValue="0.0" maxValue="1" id="ufs-E5-87w" userLabel="Slider">
<rect key="frame" x="217" y="11" width="118" height="23"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<connections>
<action selector="sliderTouchDown:" destination="z7O-8l-Zeo" eventType="touchDown" id="yV6-eN-VUb"/>
<action selector="sliderTouchUp:" destination="z7O-8l-Zeo" eventType="touchCancel" id="OyS-WZ-sEk"/>
<action selector="sliderTouchUp:" destination="z7O-8l-Zeo" eventType="touchUpOutside" id="Vfz-se-pJg"/>
<action selector="sliderTouchUp:" destination="z7O-8l-Zeo" eventType="touchUpInside" id="kZF-uW-GRo"/>
<action selector="sliderValueChanged:" destination="z7O-8l-Zeo" eventType="valueChanged" id="cwm-pm-BfT"/>
</connections>
</slider>
</barButtonItem>
</items>
</toolbar>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="MUi-CE-Ydy" firstAttribute="trailing" secondItem="CqS-Gu-I1O" secondAttribute="trailing" constant="20" symbolic="YES" id="4vm-hF-9E8"/>
<constraint firstItem="xWd-bg-0b6" firstAttribute="top" secondItem="CqS-Gu-I1O" secondAttribute="top" id="MXr-HK-07f"/>
<constraint firstAttribute="trailing" secondItem="xWd-bg-0b6" secondAttribute="trailing" id="NGT-7D-rHD"/>
<constraint firstItem="MUi-CE-Ydy" firstAttribute="leading" secondItem="CqS-Gu-I1O" secondAttribute="leading" constant="20" symbolic="YES" id="OM9-gE-OVP"/>
<constraint firstItem="xWd-bg-0b6" firstAttribute="leading" secondItem="CqS-Gu-I1O" secondAttribute="leading" id="XO5-WJ-Y3R"/>
<constraint firstItem="MUi-CE-Ydy" firstAttribute="bottom" secondItem="CqS-Gu-I1O" secondAttribute="bottom" constant="20" symbolic="YES" id="w6K-xy-EJe"/>
</constraints>
</view>
<navigationItem key="navigationItem" id="fGF-kQ-bge"/>
<simulatedOrientationMetrics key="simulatedOrientationMetrics"/>
<connections>
<outlet property="pause_button" destination="J3O-8j-Tkt" id="Dls-sg-FPm"/>
<outlet property="play_button" destination="UlF-Ga-2VX" id="243-yq-GEe"/>
<outlet property="time_label" destination="G8q-Tu-Qx0" id="jpR-6u-zp0"/>
<outlet property="time_slider" destination="ufs-E5-87w" id="ZUd-jO-4qN"/>
<outlet property="toolbar" destination="MUi-CE-Ydy" id="Lme-0P-4Xq"/>
<outlet property="video_container_view" destination="xWd-bg-0b6" id="7dL-Mp-QGc"/>
<outlet property="video_height_constraint" destination="A9A-eK-7QX" id="rMe-ze-8l5"/>
<outlet property="video_view" destination="6tN-97-YoQ" id="Q0n-dR-hqv"/>
<outlet property="video_width_constraint" destination="xcj-6M-2KJ" id="oTt-9z-KCW"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iRS-GG-bR6" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="439" y="-199"/>
</scene>
<!--LibraryViewController-->
<scene sceneID="bq0-Ch-DBo">
<objects>
<tableViewController title="Library" id="VW0-ax-bPv" userLabel="LibraryViewController" customClass="LibraryViewController" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="44" sectionHeaderHeight="10" sectionFooterHeight="10" id="hAr-jJ-10J">
<rect key="frame" x="0.0" y="0.0" width="768" height="1024"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
<prototypes>
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" accessoryType="disclosureIndicator" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="CellIdentifier" textLabel="HoX-KW-H9G" detailTextLabel="iD6-8p-XIU" style="IBUITableViewCellStyleSubtitle" id="ujV-TF-eMq">
<rect key="frame" x="0.0" y="119" width="768" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="ujV-TF-eMq" id="SAN-nE-evy">
<rect key="frame" x="0.0" y="0.0" width="735" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" tag="10" contentMode="left" text="Title" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="HoX-KW-H9G">
<rect key="frame" x="15" y="2" width="36" height="22"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="18"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
</label>
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" tag="11" contentMode="left" text="Subtitle" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="iD6-8p-XIU">
<rect key="frame" x="15" y="24" width="50" height="17"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="0.50196078431372548" green="0.50196078431372548" blue="0.50196078431372548" alpha="1" colorSpace="calibratedRGB"/>
<color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
</label>
</subviews>
</tableViewCellContentView>
<connections>
<segue destination="z7O-8l-Zeo" kind="push" identifier="playVideo" id="wKB-w6-zJS"/>
</connections>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="VW0-ax-bPv" id="9qF-zP-TH5"/>
<outlet property="delegate" destination="VW0-ax-bPv" id="9Ss-rm-lAe"/>
</connections>
</tableView>
<navigationItem key="navigationItem" id="G3n-WN-bmw">
<barButtonItem key="rightBarButtonItem" systemItem="refresh" id="Gpf-LU-6E1" userLabel="Refresh">
<connections>
<action selector="refresh:" destination="VW0-ax-bPv" id="nUp-eS-LmM"/>
</connections>
</barButtonItem>
</navigationItem>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="7RK-lx-45a" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-478" y="-199"/>
</scene>
</scenes>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
<simulatedScreenMetrics key="destination"/>
</simulatedMetricsContainer>
</document>

View file

@ -0,0 +1,185 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="5056" systemVersion="13E28" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="z4I-U6-JHy">
<dependencies>
<deployment defaultVersion="1552" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3733"/>
</dependencies>
<scenes>
<!--Navigation Controller-->
<scene sceneID="2zM-sj-9dA">
<objects>
<navigationController definesPresentationContext="YES" id="z4I-U6-JHy" sceneMemberID="viewController">
<simulatedStatusBarMetrics key="simulatedStatusBarMetrics"/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="eHD-Ir-W2J">
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
<segue destination="bdY-7c-pia" kind="relationship" relationship="rootViewController" id="2oM-BQ-UIl"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="7VH-OE-ZqU" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-1459" y="-199"/>
</scene>
<!--VideoViewController-->
<scene sceneID="cnz-j4-g9W">
<objects>
<viewController title="Playback" id="iMo-Z9-PrL" userLabel="VideoViewController" customClass="VideoViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="amE-tW-f07"/>
<viewControllerLayoutGuide type="bottom" id="uvN-Av-Fcm"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="zgN-eK-M4Q">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="nA3-W2-kn7" userLabel="VideoContainer">
<rect key="frame" x="0.0" y="0.0" width="320" height="481"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="WHW-sv-bWc" userLabel="Video" customClass="EaglUIView">
<rect key="frame" x="0.0" y="121" width="320" height="240"/>
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" constant="240" id="5z2-ux-czd"/>
<constraint firstAttribute="width" constant="320" id="76i-Rz-yha"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="centerY" secondItem="WHW-sv-bWc" secondAttribute="centerY" id="3wK-Zr-bQY"/>
<constraint firstAttribute="centerX" secondItem="WHW-sv-bWc" secondAttribute="centerX" id="X5U-dh-PaZ"/>
</constraints>
</view>
<toolbar opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="A2w-65-QSF">
<rect key="frame" x="0.0" y="524" width="320" height="44"/>
<constraints>
<constraint firstAttribute="height" constant="44" id="apr-w6-VYs"/>
</constraints>
<items>
<barButtonItem style="plain" systemItem="flexibleSpace" id="Ixt-So-LpU"/>
<barButtonItem systemItem="play" id="8Yb-MS-rAF">
<connections>
<action selector="play:" destination="iMo-Z9-PrL" id="9nM-or-ZY7"/>
</connections>
</barButtonItem>
<barButtonItem systemItem="pause" id="nH5-s3-C0i">
<connections>
<action selector="pause:" destination="iMo-Z9-PrL" id="mef-Ij-Agl"/>
</connections>
</barButtonItem>
<barButtonItem style="plain" id="VUJ-y8-aWS">
<textField key="customView" opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="00:00:00 / 00:00:00" borderStyle="roundedRect" textAlignment="center" minimumFontSize="17" id="R6T-PH-VPd" userLabel="Time">
<rect key="frame" x="116" y="7" width="139" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
</barButtonItem>
<barButtonItem style="plain" systemItem="flexibleSpace" id="LSl-TA-0qV"/>
</items>
</toolbar>
<slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="0.5" minValue="0.0" maxValue="1" translatesAutoresizingMaskIntoConstraints="NO" id="4Ns-t9-gs7" userLabel="Slider">
<rect key="frame" x="-2" y="493" width="324" height="31"/>
<connections>
<action selector="sliderTouchDown:" destination="iMo-Z9-PrL" eventType="touchDown" id="jGO-Pw-b5d"/>
<action selector="sliderTouchUp:" destination="iMo-Z9-PrL" eventType="touchCancel" id="L1U-aK-FFn"/>
<action selector="sliderTouchUp:" destination="iMo-Z9-PrL" eventType="touchUpInside" id="jRZ-vw-FQR"/>
<action selector="sliderTouchUp:" destination="iMo-Z9-PrL" eventType="touchUpOutside" id="u1u-UD-WJw"/>
<action selector="sliderValueChanged:" destination="iMo-Z9-PrL" eventType="valueChanged" id="ZOq-XS-0M1"/>
</connections>
</slider>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="A2w-65-QSF" firstAttribute="leading" secondItem="zgN-eK-M4Q" secondAttribute="leading" constant="20" symbolic="YES" id="Aki-Hx-2C9"/>
<constraint firstItem="4Ns-t9-gs7" firstAttribute="trailing" secondItem="zgN-eK-M4Q" secondAttribute="trailing" id="HFi-uV-wdo"/>
<constraint firstAttribute="bottom" secondItem="nA3-W2-kn7" secondAttribute="bottom" constant="87" id="Jdn-RD-NPI"/>
<constraint firstItem="A2w-65-QSF" firstAttribute="trailing" secondItem="zgN-eK-M4Q" secondAttribute="trailing" constant="20" symbolic="YES" id="WWj-l6-D2k"/>
<constraint firstItem="A2w-65-QSF" firstAttribute="bottom" secondItem="zgN-eK-M4Q" secondAttribute="bottom" id="e3s-lP-iPh"/>
<constraint firstAttribute="trailing" secondItem="nA3-W2-kn7" secondAttribute="trailing" id="lOJ-ew-ZyI"/>
<constraint firstItem="nA3-W2-kn7" firstAttribute="top" secondItem="zgN-eK-M4Q" secondAttribute="top" id="lUb-ik-h6u"/>
<constraint firstItem="4Ns-t9-gs7" firstAttribute="leading" secondItem="zgN-eK-M4Q" secondAttribute="leading" id="ma4-AV-cQs"/>
<constraint firstItem="nA3-W2-kn7" firstAttribute="leading" secondItem="zgN-eK-M4Q" secondAttribute="leading" id="p8G-QE-uZ8"/>
<constraint firstAttribute="bottom" secondItem="4Ns-t9-gs7" secondAttribute="bottom" constant="45" id="qfD-gf-vLB"/>
</constraints>
</view>
<navigationItem key="navigationItem" id="xMw-um-vMA"/>
<simulatedStatusBarMetrics key="simulatedStatusBarMetrics"/>
<simulatedOrientationMetrics key="simulatedOrientationMetrics"/>
<connections>
<outlet property="pause_button" destination="nH5-s3-C0i" id="VWV-EW-jB6"/>
<outlet property="play_button" destination="8Yb-MS-rAF" id="5SI-l2-mAJ"/>
<outlet property="time_label" destination="R6T-PH-VPd" id="bGs-Zr-rv3"/>
<outlet property="time_slider" destination="4Ns-t9-gs7" id="9Ne-1N-clc"/>
<outlet property="video_container_view" destination="nA3-W2-kn7" id="lEY-hP-YHD"/>
<outlet property="video_height_constraint" destination="5z2-ux-czd" id="9R7-fg-G0e"/>
<outlet property="video_view" destination="WHW-sv-bWc" id="c6W-td-a74"/>
<outlet property="video_width_constraint" destination="76i-Rz-yha" id="vSP-Kk-v8g"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="YOs-uD-FMw" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-609" y="-199"/>
</scene>
<!--LibraryViewController-->
<scene sceneID="5eb-Di-aQ1">
<objects>
<tableViewController title="Library" id="bdY-7c-pia" userLabel="LibraryViewController" customClass="LibraryViewController" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="44" sectionHeaderHeight="10" sectionFooterHeight="10" id="4vG-QM-31k">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
<prototypes>
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" accessoryType="disclosureIndicator" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="CellIdentifier" textLabel="QLZ-ec-hHM" detailTextLabel="kAu-kE-DrP" style="IBUITableViewCellStyleSubtitle" id="nmS-s6-sIj">
<rect key="frame" x="0.0" y="119" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="nmS-s6-sIj" id="P61-er-gaf">
<rect key="frame" x="0.0" y="0.0" width="287" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" tag="10" contentMode="left" text="Title" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="QLZ-ec-hHM">
<rect key="frame" x="15" y="2" width="36" height="22"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="18"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
</label>
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" tag="11" contentMode="left" text="Subtitle" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="kAu-kE-DrP">
<rect key="frame" x="15" y="24" width="50" height="17"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="0.50196078430000002" green="0.50196078430000002" blue="0.50196078430000002" alpha="1" colorSpace="calibratedRGB"/>
<color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
</label>
</subviews>
</tableViewCellContentView>
<connections>
<segue destination="iMo-Z9-PrL" kind="push" identifier="playVideo" id="jW0-JJ-SqQ"/>
</connections>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="bdY-7c-pia" id="yhT-ag-TvP"/>
<outlet property="delegate" destination="bdY-7c-pia" id="usy-2O-hgr"/>
</connections>
</tableView>
<navigationItem key="navigationItem" id="3Tj-RI-j7Z">
<barButtonItem key="rightBarButtonItem" systemItem="refresh" id="B0E-4z-3fo" userLabel="Refresh">
<connections>
<action selector="refresh:" destination="bdY-7c-pia" id="3oQ-nv-MUd"/>
</connections>
</barButtonItem>
</navigationItem>
<simulatedStatusBarMetrics key="simulatedStatusBarMetrics"/>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="pXd-g9-Hdc" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-1036" y="-199"/>
</scene>
</scenes>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
<simulatedScreenMetrics key="destination" type="retina4"/>
</simulatedMetricsContainer>
</document>

View file

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<!-- Big Buck Bunny -->
<string>http://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_480p_surround-fix.avi</string>
<string>http://mirrorblender.top-ix.org/peach/bigbuckbunny_movies/big_buck_bunny_480p_h264.mov</string>
<string>http://mirrorblender.top-ix.org/peach/bigbuckbunny_movies/big_buck_bunny_480p_stereo.ogg</string>
<string>http://mirrorblender.top-ix.org/peach/bigbuckbunny_movies/big_buck_bunny_480p_stereo.avi</string>
<!--Sintel-->
<string>http://ftp.nluug.nl/ftp/graphics/blender/apricot/trailer/Sintel_Trailer1.480p.DivX_Plus_HD.mkv</string>
<string>http://ftp.nluug.nl/ftp/graphics/blender/apricot/trailer/sintel_trailer-480p.mp4</string>
<string>http://ftp.nluug.nl/ftp/graphics/blender/apricot/trailer/sintel_trailer-480p.ogv</string>
<string>http://mirrorblender.top-ix.org/movies/sintel-1024-surround.mp4</string>
<!--Tears of Steel-->
<string>http://blender-mirror.kino3d.org/mango/download.blender.org/demo/movies/ToS/tears_of_steel_720p.mkv</string>
<string>http://blender-mirror.kino3d.org/mango/download.blender.org/demo/movies/ToS/tears_of_steel_720p.mov</string>
<string>http://media.xiph.org/mango/tears_of_steel_1080p.webm</string>
<!--Radio stations-->
<string>http://radio.hbr1.com:19800/trance.ogg</string>
<string>http://radio.hbr1.com:19800/tronic.aac</string>
<!--Non-existing entries (to debug error reporting facilities)-->
<string>http://non-existing.org/Non_Existing_Server</string>
<string>http://docs.gstreamer.com/Non_Existing_File</string>
</array>
</plist>

Binary file not shown.

View file

@ -0,0 +1,23 @@
#import <UIKit/UIKit.h>
@interface VideoViewController : UIViewController {
IBOutlet UIBarButtonItem *play_button;
IBOutlet UIBarButtonItem *pause_button;
IBOutlet UIView *video_view;
IBOutlet UIView *video_container_view;
IBOutlet NSLayoutConstraint *video_width_constraint;
IBOutlet NSLayoutConstraint *video_height_constraint;
IBOutlet UIToolbar *toolbar;
IBOutlet UITextField *time_label;
IBOutlet UISlider *time_slider;
}
@property (retain,nonatomic) NSString *uri;
-(IBAction) play:(id)sender;
-(IBAction) pause:(id)sender;
-(IBAction) sliderValueChanged:(id)sender;
-(IBAction) sliderTouchDown:(id)sender;
-(IBAction) sliderTouchUp:(id)sender;
@end

View file

@ -0,0 +1,205 @@
#import "VideoViewController.h"
#import <gst/player/player.h>
#import <UIKit/UIKit.h>
@interface VideoViewController () {
GstPlayer *player;
int media_width; /* Width of the clip */
int media_height; /* height ofthe clip */
Boolean dragging_slider; /* Whether the time slider is being dragged or not */
Boolean is_local_media; /* Whether this clip is stored locally or is being streamed */
Boolean is_playing_desired; /* Whether the user asked to go to PLAYING */
}
@end
@implementation VideoViewController
@synthesize uri;
/*
* Private methods
*/
/* The text widget acts as an slave for the seek bar, so it reflects what the seek bar shows, whether
* it is an actual pipeline position or the position the user is currently dragging to. */
- (void) updateTimeWidget
{
NSInteger position = time_slider.value / 1000;
NSInteger duration = time_slider.maximumValue / 1000;
NSString *position_txt = @" -- ";
NSString *duration_txt = @" -- ";
if (duration > 0) {
NSUInteger hours = duration / (60 * 60);
NSUInteger minutes = (duration / 60) % 60;
NSUInteger seconds = duration % 60;
duration_txt = [NSString stringWithFormat:@"%02u:%02u:%02u", hours, minutes, seconds];
}
if (position > 0) {
NSUInteger hours = position / (60 * 60);
NSUInteger minutes = (position / 60) % 60;
NSUInteger seconds = position % 60;
position_txt = [NSString stringWithFormat:@"%02u:%02u:%02u", hours, minutes, seconds];
}
NSString *text = [NSString stringWithFormat:@"%@ / %@",
position_txt, duration_txt];
time_label.text = text;
}
/*
* Methods from UIViewController
*/
- (void)viewDidLoad
{
[super viewDidLoad];
/* As soon as the GStreamer backend knows the real values, these ones will be replaced */
media_width = 320;
media_height = 240;
player = gst_player_new (gst_player_video_overlay_video_renderer_new ((__bridge gpointer)(video_view)), NULL);
g_object_set (player, "uri", [uri UTF8String], NULL);
gst_debug_set_threshold_for_name("gst-player", GST_LEVEL_TRACE);
g_signal_connect (player, "position-updated", G_CALLBACK (position_updated), (__bridge gpointer) self);
g_signal_connect (player, "duration-changed", G_CALLBACK (duration_changed), (__bridge gpointer) self);
g_signal_connect (player, "video-dimensions-changed", G_CALLBACK (video_dimensions_changed), (__bridge gpointer) self);
is_local_media = [uri hasPrefix:@"file://"];
is_playing_desired = NO;
}
- (void)viewDidDisappear:(BOOL)animated
{
if (player)
{
gst_object_unref (player);
}
[UIApplication sharedApplication].idleTimerDisabled = NO;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/* Called when the Play button is pressed */
-(IBAction) play:(id)sender
{
gst_player_play (player);
is_playing_desired = YES;
[UIApplication sharedApplication].idleTimerDisabled = YES;
}
/* Called when the Pause button is pressed */
-(IBAction) pause:(id)sender
{
gst_player_pause(player);
is_playing_desired = NO;
[UIApplication sharedApplication].idleTimerDisabled = NO;
}
/* Called when the time slider position has changed, either because the user dragged it or
* we programmatically changed its position. dragging_slider tells us which one happened */
- (IBAction)sliderValueChanged:(id)sender {
if (!dragging_slider) return;
// If this is a local file, allow scrub seeking, this is, seek as soon as the slider is moved.
if (is_local_media)
gst_player_seek (player, time_slider.value * 1000000);
[self updateTimeWidget];
}
/* Called when the user starts to drag the time slider */
- (IBAction)sliderTouchDown:(id)sender {
gst_player_pause (player);
dragging_slider = YES;
}
/* Called when the user stops dragging the time slider */
- (IBAction)sliderTouchUp:(id)sender {
dragging_slider = NO;
// If this is a remote file, scrub seeking is probably not going to work smoothly enough.
// Therefore, perform only the seek when the slider is released.
if (!is_local_media)
gst_player_seek (player, ((long)time_slider.value) * 1000000);
if (is_playing_desired)
gst_player_play (player);
}
/* Called when the size of the main view has changed, so we can
* resize the sub-views in ways not allowed by storyboarding. */
- (void)viewDidLayoutSubviews
{
CGFloat view_width = video_container_view.bounds.size.width;
CGFloat view_height = video_container_view.bounds.size.height;
CGFloat correct_height = view_width * media_height / media_width;
CGFloat correct_width = view_height * media_width / media_height;
if (correct_height < view_height) {
video_height_constraint.constant = correct_height;
video_width_constraint.constant = view_width;
} else {
video_width_constraint.constant = correct_width;
video_height_constraint.constant = view_height;
}
time_slider.frame = CGRectMake(time_slider.frame.origin.x, time_slider.frame.origin.y, toolbar.frame.size.width - time_slider.frame.origin.x - 8, time_slider.frame.size.height);
}
static void video_dimensions_changed (GstPlayer * unused, gint width, gint height, VideoViewController * self)
{
dispatch_async(dispatch_get_main_queue(), ^{
if (width > 0 && height > 0) {
[self videoDimensionsChanged:width height:height];
}
});
}
-(void) videoDimensionsChanged:(NSInteger)width height:(NSInteger)height
{
media_width = width;
media_height = height;
[self viewDidLayoutSubviews];
[video_view setNeedsLayout];
[video_view layoutIfNeeded];
}
static void position_updated (GstPlayer * unused, GstClockTime position, VideoViewController *self)
{
dispatch_async(dispatch_get_main_queue(), ^{
[self positionUpdated:(int) (position / 1000000)];
});
}
-(void) positionUpdated:(NSInteger)position
{
/* Ignore messages from the pipeline if the time sliders is being dragged */
if (dragging_slider) return;
time_slider.value = position;
[self updateTimeWidget];
}
static void duration_changed (GstPlayer * unused, GstClockTime duration, VideoViewController *self)
{
dispatch_async(dispatch_get_main_queue(), ^{
[self durationChanged:(int) (duration / 1000000)];
});
}
-(void) durationChanged:(NSInteger)duration
{
time_slider.maximumValue = duration;
[self updateTimeWidget];
}
@end

View file

@ -0,0 +1,2 @@
/* Localized versions of Info.plist keys */

View file

@ -0,0 +1,126 @@
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!-- /etc/fonts/fonts.conf file to configure system font access -->
<fontconfig>
<!-- Font directory list -->
<dir prefix="xdg"></dir>
<!-- Font cache directory list -->
<cachedir prefix="xdg"></cachedir>
<!--
Accept deprecated 'mono' alias, replacing it with 'monospace'
-->
<match target="pattern">
<test qual="any" name="family">
<string>mono</string>
</test>
<edit name="family" mode="assign" binding="same">
<string>monospace</string>
</edit>
</match>
<!--
Accept alternate 'sans serif' spelling, replacing it with 'sans-serif'
-->
<match target="pattern">
<test qual="any" name="family">
<string>sans serif</string>
</test>
<edit name="family" mode="assign" binding="same">
<string>sans-serif</string>
</edit>
</match>
<!--
Accept deprecated 'sans' alias, replacing it with 'sans-serif'
-->
<match target="pattern">
<test qual="any" name="family">
<string>sans</string>
</test>
<edit name="family" mode="assign" binding="same">
<string>sans-serif</string>
</edit>
</match>
<config>
<!--
These are the default Unicode chars that are expected to be blank
in fonts. All other blank chars are assumed to be broken and
won't appear in the resulting charsets
-->
<blank>
<int>0x0020</int> <!-- SPACE -->
<int>0x00A0</int> <!-- NO-BREAK SPACE -->
<int>0x00AD</int> <!-- SOFT HYPHEN -->
<int>0x034F</int> <!-- COMBINING GRAPHEME JOINER -->
<int>0x0600</int> <!-- ARABIC NUMBER SIGN -->
<int>0x0601</int> <!-- ARABIC SIGN SANAH -->
<int>0x0602</int> <!-- ARABIC FOOTNOTE MARKER -->
<int>0x0603</int> <!-- ARABIC SIGN SAFHA -->
<int>0x06DD</int> <!-- ARABIC END OF AYAH -->
<int>0x070F</int> <!-- SYRIAC ABBREVIATION MARK -->
<int>0x115F</int> <!-- HANGUL CHOSEONG FILLER -->
<int>0x1160</int> <!-- HANGUL JUNGSEONG FILLER -->
<int>0x1680</int> <!-- OGHAM SPACE MARK -->
<int>0x17B4</int> <!-- KHMER VOWEL INHERENT AQ -->
<int>0x17B5</int> <!-- KHMER VOWEL INHERENT AA -->
<int>0x180E</int> <!-- MONGOLIAN VOWEL SEPARATOR -->
<int>0x2000</int> <!-- EN QUAD -->
<int>0x2001</int> <!-- EM QUAD -->
<int>0x2002</int> <!-- EN SPACE -->
<int>0x2003</int> <!-- EM SPACE -->
<int>0x2004</int> <!-- THREE-PER-EM SPACE -->
<int>0x2005</int> <!-- FOUR-PER-EM SPACE -->
<int>0x2006</int> <!-- SIX-PER-EM SPACE -->
<int>0x2007</int> <!-- FIGURE SPACE -->
<int>0x2008</int> <!-- PUNCTUATION SPACE -->
<int>0x2009</int> <!-- THIN SPACE -->
<int>0x200A</int> <!-- HAIR SPACE -->
<int>0x200B</int> <!-- ZERO WIDTH SPACE -->
<int>0x200C</int> <!-- ZERO WIDTH NON-JOINER -->
<int>0x200D</int> <!-- ZERO WIDTH JOINER -->
<int>0x200E</int> <!-- LEFT-TO-RIGHT MARK -->
<int>0x200F</int> <!-- RIGHT-TO-LEFT MARK -->
<int>0x2028</int> <!-- LINE SEPARATOR -->
<int>0x2029</int> <!-- PARAGRAPH SEPARATOR -->
<int>0x202A</int> <!-- LEFT-TO-RIGHT EMBEDDING -->
<int>0x202B</int> <!-- RIGHT-TO-LEFT EMBEDDING -->
<int>0x202C</int> <!-- POP DIRECTIONAL FORMATTING -->
<int>0x202D</int> <!-- LEFT-TO-RIGHT OVERRIDE -->
<int>0x202E</int> <!-- RIGHT-TO-LEFT OVERRIDE -->
<int>0x202F</int> <!-- NARROW NO-BREAK SPACE -->
<int>0x205F</int> <!-- MEDIUM MATHEMATICAL SPACE -->
<int>0x2060</int> <!-- WORD JOINER -->
<int>0x2061</int> <!-- FUNCTION APPLICATION -->
<int>0x2062</int> <!-- INVISIBLE TIMES -->
<int>0x2063</int> <!-- INVISIBLE SEPARATOR -->
<int>0x206A</int> <!-- INHIBIT SYMMETRIC SWAPPING -->
<int>0x206B</int> <!-- ACTIVATE SYMMETRIC SWAPPING -->
<int>0x206C</int> <!-- INHIBIT ARABIC FORM SHAPING -->
<int>0x206D</int> <!-- ACTIVATE ARABIC FORM SHAPING -->
<int>0x206E</int> <!-- NATIONAL DIGIT SHAPES -->
<int>0x206F</int> <!-- NOMINAL DIGIT SHAPES -->
<int>0x2800</int> <!-- BRAILLE PATTERN BLANK -->
<int>0x3000</int> <!-- IDEOGRAPHIC SPACE -->
<int>0x3164</int> <!-- HANGUL FILLER -->
<int>0xFEFF</int> <!-- ZERO WIDTH NO-BREAK SPACE -->
<int>0xFFA0</int> <!-- HALFWIDTH HANGUL FILLER -->
<int>0xFFF9</int> <!-- INTERLINEAR ANNOTATION ANCHOR -->
<int>0xFFFA</int> <!-- INTERLINEAR ANNOTATION SEPARATOR -->
<int>0xFFFB</int> <!-- INTERLINEAR ANNOTATION TERMINATOR -->
</blank>
<!--
Rescan configuration every 30 seconds when FcFontSetList is called
-->
<rescan>
<int>30</int>
</rescan>
</config>
</fontconfig>

View file

@ -0,0 +1,39 @@
#ifndef __GST_IOS_INIT_H__
#define __GST_IOS_INIT_H__
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_G_IO_MODULE_DECLARE(name) \
extern void G_PASTE(g_io_module_, G_PASTE(name, _load_static)) (void)
#define GST_G_IO_MODULE_LOAD(name) \
G_PASTE(g_io_module_, G_PASTE(name, _load_static)) ()
/* Uncomment each line to enable the plugin categories that your application needs.
* You can also enable individual plugins. See gst_ios_init.c to see their names
*/
//#define GST_IOS_PLUGINS_GES
#define GST_IOS_PLUGINS_CORE
//#define GST_IOS_PLUGINS_CAPTURE
#define GST_IOS_PLUGINS_CODECS_RESTRICTED
//#define GST_IOS_PLUGINS_ENCODING
#define GST_IOS_PLUGINS_CODECS_GPL
#define GST_IOS_PLUGINS_NET_RESTRICTED
#define GST_IOS_PLUGINS_SYS
#define GST_IOS_PLUGINS_VIS
#define GST_IOS_PLUGINS_PLAYBACK
#define GST_IOS_PLUGINS_EFFECTS
#define GST_IOS_PLUGINS_CODECS
#define GST_IOS_PLUGINS_NET
#define GST_IOS_GIO_MODULE_GNUTLS
void gst_ios_init ();
G_END_DECLS
#endif

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,12 @@
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
#include "gst_ios_init.h"
int main(int argc, char *argv[])
{
@autoreleasepool {
gst_ios_init();
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}

View file

@ -0,0 +1,22 @@
EXTRA_DIST = \
GstPlay/AppDelegate.h \
GstPlay/AppDelegate.m \
GstPlay/EaglUIVIew.h \
GstPlay/EaglUIVIew.m \
GstPlay/en.lproj/InfoPlist.strings \
GstPlay/fonts.conf \
GstPlay/gst_ios_init.h \
GstPlay/gst_ios_init.m \
GstPlay/GstPlay-Info.plist \
GstPlay/GstPlay-Prefix.pch \
GstPlay/LibraryViewController.h \
GstPlay/LibraryViewController.m \
GstPlay/main.m \
GstPlay/MainStoryboard_iPad.storyboard \
GstPlay/MainStoryboard_iPhone.storyboard \
GstPlay/Ubuntu-R.ttf \
GstPlay/VideoViewController.h \
GstPlay/VideoViewController.m \
GstPlay.xcodeproj/project.xcworkspace/contents.xcworkspacedata \
GstPlay.xcodeproj/project.pbxproj

View file

@ -0,0 +1,27 @@
android-no-sdk {
target.path = /data/user/qt
export(target.path)
INSTALLS += target
} else:android {
x86 {
target.path = /libs/x86
} else: armeabi-v7a {
target.path = /libs/armeabi-v7a
} else {
target.path = /libs/armeabi
}
export(target.path)
INSTALLS += target
} else:unix {
isEmpty(target.path) {
qnx {
target.path = /tmp/$${TARGET}/bin
} else {
target.path = /opt/$${TARGET}/bin
}
export(target.path)
}
INSTALLS += target
}
export(INSTALLS)

Binary file not shown.

View file

@ -0,0 +1,10 @@
Font Awesome
URL: http://fontawesome.io
Font License
License: SIL OFL 1.1
URL: http://scripts.sil.org/OFL

View file

@ -0,0 +1,214 @@
var Icon = {
Glass : "\uf000",
Music : "\uf001",
Search : "\uf002",
Envelope : "\uf003",
Heart : "\uf004",
Star : "\uf005",
StarEmpty : "\uf006",
User : "\uf007",
Film : "\uf008",
ThLarge : "\uf009",
Th : "\uf00a",
ThList : "\uf00b",
Ok : "\uf00c",
Remove : "\uf00d",
ZoomIn : "\uf00e",
ZoomOut : "\uf010",
Off : "\uf011",
Signal : "\uf012",
Cog : "\uf013",
Trash : "\uf014",
Home : "\uf015",
File : "\uf016",
Time : "\uf017",
Road : "\uf018",
DownloadAlt : "\uf019",
Download : "\uf01a",
Upload : "\uf01b",
Inbox : "\uf01c",
PlayCircle : "\uf01d",
Repeat : "\uf01e",
Refresh : "\uf021",
ListAlt : "\uf022",
Lock : "\uf023",
Flag : "\uf024",
Headphones : "\uf025",
VolumeOff : "\uf026",
VolumeDown : "\uf027",
VolumeUp : "\uf028",
Qrcode : "\uf029",
Barcode : "\uf02a",
Tag : "\uf02b",
Tags : "\uf02c",
Book : "\uf02d",
Bookmark : "\uf02e",
Print : "\uf02f",
Camera : "\uf030",
Font : "\uf031",
Bold : "\uf032",
Italic : "\uf033",
TextHeight : "\uf034",
TextWidth : "\uf035",
AlignLeft : "\uf036",
AlignCenter : "\uf037",
AlignRight : "\uf038",
AlignJustify : "\uf039",
List : "\uf03a",
IndentLeft : "\uf03b",
IndentRight : "\uf03c",
FacetimeVideo : "\uf03d",
Picture : "\uf03e",
Pencil : "\uf040",
MapMarker : "\uf041",
Adjust : "\uf042",
Tint : "\uf043",
Edit : "\uf044",
Share : "\uf045",
Check : "\uf046",
Move : "\uf047",
StepBackward : "\uf048",
StepForward : "\uf049",
Backward : "\uf04a",
Play : "\uf04b",
Pause : "\uf04c",
Stop : "\uf04d",
Forward : "\uf04e",
FastForward : "\uf050",
StepForward : "\uf051",
Eject : "\uf052",
ChevronLeft : "\uf053",
ChevronRight : "\uf054",
PlusSign : "\uf055",
MinusSign : "\uf056",
RemoveSign : "\uf057",
OkSign : "\uf058",
QuestionSign : "\uf059",
InfoSign : "\uf05a",
Screenshot : "\uf05b",
RemoveCircle : "\uf05c",
OkCircle : "\uf05d",
BanCircle : "\uf05e",
ArrowLeft : "\uf060",
ArrowRight : "\uf061",
ArrowUp : "\uf062",
ArrowDown : "\uf063",
ShareAlt : "\uf064",
ResizeFull : "\uf065",
ResizeSmall : "\uf066",
Plus : "\uf067",
Minus : "\uf068",
Asterish : "\uf069",
ExclamationSign : "\uf06a",
Gift : "\uf06b",
Leave : "\uf06c",
Fire : "\uf06d",
EyeOpen : "\uf06e",
EyeClose : "\uf070",
WarningSign : "\uf071",
Plane : "\uf072",
Calendar : "\uf073",
Random : "\uf074",
Comment : "\uf075",
Magnet : "\uf076",
ChevronUp : "\uf077",
ChevronDown : "\uf078",
Retweet : "\uf079",
ShoppingCart : "\uf07a",
FolderClose : "\uf07b",
FolderOpen : "\uf07c",
ResizeVertical : "\uf07d",
ResizeHorizontal : "\uf07e",
BarChart : "\uf080",
TwitterSign : "\uf081",
FacebookSign : "\uf082",
CameraRetro : "\uf083",
Key : "\uf084",
Cogs : "\uf085",
Comments : "\uf086",
ThumbsUp : "\uf087",
ThumbsDown : "\uf088",
StarHalf : "\uf089",
HeartEmpty : "\uf08a",
Signout : "\uf08b",
LinkedinSign : "\uf08c",
Pushpin : "\uf08d",
ExternalLink : "\uf08e",
Signin : "\uf090",
Trophy : "\uf091",
GithubSign : "\uf092",
UploadAlt : "\uf093",
Lemon : "\uf094",
Phone : "\uf095",
CheckEmpty : "\uf096",
BookmarkEmpty : "\uf097",
PhoneSign : "\uf098",
Twitter : "\uf099",
Facebook : "\uf09a",
Github : "\uf09b",
Unlock : "\uf09c",
CreditCard : "\uf09d",
Rss : "\uf09e",
Hdd : "\uf0a0",
Bullhorn : "\uf0a1",
Bell : "\uf0a2",
Certificate : "\uf0a3",
HandRight : "\uf0a4",
HandLeft : "\uf0a5",
HandUp : "\uf0a6",
HandDown : "\uf0a7",
CircleArrowLeft : "\uf0a8",
CircleArrowRight : "\uf0a9",
CircleArrowUp : "\uf0aa",
CircleArrowDown : "\uf0ab",
Globe : "\uf0ac",
Wrench : "\uf0ad",
Tasks : "\uf0ae",
Filter : "\uf0b0",
Briefcase : "\uf0b1",
Fullscreen : "\uf0b2",
Group : "\uf0c0",
Link : "\uf0c1",
Cloud : "\uf0c2",
Beaker : "\uf0c3",
Cut : "\uf0c4",
Copy : "\uf0c5",
PaperClip : "\uf0c6",
Save : "\uf0c7",
SignBlank : "\uf0c8",
Reorder : "\uf0c9",
ListUl : "\uf0ca",
ListOl : "\uf0cb",
Strikethrough : "\uf0cc",
Underline : "\uf0cd",
Table : "\uf0ce",
Magic : "\uf0d0",
Truck : "\uf0d1",
Pinterest : "\uf0d2",
PinterestSign : "\uf0d3",
GooglePlusSign : "\uf0d4",
GooglePlus : "\uf0d5",
Money : "\uf0d6",
CaretDown : "\uf0d7",
CaretUp : "\uf0d8",
CaretLeft : "\uf0d9",
CaretRight : "\uf0da",
Columns : "\uf0db",
Sort : "\uf0dc",
SortDown : "\uf0dd",
SortUp : "\uf0de",
EnvelopeAlt : "\uf0e0",
Linkedin : "\uf0e1",
Undo : "\uf0e2",
Legal : "\uf0e3",
Dashboard : "\uf0e4",
CommentAlt : "\uf0e5",
CommentsAlt : "\uf0e6",
Bolt : "\uf0e7",
Sitemap : "\uf0e8",
Unbrella : "\uf0e9",
Paste : "\uf0ea",
ClosedCaptions : "\uf20a",
UserMd : "\uf200",
};

View file

@ -0,0 +1,61 @@
/* GStreamer
*
* Copyright (C) 2015 Alexandre Moreno <alexmorenocano@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include <QPainter>
#include "imagesample.h"
ImageSample::ImageSample()
: QQuickPaintedItem()
, sample_()
{
}
ImageSample::~ImageSample()
{
}
void ImageSample::paint(QPainter *painter)
{
if (sample_.size().isEmpty())
return;
float aspect_ratio = sample_.width() / sample_.height();
int w = height() * aspect_ratio;
int x = (width() - w) / 2;
painter->setViewport(x, 0, w, height());
painter->drawImage(QRectF(0, 0, width(), height()), sample_);
}
const QImage &ImageSample::sample() const
{
return sample_;
}
void ImageSample::setSample(const QImage &sample)
{
sample_ = sample;
update();
}

View file

@ -0,0 +1,46 @@
/* GStreamer
*
* Copyright (C) 2015 Alexandre Moreno <alexmorenocano@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef IMAGESAMPLE_H
#define IMAGESAMPLE_H
#include <QObject>
#include <QQuickPaintedItem>
#include <QImage>
#include <QPainter>
#include "player.h"
class ImageSample : public QQuickPaintedItem
{
Q_OBJECT
Q_PROPERTY(QImage sample READ sample WRITE setSample)
public:
ImageSample();
~ImageSample();
void paint(QPainter *painter);
const QImage &sample() const;
void setSample(const QImage &sample);
private:
QImage sample_;
};
#endif // IMAGESAMPLE_H

View file

@ -0,0 +1,78 @@
/* GStreamer
*
* Copyright (C) 2015 Alexandre Moreno <alexmorenocano@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include <QApplication>
#include <QQmlApplicationEngine>
#include <QCommandLineParser>
#include <QStringList>
#include <QUrl>
#include "player.h"
#include "imagesample.h"
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
int result;
QCommandLineParser parser;
parser.setApplicationDescription("GstPlayer");
parser.addHelpOption();
parser.addPositionalArgument("urls",
QCoreApplication::translate("main", "URLs to play, optionally."), "[urls...]");
parser.process(app);
QList<QUrl> media_files;
const QStringList args = parser.positionalArguments();
foreach (const QString file, args) {
media_files << QUrl::fromUserInput(file);
}
qmlRegisterType<Player>("Player", 1, 0, "Player");
qmlRegisterType<ImageSample>("ImageSample", 1, 0, "ImageSample");
/* the plugin must be loaded before loading the qml file to register the
* GstGLVideoItem qml item
* FIXME Add a QQmlExtensionPlugin into qmlglsink to register GstGLVideoItem
* with the QML engine, then remove this */
gst_init(NULL,NULL);
GstElement *sink = gst_element_factory_make ("qmlglsink", NULL);
gst_object_unref(sink);
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
QObject *rootObject = engine.rootObjects().first();
Player *player = rootObject->findChild<Player*>("player");
QQuickItem *videoItem = rootObject->findChild<QQuickItem*>("videoItem");
player->setVideoOutput(videoItem);
if (!media_files.isEmpty())
player->setPlaylist(media_files);
result = app.exec();
gst_deinit ();
return result;
}

732
playback/player/qt/main.qml Normal file
View file

@ -0,0 +1,732 @@
/* GStreamer
*
* Copyright (C) 2015 Alexandre Moreno <alexmorenocano@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
import QtQuick 2.4
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.3
import QtQuick.Dialogs 1.2
import QtQuick.Window 2.1
import Player 1.0
import org.freedesktop.gstreamer.GLVideoItem 1.0
import ImageSample 1.0
import "fontawesome.js" as FontAwesome
ApplicationWindow {
id: window
visible: true
width: 640
height: 480
x: 30
y: 30
color: "black"
// title : player.mediaInfo.title
Player {
id: player
objectName: "player"
volume: 0.5
positionUpdateInterval: 100
autoPlay: false
onStateChanged: {
if (state === Player.STOPPED) {
playbutton.state = "play"
}
}
onResolutionChanged: {
if (player.videoAvailable) {
window.width = resolution.width
window.height = resolution.height
}
}
}
GstGLVideoItem {
id: video
objectName: "videoItem"
anchors.centerIn: parent
width: parent.width
height: parent.height
visible: player.videoAvailable
}
ImageSample {
id: sample
anchors.centerIn: parent
sample: player.mediaInfo.sample
width: parent.width
height: parent.height
visible: !player.videoAvailable
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
onPositionChanged: {
playbar.opacity = 1.0
hidetimer.start()
}
}
Timer {
id: hidetimer
interval: 5000
onTriggered: {
if (!playbarMouseArea.containsMouse) {
playbar.opacity = 0.0
settings.visible = false
}
stop()
}
}
FileDialog {
id: fileDialog
//nameFilters: [TODO globs from mime types]
onAccepted: player.source = fileUrl
}
Action {
id: fileOpenAction
text: "Open"
onTriggered: fileDialog.open()
}
Item {
anchors.fill: parent
FontLoader {
source: "fonts/fontawesome-webfont.ttf"
}
Rectangle {
id : playbar
color: Qt.rgba(1, 1, 1, 0.7)
border.width: 1
border.color: "white"
anchors.bottom: parent.bottom
anchors.bottomMargin: 15
anchors.horizontalCenter: parent.horizontalCenter
width : grid.width + 20
height: 40//childrenRect.height + 20
radius: 5
focus: true
MouseArea {
id: playbarMouseArea
anchors.fill: parent
hoverEnabled: true
}
Rectangle {
id: settings
width: 150; height: settingsView.contentHeight
color: Qt.rgba(1, 1, 1, 0.7)
anchors.right: parent.right
anchors.bottom: parent.top
anchors.bottomMargin: 3
border.width: 1
border.color: "white"
radius: 5
visible: false
ListModel {
id: settingsModel
ListElement {
name: "Video"
}
ListElement {
name: "Audio"
}
ListElement {
name: "Subtitle"
}
}
Component {
id: settingsDelegate
Item {
width: 150; height: 20
Text {
text: model.name
font.pixelSize: 13
anchors.centerIn: parent
}
Text {
font.pixelSize: 13
font.family: "FontAwesome"
text: FontAwesome.Icon.ChevronRight
anchors.right: parent.right
anchors.rightMargin: 10
anchors.verticalCenter: parent.verticalCenter
}
MouseArea {
anchors.fill: parent
onClicked: {
switch(name) {
case 'Video':
videos.visible = true
break
case 'Audio':
audios.visible = true
break
case 'Subtitle' :
subtitles.visible = true
break
}
settings.visible = false
}
}
}
}
ListView {
id: settingsView
anchors.fill: parent
model: settingsModel
delegate: settingsDelegate
}
}
Rectangle {
id: videos
width: 150; height: videoView.contentHeight
color: Qt.rgba(1, 1, 1, 0.7)
anchors.right: parent.right
anchors.bottom: parent.top
anchors.bottomMargin: 3
border.width: 1
border.color: "white"
radius: 5
property bool selected: ListView.isCurrentItem
visible: false
Component {
id: videoDelegate
Item {
width: 150; height: 20
Text {
text: model.modelData.resolution.width + 'x' + model.modelData.resolution.height
font.pixelSize: 13
anchors.centerIn: parent
}
MouseArea {
anchors.fill: parent
onClicked: {
parent.ListView.view.currentIndex = index
player.currentVideo = model.modelData
}
}
}
}
ListView {
id : videoView
anchors.fill: parent
model: player.mediaInfo.videoStreams
delegate: videoDelegate
highlight: Rectangle {
color: "white"
radius: 5
border.width: 1
border.color: "white"
}
focus: true
clip: true
}
}
Rectangle {
id: audios
width: 150; height: audioView.contentHeight
color: Qt.rgba(1, 1, 1, 0.7)
anchors.right: parent.right
anchors.bottom: parent.top
anchors.bottomMargin: 3
border.width: 1
border.color: "white"
radius: 5
property bool selected: ListView.isCurrentItem
visible: false
Component {
id: audioDelegate
Item {
width: 150; height: 20
Text {
text: model.modelData.channels + 'channels'
font.pixelSize: 13
anchors.centerIn: parent
}
MouseArea {
anchors.fill: parent
onClicked: {
parent.ListView.view.currentIndex = index
player.currentAudio = model.modelData
}
}
}
}
ListView {
id : audioView
anchors.fill: parent
model: player.mediaInfo.audioStreams
delegate: audioDelegate
highlight: Rectangle {
color: "white"
radius: 5
border.width: 1
border.color: "white"
}
focus: true
clip: true
}
}
Rectangle {
id: subtitles
width: 150; height: subtitleView.contentHeight
color: Qt.rgba(1, 1, 1, 0.7)
anchors.right: parent.right
anchors.bottom: parent.top
anchors.bottomMargin: 3
border.width: 1
border.color: "white"
radius: 5
property bool selected: ListView.isCurrentItem
visible: false
Component {
id: subtitleDelegate
Item {
width: 150; height: 20
Text {
text: model.modelData.language
font.pixelSize: 13
anchors.centerIn: parent
}
MouseArea {
anchors.fill: parent
onClicked: {
parent.ListView.view.currentIndex = index
player.currentSubtitle = model.modelData
}
}
}
}
ListView {
id : subtitleView
anchors.fill: parent
model: player.mediaInfo.subtitleStreams
delegate: subtitleDelegate
highlight: Rectangle {
color: "white"
radius: 5
border.width: 1
border.color: "white"
}
focus: true
clip: true
}
}
Grid {
id: grid
anchors.horizontalCenter: parent.horizontalCenter
spacing: 7
rows: 1
verticalItemAlignment: Qt.AlignVCenter
Text {
id : openmedia
font.pixelSize: 17
font.family: "FontAwesome"
text: FontAwesome.Icon.FolderOpen
MouseArea {
anchors.fill: parent
onPressed: fileDialog.open()
}
}
Item {
width: 17
height: 17
Text {
anchors.centerIn: parent
font.pixelSize: 17
font.family: "FontAwesome"
text: FontAwesome.Icon.StepBackward
}
MouseArea {
anchors.fill: parent
onPressed: player.previous()
}
}
Item {
width: 25
height: 25
Text {
anchors.centerIn: parent
id : playbutton
font.family: "FontAwesome"
state: "play"
states: [
State {
name: "play"
PropertyChanges {
target: playbutton
text: FontAwesome.Icon.PlayCircle
font.pixelSize: 25
}
},
State {
name: "pause"
PropertyChanges {
target: playbutton
text: FontAwesome.Icon.Pause
font.pixelSize: 17
}
}
]
}
MouseArea {
id: playArea
anchors.fill: parent
onPressed: {
if (player.state !== Player.PLAYING) {
player.play()
playbutton.state = "pause"
} else {
player.pause()
playbutton.state = "play"
}
}
}
}
Item {
width: 17
height: 17
Text {
anchors.centerIn: parent
font.pixelSize: 17
font.family: "FontAwesome"
text: FontAwesome.Icon.StepForward
}
MouseArea {
anchors.fill: parent
onPressed: player.next()
}
}
Item {
width: 40
height: 17
Text {
id: timelabel
anchors.centerIn: parent
font.pixelSize: 13
color: "black"
text: {
var current = new Date(Math.floor(slider.value / 1e6));
current.getMinutes() + ":" + ('0'+current.getSeconds()).slice(-2)
}
}
}
Item {
width: 200
height: 38
Text {
anchors.centerIn: parent
width: parent.width
text: player.mediaInfo.title
font.pixelSize: 15
elide: Text.ElideRight
}
}
Item {
width: 40
height: 17
Text {
id: durationlabel
anchors.centerIn: parent
font.pixelSize: 13
color: "black"
text: {
var duration = new Date(Math.floor(player.duration / 1e6));
duration.getMinutes() + ":" + ('0'+duration.getSeconds()).slice(-2)
}
}
}
Text {
id: sub
font.pixelSize: 17
font.family: "FontAwesome"
text: FontAwesome.Icon.ClosedCaptions
color: player.subtitleEnabled ? "red" : "black"
MouseArea {
anchors.fill: parent
onClicked: {
player.subtitleEnabled = !player.subtitleEnabled
}
}
}
Item {
width: 17
height: 17
Text {
id : volume
anchors.centerIn: parent
font.pixelSize: 17
font.family: "FontAwesome"
text: {
if (volumeslider.value > volumeslider.maximumValue / 2) {
FontAwesome.Icon.VolumeUp
} else if (volumeslider.value === 0) {
FontAwesome.Icon.VolumeOff
} else {
FontAwesome.Icon.VolumeDown
}
}
}
Rectangle {
id : volumebar
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.top
//anchors.bottomMargin:3
color: "lightgray"
width: 17
height: 66
visible: false
radius: 5
Slider {
id: volumeslider
value: player.volume
minimumValue: 0.0
maximumValue: 1.0
stepSize: 0.001
anchors.centerIn: parent
orientation: Qt.Vertical
onPressedChanged: player.volume = value
style: SliderStyle {
groove: Item {
implicitWidth: 47
implicitHeight: 3
anchors.centerIn: parent
Rectangle {
antialiasing: true
height: parent.height
width: parent.width
color: "gray"
opacity: 0.8
radius: 5
Rectangle {
antialiasing: true
height: parent.height
width: parent.width * control.value / control.maximumValue
color: "red"
radius: 5
}
}
}
handle: Rectangle {
anchors.centerIn: parent
color: control.pressed ? "white" : "lightgray"
border.color: "gray"
border.width: 1
implicitWidth: 11
implicitHeight: 11
radius: 90
}
}
}
}
MouseArea {
anchors.fill: parent
onPressed: {
volumebar.visible = !volumebar.visible
}
}
MouseArea {
anchors.fill: volumebar
hoverEnabled: true
propagateComposedEvents: true
onClicked: mouse.accepted = false;
onPressed: mouse.accepted = false;
onReleased: mouse.accepted = false;
onDoubleClicked: mouse.accepted = false;
onPositionChanged: mouse.accepted = false;
onPressAndHold: mouse.accepted = false;
onExited: {
volumebar.visible = false
}
}
}
Text {
id: cog
font.pixelSize: 17
font.family: "FontAwesome"
text: FontAwesome.Icon.Cog
MouseArea {
anchors.fill: parent
onClicked: {
settings.visible = !settings.visible
videos.visible = false
audios.visible = false
subtitles.visible = false
}
}
}
Text {
id : fullscreen
font.pixelSize: 17
font.family: "FontAwesome"
text: FontAwesome.Icon.ResizeFull
MouseArea {
anchors.fill: parent
onClicked: {
if (window.visibility === Window.FullScreen) {
window.showNormal()
fullscreen.text = FontAwesome.Icon.ResizeFull
} else {
window.showFullScreen()
fullscreen.text = FontAwesome.Icon.ResizeSmall
}
}
}
}
}
Item {
width: playbar.width
height: 5
anchors.bottom: playbar.bottom
Slider {
id: slider
maximumValue: player.duration
value: player.position
onPressedChanged: player.seek(value)
onValueChanged: {
if (pressed)
player.seek(value)
}
enabled: player.mediaInfo.seekable
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
updateValueWhileDragging: true
MouseArea {
id: sliderMouseArea
anchors.fill: parent
hoverEnabled: true
propagateComposedEvents: true
onClicked: mouse.accepted = false;
onPressed: mouse.accepted = false;
onReleased: mouse.accepted = false;
onDoubleClicked: mouse.accepted = false;
onPositionChanged: mouse.accepted = false;
onPressAndHold: mouse.accepted = false;
}
style: SliderStyle {
groove: Item {
implicitWidth: playbar.width
implicitHeight: 5
Rectangle {
height: parent.height
width: parent.width
anchors.verticalCenter: parent.verticalCenter
color: "gray"
opacity: 0.8
Rectangle {
antialiasing: true
color: "red"
height: parent.height
width: parent.width * control.value / control.maximumValue
}
Rectangle {
antialiasing: true
color: "yellow"
height: parent.height
width: parent.width * player.buffering / 100
}
}
}
handle: Rectangle {
anchors.centerIn: parent
color: control.pressed ? "white" : "lightgray"
implicitWidth: 4
implicitHeight: 5
}
}
}
}
}
}
}

View file

@ -0,0 +1,48 @@
TEMPLATE = app
QT += qml quick widgets
CONFIG += c++11
DEFINES += GST_USE_UNSTABLE_API
RESOURCES += qml.qrc
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
# Default rules for deployment.
include(deployment.pri)
# not tested (yet)
unix:!macx {
QT_CONFIG -= no-pkg-config
CONFIG += link_pkgconfig
PKGCONFIG = \
gstreamer-1.0 \
gstreamer-player-1.0 \
gstreamer-tag-1.0
}
macx {
QMAKE_MAC_SDK = macosx10.9
INCLUDEPATH += /Library/Frameworks/GStreamer.framework/Headers
LIBS += \
-framework AppKit \
-F/Library/Frameworks -framework GStreamer
}
HEADERS += \
qgstplayer.h \
player.h \
quickrenderer.h \
imagesample.h
SOURCES += main.cpp \
qgstplayer.cpp \
player.cpp \
quickrenderer.cpp \
imagesample.cpp
DISTFILES +=

View file

@ -0,0 +1,41 @@
/* GStreamer
*
* Copyright (C) 2015 Alexandre Moreno <alexmorenocano@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "player.h"
#include "quickrenderer.h"
Player::Player(QObject *parent)
: Player(parent, new QuickRenderer)
{
}
Player::Player(QObject *parent, QuickRenderer *renderer)
: QGstPlayer::Player(parent, renderer)
, renderer_(renderer)
{
renderer_->setParent(this);
}
void Player::setVideoOutput(QQuickItem *output)
{
renderer_->setVideoItem(output);
}

View file

@ -0,0 +1,44 @@
/* GStreamer
*
* Copyright (C) 2015 Alexandre Moreno <alexmorenocano@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef PLAYER_H
#define PLAYER_H
#include <QObject>
#include <QQuickItem>
#include "qgstplayer.h"
class QuickRenderer;
class Player : public QGstPlayer::Player
{
Q_OBJECT
public:
Player(QObject *parent = 0);
void setVideoOutput(QQuickItem *output);
private:
Player(QObject *parent, QuickRenderer *renderer);
QuickRenderer *renderer_;
};
Q_DECLARE_METATYPE(Player*)
#endif // PLAYER_H

View file

@ -0,0 +1,967 @@
/* GStreamer
*
* Copyright (C) 2015 Alexandre Moreno <alexmorenocano@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "qgstplayer.h"
#include <QDebug>
#include <QSize>
#include <QMetaObject>
#include <functional>
#include <QThread>
#include <QtAlgorithms>
#include <QImage>
#include <gst/gst.h>
#include <gst/tag/tag.h>
namespace QGstPlayer {
class RegisterMetaTypes
{
public:
RegisterMetaTypes()
{
qRegisterMetaType<Player::State>("State");
}
} _register;
MediaInfo::MediaInfo(Player *player)
: QObject(player)
, uri_()
, title_()
, isSeekable_(false)
, videoStreams_()
, audioStreams_()
, subtitleStreams_()
, sample_()
{
}
QString MediaInfo::uri() const
{
return uri_;
}
QString MediaInfo::title() const
{
return title_;
}
bool MediaInfo::isSeekable() const
{
return isSeekable_;
}
const QList<QObject *> &MediaInfo::videoStreams() const
{
return videoStreams_;
}
const QList<QObject *> &MediaInfo::audioStreams() const
{
return audioStreams_;
}
const QList<QObject*> &MediaInfo::subtitleStreams() const
{
return subtitleStreams_;
}
const QImage &MediaInfo::sample()
{
return sample_;
}
void MediaInfo::update(GstPlayerMediaInfo *info)
{
Q_ASSERT(info != 0);
// FIXME since media-info signal gets emitted
// several times, we just update info iff the
// media uri has changed.
if (uri_ == gst_player_media_info_get_uri(info)) {
return;
}
uri_ = QString(gst_player_media_info_get_uri(info));
title_ = QString::fromLocal8Bit(gst_player_media_info_get_title(info));
// if media has no title, return the file name
if (title_.isEmpty()) {
QUrl url(gst_player_media_info_get_uri(info));
title_ = url.fileName();
}
emit titleChanged();
if (isSeekable_ != gst_player_media_info_is_seekable(info)) {
isSeekable_ = !isSeekable_;
emit seekableChanged();
}
if (!subtitleStreams_.isEmpty()) {
qDeleteAll(subtitleStreams_);
subtitleStreams_.clear();
}
if (!videoStreams_.isEmpty()) {
qDeleteAll(videoStreams_);
videoStreams_.clear();
}
if (!audioStreams_.isEmpty()) {
qDeleteAll(audioStreams_);
audioStreams_.clear();
}
GList *list = gst_player_get_subtitle_streams(info);
g_list_foreach (list, [](gpointer data, gpointer user_data) {
GstPlayerSubtitleInfo *info = static_cast<GstPlayerSubtitleInfo*>(data);
QList<QObject*> *subs = static_cast<QList<QObject*>*>(user_data);
subs->append(new SubtitleInfo(info));
}, &subtitleStreams_);
list = gst_player_get_video_streams(info);
g_list_foreach (list, [](gpointer data, gpointer user_data) {
GstPlayerVideoInfo *info = static_cast<GstPlayerVideoInfo*>(data);
QList<QObject*> *videos = static_cast<QList<QObject*>*>(user_data);
videos->append(new VideoInfo(info));
}, &videoStreams_);
list = gst_player_get_audio_streams(info);
g_list_foreach (list, [](gpointer data, gpointer user_data) {
GstPlayerAudioInfo *info = static_cast<GstPlayerAudioInfo*>(data);
QList<QObject*> *audios = static_cast<QList<QObject*>*>(user_data);
audios->append(new AudioInfo(info));
}, &audioStreams_);
GstSample *sample;
GstMapInfo map_info;
GstBuffer *buffer;
const GstStructure *caps_struct;
GstTagImageType type = GST_TAG_IMAGE_TYPE_UNDEFINED;
/* get image sample buffer from media */
sample = gst_player_media_info_get_image_sample (info);
if (!sample)
return;
buffer = gst_sample_get_buffer (sample);
caps_struct = gst_sample_get_info (sample);
/* if sample is retrieved from preview-image tag then caps struct
* will not be defined. */
if (caps_struct)
gst_structure_get_enum (caps_struct, "image-type",
GST_TYPE_TAG_IMAGE_TYPE, reinterpret_cast<gint*>(&type));
/* FIXME: Should we check more type ?? */
if ((type != GST_TAG_IMAGE_TYPE_FRONT_COVER) &&
(type != GST_TAG_IMAGE_TYPE_UNDEFINED) &&
(type != GST_TAG_IMAGE_TYPE_NONE)) {
g_print ("unsupport type ... %d \n", type);
return;
}
if (!gst_buffer_map (buffer, &map_info, GST_MAP_READ)) {
g_print ("failed to map gst buffer \n");
return;
}
sample_ = QImage::fromData(map_info.data, map_info.size);
if (sample_.isNull())
qWarning() << "failed to load media info sample image";
emit sampleChanged();
gst_buffer_unmap (buffer, &map_info);
}
VideoInfo::VideoInfo(GstPlayerVideoInfo *info)
: StreamInfo(reinterpret_cast<GstPlayerStreamInfo*>(info))
, video_(info)
, resolution_(gst_player_video_info_get_width(info), gst_player_video_info_get_height(info))
{
}
QSize VideoInfo::resolution() const
{
return resolution_;
}
AudioInfo::AudioInfo(GstPlayerAudioInfo *info)
: StreamInfo(reinterpret_cast<GstPlayerStreamInfo*>(info))
, audio_(info)
, language_(gst_player_audio_info_get_language(info))
, channels_(gst_player_audio_info_get_channels(info))
, bitRate_(gst_player_audio_info_get_bitrate(info))
, sampleRate_(gst_player_audio_info_get_sample_rate(info))
{
}
const QString &AudioInfo::language() const
{
return language_;
}
int AudioInfo::channels() const
{
return channels_;
}
int AudioInfo::bitRate() const
{
return bitRate_;
}
int AudioInfo::sampleRate() const
{
return sampleRate_;
}
SubtitleInfo::SubtitleInfo(GstPlayerSubtitleInfo *info)
: StreamInfo(reinterpret_cast<GstPlayerStreamInfo*>(info))
, subtitle_(info)
, language_(gst_player_subtitle_info_get_language(info))
{
}
const QString &SubtitleInfo::language() const
{
return language_;
}
int StreamInfo::index() const
{
return index_;
}
StreamInfo::StreamInfo(GstPlayerStreamInfo *info)
: stream_(info)
, index_(gst_player_stream_info_get_index(info))
{
}
bool Player::isVideoAvailable() const
{
GstPlayerVideoInfo *video_info;
video_info = gst_player_get_current_video_track (player_);
if (video_info) {
g_object_unref (video_info);
return true;
}
return false;
}
MediaInfo *Player::mediaInfo() const
{
return mediaInfo_;
}
QVariant Player::currentVideo() const
{
Q_ASSERT(player_ != 0);
GstPlayerVideoInfo *track = gst_player_get_current_video_track(player_);
if (!track)
return QVariant();
return QVariant::fromValue(new VideoInfo(track));
}
QVariant Player::currentAudio() const
{
Q_ASSERT(player_ != 0);
GstPlayerAudioInfo *track = gst_player_get_current_audio_track(player_);
if (!track)
return QVariant();
return QVariant::fromValue(new AudioInfo(track));
}
QVariant Player::currentSubtitle() const
{
Q_ASSERT(player_ != 0);
GstPlayerSubtitleInfo *track = gst_player_get_current_subtitle_track(player_);
if (!track)
return QVariant();
return QVariant::fromValue(new SubtitleInfo(track));
}
void Player::setCurrentVideo(QVariant track)
{
Q_ASSERT(player_ != 0);
VideoInfo* info = track.value<VideoInfo*>();
Q_ASSERT(info);
gst_player_set_video_track(player_, info->index());
}
void Player::setCurrentAudio(QVariant track)
{
Q_ASSERT(player_ != 0);
AudioInfo* info = track.value<AudioInfo*>();
Q_ASSERT(info);
gst_player_set_audio_track(player_, info->index());
}
void Player::setCurrentSubtitle(QVariant track)
{
Q_ASSERT(player_ != 0);
SubtitleInfo* info = track.value<SubtitleInfo*>();
Q_ASSERT(info);
gst_player_set_subtitle_track(player_, info->index());
}
bool Player::isSubtitleEnabled() const
{
return subtitleEnabled_;
}
quint32 Player::positionUpdateInterval() const
{
Q_ASSERT(player_ != 0);
return gst_player_get_position_update_interval(player_);
}
void Player::setSubtitleEnabled(bool enabled)
{
Q_ASSERT(player_ != 0);
subtitleEnabled_ = enabled;
gst_player_set_subtitle_track_enabled(player_, enabled);
emit subtitleEnabledChanged(enabled);
}
void Player::setPositionUpdateInterval(quint32 interval)
{
Q_ASSERT(player_ != 0);
gst_player_set_position_update_interval(player_, interval);
}
Player::Player(QObject *parent, VideoRenderer *renderer)
: QObject(parent)
, player_()
, state_(STOPPED)
, videoDimensions_(QSize())
, mediaInfo_()
, videoAvailable_(false)
, subtitleEnabled_(false)
, autoPlay_(false)
{
player_ = gst_player_new(renderer ? renderer->renderer() : 0,
gst_player_qt_signal_dispatcher_new(this));
g_object_connect(player_,
"swapped-signal::state-changed", G_CALLBACK (Player::onStateChanged), this,
"swapped-signal::position-updated", G_CALLBACK (Player::onPositionUpdated), this,
"swapped-signal::duration-changed", G_CALLBACK (Player::onDurationChanged), this,
"swapped-signal::buffering", G_CALLBACK (Player::onBufferingChanged), this,
"swapped-signal::video-dimensions-changed", G_CALLBACK (Player::onVideoDimensionsChanged), this,
"swapped-signal::volume-changed", G_CALLBACK (Player::onVolumeChanged), this,
"swapped-signal::mute-changed", G_CALLBACK (Player::onMuteChanged), this,
"swapped-signal::media-info-updated", G_CALLBACK (Player::onMediaInfoUpdated), this,
"swapped-signal::end-of-stream", G_CALLBACK (Player::onEndOfStreamReached), this, NULL);
mediaInfo_ = new MediaInfo(this);
gst_player_set_subtitle_track_enabled(player_, false);
}
Player::~Player()
{
if (player_) {
g_signal_handlers_disconnect_by_data(player_, this);
gst_player_stop(player_);
g_object_unref(player_);
}
}
void
Player::onStateChanged(Player * player, GstPlayerState state)
{
player->state_ = static_cast<Player::State>(state);
emit player->stateChanged(player->state_);
}
void
Player::onPositionUpdated(Player * player, GstClockTime position)
{
emit player->positionUpdated(position);
}
void
Player::onDurationChanged(Player * player, GstClockTime duration)
{
emit player->durationChanged(duration);
}
void
Player::onBufferingChanged(Player * player, int percent)
{
emit player->bufferingChanged(percent);
}
void
Player::onVideoDimensionsChanged(Player * player, int w, int h)
{
QSize res(w,h);
if (res == player->videoDimensions_)
return;
player->videoDimensions_ = res;
player->setResolution(res);
emit player->resolutionChanged(res);
}
void
Player::onVolumeChanged(Player *player)
{
qreal new_val;
new_val = gst_player_get_volume (player->player_);
emit player->volumeChanged(new_val);
}
void
Player::onMuteChanged(Player *player)
{
bool new_val;
new_val = gst_player_get_mute (player->player_);
emit player->mutedChanged(new_val);
}
void
Player::onMediaInfoUpdated(Player *player, GstPlayerMediaInfo *media_info)
{
bool val = player->isVideoAvailable();
if (player->videoAvailable_ != val) {
player->videoAvailable_ = val;
emit player->videoAvailableChanged(val);
}
player->mediaInfo()->update(media_info);
emit player->mediaInfoChanged();
}
void Player::onEndOfStreamReached(Player *player)
{
Q_ASSERT(player != 0);
emit player->endOfStream();
}
void Player::setUri(QUrl url)
{
Q_ASSERT(player_ != 0);
QByteArray uri = url.toString().toLocal8Bit();
gst_player_set_uri(player_, uri.data());
autoPlay_ ? play() : pause();
emit sourceChanged(url);
}
QList<QUrl> Player::playlist() const
{
return playlist_;
}
void Player::setPlaylist(const QList<QUrl> &playlist)
{
if (!playlist_.isEmpty()) {
playlist_.erase(playlist_.begin(), playlist_.end());
}
playlist_ = playlist;
iter_ = playlist_.begin();
setUri(*iter_);
}
void Player::next()
{
if (playlist_.isEmpty())
return;
if (iter_ == playlist_.end())
return;
setUri(*++iter_);
}
void Player::previous()
{
if (playlist_.isEmpty())
return;
if (iter_ == playlist_.begin())
return;
setUri(*--iter_);
}
bool Player::autoPlay() const
{
return autoPlay_;
}
void Player::setAutoPlay(bool auto_play)
{
autoPlay_ = auto_play;
if (autoPlay_) {
connect(this, SIGNAL(endOfStream()), SLOT(next()));
}
}
QUrl Player::source() const
{
Q_ASSERT(player_ != 0);
QString url = QString::fromLocal8Bit(gst_player_get_uri(player_));
return QUrl(url);
}
qint64 Player::duration() const
{
Q_ASSERT(player_ != 0);
return gst_player_get_duration(player_);
}
qint64 Player::position() const
{
Q_ASSERT(player_ != 0);
return gst_player_get_position(player_);
}
qreal Player::volume() const
{
Q_ASSERT(player_ != 0);
return gst_player_get_volume(player_);
}
bool Player::isMuted() const
{
Q_ASSERT(player_ != 0);
return gst_player_get_mute(player_);
}
int Player::buffering() const
{
return 0;
}
QSize Player::resolution() const
{
return videoDimensions_;
}
void Player::setResolution(QSize size)
{
videoDimensions_ = size;
}
Player::State Player::state() const
{
return state_;
}
GstElement *Player::pipeline() const
{
Q_ASSERT(player_ != 0);
return gst_player_get_pipeline(player_);
}
void Player::play()
{
Q_ASSERT(player_ != 0);
gst_player_play(player_);
}
void Player::pause()
{
Q_ASSERT(player_ != 0);
gst_player_pause(player_);
}
void Player::stop()
{
Q_ASSERT(player_ != 0);
gst_player_stop(player_);
}
void Player::seek(qint64 position)
{
Q_ASSERT(player_ != 0);
gst_player_seek(player_, position);
}
void Player::setSource(QUrl const& url)
{
Q_ASSERT(player_ != 0);
// discard playlist
if (!playlist_.isEmpty()) {
playlist_.erase(playlist_.begin(), playlist_.end());
}
setUri(url);
emit sourceChanged(url);
}
void Player::setVolume(qreal val)
{
Q_ASSERT(player_ != 0);
gst_player_set_volume(player_, val);
}
void Player::setMuted(bool val)
{
Q_ASSERT(player_ != 0);
gst_player_set_mute(player_, val);
}
void Player::setPosition(qint64 pos)
{
Q_ASSERT(player_ != 0);
gst_player_seek(player_, pos);
}
GstPlayerVideoRenderer *VideoRenderer::renderer()
{
return static_cast<GstPlayerVideoRenderer*> (gst_object_ref (renderer_));
}
VideoRenderer::VideoRenderer()
{
renderer_ = static_cast<GstPlayerVideoRenderer*>
(g_object_new (GST_TYPE_PLAYER_QT_VIDEO_RENDERER, "renderer", this, NULL));
}
VideoRenderer::~VideoRenderer()
{
if (renderer_) gst_object_unref(renderer_);
}
}
struct _GstPlayerQtVideoRenderer
{
GObject parent;
gpointer renderer;
};
struct _GstPlayerQtVideoRendererClass
{
GObjectClass parent_class;
};
static void
gst_player_qt_video_renderer_interface_init
(GstPlayerVideoRendererInterface * iface);
G_DEFINE_TYPE_WITH_CODE (GstPlayerQtVideoRenderer,
gst_player_qt_video_renderer, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GST_TYPE_PLAYER_VIDEO_RENDERER,
gst_player_qt_video_renderer_interface_init))
enum
{
QT_VIDEO_RENDERER_PROP_0,
QT_VIDEO_RENDERER_PROP_RENDERER,
QT_VIDEO_RENDERER_PROP_LAST
};
static GParamSpec * qt_video_renderer_param_specs
[QT_VIDEO_RENDERER_PROP_LAST] = { NULL, };
static void
gst_player_qt_video_renderer_set_property (GObject * object,
guint prop_id, const GValue * value, GParamSpec * pspec)
{
GstPlayerQtVideoRenderer *self = GST_PLAYER_QT_VIDEO_RENDERER (object);
switch (prop_id) {
case QT_VIDEO_RENDERER_PROP_RENDERER:
self->renderer = g_value_get_pointer (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_player_qt_video_renderer_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec)
{
GstPlayerQtVideoRenderer *self = GST_PLAYER_QT_VIDEO_RENDERER (object);
switch (prop_id) {
case QT_VIDEO_RENDERER_PROP_RENDERER:
g_value_set_pointer (value, self->renderer);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_player_qt_video_renderer_finalize (GObject * object)
{
G_OBJECT_CLASS
(gst_player_qt_video_renderer_parent_class)->finalize(object);
}
static void
gst_player_qt_video_renderer_class_init
(GstPlayerQtVideoRendererClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->set_property =
gst_player_qt_video_renderer_set_property;
gobject_class->get_property =
gst_player_qt_video_renderer_get_property;
gobject_class->finalize = gst_player_qt_video_renderer_finalize;
qt_video_renderer_param_specs
[QT_VIDEO_RENDERER_PROP_RENDERER] =
g_param_spec_pointer ("renderer", "Qt Renderer", "",
static_cast<GParamFlags>(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_properties (gobject_class,
QT_VIDEO_RENDERER_PROP_LAST,
qt_video_renderer_param_specs);
}
static void
gst_player_qt_video_renderer_init (G_GNUC_UNUSED GstPlayerQtVideoRenderer * self)
{
}
static GstElement *
gst_player_qt_video_renderer_create_video_sink
(GstPlayerVideoRenderer * iface, G_GNUC_UNUSED GstPlayer *player)
{
GstPlayerQtVideoRenderer *self = GST_PLAYER_QT_VIDEO_RENDERER (iface);
g_assert(self->renderer != NULL);
return static_cast<QGstPlayer::VideoRenderer*>(self->renderer)->createVideoSink();
}
static void
gst_player_qt_video_renderer_interface_init
(GstPlayerVideoRendererInterface * iface)
{
iface->create_video_sink = gst_player_qt_video_renderer_create_video_sink;
}
struct _GstPlayerQtSignalDispatcher
{
GObject parent;
gpointer player;
};
struct _GstPlayerQtSignalDispatcherClass
{
GObjectClass parent_class;
};
static void
gst_player_qt_signal_dispatcher_interface_init
(GstPlayerSignalDispatcherInterface * iface);
enum
{
QT_SIGNAL_DISPATCHER_PROP_0,
QT_SIGNAL_DISPATCHER_PROP_PLAYER,
QT_SIGNAL_DISPATCHER_PROP_LAST
};
G_DEFINE_TYPE_WITH_CODE (GstPlayerQtSignalDispatcher,
gst_player_qt_signal_dispatcher, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GST_TYPE_PLAYER_SIGNAL_DISPATCHER,
gst_player_qt_signal_dispatcher_interface_init));
static GParamSpec
* qt_signal_dispatcher_param_specs
[QT_SIGNAL_DISPATCHER_PROP_LAST] = { NULL, };
static void
gst_player_qt_signal_dispatcher_finalize (GObject * object)
{
G_OBJECT_CLASS
(gst_player_qt_signal_dispatcher_parent_class)->finalize
(object);
}
static void
gst_player_qt_signal_dispatcher_set_property (GObject * object,
guint prop_id, const GValue * value, GParamSpec * pspec)
{
GstPlayerQtSignalDispatcher *self =
GST_PLAYER_QT_SIGNAL_DISPATCHER (object);
switch (prop_id) {
case QT_SIGNAL_DISPATCHER_PROP_PLAYER:
self->player = g_value_get_pointer (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_player_qt_signal_dispatcher_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec)
{
GstPlayerQtSignalDispatcher *self =
GST_PLAYER_QT_SIGNAL_DISPATCHER (object);
switch (prop_id) {
case QT_SIGNAL_DISPATCHER_PROP_PLAYER:
g_value_set_pointer (value, self->player);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_player_qt_signal_dispatcher_class_init
(GstPlayerQtSignalDispatcherClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize =
gst_player_qt_signal_dispatcher_finalize;
gobject_class->set_property =
gst_player_qt_signal_dispatcher_set_property;
gobject_class->get_property =
gst_player_qt_signal_dispatcher_get_property;
qt_signal_dispatcher_param_specs
[QT_SIGNAL_DISPATCHER_PROP_PLAYER] =
g_param_spec_pointer ("player", "Player instance", "",
static_cast<GParamFlags>(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_properties (gobject_class,
QT_SIGNAL_DISPATCHER_PROP_LAST,
qt_signal_dispatcher_param_specs);
}
static void
gst_player_qt_signal_dispatcher_init
(G_GNUC_UNUSED GstPlayerQtSignalDispatcher * self)
{
}
static void
gst_player_qt_signal_dispatcher_dispatch (GstPlayerSignalDispatcher
* iface, G_GNUC_UNUSED GstPlayer * player, void (*emitter) (gpointer data), gpointer data,
GDestroyNotify destroy)
{
GstPlayerQtSignalDispatcher *self = GST_PLAYER_QT_SIGNAL_DISPATCHER (iface);
QObject dispatch;
QObject *receiver = static_cast<QObject*>(self->player);
QObject::connect(&dispatch, &QObject::destroyed, receiver, [=]() {
emitter(data);
if (destroy) destroy(data);
}, Qt::QueuedConnection);
}
static void
gst_player_qt_signal_dispatcher_interface_init
(GstPlayerSignalDispatcherInterface * iface)
{
iface->dispatch = gst_player_qt_signal_dispatcher_dispatch;
}
GstPlayerSignalDispatcher *
gst_player_qt_signal_dispatcher_new (gpointer player)
{
return static_cast<GstPlayerSignalDispatcher*>
(g_object_new (GST_TYPE_PLAYER_QT_SIGNAL_DISPATCHER,
"player", player, NULL));
}

View file

@ -0,0 +1,316 @@
/* GStreamer
*
* Copyright (C) 2015 Alexandre Moreno <alexmorenocano@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef QGSTPLAYER_H
#define QGSTPLAYER_H
#include <QObject>
#include <QUrl>
#include <QSize>
//#include <QtGui/qwindowdefs.h>
#include <QVariant>
#include <QList>
#include <QImage>
#include <gst/player/player.h>
namespace QGstPlayer {
class VideoRenderer;
class MediaInfo;
class StreamInfo;
class VideInfo;
class AudioInfo;
class SubtitleInfo;
class Player : public QObject
{
Q_OBJECT
Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
Q_PROPERTY(qint64 duration READ duration NOTIFY durationChanged)
Q_PROPERTY(qint64 position READ position NOTIFY positionUpdated)
Q_PROPERTY(quint32 positionUpdateInterval READ positionUpdateInterval
WRITE setPositionUpdateInterval)
Q_PROPERTY(qreal volume READ volume WRITE setVolume NOTIFY volumeChanged)
Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged)
Q_PROPERTY(int buffering READ buffering NOTIFY bufferingChanged)
Q_PROPERTY(QSize resolution READ resolution WRITE setResolution NOTIFY resolutionChanged)
Q_PROPERTY(State state READ state NOTIFY stateChanged)
Q_PROPERTY(QObject *mediaInfo READ mediaInfo NOTIFY mediaInfoChanged)
Q_PROPERTY(bool videoAvailable READ isVideoAvailable NOTIFY videoAvailableChanged)
Q_PROPERTY(QVariant currentVideo READ currentVideo WRITE setCurrentVideo)
Q_PROPERTY(QVariant currentAudio READ currentAudio WRITE setCurrentAudio)
Q_PROPERTY(QVariant currentSubtitle READ currentSubtitle WRITE setCurrentSubtitle)
Q_PROPERTY(bool subtitleEnabled READ isSubtitleEnabled WRITE setSubtitleEnabled
NOTIFY subtitleEnabledChanged)
Q_PROPERTY(bool autoPlay READ autoPlay WRITE setAutoPlay)
Q_PROPERTY(QList<QUrl> playlist READ playlist WRITE setPlaylist)
Q_ENUMS(State)
public:
explicit Player(QObject *parent = 0, VideoRenderer *renderer = 0);
virtual ~Player();
typedef GstPlayerError Error;
enum State {
STOPPED = GST_PLAYER_STATE_STOPPED,
BUFFERING = GST_PLAYER_STATE_BUFFERING,
PAUSED = GST_PLAYER_STATE_PAUSED,
PLAYING = GST_PLAYER_STATE_PLAYING
};
QUrl source() const;
qint64 duration() const;
qint64 position() const;
qreal volume() const;
bool isMuted() const;
int buffering() const;
State state() const;
GstElement *pipeline() const;
QSize resolution() const;
void setResolution(QSize size);
bool isVideoAvailable() const;
MediaInfo *mediaInfo() const;
QVariant currentVideo() const;
QVariant currentAudio() const;
QVariant currentSubtitle() const;
bool isSubtitleEnabled() const;
quint32 positionUpdateInterval() const;
bool autoPlay() const;
QList<QUrl> playlist() const;
signals:
void stateChanged(State new_state);
void bufferingChanged(int percent);
void endOfStream();
void positionUpdated(qint64 new_position);
void durationChanged(qint64 duration);
void resolutionChanged(QSize resolution);
void volumeChanged(qreal volume);
void mutedChanged(bool muted);
void mediaInfoChanged();
void sourceChanged(QUrl new_url);
void videoAvailableChanged(bool videoAvailable);
void subtitleEnabledChanged(bool enabled);
public slots:
void play();
void pause();
void stop();
void seek(qint64 position);
void setSource(QUrl const& url);
void setVolume(qreal val);
void setMuted(bool val);
void setPosition(qint64 pos);
void setCurrentVideo(QVariant track);
void setCurrentAudio(QVariant track);
void setCurrentSubtitle(QVariant track);
void setSubtitleEnabled(bool enabled);
void setPositionUpdateInterval(quint32 interval);
void setPlaylist(const QList<QUrl> &playlist);
void next();
void previous();
void setAutoPlay(bool auto_play);
private:
Q_DISABLE_COPY(Player)
static void onStateChanged(Player *, GstPlayerState state);
static void onPositionUpdated(Player *, GstClockTime position);
static void onDurationChanged(Player *, GstClockTime duration);
static void onBufferingChanged(Player *, int percent);
static void onVideoDimensionsChanged(Player *, int w, int h);
static void onVolumeChanged(Player *);
static void onMuteChanged(Player *);
static void onMediaInfoUpdated(Player *, GstPlayerMediaInfo *media_info);
static void onEndOfStreamReached(Player *);
void setUri(QUrl url);
GstPlayer *player_;
State state_;
QSize videoDimensions_;
MediaInfo *mediaInfo_;
bool videoAvailable_;
bool subtitleEnabled_;
bool autoPlay_;
QList<QUrl> playlist_;
QList<QUrl>::iterator iter_;
};
class VideoRenderer
{
public:
GstPlayerVideoRenderer *renderer();
virtual GstElement *createVideoSink() = 0;
protected:
VideoRenderer();
virtual ~VideoRenderer();
private:
GstPlayerVideoRenderer *renderer_;
};
class MediaInfo : public QObject
{
Q_OBJECT
Q_PROPERTY(QString uri READ uri NOTIFY uriChanged)
Q_PROPERTY(bool seekable READ isSeekable NOTIFY seekableChanged)
Q_PROPERTY(QString title READ title NOTIFY titleChanged)
Q_PROPERTY(QList<QObject*> videoStreams READ videoStreams CONSTANT)
Q_PROPERTY(QList<QObject*> audioStreams READ audioStreams CONSTANT)
Q_PROPERTY(QList<QObject*> subtitleStreams READ subtitleStreams CONSTANT)
Q_PROPERTY(QImage sample READ sample NOTIFY sampleChanged)
public:
explicit MediaInfo(Player *player = 0);
QString uri() const;
QString title() const;
bool isSeekable() const;
const QList<QObject*> &videoStreams() const;
const QList<QObject*> &audioStreams() const;
const QList<QObject*> &subtitleStreams() const;
const QImage &sample();
signals:
void uriChanged();
void seekableChanged();
void titleChanged();
void sampleChanged();
public Q_SLOTS:
void update(GstPlayerMediaInfo *info);
private:
QString uri_;
QString title_;
bool isSeekable_;
QList<QObject*> videoStreams_;
QList<QObject*> audioStreams_;
QList<QObject*> subtitleStreams_;
QImage sample_;
};
class StreamInfo : public QObject
{
Q_OBJECT
Q_PROPERTY(int index READ index CONSTANT)
public:
int index() const;
protected:
StreamInfo(GstPlayerStreamInfo* info);
private:
GstPlayerStreamInfo *stream_;
int index_;
};
class VideoInfo : public StreamInfo
{
Q_OBJECT
Q_PROPERTY(QSize resolution READ resolution CONSTANT)
public:
VideoInfo(GstPlayerVideoInfo *info);
QSize resolution() const;
private:
GstPlayerVideoInfo *video_;
QSize resolution_;
};
class AudioInfo : public StreamInfo
{
Q_OBJECT
Q_PROPERTY(QString language READ language CONSTANT)
Q_PROPERTY(int channels READ channels CONSTANT)
Q_PROPERTY(int bitRate READ bitRate CONSTANT)
Q_PROPERTY(int sampleRate READ sampleRate CONSTANT)
public:
AudioInfo(GstPlayerAudioInfo *info);
QString const& language() const;
int channels() const;
int bitRate() const;
int sampleRate() const;
private:
GstPlayerAudioInfo *audio_;
QString language_;
int channels_;
int bitRate_;
int sampleRate_;
};
class SubtitleInfo : public StreamInfo
{
Q_OBJECT
Q_PROPERTY(QString language READ language CONSTANT)
public:
SubtitleInfo(GstPlayerSubtitleInfo *info);
QString const& language() const;
private:
GstPlayerSubtitleInfo *subtitle_;
QString language_;
};
}
Q_DECLARE_METATYPE(QGstPlayer::Player*)
Q_DECLARE_METATYPE(QGstPlayer::Player::State)
Q_DECLARE_METATYPE(QGstPlayer::MediaInfo*)
extern "C" {
typedef struct _GstPlayerQtVideoRenderer
GstPlayerQtVideoRenderer;
typedef struct _GstPlayerQtVideoRendererClass
GstPlayerQtVideoRendererClass;
#define GST_TYPE_PLAYER_QT_VIDEO_RENDERER (gst_player_qt_video_renderer_get_type ())
#define GST_IS_PLAYER_QT_VIDEO_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PLAYER_QT_VIDEO_RENDERER))
#define GST_IS_PLAYER_QT_VIDEO_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PLAYER_QT_VIDEO_RENDERER))
#define GST_PLAYER_QT_VIDEO_RENDERER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_PLAYER_QT_VIDEO_RENDERER, GstPlayerQtVideoRendererClass))
#define GST_PLAYER_QT_VIDEO_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PLAYER_QT_VIDEO_RENDERER, GstPlayerQtVideoRenderer))
#define GST_PLAYER_QT_VIDEO_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PLAYER_QT_VIDEO_RENDERER, GstPlayerQtVideoRendererClass))
#define GST_PLAYER_QT_VIDEO_RENDERER_CAST(obj) ((GstPlayerQtVideoRenderer*)(obj))
GType gst_player_qt_video_renderer_get_type (void);
typedef struct _GstPlayerQtSignalDispatcher
GstPlayerQtSignalDispatcher;
typedef struct _GstPlayerQtSignalDispatcherClass
GstPlayerQtSignalDispatcherClass;
#define GST_TYPE_PLAYER_QT_SIGNAL_DISPATCHER (gst_player_qt_signal_dispatcher_get_type ())
#define GST_IS_PLAYER_QT_SIGNAL_DISPATCHER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PLAYER_QT_SIGNAL_DISPATCHER))
#define GST_IS_PLAYER_QT_SIGNAL_DISPATCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PLAYER_QT_SIGNAL_DISPATCHER))
#define GST_PLAYER_QT_SIGNAL_DISPATCHER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_PLAYER_QT_SIGNAL_DISPATCHER, GstPlayerQtSignalDispatcherClass))
#define GST_PLAYER_QT_SIGNAL_DISPATCHER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PLAYER_QT_SIGNAL_DISPATCHER, GstPlayerQtSignalDispatcher))
#define GST_PLAYER_QT_SIGNAL_DISPATCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PLAYER_QT_SIGNAL_DISPATCHER, GstPlayerQtSignalDispatcherClass))
#define GST_PLAYER_QT_SIGNAL_DISPATCHER_CAST(obj) ((GstPlayerQtSignalDispatcher*)(obj))
GType gst_player_qt_video_renderer_get_type (void);
GstPlayerSignalDispatcher *
gst_player_qt_signal_dispatcher_new (gpointer player);
}
#endif // QGSTPLAYER_H

View file

@ -0,0 +1,9 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
<file>fontawesome.js</file>
</qresource>
<qresource prefix="/fonts">
<file>fontawesome-webfont.ttf</file>
</qresource>
</RCC>

View file

@ -0,0 +1,56 @@
/* GStreamer
*
* Copyright (C) 2015 Alexandre Moreno <alexmorenocano@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "quickrenderer.h"
QuickRenderer::QuickRenderer(QObject *parent)
: QObject(parent)
, QGstPlayer::VideoRenderer()
, sink()
{
}
QuickRenderer::~QuickRenderer()
{
if (sink) gst_object_unref(sink);
}
GstElement *QuickRenderer::createVideoSink()
{
GstElement *qmlglsink = gst_element_factory_make("qmlglsink", NULL);
GstElement *glsinkbin = gst_element_factory_make ("glsinkbin", NULL);
Q_ASSERT(qmlglsink && glsinkbin);
g_object_set (glsinkbin, "sink", qmlglsink, NULL);
sink = static_cast<GstElement*>(gst_object_ref_sink(qmlglsink));
return glsinkbin;
}
void QuickRenderer::setVideoItem(QQuickItem *item)
{
Q_ASSERT(item);
g_object_set(sink, "widget", item, NULL);
}

View file

@ -0,0 +1,42 @@
/* GStreamer
*
* Copyright (C) 2015 Alexandre Moreno <alexmorenocano@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef QUICKPLAYER_H
#define QUICKPLAYER_H
#include <QObject>
#include <QQuickItem>
#include "qgstplayer.h"
class QuickRenderer : public QObject, public QGstPlayer::VideoRenderer
{
Q_OBJECT
public:
QuickRenderer(QObject *parent = 0);
~QuickRenderer();
GstElement *createVideoSink();
void setVideoItem(QQuickItem *item);
private:
GstElement *sink;
};
#endif // QUICKPLAYER_H