From 87adc3b3343f2bd3954e8c1107c6d85acbc2a399 Mon Sep 17 00:00:00 2001 From: xiaowei guan Date: Fri, 12 Jan 2024 15:29:17 +0800 Subject: [PATCH 1/3] Support ADAPTIVE_INFO property --- .../lib/src/messages.g.dart | 59 +++++++++---- .../lib/src/video_player_tizen.dart | 1 + .../video_player_avplay/lib/video_player.dart | 10 +++ .../lib/video_player_platform_interface.dart | 4 + .../video_player_avplay/pigeons/messages.dart | 1 + .../tizen/src/media_player.cc | 75 +++++++++------- .../tizen/src/media_player.h | 5 +- .../tizen/src/media_player_proxy.cc | 29 +++++++ .../tizen/src/media_player_proxy.h | 2 + .../video_player_avplay/tizen/src/messages.cc | 87 ++++++++++++++----- .../video_player_avplay/tizen/src/messages.h | 10 ++- .../tizen/src/plus_player.cc | 62 ++++++++----- .../tizen/src/plus_player.h | 6 +- .../tizen/src/video_player.h | 21 ++++- .../tizen/src/video_player_tizen_plugin.cc | 43 +-------- 15 files changed, 268 insertions(+), 147 deletions(-) diff --git a/packages/video_player_avplay/lib/src/messages.g.dart b/packages/video_player_avplay/lib/src/messages.g.dart index e117a2742..ec02d20f8 100644 --- a/packages/video_player_avplay/lib/src/messages.g.dart +++ b/packages/video_player_avplay/lib/src/messages.g.dart @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v10.0.0), do not edit directly. +// Autogenerated from Pigeon (v10.1.6), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import @@ -225,6 +225,7 @@ class CreateMessage { this.httpHeaders, this.drmConfigs, this.playerOptions, + this.streamingProperty, }); String? asset; @@ -241,6 +242,8 @@ class CreateMessage { Map? playerOptions; + Map? streamingProperty; + Object encode() { return [ asset, @@ -250,6 +253,7 @@ class CreateMessage { httpHeaders, drmConfigs, playerOptions, + streamingProperty, ]; } @@ -266,6 +270,8 @@ class CreateMessage { (result[5] as Map?)?.cast(), playerOptions: (result[6] as Map?)?.cast(), + streamingProperty: + (result[7] as Map?)?.cast(), ); } } @@ -448,7 +454,8 @@ class VideoPlayerAvplayApi { Future initialize() async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerAvplayApi.initialize', codec, + 'dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.initialize', + codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send(null) as List?; if (replyList == null) { @@ -469,7 +476,8 @@ class VideoPlayerAvplayApi { Future create(CreateMessage arg_msg) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerAvplayApi.create', codec, + 'dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.create', + codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_msg]) as List?; @@ -496,7 +504,8 @@ class VideoPlayerAvplayApi { Future dispose(PlayerMessage arg_msg) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerAvplayApi.dispose', codec, + 'dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.dispose', + codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_msg]) as List?; @@ -518,7 +527,8 @@ class VideoPlayerAvplayApi { Future setLooping(LoopingMessage arg_msg) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerAvplayApi.setLooping', codec, + 'dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.setLooping', + codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_msg]) as List?; @@ -540,7 +550,8 @@ class VideoPlayerAvplayApi { Future setVolume(VolumeMessage arg_msg) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerAvplayApi.setVolume', codec, + 'dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.setVolume', + codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_msg]) as List?; @@ -562,7 +573,8 @@ class VideoPlayerAvplayApi { Future setPlaybackSpeed(PlaybackSpeedMessage arg_msg) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerAvplayApi.setPlaybackSpeed', codec, + 'dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.setPlaybackSpeed', + codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_msg]) as List?; @@ -584,7 +596,8 @@ class VideoPlayerAvplayApi { Future play(PlayerMessage arg_msg) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerAvplayApi.play', codec, + 'dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.play', + codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_msg]) as List?; @@ -606,7 +619,8 @@ class VideoPlayerAvplayApi { Future setDeactivate(PlayerMessage arg_msg) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerAvplayApi.setDeactivate', codec, + 'dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.setDeactivate', + codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_msg]) as List?; @@ -633,7 +647,8 @@ class VideoPlayerAvplayApi { Future setActivate(PlayerMessage arg_msg) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerAvplayApi.setActivate', codec, + 'dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.setActivate', + codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_msg]) as List?; @@ -660,7 +675,8 @@ class VideoPlayerAvplayApi { Future track(TrackTypeMessage arg_msg) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerAvplayApi.track', codec, + 'dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.track', + codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_msg]) as List?; @@ -687,7 +703,8 @@ class VideoPlayerAvplayApi { Future setTrackSelection(SelectedTracksMessage arg_msg) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerAvplayApi.setTrackSelection', codec, + 'dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.setTrackSelection', + codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_msg]) as List?; @@ -714,7 +731,8 @@ class VideoPlayerAvplayApi { Future position(PlayerMessage arg_msg) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerAvplayApi.position', codec, + 'dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.position', + codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_msg]) as List?; @@ -741,7 +759,8 @@ class VideoPlayerAvplayApi { Future duration(PlayerMessage arg_msg) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerAvplayApi.duration', codec, + 'dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.duration', + codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_msg]) as List?; @@ -768,7 +787,8 @@ class VideoPlayerAvplayApi { Future seekTo(PositionMessage arg_msg) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerAvplayApi.seekTo', codec, + 'dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.seekTo', + codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_msg]) as List?; @@ -790,7 +810,8 @@ class VideoPlayerAvplayApi { Future pause(PlayerMessage arg_msg) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerAvplayApi.pause', codec, + 'dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.pause', + codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_msg]) as List?; @@ -812,7 +833,8 @@ class VideoPlayerAvplayApi { Future setMixWithOthers(MixWithOthersMessage arg_msg) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerAvplayApi.setMixWithOthers', codec, + 'dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.setMixWithOthers', + codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_msg]) as List?; @@ -834,7 +856,8 @@ class VideoPlayerAvplayApi { Future setDisplayGeometry(GeometryMessage arg_msg) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerAvplayApi.setDisplayGeometry', codec, + 'dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.setDisplayGeometry', + codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_msg]) as List?; diff --git a/packages/video_player_avplay/lib/src/video_player_tizen.dart b/packages/video_player_avplay/lib/src/video_player_tizen.dart index 36e1f1711..24fe1d5d2 100644 --- a/packages/video_player_avplay/lib/src/video_player_tizen.dart +++ b/packages/video_player_avplay/lib/src/video_player_tizen.dart @@ -42,6 +42,7 @@ class VideoPlayerTizen extends VideoPlayerPlatform { message.httpHeaders = dataSource.httpHeaders; message.drmConfigs = dataSource.drmConfigs?.toMap(); message.playerOptions = dataSource.playerOptions; + message.streamingProperty = dataSource.streamingProperty; break; case DataSourceType.file: message.uri = dataSource.uri; diff --git a/packages/video_player_avplay/lib/video_player.dart b/packages/video_player_avplay/lib/video_player.dart index c8a020a6d..50a157250 100644 --- a/packages/video_player_avplay/lib/video_player.dart +++ b/packages/video_player_avplay/lib/video_player.dart @@ -228,6 +228,7 @@ class VideoPlayerController extends ValueNotifier { httpHeaders = const {}, drmConfigs = null, playerOptions = const {}, + streamingProperty = null, super(VideoPlayerValue( duration: DurationRange(Duration.zero, Duration.zero))); @@ -248,6 +249,7 @@ class VideoPlayerController extends ValueNotifier { this.httpHeaders = const {}, this.drmConfigs, this.playerOptions, + this.streamingProperty, }) : dataSourceType = DataSourceType.network, package = null, super(VideoPlayerValue( @@ -268,6 +270,7 @@ class VideoPlayerController extends ValueNotifier { httpHeaders = const {}, drmConfigs = null, playerOptions = const {}, + streamingProperty = null, super(VideoPlayerValue( duration: DurationRange(Duration.zero, Duration.zero))); @@ -288,6 +291,7 @@ class VideoPlayerController extends ValueNotifier { httpHeaders = const {}, drmConfigs = null, playerOptions = const {}, + streamingProperty = null, super(VideoPlayerValue( duration: DurationRange(Duration.zero, Duration.zero))); @@ -308,6 +312,11 @@ class VideoPlayerController extends ValueNotifier { /// Only for [VideoPlayerController.network]. final Map? playerOptions; + /// Sets specific feature values for HTTP, MMS, or specific streaming engine (Smooth Streaming, HLS, DASH, DivX Plus Streaming, or Widevine). + /// The available streaming properties depend on the streaming protocol or engine. + /// Only for [VideoPlayerController.network]. + final Map? streamingProperty; + /// **Android only**. Will override the platform's generic file format /// detection with whatever is set here. final VideoFormat? formatHint; @@ -377,6 +386,7 @@ class VideoPlayerController extends ValueNotifier { httpHeaders: httpHeaders, drmConfigs: drmConfigs, playerOptions: playerOptions, + streamingProperty: streamingProperty, ); break; case DataSourceType.file: diff --git a/packages/video_player_avplay/lib/video_player_platform_interface.dart b/packages/video_player_avplay/lib/video_player_platform_interface.dart index d1fb0e917..928f92fe5 100644 --- a/packages/video_player_avplay/lib/video_player_platform_interface.dart +++ b/packages/video_player_avplay/lib/video_player_platform_interface.dart @@ -179,6 +179,7 @@ class DataSource { this.httpHeaders = const {}, this.drmConfigs, this.playerOptions, + this.streamingProperty, }); /// The way in which the video was originally loaded. @@ -214,6 +215,9 @@ class DataSource { /// Set additional optional player settings. Map? playerOptions; + + /// Sets specific feature values for HTTP, MMS, or specific streaming engine + Map? streamingProperty; } /// The way in which the video was originally loaded. diff --git a/packages/video_player_avplay/pigeons/messages.dart b/packages/video_player_avplay/pigeons/messages.dart index 5dc95fc38..6e4315298 100644 --- a/packages/video_player_avplay/pigeons/messages.dart +++ b/packages/video_player_avplay/pigeons/messages.dart @@ -66,6 +66,7 @@ class CreateMessage { Map? httpHeaders; Map? drmConfigs; Map? playerOptions; + Map? streamingProperty; } class MixWithOthersMessage { diff --git a/packages/video_player_avplay/tizen/src/media_player.cc b/packages/video_player_avplay/tizen/src/media_player.cc index 6022136a6..efcefdea6 100644 --- a/packages/video_player_avplay/tizen/src/media_player.cc +++ b/packages/video_player_avplay/tizen/src/media_player.cc @@ -70,11 +70,9 @@ MediaPlayer::~MediaPlayer() { } } -int64_t MediaPlayer::Create(const std::string &uri, int drm_type, - const std::string &license_server_url, - bool is_prebuffer_mode, - flutter::EncodableMap &http_headers) { - LOG_INFO("[MediaPlayer] uri: %s, drm_type: %d.", uri.c_str(), drm_type); +int64_t MediaPlayer::Create(const std::string &uri, + const CreateMessage &create_message) { + LOG_INFO("[MediaPlayer] uri: %s.", uri.c_str()); if (uri.empty()) { LOG_ERROR("[MediaPlayer] The uri must not be empty."); @@ -88,38 +86,53 @@ int64_t MediaPlayer::Create(const std::string &uri, int drm_type, return -1; } - if (!http_headers.empty()) { - auto iter = http_headers.find(flutter::EncodableValue("Cookie")); - if (iter != http_headers.end()) { - if (std::holds_alternative(iter->second)) { - std::string cookie = std::get(iter->second); - ret = - player_set_streaming_cookie(player_, cookie.c_str(), cookie.size()); - if (ret != PLAYER_ERROR_NONE) { - LOG_ERROR("[MediaPlayer] player_set_streaming_cookie failed: %s.", - get_error_message(ret)); - } + if (!create_message.http_headers()->empty()) { + std::string cookie = flutter_common::GetValue(create_message.http_headers(), + "Cookie", std::string()); + if (!cookie.empty()) { + int ret = + player_set_streaming_cookie(player_, cookie.c_str(), cookie.size()); + if (ret != PLAYER_ERROR_NONE) { + LOG_ERROR("[MediaPlayer] player_set_streaming_cookie failed: %s.", + get_error_message(ret)); } } - - iter = http_headers.find(flutter::EncodableValue("User-Agent")); - if (iter != http_headers.end()) { - if (std::holds_alternative(iter->second)) { - std::string user_agent = std::get(iter->second); - ret = player_set_streaming_user_agent(player_, user_agent.c_str(), - user_agent.size()); - if (ret != PLAYER_ERROR_NONE) { - LOG_ERROR("[MediaPlayer] player_set_streaming_user_agent failed: %s.", - get_error_message(ret)); - } + std::string user_agent = flutter_common::GetValue( + create_message.http_headers(), "User-Agent", std::string()); + if (!user_agent.empty()) { + int ret = player_set_streaming_user_agent(player_, user_agent.c_str(), + user_agent.size()); + if (ret != PLAYER_ERROR_NONE) { + LOG_ERROR("[MediaPlayer] player_set_streaming_user_agent failed: %s.", + get_error_message(ret)); } } } - if (drm_type != 0) { - if (!SetDrm(uri, drm_type, license_server_url)) { - LOG_ERROR("[MediaPlayer] Failed to set drm."); - return -1; + if (create_message.streaming_property() != nullptr && + !create_message.streaming_property()->empty()) { + std::string adaptive_info = flutter_common::GetValue( + create_message.streaming_property(), "ADAPTIVE_INFO", std::string()); + if (!adaptive_info.empty()) { + media_player_proxy_->player_set_adaptive_streaming_info( + player_, + const_cast( + reinterpret_cast(adaptive_info.c_str())), + PLAYER_ADAPTIVE_INFO_URL_CUSTOM); + } + } + + if (create_message.drm_configs() != nullptr && + !create_message.drm_configs()->empty()) { + int drm_type = + flutter_common::GetValue(create_message.drm_configs(), "drmType", 0); + std::string license_server_url = flutter_common::GetValue( + create_message.drm_configs(), "licenseServerUrl", std::string()); + if (drm_type != 0) { + if (!SetDrm(uri, drm_type, license_server_url)) { + LOG_ERROR("[MediaPlayer] Fail to set drm."); + return -1; + } } } diff --git a/packages/video_player_avplay/tizen/src/media_player.h b/packages/video_player_avplay/tizen/src/media_player.h index cc43c9259..4f3eb47ed 100644 --- a/packages/video_player_avplay/tizen/src/media_player.h +++ b/packages/video_player_avplay/tizen/src/media_player.h @@ -21,9 +21,8 @@ class MediaPlayer : public VideoPlayer { FlutterDesktopViewRef flutter_view); ~MediaPlayer(); - int64_t Create(const std::string &uri, int drm_type, - const std::string &license_server_url, bool is_prebuffer_mode, - flutter::EncodableMap &http_headers) override; + int64_t Create(const std::string &uri, + const CreateMessage &create_message) override; void Dispose() override; void SetDisplayRoi(int32_t x, int32_t y, int32_t width, diff --git a/packages/video_player_avplay/tizen/src/media_player_proxy.cc b/packages/video_player_avplay/tizen/src/media_player_proxy.cc index 751404309..1a2ed94dc 100644 --- a/packages/video_player_avplay/tizen/src/media_player_proxy.cc +++ b/packages/video_player_avplay/tizen/src/media_player_proxy.cc @@ -16,24 +16,35 @@ typedef int (*FuncPlayerSetEcoreWlDisplay)(player_h player, typedef int (*FuncPlayerSetDrmHandle)(player_h player, player_drm_type_e drm_type, int drm_handle); + typedef int (*FuncPlayerSetDrmInitCompleteCB)( player_h player, security_init_complete_cb callback, void* user_data); + typedef int (*FuncPlayerSetDrmInitDataCB)(player_h player, set_drm_init_data_cb callback, void* user_data); + typedef int (*FuncPlayerGetAdaptiveStreamingInfo)(player_h player, void* adaptive_info, int adaptive_type); + typedef int (*FuncPlayerGetTrackCountV2)(player_h player, player_stream_type_e type, int* pcount); + typedef int (*FuncPlayerGetVideoTrackInfoV2)( player_h player, int index, player_video_track_info_v2** track_info); + typedef int (*FuncPlayerGetAudioTrackInfoV2)( player_h player, int index, player_audio_track_info_v2** track_info); + typedef int (*FuncPlayerGetSubtitleTrackInfoV2)( player_h player, int index, player_subtitle_track_info_v2** track_info); +typedef int (*FuncPlayerSetAdaptiveStreamingInfo)(player_h player, + void* adaptive_info, + int adaptive_type); + MediaPlayerProxy::MediaPlayerProxy() { media_player_handle_ = dlopen("libcapi-media-player.so.0", RTLD_LAZY); if (media_player_handle_ == nullptr) { @@ -200,3 +211,21 @@ int MediaPlayerProxy::player_get_subtitle_track_info_v2( } return player_get_subtitle_track_info_v2(player, index, track_info); } + +int MediaPlayerProxy::player_set_adaptive_streaming_info(player_h player, + void* adaptive_info, + int adaptive_type) { + if (!media_player_handle_) { + LOG_ERROR("media_player_handle_ not valid"); + return PLAYER_ERROR_NOT_AVAILABLE; + } + FuncPlayerSetAdaptiveStreamingInfo player_set_adaptive_streaming_info = + reinterpret_cast( + dlsym(media_player_handle_, "player_set_adaptive_streaming_info")); + if (!player_set_adaptive_streaming_info) { + LOG_ERROR("Fail to find player_set_adaptive_streaming_info."); + return PLAYER_ERROR_NOT_AVAILABLE; + } + return player_set_adaptive_streaming_info(player, adaptive_info, + adaptive_type); +} diff --git a/packages/video_player_avplay/tizen/src/media_player_proxy.h b/packages/video_player_avplay/tizen/src/media_player_proxy.h index 1229a42b4..2d21921db 100644 --- a/packages/video_player_avplay/tizen/src/media_player_proxy.h +++ b/packages/video_player_avplay/tizen/src/media_player_proxy.h @@ -130,6 +130,8 @@ class MediaPlayerProxy { player_audio_track_info_v2** track_info); int player_get_subtitle_track_info_v2( player_h player, int index, player_subtitle_track_info_v2** track_info); + int player_set_adaptive_streaming_info(player_h player, void* adaptive_info, + int adaptive_type); private: void* media_player_handle_ = nullptr; diff --git a/packages/video_player_avplay/tizen/src/messages.cc b/packages/video_player_avplay/tizen/src/messages.cc index 1fbe61c17..a8e743436 100644 --- a/packages/video_player_avplay/tizen/src/messages.cc +++ b/packages/video_player_avplay/tizen/src/messages.cc @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v10.0.0), do not edit directly. +// Autogenerated from Pigeon (v10.1.6), do not edit directly. // See also: https://pub.dev/packages/pigeon #undef _HAS_EXCEPTIONS @@ -263,7 +263,8 @@ CreateMessage::CreateMessage(const std::string* asset, const std::string* uri, const std::string* format_hint, const EncodableMap* http_headers, const EncodableMap* drm_configs, - const EncodableMap* player_options) + const EncodableMap* player_options, + const EncodableMap* streaming_property) : asset_(asset ? std::optional(*asset) : std::nullopt), uri_(uri ? std::optional(*uri) : std::nullopt), package_name_(package_name ? std::optional(*package_name) @@ -276,7 +277,10 @@ CreateMessage::CreateMessage(const std::string* asset, const std::string* uri, : std::nullopt), player_options_(player_options ? std::optional(*player_options) - : std::nullopt) {} + : std::nullopt), + streaming_property_(streaming_property + ? std::optional(*streaming_property) + : std::nullopt) {} const std::string* CreateMessage::asset() const { return asset_ ? &(*asset_) : nullptr; @@ -365,9 +369,22 @@ void CreateMessage::set_player_options(const EncodableMap& value_arg) { player_options_ = value_arg; } +const EncodableMap* CreateMessage::streaming_property() const { + return streaming_property_ ? &(*streaming_property_) : nullptr; +} + +void CreateMessage::set_streaming_property(const EncodableMap* value_arg) { + streaming_property_ = + value_arg ? std::optional(*value_arg) : std::nullopt; +} + +void CreateMessage::set_streaming_property(const EncodableMap& value_arg) { + streaming_property_ = value_arg; +} + EncodableList CreateMessage::ToEncodableList() const { EncodableList list; - list.reserve(7); + list.reserve(8); list.push_back(asset_ ? EncodableValue(*asset_) : EncodableValue()); list.push_back(uri_ ? EncodableValue(*uri_) : EncodableValue()); list.push_back(package_name_ ? EncodableValue(*package_name_) @@ -380,6 +397,8 @@ EncodableList CreateMessage::ToEncodableList() const { : EncodableValue()); list.push_back(player_options_ ? EncodableValue(*player_options_) : EncodableValue()); + list.push_back(streaming_property_ ? EncodableValue(*streaming_property_) + : EncodableValue()); return list; } @@ -414,6 +433,11 @@ CreateMessage CreateMessage::FromEncodableList(const EncodableList& list) { decoded.set_player_options( std::get(encodable_player_options)); } + auto& encodable_streaming_property = list[7]; + if (!encodable_streaming_property.IsNull()) { + decoded.set_streaming_property( + std::get(encodable_streaming_property)); + } return decoded; } @@ -698,7 +722,9 @@ void VideoPlayerAvplayApi::SetUp(flutter::BinaryMessenger* binary_messenger, VideoPlayerAvplayApi* api) { { auto channel = std::make_unique>( - binary_messenger, "dev.flutter.pigeon.VideoPlayerAvplayApi.initialize", + binary_messenger, + "dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi." + "initialize", &GetCodec()); if (api != nullptr) { channel->SetMessageHandler( @@ -723,7 +749,8 @@ void VideoPlayerAvplayApi::SetUp(flutter::BinaryMessenger* binary_messenger, } { auto channel = std::make_unique>( - binary_messenger, "dev.flutter.pigeon.VideoPlayerAvplayApi.create", + binary_messenger, + "dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.create", &GetCodec()); if (api != nullptr) { channel->SetMessageHandler( @@ -757,7 +784,8 @@ void VideoPlayerAvplayApi::SetUp(flutter::BinaryMessenger* binary_messenger, } { auto channel = std::make_unique>( - binary_messenger, "dev.flutter.pigeon.VideoPlayerAvplayApi.dispose", + binary_messenger, + "dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.dispose", &GetCodec()); if (api != nullptr) { channel->SetMessageHandler( @@ -790,7 +818,9 @@ void VideoPlayerAvplayApi::SetUp(flutter::BinaryMessenger* binary_messenger, } { auto channel = std::make_unique>( - binary_messenger, "dev.flutter.pigeon.VideoPlayerAvplayApi.setLooping", + binary_messenger, + "dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi." + "setLooping", &GetCodec()); if (api != nullptr) { channel->SetMessageHandler( @@ -823,7 +853,8 @@ void VideoPlayerAvplayApi::SetUp(flutter::BinaryMessenger* binary_messenger, } { auto channel = std::make_unique>( - binary_messenger, "dev.flutter.pigeon.VideoPlayerAvplayApi.setVolume", + binary_messenger, + "dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.setVolume", &GetCodec()); if (api != nullptr) { channel->SetMessageHandler( @@ -857,7 +888,8 @@ void VideoPlayerAvplayApi::SetUp(flutter::BinaryMessenger* binary_messenger, { auto channel = std::make_unique>( binary_messenger, - "dev.flutter.pigeon.VideoPlayerAvplayApi.setPlaybackSpeed", + "dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi." + "setPlaybackSpeed", &GetCodec()); if (api != nullptr) { channel->SetMessageHandler( @@ -891,7 +923,8 @@ void VideoPlayerAvplayApi::SetUp(flutter::BinaryMessenger* binary_messenger, } { auto channel = std::make_unique>( - binary_messenger, "dev.flutter.pigeon.VideoPlayerAvplayApi.play", + binary_messenger, + "dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.play", &GetCodec()); if (api != nullptr) { channel->SetMessageHandler( @@ -925,7 +958,9 @@ void VideoPlayerAvplayApi::SetUp(flutter::BinaryMessenger* binary_messenger, { auto channel = std::make_unique>( binary_messenger, - "dev.flutter.pigeon.VideoPlayerAvplayApi.setDeactivate", &GetCodec()); + "dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi." + "setDeactivate", + &GetCodec()); if (api != nullptr) { channel->SetMessageHandler( [api](const EncodableValue& message, @@ -957,7 +992,9 @@ void VideoPlayerAvplayApi::SetUp(flutter::BinaryMessenger* binary_messenger, } { auto channel = std::make_unique>( - binary_messenger, "dev.flutter.pigeon.VideoPlayerAvplayApi.setActivate", + binary_messenger, + "dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi." + "setActivate", &GetCodec()); if (api != nullptr) { channel->SetMessageHandler( @@ -990,7 +1027,8 @@ void VideoPlayerAvplayApi::SetUp(flutter::BinaryMessenger* binary_messenger, } { auto channel = std::make_unique>( - binary_messenger, "dev.flutter.pigeon.VideoPlayerAvplayApi.track", + binary_messenger, + "dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.track", &GetCodec()); if (api != nullptr) { channel->SetMessageHandler( @@ -1025,7 +1063,8 @@ void VideoPlayerAvplayApi::SetUp(flutter::BinaryMessenger* binary_messenger, { auto channel = std::make_unique>( binary_messenger, - "dev.flutter.pigeon.VideoPlayerAvplayApi.setTrackSelection", + "dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi." + "setTrackSelection", &GetCodec()); if (api != nullptr) { channel->SetMessageHandler( @@ -1058,7 +1097,8 @@ void VideoPlayerAvplayApi::SetUp(flutter::BinaryMessenger* binary_messenger, } { auto channel = std::make_unique>( - binary_messenger, "dev.flutter.pigeon.VideoPlayerAvplayApi.position", + binary_messenger, + "dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.position", &GetCodec()); if (api != nullptr) { channel->SetMessageHandler( @@ -1092,7 +1132,8 @@ void VideoPlayerAvplayApi::SetUp(flutter::BinaryMessenger* binary_messenger, } { auto channel = std::make_unique>( - binary_messenger, "dev.flutter.pigeon.VideoPlayerAvplayApi.duration", + binary_messenger, + "dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.duration", &GetCodec()); if (api != nullptr) { channel->SetMessageHandler( @@ -1126,7 +1167,8 @@ void VideoPlayerAvplayApi::SetUp(flutter::BinaryMessenger* binary_messenger, } { auto channel = std::make_unique>( - binary_messenger, "dev.flutter.pigeon.VideoPlayerAvplayApi.seekTo", + binary_messenger, + "dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.seekTo", &GetCodec()); if (api != nullptr) { channel->SetMessageHandler( @@ -1161,7 +1203,8 @@ void VideoPlayerAvplayApi::SetUp(flutter::BinaryMessenger* binary_messenger, } { auto channel = std::make_unique>( - binary_messenger, "dev.flutter.pigeon.VideoPlayerAvplayApi.pause", + binary_messenger, + "dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.pause", &GetCodec()); if (api != nullptr) { channel->SetMessageHandler( @@ -1195,7 +1238,8 @@ void VideoPlayerAvplayApi::SetUp(flutter::BinaryMessenger* binary_messenger, { auto channel = std::make_unique>( binary_messenger, - "dev.flutter.pigeon.VideoPlayerAvplayApi.setMixWithOthers", + "dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi." + "setMixWithOthers", &GetCodec()); if (api != nullptr) { channel->SetMessageHandler( @@ -1230,7 +1274,8 @@ void VideoPlayerAvplayApi::SetUp(flutter::BinaryMessenger* binary_messenger, { auto channel = std::make_unique>( binary_messenger, - "dev.flutter.pigeon.VideoPlayerAvplayApi.setDisplayGeometry", + "dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi." + "setDisplayGeometry", &GetCodec()); if (api != nullptr) { channel->SetMessageHandler( diff --git a/packages/video_player_avplay/tizen/src/messages.h b/packages/video_player_avplay/tizen/src/messages.h index 03b606424..fd52f5f70 100644 --- a/packages/video_player_avplay/tizen/src/messages.h +++ b/packages/video_player_avplay/tizen/src/messages.h @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v10.0.0), do not edit directly. +// Autogenerated from Pigeon (v10.1.6), do not edit directly. // See also: https://pub.dev/packages/pigeon #ifndef PIGEON_MESSAGES_H_ @@ -237,7 +237,8 @@ class CreateMessage { const std::string* format_hint, const flutter::EncodableMap* http_headers, const flutter::EncodableMap* drm_configs, - const flutter::EncodableMap* player_options); + const flutter::EncodableMap* player_options, + const flutter::EncodableMap* streaming_property); const std::string* asset() const; void set_asset(const std::string_view* value_arg); @@ -267,6 +268,10 @@ class CreateMessage { void set_player_options(const flutter::EncodableMap* value_arg); void set_player_options(const flutter::EncodableMap& value_arg); + const flutter::EncodableMap* streaming_property() const; + void set_streaming_property(const flutter::EncodableMap* value_arg); + void set_streaming_property(const flutter::EncodableMap& value_arg); + private: static CreateMessage FromEncodableList(const flutter::EncodableList& list); flutter::EncodableList ToEncodableList() const; @@ -279,6 +284,7 @@ class CreateMessage { std::optional http_headers_; std::optional drm_configs_; std::optional player_options_; + std::optional streaming_property_; }; // Generated class from Pigeon that represents data sent in messages. diff --git a/packages/video_player_avplay/tizen/src/plus_player.cc b/packages/video_player_avplay/tizen/src/plus_player.cc index c33ad39c6..d2835714f 100644 --- a/packages/video_player_avplay/tizen/src/plus_player.cc +++ b/packages/video_player_avplay/tizen/src/plus_player.cc @@ -66,10 +66,8 @@ void PlusPlayer::RegisterListener() { ::RegisterListener(player_, &listener_, this); } -int64_t PlusPlayer::Create(const std::string &uri, int drm_type, - const std::string &license_server_url, - bool is_prebuffer_mode, - flutter::EncodableMap &http_headers) { +int64_t PlusPlayer::Create(const std::string &uri, + const CreateMessage &create_message) { LOG_INFO("[PlusPlayer] Create player."); if (video_format_ == "dash") { @@ -83,21 +81,25 @@ int64_t PlusPlayer::Create(const std::string &uri, int drm_type, return -1; } - if (!http_headers.empty()) { - auto iter = http_headers.find(flutter::EncodableValue("Cookie")); - if (iter != http_headers.end()) { - if (std::holds_alternative(iter->second)) { - std::string cookie = std::get(iter->second); - SetStreamingProperty(player_, "COOKIE", cookie); - } + if (!create_message.http_headers()->empty()) { + std::string cookie = flutter_common::GetValue(create_message.http_headers(), + "Cookie", std::string()); + if (!cookie.empty()) { + SetStreamingProperty(player_, "COOKIE", cookie); + } + std::string user_agent = flutter_common::GetValue( + create_message.http_headers(), "User-Agent", std::string()); + if (!user_agent.empty()) { + SetStreamingProperty(player_, "USER_AGENT", user_agent); } + } - iter = http_headers.find(flutter::EncodableValue("User-Agent")); - if (iter != http_headers.end()) { - if (std::holds_alternative(iter->second)) { - std::string user_agent = std::get(iter->second); - SetStreamingProperty(player_, "USER_AGENT", user_agent); - } + if (create_message.streaming_property() != nullptr && + !create_message.streaming_property()->empty()) { + std::string adaptive_info = flutter_common::GetValue( + create_message.streaming_property(), "ADAPTIVE_INFO", std::string()); + if (!adaptive_info.empty()) { + SetStreamingProperty(player_, "ADAPTIVE_INFO", adaptive_info); } } @@ -118,10 +120,17 @@ int64_t PlusPlayer::Create(const std::string &uri, int drm_type, RegisterListener(); - if (drm_type != 0) { - if (!SetDrm(uri, drm_type, license_server_url)) { - LOG_ERROR("[PlusPlayer] Fail to set drm."); - return -1; + if (create_message.drm_configs() != nullptr && + !create_message.drm_configs()->empty()) { + int drm_type = + flutter_common::GetValue(create_message.drm_configs(), "drmType", 0); + std::string license_server_url = flutter_common::GetValue( + create_message.drm_configs(), "licenseServerUrl", std::string()); + if (drm_type != 0) { + if (!SetDrm(uri, drm_type, license_server_url)) { + LOG_ERROR("[PlusPlayer] Fail to set drm."); + return -1; + } } } @@ -132,9 +141,14 @@ int64_t PlusPlayer::Create(const std::string &uri, int drm_type, SetDisplayRoi(0, 0, 1, 1); - if (is_prebuffer_mode) { - SetPrebufferMode(player_, true); - is_prebuffer_mode_ = true; + if (create_message.player_options() != nullptr && + !create_message.player_options()->empty()) { + bool is_prebuffer_mode = flutter_common::GetValue( + create_message.player_options(), "prebufferMode", false); + if (is_prebuffer_mode) { + SetPrebufferMode(player_, true); + is_prebuffer_mode_ = true; + } } if (!PrepareAsync(player_)) { diff --git a/packages/video_player_avplay/tizen/src/plus_player.h b/packages/video_player_avplay/tizen/src/plus_player.h index 676e60cac..9b469f6ed 100644 --- a/packages/video_player_avplay/tizen/src/plus_player.h +++ b/packages/video_player_avplay/tizen/src/plus_player.h @@ -11,6 +11,7 @@ #include #include "drm_manager.h" +#include "messages.h" #include "plusplayer/plusplayer_wrapper.h" #include "video_player.h" @@ -21,9 +22,8 @@ class PlusPlayer : public VideoPlayer { std::string &video_format); ~PlusPlayer(); - int64_t Create(const std::string &uri, int drm_type, - const std::string &license_server_url, bool is_prebuffer_mode, - flutter::EncodableMap &http_headers) override; + int64_t Create(const std::string &uri, + const CreateMessage &create_message) override; void Dispose() override; void SetDisplayRoi(int32_t x, int32_t y, int32_t width, diff --git a/packages/video_player_avplay/tizen/src/video_player.h b/packages/video_player_avplay/tizen/src/video_player.h index d10ebb2f6..0a293c9d2 100644 --- a/packages/video_player_avplay/tizen/src/video_player.h +++ b/packages/video_player_avplay/tizen/src/video_player.h @@ -17,6 +17,7 @@ #include #include "ecore_wl2_window_proxy.h" +#include "messages.h" class VideoPlayer { public: @@ -28,10 +29,8 @@ class VideoPlayer { VideoPlayer &operator=(const VideoPlayer &) = delete; virtual ~VideoPlayer(); - virtual int64_t Create(const std::string &uri, int drm_type, - const std::string &license_server_url, - bool is_prebuffer_mode, - flutter::EncodableMap &http_headers) = 0; + virtual int64_t Create(const std::string &uri, + const CreateMessage &create_message) = 0; virtual void Dispose() = 0; virtual void SetDisplayRoi(int32_t x, int32_t y, int32_t width, @@ -82,4 +81,18 @@ class VideoPlayer { Ecore_Pipe *sink_event_pipe_ = nullptr; }; +namespace flutter_common { + +template +inline const T GetValue(const flutter::EncodableMap *map, + const std::string &key, T &&default_value) { + auto it = map->find(flutter::EncodableValue(key)); + if (it != map->end() && std::holds_alternative(it->second)) { + return std::get(it->second); + } + return default_value; +} + +} // namespace flutter_common + #endif // FLUTTER_PLUGIN_VIDEO_PLAYER_H_ diff --git a/packages/video_player_avplay/tizen/src/video_player_tizen_plugin.cc b/packages/video_player_avplay/tizen/src/video_player_tizen_plugin.cc index 1b2dfa885..ed38cdc8c 100644 --- a/packages/video_player_avplay/tizen/src/video_player_tizen_plugin.cc +++ b/packages/video_player_avplay/tizen/src/video_player_tizen_plugin.cc @@ -109,11 +109,7 @@ ErrorOr VideoPlayerTizenPlugin::Create( return FlutterError("Operation failed", "Could not get a Flutter view."); } std::string uri; - int32_t drm_type = 0; // DRM_TYPE_NONE - std::string license_server_url; - bool prebuffer_mode; std::string format; - flutter::EncodableMap http_headers = {}; if (msg.asset() && !msg.asset()->empty()) { char *res_path = app_get_resource_path(); @@ -128,39 +124,6 @@ ErrorOr VideoPlayerTizenPlugin::Create( if (msg.format_hint() && !msg.format_hint()->empty()) { format = *msg.format_hint(); } - - const flutter::EncodableMap *drm_configs = msg.drm_configs(); - if (drm_configs) { - auto iter = drm_configs->find(flutter::EncodableValue("drmType")); - if (iter != drm_configs->end()) { - if (std::holds_alternative(iter->second)) { - drm_type = std::get(iter->second); - } - } - iter = drm_configs->find(flutter::EncodableValue("licenseServerUrl")); - if (iter != drm_configs->end()) { - if (std::holds_alternative(iter->second)) { - license_server_url = std::get(iter->second); - } - } - } - - const flutter::EncodableMap *player_options = msg.player_options(); - if (player_options) { - auto iter = - player_options->find(flutter::EncodableValue("prebufferMode")); - if (iter != player_options->end()) { - if (std::holds_alternative(iter->second)) { - prebuffer_mode = std::get(iter->second); - } - } - } - - const flutter::EncodableMap *http_headers_map = msg.http_headers(); - if (http_headers_map) { - http_headers = *http_headers_map; - } - } else { return FlutterError("Invalid argument", "Either asset or uri must be set."); } @@ -170,8 +133,7 @@ ErrorOr VideoPlayerTizenPlugin::Create( auto player = std::make_unique( plugin_registrar_->messenger(), FlutterDesktopPluginRegistrarGetView(registrar_ref_), format); - player_id = player->Create(uri, drm_type, license_server_url, - prebuffer_mode, http_headers); + player_id = player->Create(uri, msg); if (player_id == -1) { return FlutterError("Operation failed", "Failed to create a player."); } @@ -180,8 +142,7 @@ ErrorOr VideoPlayerTizenPlugin::Create( auto player = std::make_unique( plugin_registrar_->messenger(), FlutterDesktopPluginRegistrarGetView(registrar_ref_)); - player_id = player->Create(uri, drm_type, license_server_url, - prebuffer_mode, http_headers); + player_id = player->Create(uri, msg); if (player_id == -1) { return FlutterError("Operation failed", "Failed to create a player."); } From 27f9b514f2284f08a93858152b13141c301aa767 Mon Sep 17 00:00:00 2001 From: xiaowei guan Date: Tue, 23 Jan 2024 14:03:44 +0800 Subject: [PATCH 2/3] Change string property type to Map --- packages/video_player_avplay/lib/video_player.dart | 2 +- .../lib/video_player_platform_interface.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/video_player_avplay/lib/video_player.dart b/packages/video_player_avplay/lib/video_player.dart index 50a157250..a5f815996 100644 --- a/packages/video_player_avplay/lib/video_player.dart +++ b/packages/video_player_avplay/lib/video_player.dart @@ -315,7 +315,7 @@ class VideoPlayerController extends ValueNotifier { /// Sets specific feature values for HTTP, MMS, or specific streaming engine (Smooth Streaming, HLS, DASH, DivX Plus Streaming, or Widevine). /// The available streaming properties depend on the streaming protocol or engine. /// Only for [VideoPlayerController.network]. - final Map? streamingProperty; + final Map? streamingProperty; /// **Android only**. Will override the platform's generic file format /// detection with whatever is set here. diff --git a/packages/video_player_avplay/lib/video_player_platform_interface.dart b/packages/video_player_avplay/lib/video_player_platform_interface.dart index 928f92fe5..f298c43a2 100644 --- a/packages/video_player_avplay/lib/video_player_platform_interface.dart +++ b/packages/video_player_avplay/lib/video_player_platform_interface.dart @@ -217,7 +217,7 @@ class DataSource { Map? playerOptions; /// Sets specific feature values for HTTP, MMS, or specific streaming engine - Map? streamingProperty; + Map? streamingProperty; } /// The way in which the video was originally loaded. From d185dc11e367837834c72b352c429accc11caea4 Mon Sep 17 00:00:00 2001 From: xiaowei guan Date: Tue, 23 Jan 2024 17:20:46 +0800 Subject: [PATCH 3/3] Version up --- packages/video_player_avplay/CHANGELOG.md | 4 ++++ packages/video_player_avplay/README.md | 2 +- packages/video_player_avplay/pubspec.yaml | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/video_player_avplay/CHANGELOG.md b/packages/video_player_avplay/CHANGELOG.md index b56361f01..90372dae9 100644 --- a/packages/video_player_avplay/CHANGELOG.md +++ b/packages/video_player_avplay/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.3.0 + +* Support ADAPTIVE_INFO property. + ## 0.2.3 * [dash] DASH unique event including index tag. diff --git a/packages/video_player_avplay/README.md b/packages/video_player_avplay/README.md index bace3e533..dae346021 100644 --- a/packages/video_player_avplay/README.md +++ b/packages/video_player_avplay/README.md @@ -12,7 +12,7 @@ To use this package, add `video_player_avplay` as a dependency in your `pubspec. ```yaml dependencies: - video_player_avplay: ^0.2.3 + video_player_avplay: ^0.3.0 ``` Then you can import `video_player_avplay` in your Dart code: diff --git a/packages/video_player_avplay/pubspec.yaml b/packages/video_player_avplay/pubspec.yaml index ad635d6f5..ddfa845fc 100644 --- a/packages/video_player_avplay/pubspec.yaml +++ b/packages/video_player_avplay/pubspec.yaml @@ -2,7 +2,7 @@ name: video_player_avplay description: Flutter plugin for displaying inline video on Tizen TV devices. homepage: https://github.com/flutter-tizen/plugins repository: https://github.com/flutter-tizen/plugins/tree/master/packages/video_player_avplay -version: 0.2.3 +version: 0.3.0 environment: sdk: ">=2.18.0 <4.0.0"