-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: pingkai <[email protected]>
- Loading branch information
1 parent
e00d4e4
commit 0bfd9b9
Showing
9 changed files
with
109 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// Created by moqi on 2020/7/20. | ||
// | ||
|
||
#include "CicadaPlayerPrototype.h" | ||
#include "SuperMediaPlayer.h" | ||
using namespace Cicada; | ||
CicadaPlayerPrototype *CicadaPlayerPrototype::playerQueue[]; | ||
int CicadaPlayerPrototype::_nextSlot; | ||
void CicadaPlayerPrototype::addPrototype(Cicada::CicadaPlayerPrototype *se) | ||
{ | ||
playerQueue[_nextSlot++] = se; | ||
} | ||
ICicadaPlayer *CicadaPlayerPrototype::create(const options *opts = nullptr) | ||
{ | ||
int score_res = 0; | ||
CicadaPlayerPrototype *playerType = nullptr; | ||
|
||
for (int i = 0; i < _nextSlot; ++i) { | ||
int score = playerQueue[i]->probeScore(opts); | ||
|
||
if (score > score_res) { | ||
score_res = score; | ||
playerType = playerQueue[i]; | ||
|
||
if (score >= SUPPORT_MAX) { | ||
break; | ||
} | ||
} | ||
} | ||
|
||
if (playerType && score_res > SUPPORT_NOT) { | ||
ICicadaPlayer *player = playerType->clone(); | ||
return player; | ||
} | ||
|
||
return new SuperMediaPlayer(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// Created by moqi on 2020/7/20. | ||
// | ||
|
||
#ifndef CICADAMEDIA_CICADAPLAYERPROTOTYPE_H | ||
#define CICADAMEDIA_CICADAPLAYERPROTOTYPE_H | ||
#include "ICicadaPlayer.h" | ||
#include <base/options.h> | ||
#include <base/prototype.h> | ||
#include <utils/CicadaType.h> | ||
namespace Cicada { | ||
class CICADA_CPLUS_EXTERN CicadaPlayerPrototype { | ||
static CicadaPlayerPrototype *playerQueue[10]; | ||
static int _nextSlot; | ||
|
||
public: | ||
virtual ~CicadaPlayerPrototype() = default; | ||
|
||
virtual ICicadaPlayer *clone() = 0; | ||
|
||
virtual bool is_supported(const options *opts) = 0; | ||
|
||
virtual int probeScore(const options *opts) | ||
{ | ||
if (is_supported(opts)) { | ||
return SUPPORT_DEFAULT; | ||
} | ||
return 0; | ||
} | ||
|
||
static void addPrototype(CicadaPlayerPrototype *se); | ||
|
||
static ICicadaPlayer *create(const options *opts); | ||
}; | ||
}// namespace Cicada | ||
|
||
|
||
#endif//CICADAMEDIA_CICADAPLAYERPROTOTYPE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters