Skip to content

ofVideoPlayer room for improvement #6793

@dimitre

Description

@dimitre

PRs

Issue to address

I'm spending some time reading ofVideoPlayer code to understand better how it is structured.
So I'm opening here to ask opinions and share thoughts.

Some things caught my attention in the process, the first of them is this function

void ofVideoPlayer::setPlayer(shared_ptr<ofBaseVideoPlayer> newPlayer)

which has a shared_ptr as a parameter. and assigns a shared_ptr to another shared_ptr here

player = newPlayer;

I can see they are using two different addresses if I print them

cout << "setPlayer " << &player << " " << newPlayer << endl;

I've noticed there are some checks in different parts of the code which call this function, some call setPixelFormat, and some don't.

	if( !player ){
		setPlayer(std::make_shared<OF_VID_PLAYER_TYPE>());
		player->setPixelFormat(internalPixelFormat);
	}

We can substitute this checks with a function which creates the shared pointer without passing as a function parameter, something like this

void ofVideoPlayer::checkPlayer(){
	if( !player ){
		player = std::make_shared<OF_VID_PLAYER_TYPE>();
		player->setPixelFormat(internalPixelFormat);
		setPixelFormat(internalPixelFormat);	//this means that it will try to set the pixel format you
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions