Skip to content

Commit

Permalink
fix(mediaplayer): description length over 256 when getOption
Browse files Browse the repository at this point in the history
  • Loading branch information
I-m-SuperMan authored and pingkai committed Feb 18, 2020
1 parent 3318748 commit 5cc1b00
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 11 additions & 1 deletion mediaPlayer/MediaPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,19 @@ namespace Cicada {
mCacheManager = new CacheManager();
mCacheManager->setCacheConfig(mCacheConfig);
mCacheManager->setSourceUrl(url);
char value[MAX_OPT_VALUE_LENGTH] = {0};

char descriptionLen[MAX_OPT_VALUE_LENGTH] = {0};
CicadaGetOption(handle, "descriptionLen", descriptionLen);
int len = atoi(descriptionLen);

char *value = static_cast<char *>(malloc(len + 1));
memset(value,0 , len+1);

CicadaGetOption(handle, "description", value);
mCacheManager->setDescription(value);

free(value);

mCacheManager->setCacheFailCallback([this](int code, string msg) -> void {
AF_LOGE("Cache fail : code = %d , msg = %s", code, msg.c_str());
this->eventCallback(MEDIA_PLAYER_EVENT_CACHE_ERROR, msg.c_str(), this);
Expand Down
4 changes: 3 additions & 1 deletion mediaPlayer/SuperMediaPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,9 @@ namespace Cicada {

snprintf(value, MAX_OPT_VALUE_LENGTH, "%" PRId64 "", size);
} else if (theKey == "description") {
snprintf(value, MAX_OPT_VALUE_LENGTH, "%s", mSet.mOptions.get("description").c_str());
sprintf(value, "%s", mSet.mOptions.get("description").c_str());
} else if (theKey == "descriptionLen") {
snprintf(value, MAX_OPT_VALUE_LENGTH, "%lu", mSet.mOptions.get("description").length());
} else if (theKey == "renderFps") {
float renderFps = GetVideoRenderFps();
snprintf(value, MAX_OPT_VALUE_LENGTH, "%f", renderFps);
Expand Down

0 comments on commit 5cc1b00

Please sign in to comment.