Browse Source

Improve indentation of `VideoSource`

master
Krisjanis Rijnieks 10 years ago
parent
commit
ffc2a54151
  1. 110
      src/Sources/VideoSource.cpp
  2. 60
      src/Sources/VideoSource.h

110
src/Sources/VideoSource.cpp

@ -1,78 +1,70 @@
#include "VideoSource.h" #include "VideoSource.h"
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
bool VideoSource::enableAudio = false; bool VideoSource::enableAudio = false;
VideoSource::VideoSource() { VideoSource::VideoSource() {
//cout << "VideoSource constr" << endl; loadable = true;
loadable = true; loaded = false;
loaded = false; type = SourceType::SOURCE_TYPE_VIDEO;
type = SourceType::SOURCE_TYPE_VIDEO;
#ifdef TARGET_RASPBERRY_PI #ifdef TARGET_RASPBERRY_PI
omxPlayer = NULL; omxPlayer = NULL;
#else #else
videoPlayer = NULL; videoPlayer = NULL;
#endif #endif
} }
VideoSource::~VideoSource() {} VideoSource::~VideoSource() {}
void VideoSource::loadVideo(std::string& filePath) { void VideoSource::loadVideo(std::string & filePath) {
path = filePath; path = filePath;
//cout << "loading video: " << filePath << endl; setNameFromPath(filePath);
setNameFromPath(filePath);
#ifdef TARGET_RASPBERRY_PI #ifdef TARGET_RASPBERRY_PI
// Do things with the OMX player ofxOMXPlayerSettings settings;
ofxOMXPlayerSettings settings; settings.videoPath = filePath;
settings.videoPath = filePath; settings.useHDMIForAudio = true;
settings.useHDMIForAudio = true; //default true settings.enableTexture = true;
settings.enableTexture = true; //default true settings.enableLooping = true;
settings.enableLooping = true; //default true settings.enableAudio = VideoSource::enableAudio
settings.enableAudio = VideoSource::enableAudio; //default true, save resources by disabling omxPlayer = new ofxOMXPlayer();
//settings.doFlipTexture = true; //default false omxPlayer->setup(settings);
omxPlayer = new ofxOMXPlayer(); texture = &(omxPlayer->getTextureReference());
omxPlayer->setup(settings);
texture = &(omxPlayer->getTextureReference());
#else #else
// regular ofVideoPlayer videoPlayer = new ofVideoPlayer();
videoPlayer = new ofVideoPlayer(); videoPlayer->loadMovie(filePath);
videoPlayer->loadMovie(filePath); videoPlayer->setLoopState(OF_LOOP_NORMAL);
videoPlayer->setLoopState(OF_LOOP_NORMAL); videoPlayer->setVolume(VideoSource::enableAudio ? 1.0f : 0.0f);
videoPlayer->setVolume(VideoSource::enableAudio ? 1.0f : 0.0f); videoPlayer->play();
videoPlayer->play(); texture = &(videoPlayer->getTextureReference());
texture = &(videoPlayer->getTextureReference()); ofAddListener(ofEvents().update, this, &VideoSource::update);
ofAddListener(ofEvents().update, this, &VideoSource::update);
#endif #endif
loaded = true; loaded = true;
} }
void VideoSource::clear() { void VideoSource::clear() {
texture = NULL; texture = NULL;
#ifdef TARGET_RASPBERRY_PI #ifdef TARGET_RASPBERRY_PI
omxPlayer->close(); omxPlayer->close();
delete omxPlayer; delete omxPlayer;
omxPlayer = NULL; omxPlayer = NULL;
#else #else
ofRemoveListener(ofEvents().update, this, &VideoSource::update); ofRemoveListener(ofEvents().update, this, &VideoSource::update);
videoPlayer->stop(); videoPlayer->stop();
videoPlayer->close(); videoPlayer->close();
delete videoPlayer; delete videoPlayer;
videoPlayer = NULL; videoPlayer = NULL;
#endif #endif
//path = ""; loaded = false;
//name = ""; }
loaded = false;
}
#ifndef TARGET_RASPBERRY_PI #ifndef TARGET_RASPBERRY_PI
void VideoSource::update(ofEventArgs &args) { void VideoSource::update(ofEventArgs & args) {
if (videoPlayer != NULL) { if (videoPlayer != NULL) {
videoPlayer->update(); videoPlayer->update();
} }
} }
#endif #endif
} } // namespace piMapper
} } // namespace ofx

60
src/Sources/VideoSource.h

@ -2,53 +2,41 @@
#include "ofMain.h" #include "ofMain.h"
#include "BaseSource.h" #include "BaseSource.h"
#ifdef TARGET_RASPBERRY_PI #ifdef TARGET_RASPBERRY_PI
/* #include "ofxOMXPlayer.h"
Notice that if you get an error like this:
fatal error: libavcodec/opt.h: No such file or directory
Create a file opt.h in addons/ofxOMXPlayer/libs/ffmpeg/libavcodec/
with the following contents:
#ifndef AVCODEC_OPT_H
#define AVCODEC_OPT_H
#include "libavcodec/version.h"
#if FF_API_OPT_H
#include "libavutil/opt.h"
#endif
#endif // AVCODEC_OPT_H
More here: https://github.com/jvcleave/ofxOMXPlayer/issues/34
*/
#include "ofxOMXPlayer.h"
#endif #endif
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
class VideoSource : public BaseSource { class VideoSource : public BaseSource {
public: public:
// TODO: Create enableAudio() and disableAudio() methods // TODO: Create enableAudio() and disableAudio() methods
// for live audio enabling and disabling. // for live audio enabling and disabling.
static bool enableAudio; static bool enableAudio;
VideoSource(); VideoSource();
~VideoSource(); ~VideoSource();
std::string& getPath();
void loadVideo(std::string& path); std::string & getPath();
void clear(); void loadVideo(std::string & path);
void clear();
#ifndef TARGET_RASPBERRY_PI #ifndef TARGET_RASPBERRY_PI
void update(ofEventArgs& args); void update(ofEventArgs & args);
#endif #endif
private: private:
#ifdef TARGET_RASPBERRY_PI #ifdef TARGET_RASPBERRY_PI
ofxOMXPlayer* omxPlayer; // Naming different for less confusion ofxOMXPlayer * omxPlayer; // Naming different for less confusion
#else #else
// Go with ofVideoPlayer or // Go with ofVideoPlayer or
// TODO: High Performance Video player on newer Macs // TODO: High Performance Video player on newer Macs
ofVideoPlayer* videoPlayer; ofVideoPlayer * videoPlayer;
#endif #endif
}; };
} }
} }
Loading…
Cancel
Save