├── NativeOSXCanvas
├── .gitignore
├── QTKitCanvas.xcodeproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ ├── xcuserdata
│ │ │ ├── jesse.xcuserdatad
│ │ │ │ ├── UserInterfaceState.xcuserstate
│ │ │ │ └── WorkspaceSettings.xcsettings
│ │ │ └── datavyu.xcuserdatad
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcshareddata
│ │ │ └── IDEWorkspaceChecks.plist
│ └── xcuserdata
│ │ ├── datavyu.xcuserdatad
│ │ └── xcschemes
│ │ │ └── xcschememanagement.plist
│ │ └── jesse.xcuserdatad
│ │ ├── xcschemes
│ │ ├── xcschememanagement.plist
│ │ ├── JAWTExample.xcscheme
│ │ ├── Compile Java.xcscheme
│ │ ├── Compile Native.xcscheme
│ │ └── Assemble Application.xcscheme
│ │ └── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
├── src
│ ├── java
│ │ └── com
│ │ │ └── apple
│ │ │ └── dts
│ │ │ └── samplecode
│ │ │ └── jawtexample
│ │ │ ├── LayerBackedCanvas.java
│ │ │ ├── NativeDrawnCanvas.java
│ │ │ └── JAWTExample.java
│ └── native
│ │ └── DrawingCanvas.m
└── make
│ ├── find-classrefs.sh
│ └── build.xml
├── src
├── main
│ ├── cpp
│ │ ├── MediaPLayerTest.xcodeproj
│ │ │ └── project.xcworkspace
│ │ │ │ └── contents.xcworkspacedata
│ │ ├── FfmpegJavaMediaPlayer.xcodeproj
│ │ │ ├── project.xcworkspace
│ │ │ │ └── contents.xcworkspacedata
│ │ │ └── xcuserdata
│ │ │ │ ├── datavyu.xcuserdatad
│ │ │ │ └── xcschemes
│ │ │ │ │ └── xcschememanagement.plist
│ │ │ │ └── RedaNezzar.xcuserdatad
│ │ │ │ └── xcschemes
│ │ │ │ ├── xcschememanagement.plist
│ │ │ │ └── FfmpegJavaMediaPlayer.xcscheme
│ │ ├── FfmpegErrorUtils.h
│ │ ├── FfmpegJavaAVPipline.h
│ │ ├── packages.config
│ │ ├── MediaPlayer.xcodeproj
│ │ │ ├── project.xcworkspace
│ │ │ │ ├── contents.xcworkspacedata
│ │ │ │ ├── xcuserdata
│ │ │ │ │ └── datavyu.xcuserdatad
│ │ │ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ │ └── xcshareddata
│ │ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ └── xcuserdata
│ │ │ │ ├── RedaNezzar.xcuserdatad
│ │ │ │ └── xcschemes
│ │ │ │ │ ├── xcschememanagement.plist
│ │ │ │ │ └── MediaPlayer.xcscheme
│ │ │ │ └── datavyu.xcuserdatad
│ │ │ │ └── xcschemes
│ │ │ │ └── xcschememanagement.plist
│ │ ├── PipelineData.cpp
│ │ ├── MediaPlayer.xcworkspace
│ │ │ ├── xcshareddata
│ │ │ │ ├── WorkspaceSettings.xcsettings
│ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ └── contents.xcworkspacedata
│ │ ├── PlayerState.h
│ │ ├── org_datavyu_plugins_ffmpeg_NativeMediaPlayer_MediaErrorEvent.h
│ │ ├── TestDecoder.cpp
│ │ ├── FfmpegPipelineFactory.h
│ │ ├── FfmpegPipelineFactory.cpp
│ │ ├── Logger.cpp
│ │ ├── FfmpegJniUtils.h
│ │ ├── Info.plist
│ │ ├── AudioVideoFormats.cpp
│ │ ├── AudioVideoFormats.h
│ │ ├── org_datavyu_plugins_ffmpeg_NativeMediaPlayer_EventQueueThread.h
│ │ ├── player.cpp
│ │ ├── Clock.cpp
│ │ ├── FFplay.vcxproj.filters
│ │ ├── TestClock.cpp
│ │ ├── Clock.h
│ │ ├── FfmpegJavaAvPlayback.h
│ │ ├── Decoder.h
│ │ ├── FfmpegSdlMediaPlayer.vcxproj.filters
│ │ ├── Media.h
│ │ ├── org_datavyu_plugins_ffmpeg_NativeMediaPlayer.h
│ │ ├── Singleton.h
│ │ ├── PipelineData.h
│ │ ├── FfmpegJavaAvPlaybackPipline.h
│ │ ├── FfmpegSdlAvPlaybackPipeline.h
│ │ ├── FfmpegJavaMediaPlayer.vcxproj.filters
│ │ ├── PacketQueue.h
│ │ ├── PipelineOptions.h
│ │ ├── FfmpegAvPlayback.cpp
│ │ ├── JniUtils.h
│ │ ├── Media.cpp
│ │ ├── TestPacketQueue.cpp
│ │ ├── VideoState.vcxitems
│ │ ├── JavaPlayerEventDispatcher.h
│ │ ├── FrameQueue.cpp
│ │ ├── JniUtils.cpp
│ │ ├── PacketQueue.cpp
│ │ ├── FrameQueue.h
│ │ ├── Pipeline.h
│ │ ├── MediaPlayer.sln
│ │ ├── Decoder.cpp
│ │ ├── FfmpegErrorUtils.cpp
│ │ ├── FfmpegSdlMediaPlayer.xcodeproj
│ │ │ └── xcshareddata
│ │ │ │ └── xcschemes
│ │ │ │ └── MediaPlayerWorkspace.xcscheme
│ │ └── MediaPlayerErrors.h
│ ├── java
│ │ └── org
│ │ │ └── datavyu
│ │ │ ├── plugins
│ │ │ ├── PlayerEvent.java
│ │ │ ├── MediaErrorListener.java
│ │ │ ├── SdlKeyEventListener.java
│ │ │ ├── PlayerStateListener.java
│ │ │ ├── MediaException.java
│ │ │ ├── MediaPlayerData.java
│ │ │ ├── MediaPlayerWindow.java
│ │ │ ├── nativeosx
│ │ │ │ ├── NativeOSXPlayer.java
│ │ │ │ └── AVFoundationMediaPlayer.java
│ │ │ ├── PlayerStateEvent.java
│ │ │ ├── ffmpeg
│ │ │ │ ├── FfmpegMediaPlayer.java
│ │ │ │ └── AudioPlayerThread.java
│ │ │ ├── PlaybackRateController.java
│ │ │ └── DatavyuMediaPlayer.java
│ │ │ └── util
│ │ │ ├── Utils.java
│ │ │ └── MediaErrorToHeaderFile.java
│ └── resources
│ │ └── log4j2.xml
└── test
│ └── java
│ ├── winTestngSuite.xml
│ ├── macTestngSuite.xml
│ └── org
│ └── datavyu
│ └── plugins
│ └── ffmpeg
│ ├── MediaInformation.java
│ ├── FfmpegJavaMediaPlayerTest.java
│ └── FfmpegSdlMediaPlayerTest.java
├── demo
├── SimpleJavaFXMediaPlayer.java
├── SimpleAVFoundationMediaPlayer.java
├── SimpleSdlMediaPlayer.java
└── JavaFXMediaPlayer.java
├── .travis.yml
├── .appveyor.yml
├── .gitignore
└── .gitattributes
/NativeOSXCanvas/.gitignore:
--------------------------------------------------------------------------------
1 | .build/
2 |
3 |
--------------------------------------------------------------------------------
/src/main/cpp/MediaPLayerTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
--------------------------------------------------------------------------------
/src/main/cpp/FfmpegJavaMediaPlayer.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
--------------------------------------------------------------------------------
/src/main/cpp/FfmpegErrorUtils.h:
--------------------------------------------------------------------------------
1 | #ifndef _FFMPEG_ERROR_UTILS_H_
2 | #define _FFMPEG_ERROR_UTILS_H_
3 |
4 | int FfmpegToJavaErrNo(int ffmpegErrNo);
5 |
6 | #endif // _FFMPEG_ERROR_UTILS_H_
7 |
--------------------------------------------------------------------------------
/src/main/cpp/FfmpegJavaAVPipline.h:
--------------------------------------------------------------------------------
1 | #ifndef FFMPEGJAVAAVPIPELINE_H_
2 | #define FFMPEGJAVAAVPIPELINE_H_
3 |
4 | class FfmpegJavaAVPipline {};
5 |
6 | #endif // !FFMPEGAVJAVAPIPELINE_H_
7 |
--------------------------------------------------------------------------------
/src/main/cpp/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/src/main/cpp/MediaPlayer.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/src/main/cpp/PipelineData.cpp:
--------------------------------------------------------------------------------
1 | #include "PipelineData.h"
2 |
3 | CPipelineData::CPipelineData(CPipelineOptions *pOptions)
4 | : CPipeline(pOptions) {}
5 |
6 | CPipelineData::~CPipelineData() {}
7 |
8 | void CPipelineData::Dispose() {}
9 |
--------------------------------------------------------------------------------
/demo/SimpleJavaFXMediaPlayer.java:
--------------------------------------------------------------------------------
1 | import javafx.application.Application;
2 |
3 | public class SimpleJavaFXMediaPlayer {
4 | public static void main(String[] args) {
5 | Application.launch(JavaFXMediaPlayer.class, args);
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/NativeOSXCanvas/QTKitCanvas.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/src/main/cpp/MediaPlayer.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/main/java/org/datavyu/plugins/PlayerEvent.java:
--------------------------------------------------------------------------------
1 | package org.datavyu.plugins;
2 |
3 | /**
4 | * Generic player event
5 | *
6 | *
This is the super-class to other player event classes
7 | */
8 | public class PlayerEvent {
9 | public PlayerEvent() {}
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/cpp/MediaPlayer.xcodeproj/project.xcworkspace/xcuserdata/datavyu.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/databrary/datavyu-ffmpegplugin/HEAD/src/main/cpp/MediaPlayer.xcodeproj/project.xcworkspace/xcuserdata/datavyu.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/NativeOSXCanvas/QTKitCanvas.xcodeproj/project.xcworkspace/xcuserdata/jesse.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/databrary/datavyu-ffmpegplugin/HEAD/NativeOSXCanvas/QTKitCanvas.xcodeproj/project.xcworkspace/xcuserdata/jesse.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/NativeOSXCanvas/QTKitCanvas.xcodeproj/project.xcworkspace/xcuserdata/datavyu.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/databrary/datavyu-ffmpegplugin/HEAD/NativeOSXCanvas/QTKitCanvas.xcodeproj/project.xcworkspace/xcuserdata/datavyu.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/src/test/java/winTestngSuite.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/main/cpp/PlayerState.h:
--------------------------------------------------------------------------------
1 | #ifndef PLAYERSTATE_H_
2 | #define PLAYERSTATE_H_
3 |
4 | namespace PlayerState {
5 | enum State {
6 | Unknown = 0,
7 | Ready = 1,
8 | Playing = 2,
9 | Paused = 3,
10 | Stopped = 4,
11 | Stalled = 5,
12 | Finished = 6,
13 | Error = 7
14 | };
15 | }
16 |
17 | #endif
18 |
--------------------------------------------------------------------------------
/src/main/cpp/MediaPlayer.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/main/cpp/MediaPlayer.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/NativeOSXCanvas/QTKitCanvas.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/test/java/macTestngSuite.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/main/cpp/FfmpegJavaMediaPlayer.xcodeproj/xcuserdata/datavyu.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | FfmpegJavaMediaPlayer.xcscheme
8 |
9 | orderHint
10 | 1
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/main/cpp/org_datavyu_plugins_ffmpeg_NativeMediaPlayer_MediaErrorEvent.h:
--------------------------------------------------------------------------------
1 | /* DO NOT EDIT THIS FILE - it is machine generated */
2 | #include
3 | /* Header for class org_datavyu_plugins_ffmpeg_NativeMediaPlayer_MediaErrorEvent */
4 |
5 | #ifndef _Included_org_datavyu_plugins_ffmpeg_NativeMediaPlayer_MediaErrorEvent
6 | #define _Included_org_datavyu_plugins_ffmpeg_NativeMediaPlayer_MediaErrorEvent
7 | #ifdef __cplusplus
8 | extern "C" {
9 | #endif
10 | #ifdef __cplusplus
11 | }
12 | #endif
13 | #endif
14 |
--------------------------------------------------------------------------------
/src/main/cpp/TestDecoder.cpp:
--------------------------------------------------------------------------------
1 | // Note, the tests here are limited to memory allo/free
2 | // TODO(fraudies): Add more tests with e.g. a single video frame/file to decode.
3 |
4 | #include "gtest/gtest.h"
5 |
6 | #include "Decoder.h"
7 |
8 | #include
9 |
10 | TEST(DecoderTest, CreateDeleteTest) {
11 | std::condition_variable empty_queue_cond;
12 | PacketQueue packetQueue;
13 | AVCodecContext *pAvctx = avcodec_alloc_context3(NULL);
14 | Decoder decoder(pAvctx, &packetQueue, &empty_queue_cond);
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/cpp/MediaPlayer.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
12 |
13 |
15 |
16 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/src/main/cpp/FfmpegPipelineFactory.h:
--------------------------------------------------------------------------------
1 | #ifndef FFMPEGPIPELINEFACTORY_H_
2 | #define FFMPEGPIPELINEFACTORY_H_
3 |
4 | #include "PipelineFactory.h"
5 | #include "PipelineOptions.h"
6 | #include "FfmpegSdlAvPlaybackPipeline.h"
7 | #include "FfmpegJavaAvPlaybackPipline.h"
8 | #include "FfmpegMediaErrors.h"
9 |
10 | class FfmpegPipelineFactory : public PipelineFactory {
11 | public:
12 | FfmpegPipelineFactory();
13 | virtual ~FfmpegPipelineFactory();
14 |
15 | uint32_t CreatePlayerPipeline(CPipelineOptions *pOptions, CPipeline** ppPipeline);
16 |
17 | private:
18 | };
19 | #endif // FFMPEGPIPELINEFACTORY_H_
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | os: osx
2 |
3 | osx_image: xcode9.3
4 |
5 | git:
6 | depth: 1
7 |
8 | branches:
9 | only:
10 | - dev
11 | - master
12 |
13 | language: java
14 |
15 | cache:
16 | directories:
17 | - $HOME/.m2
18 | - $HOME/resources
19 |
20 | install:
21 | - curl -L https://github.com/databrary/FFplay64/raw/master/dependencies.zip -o $TRAVIS_BUILD_DIR/src/main/cpp/dependencies.zip
22 | - unzip -qq $TRAVIS_BUILD_DIR/src/main/cpp/dependencies.zip -d $TRAVIS_BUILD_DIR/src/main/cpp/
23 | - java -version
24 | - mvn -version
25 |
26 | script:
27 | - mvn -T 4 -Prelease,mac -Dmaven.test.skip=true clean package
--------------------------------------------------------------------------------
/src/main/cpp/FfmpegPipelineFactory.cpp:
--------------------------------------------------------------------------------
1 | #include "FfmpegPipelineFactory.h"
2 |
3 | FfmpegPipelineFactory::FfmpegPipelineFactory()
4 | {}
5 |
6 | FfmpegPipelineFactory::~FfmpegPipelineFactory()
7 | {}
8 |
9 | uint32_t FfmpegPipelineFactory::CreatePlayerPipeline(CPipelineOptions *pOptions, CPipeline **ppPipeline) {
10 |
11 | *ppPipeline = NULL;
12 | if (pOptions->GetStreamData())
13 | *ppPipeline = new (nothrow) FfmpegJavaAvPlaybackPipline(pOptions);
14 | else
15 | *ppPipeline = new (nothrow) FfmpegSdlAvPlaybackPipeline(pOptions);
16 |
17 | if (NULL == ppPipeline)
18 | return ERROR_PIPELINE_NULL;
19 |
20 | return ERROR_NONE;
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/cpp/MediaPlayer.xcodeproj/xcuserdata/RedaNezzar.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | MediaPlayer.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | E95D243021966BBF007A6758
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/main/cpp/MediaPlayer.xcodeproj/xcuserdata/datavyu.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | MediaPlayer.xcscheme
8 |
9 | orderHint
10 | 2
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | E95D243021966BBF007A6758
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/main/cpp/FfmpegJavaMediaPlayer.xcodeproj/xcuserdata/RedaNezzar.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | FfmpegJavaMediaPlayer.xcscheme
8 |
9 | orderHint
10 | 3
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | E95564D421963D3800A2AD8D
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/main/java/org/datavyu/plugins/MediaErrorListener.java:
--------------------------------------------------------------------------------
1 | package org.datavyu.plugins;
2 |
3 | /**
4 | * An interface used to receive notifications of errors, encountered
5 | * while processing media.
6 | */
7 | public interface MediaErrorListener {
8 | /**
9 | * Reports the occurrence of a error in media processing. An error may
10 | * or may not cause a stop in processing.
11 | *
12 | * @param source the source of the warning, likely the object calling this method.
13 | * @param errorCode an error code from the internal playback processor
14 | * @param message a String containing the warning.
15 | */
16 | void onError(Object source, int errorCode, String message);
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/org/datavyu/util/Utils.java:
--------------------------------------------------------------------------------
1 | package org.datavyu.util;
2 |
3 | import org.apache.logging.log4j.LogManager;
4 | import org.apache.logging.log4j.Logger;
5 |
6 | public class Utils {
7 | private static final Logger logger = LogManager.getFormatterLogger(Utils.class);
8 | public static final char SEPARATOR;
9 | public static final boolean isMac;
10 | public static final boolean isWindows;
11 |
12 | static {
13 | // Look for Platform
14 | String OS = System.getProperty("os.name").toLowerCase();
15 | isMac = OS.contains("mac");
16 | isWindows = OS.contains("win");
17 | logger.info("Platform detected : " + (isMac ? "Mac OS" : "Windows"));
18 |
19 | SEPARATOR = isMac ? '.' : '-';
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/resources/log4j2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/main/java/org/datavyu/plugins/SdlKeyEventListener.java:
--------------------------------------------------------------------------------
1 | package org.datavyu.plugins;
2 |
3 | /**
4 | * An interface used to receive notifications of key events, encountered
5 | * while using the SDL media player.
6 | */
7 | public interface SdlKeyEventListener {
8 |
9 | /**
10 | * Reports the occurrence of a key event in SDL Media player window.
11 | * The SDL key Code is mapped to a Java Key Code ID in the Native.
12 | *
13 | * @param source the source of the event, likely the object calling this method.
14 | * @param nativeMediaRef the native reference of the SDL media Player.
15 | * @param javaKeyCode a KeyEvent value.
16 | */
17 | void onKeyEvent(Object source, long nativeMediaRef,int javaKeyCode);
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/cpp/Logger.cpp:
--------------------------------------------------------------------------------
1 | #include "Logger.h"
2 | // compile cl Logger.cpp
3 | // Run Logger.exe
4 |
5 | int main(int argc, char** argv) {
6 | Logger* pLogger = new StreamLogger(&std::cerr);
7 | //Logger* pLogger = new FileLogger("logger.txt");
8 | pLogger->setLevel(Logger::ALL);
9 | pLogger->info("This is the first logging message");
10 | pLogger->warn("You better get smaller than %d.", 5);
11 | pLogger->debug("Hehe, a floating point %2.2f", 3.14);
12 | pLogger->error("This is an error with code %d.", 7);
13 | pLogger->warn("This is a warning with decimal %f.", 1.5);
14 | pLogger->debug("A debug message with another string %s.", "another one");
15 | pLogger->info("Just so you know!");
16 | delete pLogger;
17 | pLogger = nullptr;
18 | return 0;
19 | }
--------------------------------------------------------------------------------
/src/main/cpp/FfmpegJniUtils.h:
--------------------------------------------------------------------------------
1 | #ifndef _FFMPEG_JNI_UTILS_H_
2 | #define _FFMPEG_JNI_UTILS_H_
3 |
4 | #include "AudioVideoFormats.h"
5 | #include
6 |
7 | // This mapping is taken from java.awt.color.ColorSpace.java
8 | #define TYPE_RGB 5
9 |
10 | uint32_t SetJAudioFormat(JNIEnv *env, jobject j_audio_format,
11 | const AudioFormat &audio_format);
12 |
13 | uint32_t SetJPixelFormat(JNIEnv *env, jobject j_pixel_format,
14 | const PixelFormat &pixel_format);
15 |
16 | uint32_t GetAudioFormat(JNIEnv *env, jobject j_audio_format,
17 | AudioFormat *p_audio_format);
18 |
19 | uint32_t GetPixelFormat(JNIEnv *env, jobject j_pixel_format,
20 | PixelFormat *p_pixel_format);
21 |
22 | #endif //_FFMPEG_JNI_UTILS_H_
23 |
--------------------------------------------------------------------------------
/src/main/cpp/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/NativeOSXCanvas/QTKitCanvas.xcodeproj/xcuserdata/datavyu.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | Assemble Application.xcscheme
8 |
9 | orderHint
10 | 3
11 |
12 | Compile Java.xcscheme
13 |
14 | orderHint
15 | 1
16 |
17 | Compile Native.xcscheme
18 |
19 | orderHint
20 | 2
21 |
22 | QTKitCanvas.xcscheme
23 |
24 | orderHint
25 | 0
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/NativeOSXCanvas/QTKitCanvas.xcodeproj/project.xcworkspace/xcuserdata/jesse.xcuserdatad/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | BuildLocationStyle
6 | UseAppPreferences
7 | CustomBuildLocationType
8 | RelativeToDerivedData
9 | DerivedDataLocationStyle
10 | Default
11 | HasAskedToTakeAutomaticSnapshotBeforeSignificantChanges
12 |
13 | IssueFilterStyle
14 | ShowActiveSchemeOnly
15 | LiveSourceIssuesEnabled
16 |
17 | SnapshotAutomaticallyBeforeSignificantChanges
18 |
19 | SnapshotLocationStyle
20 | Default
21 |
22 |
23 |
--------------------------------------------------------------------------------
/demo/SimpleAVFoundationMediaPlayer.java:
--------------------------------------------------------------------------------
1 | import org.datavyu.plugins.nativeosx.AVFoundationMediaPlayer;
2 | import org.datavyu.plugins.MediaPlayer;
3 |
4 | import javax.swing.*;
5 | import java.io.File;
6 | import java.net.URI;
7 |
8 | public class SimpleAVFoundationMediaPlayer {
9 | public static void main(String[] args) {
10 | // Define the media file
11 | URI mediaPath = new File("Nature_30fps_1080p.mp4").toURI();
12 |
13 | // Create the media player using the constructor with File
14 | MediaPlayer mediaPlayer = new AVFoundationMediaPlayer(mediaPath, new JDialog());
15 |
16 | mediaPlayer.addMediaErrorListener(
17 | (source, errorCode, message) ->
18 | System.err.println(source.getClass() + " - " + errorCode + ": " + message));
19 |
20 | // Initialize the player
21 | mediaPlayer.init();
22 |
23 | // Open a JFrame to control the media player through key commands
24 | new JMediaPlayerControlFrame(mediaPlayer);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/cpp/AudioVideoFormats.cpp:
--------------------------------------------------------------------------------
1 | #include "AudioVideoFormats.h"
2 | #include "AudioVideoFormats.h"
3 |
4 | extern "C" {
5 | #include // codecs
6 | }
7 |
8 | AudioFormat::AudioFormat() {}
9 |
10 | void AudioFormat::ToAudioParams(AudioParams *pAudioParams) const {
11 | pAudioParams->num_channels_ = num_channels_;
12 | pAudioParams->frame_size_ = frame_size_;
13 | pAudioParams->frequency_ = sample_rate_;
14 | pAudioParams->bytes_per_sec_ = frame_rate_;
15 | pAudioParams->channel_layout_ = av_get_default_channel_layout(num_channels_);
16 | // TODO(fraudies): Support more formats (currently not necessary because of
17 | // the javax SoundLine does not support more formats
18 | if (strcmp("PCM_UNSIGNED", encoding_name_.c_str()) == 0) {
19 | pAudioParams->sample_format_ = AV_SAMPLE_FMT_U8;
20 | } else if (strcmp("PCM_SIGNED", encoding_name_.c_str()) == 0) {
21 | pAudioParams->sample_format_ = AV_SAMPLE_FMT_S16;
22 | }
23 | }
24 |
25 | PixelFormat::PixelFormat() {}
26 |
--------------------------------------------------------------------------------
/src/main/cpp/AudioVideoFormats.h:
--------------------------------------------------------------------------------
1 | #ifndef _AUDIO_VIDEO_FORMATS_H_
2 | #define _AUDIO_VIDEO_FORMATS_H_
3 | #include
4 |
5 | extern "C" {
6 | #include "libavutil/pixfmt.h"
7 | #include "libavutil/samplefmt.h"
8 | }
9 |
10 | // TODO(fraudies): Consolidate AudioParams and AudioFormat
11 | typedef struct AudioParams {
12 | int frequency_;
13 | int num_channels_;
14 | int64_t channel_layout_;
15 | enum AVSampleFormat sample_format_;
16 | int frame_size_;
17 | int bytes_per_sec_;
18 | } AudioParams;
19 |
20 | class AudioFormat {
21 | public:
22 | std::string encoding_name_;
23 | float sample_rate_;
24 | int sample_size_in_bits_;
25 | int num_channels_;
26 | int frame_size_;
27 | float frame_rate_;
28 | bool is_big_endian_;
29 | AudioFormat();
30 | void ToAudioParams(AudioParams *pAudioParams) const;
31 | };
32 |
33 | class PixelFormat {
34 | public:
35 | AVPixelFormat pixel_format_;
36 | int num_components_;
37 | PixelFormat();
38 | };
39 |
40 | #endif // _AUDIO_VIDEO_FORMATS_H_
41 |
--------------------------------------------------------------------------------
/src/main/cpp/org_datavyu_plugins_ffmpeg_NativeMediaPlayer_EventQueueThread.h:
--------------------------------------------------------------------------------
1 | /* DO NOT EDIT THIS FILE - it is machine generated */
2 | #include
3 | /* Header for class org_datavyu_plugins_ffmpeg_NativeMediaPlayer_EventQueueThread */
4 |
5 | #ifndef _Included_org_datavyu_plugins_ffmpeg_NativeMediaPlayer_EventQueueThread
6 | #define _Included_org_datavyu_plugins_ffmpeg_NativeMediaPlayer_EventQueueThread
7 | #ifdef __cplusplus
8 | extern "C" {
9 | #endif
10 | #undef org_datavyu_plugins_ffmpeg_NativeMediaPlayer_EventQueueThread_MIN_PRIORITY
11 | #define org_datavyu_plugins_ffmpeg_NativeMediaPlayer_EventQueueThread_MIN_PRIORITY 1L
12 | #undef org_datavyu_plugins_ffmpeg_NativeMediaPlayer_EventQueueThread_NORM_PRIORITY
13 | #define org_datavyu_plugins_ffmpeg_NativeMediaPlayer_EventQueueThread_NORM_PRIORITY 5L
14 | #undef org_datavyu_plugins_ffmpeg_NativeMediaPlayer_EventQueueThread_MAX_PRIORITY
15 | #define org_datavyu_plugins_ffmpeg_NativeMediaPlayer_EventQueueThread_MAX_PRIORITY 10L
16 | #ifdef __cplusplus
17 | }
18 | #endif
19 | #endif
20 |
--------------------------------------------------------------------------------
/src/main/cpp/player.cpp:
--------------------------------------------------------------------------------
1 | #include "FfmpegSdlAvPlayback.h"
2 |
3 | int runFFmpegPlayer(const char *input_filename, AVInputFormat *file_iformat) {
4 |
5 | av_log_set_flags(AV_LOG_SKIP_REPEATED);
6 | av_log(NULL, AV_LOG_WARNING, "Init Network\n");
7 | FfmpegSdlAvPlayback *p_player = new FfmpegSdlAvPlayback();
8 | int err = p_player->OpenVideo(input_filename, file_iformat);
9 | if (err) {
10 | fprintf(stderr, "Error %d when opening input file %s", err, input_filename);
11 | return err;
12 | }
13 | FfmpegSdlAvPlayback::InitializeAndListenForEvents(p_player);
14 |
15 | return 0;
16 | }
17 |
18 | int main(int argc, char **argv) {
19 | static const char *input_filename =
20 | //"Nature_30fps_1080p.mp4";
21 | "DatavyuSampleVideo.mp4";
22 | //"counter.mp4";
23 | //"http://www.html5videoplayer.net/videos/toystory.mp4";
24 | AVInputFormat *file_iformat = nullptr;
25 |
26 | /******************************************************
27 | * Uncomment this part to test the ffmpeg player
28 | ******************************************************/
29 | runFFmpegPlayer(input_filename, file_iformat);
30 |
31 | return 0;
32 | }
33 |
--------------------------------------------------------------------------------
/.appveyor.yml:
--------------------------------------------------------------------------------
1 | version: 1.0.{build}
2 |
3 | image: Visual Studio 2017
4 |
5 | clone_depth: 1
6 |
7 | branches:
8 | only:
9 | - master
10 | - dev
11 |
12 | environment:
13 | JAVA_HOME: C:\Program Files\Java\jdk1.8.0
14 |
15 | install:
16 | - ps: |
17 | if (!(Test-path -Path "C:\FFplay64")) {
18 | Write-Output "Download FFmpeg Dependencies"
19 | Invoke-WebRequest "https://github.com/databrary/FFplay64/raw/master/FFplay64.zip" -OutFile "C:\FFplay64.zip"
20 | Write-Output "Extract FFmpeg dependencies"
21 | Expand-Archive -LiteralPath C:\FFplay64.zip -DestinationPath C:\
22 | }
23 | $msbuild = (Get-Command msbuild).path
24 | Write-Output $msbuild
25 |
26 | - cmd: SET PATH=%JAVA_HOME%\bin;%PATH%
27 | - cmd: mvn --version
28 | - cmd: java -version
29 |
30 | cache:
31 | - C:\apache-maven-3.5.4\
32 | - C:\Users\appveyor\.m2
33 | - C:\FFplay64\
34 | - C:\resources\
35 |
36 | before_build:
37 | - cd %APPVEYOR_BUILD_FOLDER%\src\main\cpp
38 | - nuget restore MediaPlayer.sln
39 | - cd %APPVEYOR_BUILD_FOLDER%
40 |
41 | build_script:
42 | - mvn -T 4 -Prelease,win64 clean compile
43 |
44 | #test_script:
45 | # - mvn -T 4 -Prelease,win64 test
--------------------------------------------------------------------------------
/src/main/cpp/Clock.cpp:
--------------------------------------------------------------------------------
1 | #include "Clock.h"
2 |
3 | extern "C" {
4 | #include "libavutil/log.h"
5 | }
6 |
7 | Clock::Clock(const int *queue_serial)
8 | : time(0.0), serial(-1), p_serial_(queue_serial) {
9 | SetTime(NAN, -1);
10 | }
11 |
12 | Clock::~Clock() {
13 | if (p_serial_) {
14 | p_serial_ == nullptr;
15 | }
16 | }
17 |
18 | Clock::Clock() : time(0.0), serial(-1), p_serial_(&serial) { SetTime(NAN, -1); }
19 |
20 | double Clock::GetTime() const {
21 | if (SerialNoMatch()) {
22 | return NAN;
23 | }
24 | return time;
25 | }
26 |
27 | void Clock::SetTime(double newTime, int newSerial) {
28 | if (!isnan(newTime)) {
29 | time = newTime;
30 | }
31 | serial = newSerial;
32 | }
33 |
34 | void Clock::SyncMasterToSlave(Clock *master, Clock *slave,
35 | double noSyncThreshold) {
36 | double master_time = master->GetTime();
37 | double slave_time = slave->GetTime();
38 | if (!isnan(slave_time) &&
39 | (isnan(master_time) ||
40 | fabs(master_time - slave_time) > noSyncThreshold)) {
41 | av_log(NULL, AV_LOG_TRACE, "Sync %7.2f to %7.2f\n", slave_time,
42 | master_time);
43 | master->SetTime(slave_time, slave->serial);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/cpp/FFplay.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 | Source Files
23 |
24 |
25 |
26 |
27 | Header Files
28 |
29 |
30 |
--------------------------------------------------------------------------------
/src/main/cpp/TestClock.cpp:
--------------------------------------------------------------------------------
1 | #include "Clock.h"
2 | #include "gtest/gtest.h"
3 |
4 | #ifdef __APPLE__
5 | #include
6 | #endif
7 | #include
8 | #include
9 | #include
10 |
11 | // TODO(fraudies): Add test for sync method
12 |
13 | TEST(ClockTest, CreateAndDeleteClockTest) {
14 | int serial = 0;
15 | Clock clock(&serial);
16 | ASSERT_EQ(clock.GetSerial(), -1.0);
17 | }
18 |
19 | TEST(ClockTest, SetGetTimeTest) {
20 | // Create a clock
21 | int serial = 0;
22 | Clock clock(&serial);
23 |
24 | // Set different serial should return NAN
25 | clock.SetTime(1.0, 2);
26 | ASSERT_TRUE(isnan(clock.GetTime()));
27 |
28 | // Set clock with same serial and get time
29 | double time = av_gettime_relative() / MICRO;
30 | clock.SetTime(time, serial);
31 | // ASSERT LESS THAN
32 | ASSERT_LT(fabs(clock.GetTime() - time),
33 | std::numeric_limits::epsilon());
34 |
35 | // Wait for 100 msec
36 | std::this_thread::sleep_for(std::chrono::milliseconds(100));
37 | double speed = 1.0;
38 | double newTime = av_gettime_relative() / MICRO;
39 |
40 | // ASSERT LESS THAN, the expired time does not matter, only the setTime
41 | // changes the clock's time
42 | ASSERT_LT(fabs(clock.GetTime() - time),
43 | std::numeric_limits::epsilon());
44 | }
45 |
--------------------------------------------------------------------------------
/NativeOSXCanvas/src/java/com/apple/dts/samplecode/jawtexample/LayerBackedCanvas.java:
--------------------------------------------------------------------------------
1 | /*
2 |
3 |
4 | */
5 |
6 | package com.apple.dts.samplecode.jawtexample;
7 |
8 | import java.awt.Canvas;
9 |
10 | public class LayerBackedCanvas extends Canvas {
11 | static {
12 | // Standard JNI: load the native library
13 | System.loadLibrary("JAWTExample");
14 | }
15 |
16 | public void addNotify() {
17 | super.addNotify();
18 | addNativeCoreAnimationLayer("file:///Users/jesse/Desktop/minecraft.mp4");
19 | }
20 |
21 | // This method is implemented in native code. See NativeCanvas.m
22 | public native void addNativeCoreAnimationLayer(String path);
23 |
24 | public native void stop();
25 |
26 | public native void play();
27 |
28 | public native void setTime(long time);
29 |
30 | public native void setVolume(float time);
31 |
32 | public native void release();
33 |
34 | public native double getMovieHeight();
35 |
36 | public native double getMovieWidth();
37 |
38 | public native long getCurrentTime();
39 |
40 | public native long getDuration();
41 |
42 | public native float getRate();
43 |
44 | public native boolean isPlaying();
45 |
46 | public native void setRate(float rate);
47 |
48 | public native float getFPS();
49 |
50 | }
--------------------------------------------------------------------------------
/NativeOSXCanvas/make/find-classrefs.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Prints all class references made by all classes in a Jar file
4 | # Depends on the output formatting of javap
5 |
6 | # create a temporary working directory
7 | dir=`mktemp -d $TMPDIR/classrefs.XXXXXX`
8 |
9 | asm_dump="$dir/asm_dump"
10 | all_classes="$dir/all_classes"
11 |
12 | # for each class in a Jar file, dump the full assembly
13 | javap -c -classpath "$1" `/usr/bin/jar tf "$1" | grep "\.class" | sort | xargs | sed -e 's/\.class//g'` > $asm_dump
14 |
15 | # dump the initial list of all classes in the Jar file
16 | /usr/bin/jar tf $1 | grep "\.class" | sed -e 's/\.class//g' >> $all_classes
17 |
18 | # dump all static class references
19 | cat $asm_dump | grep //class | awk -F"//class " '{print $2}' | sort | uniq >> $all_classes
20 |
21 | # dump all references to classes made in methods
22 | cat $asm_dump | grep //Method | awk -F"//Method " '{print $2}' | sort | uniq | grep "\." | awk -F"." '{print $1}' | sort | uniq >> $all_classes
23 |
24 | # dump all references to classes by direct field access
25 | cat $asm_dump | grep //Field | awk -F"//Field " '{print $2}' | sort | uniq | grep "\:L" | awk -F"\:L" '{print $2}' | sort | uniq | awk -F"\;" '{print $1}' >> $all_classes
26 |
27 | # sort and reformat
28 | sort $all_classes | uniq | grep -v "\"" | sed -e 's/\//\./g'
29 |
30 | # cleanup
31 | rm -rf $dir
32 |
--------------------------------------------------------------------------------
/demo/SimpleSdlMediaPlayer.java:
--------------------------------------------------------------------------------
1 | import org.apache.logging.log4j.LogManager;
2 | import org.apache.logging.log4j.Logger;
3 | import org.datavyu.plugins.MediaPlayerWindow;
4 | import org.datavyu.plugins.ffmpeg.FfmpegSdlMediaPlayer;
5 |
6 | import java.io.File;
7 | import java.net.URI;
8 |
9 | public class SimpleSdlMediaPlayer {
10 | private static Logger logger = LogManager.getLogger(SimpleSdlMediaPlayer.class);
11 |
12 | public static void main(String[] args) {
13 | // Define the media file
14 | URI mediaPath = new File("Nature_30fps_1080p.mp4").toURI();
15 |
16 | // Create the media player using the constructor with File
17 | MediaPlayerWindow mediaPlayer = new FfmpegSdlMediaPlayer(mediaPath);
18 |
19 | // Handle Media Player errors
20 | mediaPlayer.addMediaErrorListener(
21 | (source, errorCode, message) -> logger.error(errorCode + ": " + message));
22 |
23 | // Initialize the player
24 | mediaPlayer.init();
25 |
26 | // Open a simple JFrame to control the media player through key commands
27 | // Be creative and create your own controller
28 | JMediaPlayerControlFrame controller = new JMediaPlayerControlFrame(mediaPlayer);
29 |
30 | // Handle Window Key events
31 | mediaPlayer.addSdlKeyEventListener(
32 | (source, nativeMediaRef, javaKeyCode) -> controller.handleKeyEvents(javaKeyCode));
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.dll
2 | *.dylib
3 | *.jnilib
4 | *.lib
5 | *.obj
6 | *.exp
7 | *.log
8 | *.exe
9 | *.pdb
10 | *.txt
11 | bin/
12 | *.iml
13 | .idea/*
14 | .vscode/*
15 | target/*
16 | out/*
17 | src/main/cpp/*.txt
18 | .classpath
19 | .factorypath
20 | .project
21 | .settings
22 |
23 | # User-specific files
24 | *.suo
25 | *.user
26 | *.userosscache
27 | *.sln.docstates
28 |
29 | # User-specific files (MonoDevelop/Xamarin Studio)
30 | *.userprefs
31 |
32 | # Build results
33 | [Dd]ebug/
34 | [Dd]ebugPublic/
35 | [Rr]elease/
36 | [Rr]eleases/
37 | x64/
38 | x86/
39 | bld/
40 | [Bb]in/
41 | [Oo]bj/
42 | [Ll]og/
43 |
44 | # Debug files/resources
45 | *.aps
46 | *.TMP
47 | *.rc
48 | resource.h
49 |
50 | # Visual Studio 2015/2017 cache/options directory
51 | .vs/
52 |
53 | # Uncomment if you have tasks that create the project's static files in wwwroot
54 | #wwwroot/
55 |
56 | # Video Files
57 | *.mp4
58 | *.avi
59 |
60 | # Google Test Package
61 | packages/
62 |
63 | .DS_Store
64 |
65 | **/dependencies/*
66 | SDL2.framework/*
67 |
68 | # Xcode files
69 | ## Build generated
70 | build/
71 | DerivedData/
72 |
73 | ## Various settings
74 | *.pbxuser
75 | !default.pbxuser
76 | *.mode1v3
77 | !default.mode1v3
78 | *.mode2v3
79 | !default.mode2v3
80 | *.perspectivev3
81 | !default.perspectivev3
82 | **/xcuserdata/*
83 |
84 | ## Other
85 | *.moved-aside
86 | *.xccheckout
87 | *.xcscmblueprint
88 |
--------------------------------------------------------------------------------
/NativeOSXCanvas/QTKitCanvas.xcodeproj/xcuserdata/jesse.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | Assemble Application.xcscheme
8 |
9 | orderHint
10 | 3
11 |
12 | Compile Java.xcscheme
13 |
14 | orderHint
15 | 1
16 |
17 | Compile Native.xcscheme
18 |
19 | orderHint
20 | 2
21 |
22 | JAWTExample.xcscheme
23 |
24 | orderHint
25 | 0
26 |
27 |
28 | SuppressBuildableAutocreation
29 |
30 | 89D0F0480F393A6F007831A7
31 |
32 | primary
33 |
34 |
35 | 89D0F04F0F393AD9007831A7
36 |
37 | primary
38 |
39 |
40 | 89D0F1C90F3B704E007831A7
41 |
42 | primary
43 |
44 |
45 | 8D1107260486CEB800E47090
46 |
47 | primary
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/src/main/java/org/datavyu/plugins/PlayerStateListener.java:
--------------------------------------------------------------------------------
1 | package org.datavyu.plugins;
2 |
3 | /** */
4 | public interface PlayerStateListener {
5 | /**
6 | * The ready state indicates the media is loaded. For
7 | * best results, developers should wait on
8 | * OnReady() before playing a media.
9 | *
10 | * @param evt
11 | */
12 | void onReady(PlayerStateEvent evt);
13 |
14 | /**
15 | * The play state indicates the media is beginning to play.
16 | *
17 | * @param evt
18 | */
19 | void onPlaying(PlayerStateEvent evt);
20 |
21 | /**
22 | * The pause state indicates playback has paused.
23 | *
24 | * @param evt
25 | */
26 | void onPause(PlayerStateEvent evt);
27 |
28 | /**
29 | * The stop state indicates playback has paused and presentation
30 | * time has been reset back to 0. If the player is asked to
31 | * play() again, playback begins from the beginning.
32 | *
33 | * @param evt
34 | */
35 | void onStop(PlayerStateEvent evt);
36 |
37 | void onStall(PlayerStateEvent evt);
38 |
39 | /**
40 | * The finish state indicates playback has completed playback
41 | * to the end.
42 | *
43 | * @param evt
44 | */
45 | void onFinish(PlayerStateEvent evt);
46 |
47 | /**
48 | * The error notification provides information on any error
49 | * during playback.
50 | *
51 | * @param evt
52 | */
53 | void onHalt(PlayerStateEvent evt);
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/cpp/Clock.h:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | extern "C" {
4 | #include // timer
5 | }
6 |
7 | #ifndef CLOCK_H_
8 | #define CLOCK_H_
9 |
10 | #define MICRO 1000000.0
11 |
12 | // Clock to keep decoding in sync
13 | //
14 | // This is a port of the Clock ffplay.c from ffmpeg into c++
15 | //
16 | // Big warning: This clock is NOT thread safe. The original ffplay.c code used
17 | // locks around the clock for the set/get in some places. We may decide to move
18 | // these locks into the set/get method if deemed necessary (it would be better
19 | // code design at the cost of performance).
20 | //
21 | class Clock {
22 | public:
23 | Clock(const int *queue_serial);
24 |
25 | Clock();
26 |
27 | virtual ~Clock();
28 |
29 | double GetTime() const; // for stream time, depends on rate
30 |
31 | inline double GetSerial() const { return serial; }
32 |
33 | void SetTime(double newTime, int newSerial);
34 |
35 | static void SyncMasterToSlave(Clock *master, Clock *slave,
36 | double noSyncThreshold);
37 |
38 | private:
39 | double time; // clock time
40 | int serial; // clock is based on a packet with this serial
41 | const int *p_serial_; // pointer to the current packet queue serial,
42 | // used for obsolete clock detection
43 |
44 | inline bool SerialNoMatch() const { return *p_serial_ != serial; }
45 | };
46 |
47 | #endif CLOCK_H_
48 |
--------------------------------------------------------------------------------
/src/main/java/org/datavyu/plugins/MediaException.java:
--------------------------------------------------------------------------------
1 | package org.datavyu.plugins;
2 |
3 | public class MediaException extends RuntimeException {
4 |
5 | private MediaError error = null;
6 |
7 | /**
8 | * Constructor which merely passes its parameter to the corresponding
9 | * superclass constructor
10 | * {@link RuntimeException#RuntimeException(java.lang.String)}.
11 | *
12 | * @param message The detail message.
13 | */
14 | public MediaException(String message) {
15 | super(message);
16 | }
17 |
18 | /**
19 | * Constructor which merely passes its parameters to the corresponding
20 | * superclass constructor
21 | * {@link RuntimeException#RuntimeException(java.lang.String, java.lang.Throwable)}.
22 | *
23 | * @param message The detail message.
24 | * @param cause The cause.
25 | */
26 | public MediaException(String message, Throwable cause) {
27 | super(message, cause);
28 | }
29 |
30 | /**
31 | * Constructor which merely passes its parameters to the
32 | * corresponding superclass constructor
33 | * {@link RuntimeException#RuntimeException(java.lang.String, java.lang.Throwable)}.
34 | *
35 | * @param message The detail message.
36 | * @param cause The cause.
37 | * @param error The media error.
38 | */
39 | public MediaException(String message, Throwable cause, MediaError error) {
40 | super(message, cause);
41 | this.error = error;
42 | }
43 |
44 | public MediaError getMediaError() {
45 | return error;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/org/datavyu/util/MediaErrorToHeaderFile.java:
--------------------------------------------------------------------------------
1 | package org.datavyu.util;
2 |
3 | import org.datavyu.plugins.MediaError;
4 |
5 | import java.io.File;
6 | import java.io.FileNotFoundException;
7 | import java.io.PrintWriter;
8 |
9 | /**
10 | * Generates the header file for the media error.
11 | *
12 | * This file is only used during the compile process.
13 | *
14 | *
TODO(fraudies): Run this during the build with maven and add arguments for output path/file
15 | */
16 | public class MediaErrorToHeaderFile {
17 | public static void main(String[] args) {
18 | String fileName = "FfmpegMediaErrors.h";
19 | try {
20 | PrintWriter writer = new PrintWriter(new File(fileName));
21 | writer.println("//DO NOT EDIT -- MACHINE GENERATED");
22 | writer.println("#ifndef _FFMPEG_MEDIA_ERRORS_H_");
23 | writer.println("#define _FFMPEG_MEDIA_ERRORS_H_");
24 | writer.println();
25 | for (MediaError mediaError : MediaError.values()) {
26 | writer.println("#define \t" + mediaError.name() + " \t" + mediaError.code());
27 | }
28 | writer.println();
29 | writer.println("#endif // _FFMPEG_MEDIA_ERRORS_H_");
30 | writer.close();
31 | } catch (FileNotFoundException noFile) {
32 | System.err.println(noFile.getMessage());
33 | }
34 | System.out.println(
35 | "Generated header file for '"
36 | + MediaError.class.getName()
37 | + "' and wrote it to '"
38 | + fileName
39 | + "'");
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/org/datavyu/plugins/MediaPlayerData.java:
--------------------------------------------------------------------------------
1 | package org.datavyu.plugins;
2 |
3 | import javax.sound.sampled.AudioFormat;
4 | import java.awt.color.ColorSpace;
5 |
6 | /**
7 | * This provides the interface to the media player data when we
8 | * decide to play back data through java.
9 | *
10 | *
Otherwise, we play back data natively.
11 | */
12 | public interface MediaPlayerData extends MediaPlayer {
13 |
14 | /**
15 | * Checks if the media has audio data
16 | *
17 | * @return True if data exists; otherwise false
18 | */
19 | boolean hasAudioData();
20 |
21 | /**
22 | * Checks if the media has image data
23 | *
24 | * @return True if data exists; otherwise false
25 | */
26 | boolean hasImageData();
27 |
28 | /**
29 | * Returns the output audio format that the audio data is
30 | * formatted in
31 | *
32 | * @return The audio format
33 | */
34 | AudioFormat getAudioFormat();
35 |
36 | /**
37 | * Returns the color space that the image data is formatted in
38 | *
39 | * @return The color space
40 | */
41 | ColorSpace getColorSpace();
42 |
43 | /**
44 | * Update the byte buffer with the most recent audio data to play
45 | *
46 | * @param data The data that is updated on the native side
47 | */
48 | void updateAudioData(byte[] data);
49 |
50 | /**
51 | * Update the byte buffer with the most recent image data to play
52 | *
53 | * @param data The data that is updated on the native side
54 | */
55 | void updateImageData(byte[] data);
56 | }
57 |
--------------------------------------------------------------------------------
/src/main/cpp/FfmpegJavaAvPlayback.h:
--------------------------------------------------------------------------------
1 | #ifndef FFMPEGJAVAAVPLAYBACK_H_
2 | #define FFMPEGJAVAAVPLAYBACK_H_
3 |
4 | #include "FfmpegAVPlayback.h"
5 | #include "VideoState.h"
6 |
7 | class FfmpegJavaAvPlayback : public FfmpegAvPlayback {
8 | private:
9 | const AudioFormat *kPtrAudioFormat;
10 | const PixelFormat *kPtrPixelFormat;
11 | const int kAudioBufferSizeInBy;
12 |
13 | struct SwsContext *p_img_convert_ctx_;
14 | double remaining_time_to_display_;
15 |
16 | public:
17 | FfmpegJavaAvPlayback(const AudioFormat *kPtrAudioFormat,
18 | const PixelFormat *kPtrPixelFormat,
19 | const int kAudioBufferSizeInBy);
20 | virtual ~FfmpegJavaAvPlayback();
21 |
22 | int Init(const char *p_filename, AVInputFormat *p_input_format);
23 |
24 | int AudioOpen(int64_t wanted_channel_layout, int wanted_nb_channels,
25 | int wanted_sample_rate, struct AudioParams *audio_hw_params);
26 |
27 | VideoState *GetVideoState();
28 |
29 | void Destroy();
30 |
31 | int StartStream();
32 |
33 | void SetBalance(float balance);
34 | float GetBalance();
35 |
36 | void SetAudioSyncDelay(long millis);
37 | long getAudioSyncDelay();
38 |
39 | int GetImageWidth() const;
40 | int GetImageHeight() const;
41 |
42 | bool HasImageData() const;
43 | bool HasAudioData() const;
44 |
45 | bool DoDisplay(double *p_remaining_time);
46 |
47 | void UpdateImageBuffer(uint8_t *p_image_data, const long len);
48 | void UpdateAudioBuffer(uint8_t *p_audio_data, const long len);
49 |
50 | void GetAudioFormat(AudioFormat *p_audio_format);
51 | void GetPixelFormat(PixelFormat *p_pixel_format);
52 | };
53 |
54 | #endif // end of FFMPEGJAVAAVPLAYBACK_H_
55 |
--------------------------------------------------------------------------------
/NativeOSXCanvas/QTKitCanvas.xcodeproj/xcuserdata/jesse.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
8 |
20 |
21 |
22 |
24 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/src/main/java/org/datavyu/plugins/MediaPlayerWindow.java:
--------------------------------------------------------------------------------
1 | package org.datavyu.plugins;
2 |
3 | import java.util.ListIterator;
4 |
5 | /**
6 | * This provides the interface to control the media player Window when we
7 | * decide to play back streams through native display.
8 | */
9 | public interface MediaPlayerWindow extends MediaPlayer {
10 |
11 | /**
12 | * Adds a listener for SDL player key events.
13 | *
14 | * @param listener listener to be added
15 | * @throws IllegalArgumentException if listener is null.
16 | */
17 | void addSdlKeyEventListener(SdlKeyEventListener listener);
18 |
19 | /**
20 | * Removes a listener for SDL player key events.
21 | *
22 | * @param listener listener to be removed
23 | * @throws IllegalArgumentException if listener is null.
24 | */
25 | void removeSdlKeyEventListener(SdlKeyEventListener listener);
26 |
27 | /**
28 | * Expose SDL player window, this method is available only for the SDL player, will throw an
29 | * exception if called from a Java player.
30 | */
31 | void showWindow();
32 |
33 | /**
34 | * Hide SDL player window, this method is available only for the SDL player, will throw an
35 | * exception if called from a Java player.
36 | */
37 | void hideWindow();
38 |
39 | boolean isVisible();
40 |
41 | /**
42 | * Return Window Height
43 | *
44 | * @return window height
45 | */
46 | int getWindowHeight();
47 |
48 | /**
49 | * Return Window Width
50 | *
51 | * @return window width
52 | */
53 | int getWindowWidth();
54 |
55 | /**
56 | * Set Window new width and height
57 | *
58 | * @param width
59 | * @param height
60 | */
61 | void setWindowSize(int width, int height);
62 | }
63 |
--------------------------------------------------------------------------------
/src/main/java/org/datavyu/plugins/nativeosx/NativeOSXPlayer.java:
--------------------------------------------------------------------------------
1 | package org.datavyu.plugins.nativeosx;
2 |
3 | import org.apache.logging.log4j.LogManager;
4 | import org.apache.logging.log4j.Logger;
5 | import org.datavyu.util.LibraryLoader;
6 |
7 | import java.awt.*;
8 | import java.net.URI;
9 |
10 | public class NativeOSXPlayer extends Canvas {
11 |
12 | private static Logger logger = LogManager.getLogger(NativeOSXPlayer.class);
13 | private final URI mediaPath;
14 |
15 | static {
16 | try {
17 | LibraryLoader.extractAndLoad("NativeOSXCanvas");
18 | } catch (Exception e) {
19 | logger.error("Unable to load the native library: ", e);
20 | }
21 | }
22 |
23 | public NativeOSXPlayer(URI mediaPath) {
24 | this.mediaPath = mediaPath;
25 | }
26 |
27 | public void addNotify() {
28 | super.addNotify();
29 | addNativeOSXCoreAnimationLayer("file://" + mediaPath.getPath());
30 | }
31 |
32 | // This method is implemented in native code. See NativeOSXCanvas.m
33 | native void addNativeOSXCoreAnimationLayer(String path);
34 |
35 | native void stop(int id);
36 |
37 | native void play(int id);
38 |
39 | native void setTime(long time, int id);
40 |
41 | native void setTimePrecise(long time, int id);
42 |
43 | native void setTimeModerate(long time, int id);
44 |
45 | native void setVolume(float time, int id);
46 |
47 | native void release(int id);
48 |
49 | native double getMovieHeight(int id);
50 |
51 | native double getMovieWidth(int id);
52 |
53 | native long getCurrentTime(int id);
54 |
55 | native long getDuration(int id);
56 |
57 | native float getRate(int id);
58 |
59 | native void setRate(float rate, int id);
60 |
61 | native boolean isPlaying(int id);
62 |
63 | native float getFPS(int id);
64 | }
65 |
--------------------------------------------------------------------------------
/src/main/cpp/Decoder.h:
--------------------------------------------------------------------------------
1 | #include "FrameQueue.h"
2 | #include "PacketQueue.h"
3 | #include
4 | #include
5 |
6 | extern "C" {
7 | #include // codecs
8 | #include // error codes
9 | #include
10 | }
11 |
12 | #ifndef DECODER_H_
13 | #define DECODER_H_
14 |
15 | class Decoder {
16 | public:
17 | Decoder(AVCodecContext *avctx, PacketQueue *queue,
18 | std::condition_variable *empty_queue_cond);
19 | virtual ~Decoder();
20 |
21 | int Decode(AVFrame *frame);
22 |
23 | inline void SetStartPts(int64_t start_pts) { start_pts_ = start_pts; }
24 | void SetStartPtsTimebase(AVRational start_pts_timebase) {
25 | start_pts_timebase_ = start_pts_timebase;
26 | }
27 |
28 | inline int GetSerial() const { return serial_; }
29 | inline int64_t GetNumberOfIncorrectDtsValues() const {
30 | return p_codec_context_->pts_correction_num_faulty_dts;
31 | }
32 | inline int64_t GetNumberOfIncorrectPtsValues() const {
33 | return p_codec_context_->pts_correction_num_faulty_pts;
34 | }
35 |
36 | inline bool IsFinished() const { return is_finished_; }
37 | inline void setFinished(bool finished) { is_finished_ = finished; }
38 |
39 | int Start(const std::function &decoding);
40 | void Stop(FrameQueue *frame_queue);
41 |
42 | private:
43 | AVPacket packet_;
44 | AVCodecContext *p_codec_context_;
45 | PacketQueue *p_packet_queue_;
46 | std::condition_variable *p_is_empty_condition_;
47 | int serial_;
48 | bool is_finished_;
49 | bool is_packet_pending_;
50 | int do_reorder_; // let decoder reorder pts 0=off 1=on -1=auto
51 | int64_t start_pts_;
52 | AVRational start_pts_timebase_;
53 | int64_t next_pts_;
54 | AVRational next_pts_timebase_;
55 | std::thread *p_decoder_thread_;
56 | };
57 |
58 | #endif DECODER_H_
59 |
--------------------------------------------------------------------------------
/src/main/cpp/FfmpegSdlMediaPlayer.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Header Files
20 |
21 |
22 | Header Files
23 |
24 |
25 | Header Files
26 |
27 |
28 | Header Files
29 |
30 |
31 |
32 |
33 | Source Files
34 |
35 |
36 | Source Files
37 |
38 |
39 | Source Files
40 |
41 |
42 |
--------------------------------------------------------------------------------
/src/main/cpp/Media.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 | *
5 | * This code is free software; you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License version 2 only, as
7 | * published by the Free Software Foundation. Oracle designates this
8 | * particular file as subject to the "Classpath" exception as provided
9 | * by Oracle in the LICENSE file that accompanied this code.
10 | *
11 | * This code is distributed in the hope that it will be useful, but WITHOUT
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * version 2 for more details (a copy is included in the LICENSE file that
15 | * accompanied this code).
16 | *
17 | * You should have received a copy of the GNU General Public License version
18 | * 2 along with this work; if not, write to the Free Software Foundation,
19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 | *
21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 | * or visit www.oracle.com if you need additional information or have any
23 | * questions.
24 | */
25 |
26 | #ifndef _MEDIA_H_
27 | #define _MEDIA_H_
28 |
29 | #include "Pipeline.h"
30 | #include