Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions addons/ofxEmscripten/src/ofxEmscriptenVideoPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ ofxEmscriptenVideoPlayer::~ofxEmscriptenVideoPlayer() {
html5video_player_delete(player_id);
}

bool ofxEmscriptenVideoPlayer::load(string name){
bool ofxEmscriptenVideoPlayer::load(const of::filesystem::path & fileName){
std::string name = ofPathToString(fileName);
if (name.substr(0, 7) == "http://" || name.substr(0, 8) == "https://"){
html5video_player_load_url(player_id, name.c_str());
html5video_player_load_url(player_id, fileName.c_str());
} else{
html5video_player_load(player_id, ofToDataPath(name).c_str());
html5video_player_load(player_id, ofToDataPath(fileName).c_str());
}
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion addons/ofxEmscripten/src/ofxEmscriptenVideoPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ofxEmscriptenVideoPlayer: public ofBaseVideoPlayer {
~ofxEmscriptenVideoPlayer();

//needs implementing
bool load(const std::string fileName);
bool load(const of::filesystem::path & fileName);
void close();
void update();

Expand Down
4 changes: 2 additions & 2 deletions addons/ofxiOS/src/video/ofxiOSVideoPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ofxiOSVideoPlayer : public ofBaseVideoPlayer {
void enableTextureCache();
void disableTextureCache();

bool load(std::string name);
bool load(const of::filesystem::path & fileName);
void close();
void update();

Expand Down Expand Up @@ -62,7 +62,7 @@ class ofxiOSVideoPlayer : public ofBaseVideoPlayer {
void * getAVFoundationVideoPlayer();

[[deprecated("use load()")]]
bool loadMovie(std::string name);
bool loadMovie(const of::filesystem::path & fileName);
[[deprecated("use getPixels()")]]
ofPixels & getPixelsRef();
[[deprecated("use getPixels()")]]
Expand Down
8 changes: 4 additions & 4 deletions addons/ofxiOS/src/video/ofxiOSVideoPlayer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@
}

//----------------------------------------
bool ofxiOSVideoPlayer::load(string name) {
bool ofxiOSVideoPlayer::load(const of::filesystem::path & fileName) {

if(!videoPlayer) {
videoPlayer = (__bridge_retained void *)[[AVFoundationVideoPlayer alloc] init];
[(__bridge AVFoundationVideoPlayer *)videoPlayer setWillBeUpdatedExternally:YES];
}

NSString * videoPath = [NSString stringWithUTF8String:ofToDataPath(name).c_str()];
NSString * videoPath = [NSString stringWithUTF8String:ofToDataPath(fileName).c_str()];
[(__bridge AVFoundationVideoPlayer*)videoPlayer loadWithPath:videoPath];

bResetPixels = true;
Expand Down Expand Up @@ -589,8 +589,8 @@
}

//---------------------------------------- DEPRECATED.
bool ofxiOSVideoPlayer::loadMovie(string name) {
return load(name);
bool ofxiOSVideoPlayer::loadMovie(const of::filesystem::path & fileName) {
return load(fileName);
}

ofPixels & ofxiOSVideoPlayer::getPixelsRef() {
Expand Down
4 changes: 2 additions & 2 deletions libs/openFrameworks/types/ofBaseTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ ofBaseVideoPlayer::~ofBaseVideoPlayer(){

}

void ofBaseVideoPlayer::loadAsync(std::string name){
void ofBaseVideoPlayer::loadAsync(const of::filesystem::path & fileName){
ofLogWarning("ofBaseVideoPlayer") << "loadAsync() not implemented, loading synchronously";
load(name);
load(fileName);
}

//---------------------------------------------------------------------------
Expand Down
9 changes: 4 additions & 5 deletions libs/openFrameworks/video/ofAVFoundationPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ class ofAVFoundationPlayer : public ofBaseVideoPlayer {
ofAVFoundationPlayer();
~ofAVFoundationPlayer();

//FIXME: FS
bool load(std::string name);
void loadAsync(std::string name);
bool load(const of::filesystem::path & fileName) override;
void loadAsync(const of::filesystem::path & fileName) override;
void close();
void update();

Expand Down Expand Up @@ -88,7 +87,7 @@ class ofAVFoundationPlayer : public ofBaseVideoPlayer {
#endif

[[deprecated("use load()")]]
bool loadMovie(std::string name);
bool loadMovie(const of::filesystem::path & fileName);
[[deprecated("use getPixels()")]]
ofPixels & getPixelsRef();
[[deprecated("use getPixels()")]]
Expand All @@ -98,7 +97,7 @@ class ofAVFoundationPlayer : public ofBaseVideoPlayer {

protected:

bool loadPlayer(std::string name, bool bAsync);
bool loadPlayer(const of::filesystem::path & fileName, bool bAsync);
void disposePlayer();
bool isReady() const;

Expand Down
26 changes: 13 additions & 13 deletions libs/openFrameworks/video/ofAVFoundationPlayer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -52,31 +52,31 @@
}

//--------------------------------------------------------------
void ofAVFoundationPlayer::loadAsync(std::string name){
loadPlayer(name, true);
void ofAVFoundationPlayer::loadAsync(const of::filesystem::path & fileName){
loadPlayer(fileName, true);
}

//--------------------------------------------------------------
bool ofAVFoundationPlayer::load(std::string name) {
return loadPlayer(name, false);
bool ofAVFoundationPlayer::load(const of::filesystem::path & fileName) {
return loadPlayer(fileName, false);
}

//--------------------------------------------------------------
// FIXME: fs::path
bool ofAVFoundationPlayer::loadPlayer(std::string name, bool bAsync) {
bool ofAVFoundationPlayer::loadPlayer(const of::filesystem::path & fileName, bool bAsync) {
if( ofGetUsingArbTex() == false ){
killTextureCache();
bUseTextureCache = false;
}

NSString * videoPath = [NSString stringWithUTF8String:name.c_str()];
NSString * videoLocalPath = [NSString stringWithUTF8String:ofToDataPath(name).c_str()];
NSString * videoPath = [NSString stringWithUTF8String:fileName.c_str()];
NSString * videoLocalPath = [NSString stringWithUTF8String:ofToDataPath(fileName).c_str()];

BOOL bStream = NO;

bStream = bStream || (ofIsStringInString(name, "http://"));
bStream = bStream || (ofIsStringInString(name, "https://"));
bStream = bStream || (ofIsStringInString(name, "rtsp://"));
std::string fileNameStr { ofPathToString(fileName) };
bStream = bStream || (ofIsStringInString(fileNameStr, "http://"));
bStream = bStream || (ofIsStringInString(fileNameStr, "https://"));
bStream = bStream || (ofIsStringInString(fileNameStr, "rtsp://"));

NSURL * url = nil;
if(bStream == YES) {
Expand Down Expand Up @@ -762,8 +762,8 @@
#endif

//-------------------------------------------------------------- DEPRECATED.
bool ofAVFoundationPlayer::loadMovie(std::string name) {
return load(name);
bool ofAVFoundationPlayer::loadMovie(const of::filesystem::path & fileName) {
return load(fileName);
}

ofPixels & ofAVFoundationPlayer::getPixelsRef() {
Expand Down
5 changes: 2 additions & 3 deletions libs/openFrameworks/video/ofDirectShowPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1146,9 +1146,8 @@ ofDirectShowPlayer & ofDirectShowPlayer::operator=(ofDirectShowPlayer&& other) {
return *this;
}

// FIXME: fs::path
bool ofDirectShowPlayer::load(std::string stringPath){
auto path = ofToDataPath(of::filesystem::path(stringPath));
bool ofDirectShowPlayer::load(const of::filesystem::path & fileName){
auto path = ofToDataPath(fileName);

close();
player.reset(new DirectShowVideo());
Expand Down
2 changes: 1 addition & 1 deletion libs/openFrameworks/video/ofDirectShowPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ofDirectShowPlayer : public ofBaseVideoPlayer{
ofDirectShowPlayer(ofDirectShowPlayer &&);
ofDirectShowPlayer & operator=(ofDirectShowPlayer&&);

bool load(std::string path);
bool load(const of::filesystem::path & fileName) override;
void update();

void close();
Expand Down
11 changes: 6 additions & 5 deletions libs/openFrameworks/video/ofGstVideoPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,14 @@ bool ofGstVideoPlayer::createPipeline(std::string name){
#endif
}

void ofGstVideoPlayer::loadAsync(std::string name){
void ofGstVideoPlayer::loadAsync(const of::filesystem::path & fileName){
bAsyncLoad = true;
load(name);
load(fileName);
}

// FIXME: fs::path
bool ofGstVideoPlayer::load(std::string name){
bool ofGstVideoPlayer::load(const of::filesystem::path & fileName){
std::string name { ofPathToString(fileName) };
if( name.find( "file://",0 ) != std::string::npos){
bIsStream = bAsyncLoad;
}else if( name.find( "://",0 ) == std::string::npos){
Expand All @@ -217,7 +218,7 @@ bool ofGstVideoPlayer::load(std::string name){
internalPixelFormat = OF_PIXELS_NATIVE;
bIsAllocated = false;
videoUtils.reallocateOnNextFrame();
g_object_set(G_OBJECT(videoUtils.getPipeline()), "uri", name.c_str(), (void*)NULL);
g_object_set(G_OBJECT(videoUtils.getPipeline()), "uri", fileName.c_str(), (void*)NULL);
gst_element_set_state (videoUtils.getPipeline(), GST_STATE_PAUSED);
if(!bIsStream){
gst_element_get_state (videoUtils.getPipeline(), NULL, NULL, -1);
Expand All @@ -227,7 +228,7 @@ bool ofGstVideoPlayer::load(std::string name){
}
}else{
ofGstUtils::startGstMainLoop();
return createPipeline(name) &&
return createPipeline(fileName) &&
videoUtils.startPipeline() &&
(bIsStream || allocate());
}
Expand Down
4 changes: 2 additions & 2 deletions libs/openFrameworks/video/ofGstVideoPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class ofGstVideoPlayer: public ofBaseVideoPlayer, public ofGstAppSink{
bool setPixelFormat(ofPixelFormat pixelFormat);
ofPixelFormat getPixelFormat() const;

void loadAsync(std::string name);
bool load(std::string uri);
void loadAsync(const of::filesystem::path & fileName) override;
bool load(const of::filesystem::path & fileName) override;

void update();

Expand Down
13 changes: 7 additions & 6 deletions libs/openFrameworks/video/ofMediaFoundationPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -658,19 +658,20 @@ std::shared_ptr<ofMediaFoundationPlayer::MEDXDeviceManager> ofMediaFoundationPla
}

//----------------------------------------------
bool ofMediaFoundationPlayer::load(std::string name) {
return _load(name, false);
bool ofMediaFoundationPlayer::load(const of::filesystem::path & fileName) {
return _load(fileName, false);
}

//----------------------------------------------
void ofMediaFoundationPlayer::loadAsync(std::string name) {
_load(name, true);
void ofMediaFoundationPlayer::loadAsync(const of::filesystem::path & fileName) {
_load(fileName, true);
}

//----------------------------------------------
bool ofMediaFoundationPlayer::_load(std::string name, bool abAsync) {
bool ofMediaFoundationPlayer::_load(const of::filesystem::path & fileName, bool abAsync) {
close();

std::string name = ofPathToString(fileName);
mBLoadAsync = abAsync;

bool bStream = false;
Expand All @@ -679,7 +680,7 @@ bool ofMediaFoundationPlayer::_load(std::string name, bool abAsync) {
bStream = bStream || ofIsStringInString(name, "rtsp://");
bStream = bStream || ofIsStringInString(name, "rtmp://");

of::filesystem::path absPath = name;
of::filesystem::path absPath = fileName;

if (!bStream) {
if (ofFile::doesFileExist(absPath)) {
Expand Down
8 changes: 4 additions & 4 deletions libs/openFrameworks/video/ofMediaFoundationPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ class ofMediaFoundationPlayer : public ofBaseVideoPlayer, public of::MediaEngine

static void setDurationHackEnabled(bool ab);

bool load(std::string name) override;
void loadAsync(std::string name) override;
void close() override;
bool load(const of::filesystem::path & fileName) override;
void loadAsync(const of::filesystem::path & fileName) override;
void close() override;

bool isInitialized() const override;

Expand Down Expand Up @@ -159,7 +159,7 @@ class ofMediaFoundationPlayer : public ofBaseVideoPlayer, public of::MediaEngine
ofEvent<MF_MEDIA_ENGINE_ERR> MFErrorEvent;

protected:
bool _load(std::string name, bool abAsync);
bool _load(const of::filesystem::path & fileName, bool abAsync);
void OnMediaEngineEvent(DWORD aEvent, DWORD_PTR param1, DWORD param2) override;

class MEDXDeviceManager {
Expand Down
6 changes: 3 additions & 3 deletions libs/openFrameworks/video/ofVideoBaseTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ class ofBaseVideoPlayer: virtual public ofBaseVideo{
/// \param name The name of the video resource to load.
/// \return True if the video was loaded successfully.
/// \sa loadAsync()
// FIXME: FS
virtual bool load(std::string name) = 0;

virtual bool load(const of::filesystem::path & fileName) = 0;
/// \brief Asynchronously load a video resource by name.
///
/// The list of supported video types and sources (e.g. rtsp:// sources) is
Expand All @@ -219,7 +219,7 @@ class ofBaseVideoPlayer: virtual public ofBaseVideo{
///
/// \param name The name of the video resource to load.
/// \sa isLoaded()
virtual void loadAsync(std::string name);
virtual void loadAsync(const of::filesystem::path & fileName);

/// \brief Play the video from the current playhead position.
///
Expand Down
21 changes: 10 additions & 11 deletions libs/openFrameworks/video/ofVideoPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ ofVideoPlayer::ofVideoPlayer() {

//---------------------------------------------------------------------------
ofVideoPlayer::ofVideoPlayer(const of::filesystem::path & fileName) : ofVideoPlayer() {
// FIXME: Convert internally everything to FS
load(ofPathToString(fileName));
load(fileName);
}

//---------------------------------------------------------------------------
Expand Down Expand Up @@ -152,16 +151,16 @@ ofPixelFormat ofVideoPlayer::getPixelFormat() const{
}

//---------------------------------------------------------------------------
bool ofVideoPlayer::load(string name){
bool ofVideoPlayer::load(const of::filesystem::path & fileName){
if( !player ){
setPlayer(std::make_shared<OF_VID_PLAYER_TYPE>());
player->setPixelFormat(internalPixelFormat);
}

bool bOk = player->load(name);
bool bOk = player->load(fileName);

if( bOk){
moviePath = name;
moviePath = fileName;
if(bUseTexture){
if(player->getTexturePtr()==nullptr){
if(tex.empty()) {
Expand All @@ -185,23 +184,23 @@ bool ofVideoPlayer::load(string name){
}

//---------------------------------------------------------------------------
void ofVideoPlayer::loadAsync(string name){
void ofVideoPlayer::loadAsync(const of::filesystem::path & fileName){
if( !player ){
setPlayer(std::make_shared<OF_VID_PLAYER_TYPE>());
player->setPixelFormat(internalPixelFormat);
}

player->loadAsync(name);
moviePath = name;
player->loadAsync(fileName);
moviePath = fileName;
}

//---------------------------------------------------------------------------
bool ofVideoPlayer::loadMovie(string name){
return load(name);
bool ofVideoPlayer::loadMovie(const of::filesystem::path & fileName){
return load(fileName);
}

//---------------------------------------------------------------------------
string ofVideoPlayer::getMoviePath() const{
of::filesystem::path ofVideoPlayer::getMoviePath() const {
return moviePath;
}

Expand Down
Loading