Skip to content

Commit

Permalink
Revert "ofVideoPlayer using fs::path (openframeworks#8138)"
Browse files Browse the repository at this point in the history
This reverts commit 2bd8b45.
  • Loading branch information
roymacdonald committed Oct 10, 2024
1 parent 2bd8b45 commit 5f679c2
Show file tree
Hide file tree
Showing 16 changed files with 70 additions and 70 deletions.
7 changes: 3 additions & 4 deletions addons/ofxEmscripten/src/ofxEmscriptenVideoPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ ofxEmscriptenVideoPlayer::~ofxEmscriptenVideoPlayer() {
html5video_player_delete(player_id);
}

bool ofxEmscriptenVideoPlayer::load(const of::filesystem::path & fileName){
std::string name = ofPathToString(fileName);
bool ofxEmscriptenVideoPlayer::load(string name){
if (name.substr(0, 7) == "http://" || name.substr(0, 8) == "https://"){
html5video_player_load_url(player_id, fileName.c_str());
html5video_player_load_url(player_id, name.c_str());
} else{
html5video_player_load(player_id, ofToDataPath(fileName).c_str());
html5video_player_load(player_id, ofToDataPath(name).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 of::filesystem::path & fileName);
bool load(const std::string 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(const of::filesystem::path & fileName);
bool load(std::string name);
void close();
void update();

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

[[deprecated("use load()")]]
bool loadMovie(const of::filesystem::path & fileName);
bool loadMovie(std::string name);
[[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(const of::filesystem::path & fileName) {
bool ofxiOSVideoPlayer::load(string name) {

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

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

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

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

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(const of::filesystem::path & fileName){
void ofBaseVideoPlayer::loadAsync(std::string name){
ofLogWarning("ofBaseVideoPlayer") << "loadAsync() not implemented, loading synchronously";
load(fileName);
load(name);
}

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

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

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

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

protected:

bool loadPlayer(const of::filesystem::path & fileName, bool bAsync);
bool loadPlayer(std::string name, 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(const of::filesystem::path & fileName){
loadPlayer(fileName, true);
void ofAVFoundationPlayer::loadAsync(std::string name){
loadPlayer(name, true);
}

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

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

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

BOOL bStream = NO;

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

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

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

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

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

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(const of::filesystem::path & fileName) override;
bool load(std::string path);
void update();

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

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

// FIXME: fs::path
bool ofGstVideoPlayer::load(const of::filesystem::path & fileName){
std::string name { ofPathToString(fileName) };
bool ofGstVideoPlayer::load(std::string name){
if( name.find( "file://",0 ) != std::string::npos){
bIsStream = bAsyncLoad;
}else if( name.find( "://",0 ) == std::string::npos){
Expand All @@ -218,7 +217,7 @@ bool ofGstVideoPlayer::load(const of::filesystem::path & fileName){
internalPixelFormat = OF_PIXELS_NATIVE;
bIsAllocated = false;
videoUtils.reallocateOnNextFrame();
g_object_set(G_OBJECT(videoUtils.getPipeline()), "uri", fileName.c_str(), (void*)NULL);
g_object_set(G_OBJECT(videoUtils.getPipeline()), "uri", name.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 @@ -228,7 +227,7 @@ bool ofGstVideoPlayer::load(const of::filesystem::path & fileName){
}
}else{
ofGstUtils::startGstMainLoop();
return createPipeline(fileName) &&
return createPipeline(name) &&
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(const of::filesystem::path & fileName) override;
bool load(const of::filesystem::path & fileName) override;
void loadAsync(std::string name);
bool load(std::string uri);

void update();

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

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

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

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

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

bool bStream = false;
Expand All @@ -680,7 +679,7 @@ bool ofMediaFoundationPlayer::_load(const of::filesystem::path & fileName, bool
bStream = bStream || ofIsStringInString(name, "rtsp://");
bStream = bStream || ofIsStringInString(name, "rtmp://");

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

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(const of::filesystem::path & fileName) override;
void loadAsync(const of::filesystem::path & fileName) override;
void close() override;
bool load(std::string name) override;
void loadAsync(std::string name) 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(const of::filesystem::path & fileName, bool abAsync);
bool _load(std::string name, 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()

virtual bool load(const of::filesystem::path & fileName) = 0;
// FIXME: FS
virtual bool load(std::string name) = 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(const of::filesystem::path & fileName);
virtual void loadAsync(std::string name);

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

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

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

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

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

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

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

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

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

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

Expand Down
Loading

0 comments on commit 5f679c2

Please sign in to comment.