openframeworks / openframeworks/openFrameworks

ofVideoPlayer room for improvement

Open
#6,793 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
10.4k
Forks
2.6k
Avg merge
1d 21h
Merged PRs (30d)
9

Description

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
	}
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the ofVideoPlayer implementation around setPlayer, player initialization, and setPixelFormat, then review PR 8189 and issue 5797 for related context. The issue does not define a final change or acceptance criteria; completion would require maintainer agreement on the proposed refactor and its scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
audio-video-rtc
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.