Skip to content

Commit

Permalink
feat(mediaplayer): add SetIPResolveType api
Browse files Browse the repository at this point in the history
Signed-off-by: pingkai <[email protected]>
  • Loading branch information
pingkai committed Jun 1, 2020
1 parent 470d557 commit 126e368
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmdline/cicadaPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ int main(int argc, char *argv[])
player->SetDataSource(url.c_str());
player->SetAutoPlay(true);
player->SetLoop(true);
player->SetIPResolveType(IpResolveWhatEver);
player->Prepare();
player->SelectTrack(-1);
bool quite = false;
Expand Down
6 changes: 6 additions & 0 deletions mediaPlayer/MediaPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1121,4 +1121,10 @@ namespace Cicada {
GET_PLAYER_HANDLE;
CicadaSetOption(handle, "streamTypes", to_string(flags).c_str());
}

void MediaPlayer::SetIPResolveType(IpResolveType type)
{
GET_PLAYER_HANDLE;
CicadaSetOption(handle, "IPResolveType", to_string(type).c_str());
}
}
3 changes: 3 additions & 0 deletions mediaPlayer/MediaPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ namespace Cicada {

void SetStreamTypeFlags(uint64_t flags);


void SetIPResolveType(IpResolveType type);

/*
* set player listener
*/
Expand Down
15 changes: 15 additions & 0 deletions mediaPlayer/SuperMediaPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,9 @@ namespace Cicada {
if (flags & AUDIO_FLAG) {
mSet.bDisableAudio = false;
}
} else if (theKey == "IPResolveType") {
uint64_t type = atoll(value);
mSet.mIpType = static_cast<IpResolveType>(type);
}

return 0;
Expand Down Expand Up @@ -3575,6 +3578,18 @@ namespace Cicada {
IDataSource::SourceConfig config{};
config.low_speed_time_ms = mSet.timeout_ms;
config.low_speed_limit = 1;

switch (mSet.mIpType) {
case IpResolveWhatEver:
config.resolveType = IDataSource::SourceConfig::IpResolveWhatEver;
break;
case IpResolveV4:
config.resolveType = IDataSource::SourceConfig::IpResolveV4;
break;
case IpResolveV6:
config.resolveType = IDataSource::SourceConfig::IpResolveV6;
break;
}
// config.max_time_ms = mSet.timeout;
config.connect_time_out_ms = mSet.timeout_ms;
config.http_proxy = mSet.http_proxy;
Expand Down
2 changes: 2 additions & 0 deletions mediaPlayer/native_cicada_player_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ typedef enum _StreamType {
ST_TYPE_SUB,
} StreamType;

typedef enum _IpResolveType { IpResolveWhatEver, IpResolveV4, IpResolveV6 } IpResolveType;

#define VIDEO_FLAG 1 << ST_TYPE_VIDEO
#define AUDIO_FLAG 1 << ST_TYPE_AUDIO
#define SUB_FLAG 1 << ST_TYPE_SUB
Expand Down
1 change: 1 addition & 0 deletions mediaPlayer/player_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ namespace Cicada {
url = "";
refer = "";
timeout_ms = 15000;
mIpType = IpResolveWhatEver;
RTMaxDelayTime = 0;
bLooping = false;
bDisableAudio = false;
Expand Down
1 change: 1 addition & 0 deletions mediaPlayer/player_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ namespace Cicada {
std::string userAgent{""};
int timeout_ms{15000};
int RTMaxDelayTime{0};
IpResolveType mIpType{IpResolveWhatEver};
bool bLooping{false};
bool bDisableAudio{false};
bool bDisableVideo{false};
Expand Down

0 comments on commit 126e368

Please sign in to comment.