Skip to content

Commit

Permalink
feat(mediaplayer): add pixelBufferOutputFormat config for apple platform
Browse files Browse the repository at this point in the history
Signed-off-by: pingkai <pingkai010@gmail.com>
  • Loading branch information
pingkai committed Jun 9, 2020
1 parent 22dae44 commit 1048145
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 2 deletions.
3 changes: 3 additions & 0 deletions mediaPlayer/MediaPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,9 @@ namespace Cicada {
CicadaSetOption(handle, "http_proxy", playerConfig.httpProxy.c_str());
CicadaSetOption(handle, "ClearShowWhenStop", playerConfig.bClearShowWhenStop ? "1" : "0");
CicadaSetOption(handle, "enableVideoTunnelRender", playerConfig.bEnableTunnelRender ? "1" : "0");
if (playerConfig.pixelBufferOutputFormat != 0) {
CicadaSetOption(handle, "pixelBufferOutputFormat", to_string(playerConfig.pixelBufferOutputFormat).c_str());
}
CicadaRemoveAllCustomHttpHeader(handle);

//add custom http header
Expand Down
1 change: 1 addition & 0 deletions mediaPlayer/MediaPlayerConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace Cicada {
startBufferDuration = 500;
bClearShowWhenStop = false;
bEnableTunnelRender = false;
pixelBufferOutputFormat = 0;
}

std::string MediaPlayerConfig::toString() const
Expand Down
5 changes: 5 additions & 0 deletions mediaPlayer/MediaPlayerConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ namespace Cicada {
/* enable tunnel render*/
bool bEnableTunnelRender;
std::vector<std::string> customHeaders;
/* set the video format for renderFrame callback
* vtb decoder only, equal to OSType, not be supported by other decoder
* support 420v 420f y420 BGRA
* */
uint32_t pixelBufferOutputFormat;

public:
std::string toString() const;
Expand Down
18 changes: 16 additions & 2 deletions mediaPlayer/SuperMediaPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@

#ifdef __APPLE__

#include <TargetConditionals.h>
#include <render/audio/Apple/AFAudioSessionWrapper.h>
#include <TargetConditionals.h>
#include <codec/Apple/AppleVideoToolBox.cpp>
#include <render/audio/Apple/AFAudioSessionWrapper.h>

#endif

Expand Down Expand Up @@ -583,6 +584,8 @@ namespace Cicada {
mSet.mIpType = static_cast<IpResolveType>(type);
} else if (theKey == "fastStart") {
mSet.mFastStart = atol(value) != 0;
} else if (theKey == "pixelBufferOutputFormat") {
mSet.pixelBufferOutputFormat = atol(value);
}

return 0;
Expand Down Expand Up @@ -3198,6 +3201,17 @@ namespace Cicada {
if (mVideoDecoder == nullptr) {
return gen_framework_errno(error_class_codec, codec_error_video_not_support);
}
#ifdef __APPLE__
if (mFrameCb && mSet.pixelBufferOutputFormat) {
auto *vtbDecoder = dynamic_cast<AFVTBDecoder *>(mVideoDecoder.get());
if (vtbDecoder) {
int ret1 = vtbDecoder->setPixelBufferFormat(mSet.pixelBufferOutputFormat);
if (ret1 < 0) {
AF_LOGW("setPixelBufferFormat error\n");
}
}
}
#endif

void *view = nullptr;

Expand Down
1 change: 1 addition & 0 deletions mediaPlayer/player_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ namespace Cicada {
maxASeekDelta = 21 * 1000 * 1000;
maxVideoRecoverSize = 300;
mFastStart = true;
pixelBufferOutputFormat = 0;
}
}

1 change: 1 addition & 0 deletions mediaPlayer/player_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ namespace Cicada {

int maxVideoRecoverSize;
bool mFastStart{true};
uint32_t pixelBufferOutputFormat;
};
}

Expand Down

0 comments on commit 1048145

Please sign in to comment.