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

60
src/Sources/VideoSource.h

@ -2,53 +2,41 @@
#include "ofMain.h"
#include "BaseSource.h"
#ifdef TARGET_RASPBERRY_PI
/*
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"
#include "ofxOMXPlayer.h"
#endif
namespace ofx {
namespace piMapper {
class VideoSource : public BaseSource {
public:
namespace piMapper {
class VideoSource : public BaseSource {
public:
// TODO: Create enableAudio() and disableAudio() methods
// for live audio enabling and disabling.
static bool enableAudio;
// TODO: Create enableAudio() and disableAudio() methods
// for live audio enabling and disabling.
static bool enableAudio;
VideoSource();
~VideoSource();
std::string& getPath();
void loadVideo(std::string& path);
void clear();
VideoSource();
~VideoSource();
std::string & getPath();
void loadVideo(std::string & path);
void clear();
#ifndef TARGET_RASPBERRY_PI
void update(ofEventArgs& args);
void update(ofEventArgs & args);
#endif
private:
private:
#ifdef TARGET_RASPBERRY_PI
ofxOMXPlayer* omxPlayer; // Naming different for less confusion
ofxOMXPlayer * omxPlayer; // Naming different for less confusion
#else
// Go with ofVideoPlayer or
// TODO: High Performance Video player on newer Macs
ofVideoPlayer* videoPlayer;
// Go with ofVideoPlayer or
// TODO: High Performance Video player on newer Macs
ofVideoPlayer * videoPlayer;
#endif
};
}
};
}
}
Loading…
Cancel
Save