Skip to content

Commit

Permalink
Support ADAPTIVE_INFO property
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaowei-guan committed Jan 12, 2024
1 parent 00d1524 commit 87adc3b
Show file tree
Hide file tree
Showing 15 changed files with 268 additions and 147 deletions.
59 changes: 41 additions & 18 deletions packages/video_player_avplay/lib/src/messages.g.dart
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -225,6 +225,7 @@ class CreateMessage {
this.httpHeaders,
this.drmConfigs,
this.playerOptions,
this.streamingProperty,
});

String? asset;
Expand All @@ -241,6 +242,8 @@ class CreateMessage {

Map<Object?, Object?>? playerOptions;

Map<Object?, Object?>? streamingProperty;

Object encode() {
return <Object?>[
asset,
Expand All @@ -250,6 +253,7 @@ class CreateMessage {
httpHeaders,
drmConfigs,
playerOptions,
streamingProperty,
];
}

Expand All @@ -266,6 +270,8 @@ class CreateMessage {
(result[5] as Map<Object?, Object?>?)?.cast<Object?, Object?>(),
playerOptions:
(result[6] as Map<Object?, Object?>?)?.cast<Object?, Object?>(),
streamingProperty:
(result[7] as Map<Object?, Object?>?)?.cast<Object?, Object?>(),
);
}
}
Expand Down Expand Up @@ -448,7 +454,8 @@ class VideoPlayerAvplayApi {

Future<void> initialize() async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.VideoPlayerAvplayApi.initialize', codec,
'dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.initialize',
codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList = await channel.send(null) as List<Object?>?;
if (replyList == null) {
Expand All @@ -469,7 +476,8 @@ class VideoPlayerAvplayApi {

Future<PlayerMessage> create(CreateMessage arg_msg) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.VideoPlayerAvplayApi.create', codec,
'dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.create',
codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_msg]) as List<Object?>?;
Expand All @@ -496,7 +504,8 @@ class VideoPlayerAvplayApi {

Future<void> dispose(PlayerMessage arg_msg) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.VideoPlayerAvplayApi.dispose', codec,
'dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.dispose',
codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_msg]) as List<Object?>?;
Expand All @@ -518,7 +527,8 @@ class VideoPlayerAvplayApi {

Future<void> setLooping(LoopingMessage arg_msg) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.VideoPlayerAvplayApi.setLooping', codec,
'dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.setLooping',
codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_msg]) as List<Object?>?;
Expand All @@ -540,7 +550,8 @@ class VideoPlayerAvplayApi {

Future<void> setVolume(VolumeMessage arg_msg) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.VideoPlayerAvplayApi.setVolume', codec,
'dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.setVolume',
codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_msg]) as List<Object?>?;
Expand All @@ -562,7 +573,8 @@ class VideoPlayerAvplayApi {

Future<void> setPlaybackSpeed(PlaybackSpeedMessage arg_msg) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.VideoPlayerAvplayApi.setPlaybackSpeed', codec,
'dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.setPlaybackSpeed',
codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_msg]) as List<Object?>?;
Expand All @@ -584,7 +596,8 @@ class VideoPlayerAvplayApi {

Future<void> play(PlayerMessage arg_msg) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.VideoPlayerAvplayApi.play', codec,
'dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.play',
codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_msg]) as List<Object?>?;
Expand All @@ -606,7 +619,8 @@ class VideoPlayerAvplayApi {

Future<bool> setDeactivate(PlayerMessage arg_msg) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.VideoPlayerAvplayApi.setDeactivate', codec,
'dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.setDeactivate',
codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_msg]) as List<Object?>?;
Expand All @@ -633,7 +647,8 @@ class VideoPlayerAvplayApi {

Future<bool> setActivate(PlayerMessage arg_msg) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.VideoPlayerAvplayApi.setActivate', codec,
'dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.setActivate',
codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_msg]) as List<Object?>?;
Expand All @@ -660,7 +675,8 @@ class VideoPlayerAvplayApi {

Future<TrackMessage> track(TrackTypeMessage arg_msg) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.VideoPlayerAvplayApi.track', codec,
'dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.track',
codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_msg]) as List<Object?>?;
Expand All @@ -687,7 +703,8 @@ class VideoPlayerAvplayApi {

Future<bool> setTrackSelection(SelectedTracksMessage arg_msg) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.VideoPlayerAvplayApi.setTrackSelection', codec,
'dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.setTrackSelection',
codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_msg]) as List<Object?>?;
Expand All @@ -714,7 +731,8 @@ class VideoPlayerAvplayApi {

Future<PositionMessage> position(PlayerMessage arg_msg) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.VideoPlayerAvplayApi.position', codec,
'dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.position',
codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_msg]) as List<Object?>?;
Expand All @@ -741,7 +759,8 @@ class VideoPlayerAvplayApi {

Future<DurationMessage> duration(PlayerMessage arg_msg) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.VideoPlayerAvplayApi.duration', codec,
'dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.duration',
codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_msg]) as List<Object?>?;
Expand All @@ -768,7 +787,8 @@ class VideoPlayerAvplayApi {

Future<void> seekTo(PositionMessage arg_msg) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.VideoPlayerAvplayApi.seekTo', codec,
'dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.seekTo',
codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_msg]) as List<Object?>?;
Expand All @@ -790,7 +810,8 @@ class VideoPlayerAvplayApi {

Future<void> pause(PlayerMessage arg_msg) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.VideoPlayerAvplayApi.pause', codec,
'dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.pause',
codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_msg]) as List<Object?>?;
Expand All @@ -812,7 +833,8 @@ class VideoPlayerAvplayApi {

Future<void> setMixWithOthers(MixWithOthersMessage arg_msg) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.VideoPlayerAvplayApi.setMixWithOthers', codec,
'dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.setMixWithOthers',
codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_msg]) as List<Object?>?;
Expand All @@ -834,7 +856,8 @@ class VideoPlayerAvplayApi {

Future<void> setDisplayGeometry(GeometryMessage arg_msg) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.VideoPlayerAvplayApi.setDisplayGeometry', codec,
'dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.setDisplayGeometry',
codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_msg]) as List<Object?>?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions packages/video_player_avplay/lib/video_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
httpHeaders = const <String, String>{},
drmConfigs = null,
playerOptions = const <String, dynamic>{},
streamingProperty = null,
super(VideoPlayerValue(
duration: DurationRange(Duration.zero, Duration.zero)));

Expand All @@ -248,6 +249,7 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
this.httpHeaders = const <String, String>{},
this.drmConfigs,
this.playerOptions,
this.streamingProperty,
}) : dataSourceType = DataSourceType.network,
package = null,
super(VideoPlayerValue(
Expand All @@ -268,6 +270,7 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
httpHeaders = const <String, String>{},
drmConfigs = null,
playerOptions = const <String, dynamic>{},
streamingProperty = null,
super(VideoPlayerValue(
duration: DurationRange(Duration.zero, Duration.zero)));

Expand All @@ -288,6 +291,7 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
httpHeaders = const <String, String>{},
drmConfigs = null,
playerOptions = const <String, dynamic>{},
streamingProperty = null,
super(VideoPlayerValue(
duration: DurationRange(Duration.zero, Duration.zero)));

Expand All @@ -308,6 +312,11 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
/// Only for [VideoPlayerController.network].
final Map<String, dynamic>? 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<String, dynamic>? streamingProperty;

/// **Android only**. Will override the platform's generic file format
/// detection with whatever is set here.
final VideoFormat? formatHint;
Expand Down Expand Up @@ -377,6 +386,7 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
httpHeaders: httpHeaders,
drmConfigs: drmConfigs,
playerOptions: playerOptions,
streamingProperty: streamingProperty,
);
break;
case DataSourceType.file:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ class DataSource {
this.httpHeaders = const <String, String>{},
this.drmConfigs,
this.playerOptions,
this.streamingProperty,
});

/// The way in which the video was originally loaded.
Expand Down Expand Up @@ -214,6 +215,9 @@ class DataSource {

/// Set additional optional player settings.
Map<String, dynamic>? playerOptions;

/// Sets specific feature values for HTTP, MMS, or specific streaming engine
Map<String, dynamic>? streamingProperty;
}

/// The way in which the video was originally loaded.
Expand Down
1 change: 1 addition & 0 deletions packages/video_player_avplay/pigeons/messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class CreateMessage {
Map<Object?, Object?>? httpHeaders;
Map<Object?, Object?>? drmConfigs;
Map<Object?, Object?>? playerOptions;
Map<Object?, Object?>? streamingProperty;
}

class MixWithOthersMessage {
Expand Down
75 changes: 44 additions & 31 deletions packages/video_player_avplay/tizen/src/media_player.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand All @@ -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<std::string>(iter->second)) {
std::string cookie = std::get<std::string>(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<std::string>(iter->second)) {
std::string user_agent = std::get<std::string>(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<void *>(
reinterpret_cast<const void *>(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;
}
}
}

Expand Down
Loading

0 comments on commit 87adc3b

Please sign in to comment.