diff --git a/cmdline/cicadaPlayer.cpp b/cmdline/cicadaPlayer.cpp index 4d2b8be17..568e30736 100644 --- a/cmdline/cicadaPlayer.cpp +++ b/cmdline/cicadaPlayer.cpp @@ -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; diff --git a/mediaPlayer/MediaPlayer.cpp b/mediaPlayer/MediaPlayer.cpp index 5b329ef21..e0138f816 100644 --- a/mediaPlayer/MediaPlayer.cpp +++ b/mediaPlayer/MediaPlayer.cpp @@ -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()); + } } diff --git a/mediaPlayer/MediaPlayer.h b/mediaPlayer/MediaPlayer.h index 762ea92f0..2d4e0d66c 100644 --- a/mediaPlayer/MediaPlayer.h +++ b/mediaPlayer/MediaPlayer.h @@ -66,6 +66,9 @@ namespace Cicada { void SetStreamTypeFlags(uint64_t flags); + + void SetIPResolveType(IpResolveType type); + /* * set player listener */ diff --git a/mediaPlayer/SuperMediaPlayer.cpp b/mediaPlayer/SuperMediaPlayer.cpp index 60bca1e7b..b8f7955bc 100644 --- a/mediaPlayer/SuperMediaPlayer.cpp +++ b/mediaPlayer/SuperMediaPlayer.cpp @@ -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(type); } return 0; @@ -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; diff --git a/mediaPlayer/native_cicada_player_def.h b/mediaPlayer/native_cicada_player_def.h index bba981b15..25351c181 100644 --- a/mediaPlayer/native_cicada_player_def.h +++ b/mediaPlayer/native_cicada_player_def.h @@ -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 diff --git a/mediaPlayer/player_types.cpp b/mediaPlayer/player_types.cpp index 5e7d6708a..e65e03142 100644 --- a/mediaPlayer/player_types.cpp +++ b/mediaPlayer/player_types.cpp @@ -30,6 +30,7 @@ namespace Cicada { url = ""; refer = ""; timeout_ms = 15000; + mIpType = IpResolveWhatEver; RTMaxDelayTime = 0; bLooping = false; bDisableAudio = false; diff --git a/mediaPlayer/player_types.h b/mediaPlayer/player_types.h index e7a4b49ed..9ceb73a5d 100644 --- a/mediaPlayer/player_types.h +++ b/mediaPlayer/player_types.h @@ -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};