Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP][video_player_avplay]Add setData and getData interface #822

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
989 changes: 556 additions & 433 deletions packages/video_player_avplay/lib/src/messages.g.dart

Large diffs are not rendered by default.

46 changes: 46 additions & 0 deletions packages/video_player_avplay/lib/src/video_player_tizen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,38 @@ class VideoPlayerTizen extends VideoPlayerPlatform {
);
}

@override
Future<bool> setData(int playerId, Map<DashPlayerProperty, Object> data) {
return _api.setData(
DataMapMessage(
playerId: playerId,
data: <Object?, Object?>{
for (final MapEntry<DashPlayerProperty, Object> entry in data.entries)
_dashPlayerPropertyMap[entry.key]: entry.value,
},
),
);
}

@override
Future<Map<DashPlayerProperty, Object>> getData(
int playerId,
Set<DashPlayerProperty> keys,
) async {
final List<String?> keysList = <String?>[];
for (final DashPlayerProperty key in keys) {
keysList.add(_dashPlayerPropertyMap[key]);
}
final DataMapMessage msg = await _api.getData(
DataKeyMessage(playerId: playerId, data: keysList),
);

return <DashPlayerProperty, Object>{
for (final MapEntry<Object?, Object?> entry in msg.data.entries)
_dashPlayerPropertyReverseMap[entry.key]!: entry.value!,
};
}

@override
Future<void> setStreamingProperty(
int playerId,
Expand Down Expand Up @@ -383,4 +415,18 @@ class VideoPlayerTizen extends VideoPlayerPlatform {
BufferConfigType.bufferingTimeoutInSecForPlay:
'buffering_timeout_in_sec_for_play',
};

static const Map<DashPlayerProperty, String> _dashPlayerPropertyMap =
<DashPlayerProperty, String>{
DashPlayerProperty.maxBandWidth: 'max-bandwidth',
DashPlayerProperty.mpeghMetadata: 'mpegh-metadata',
DashPlayerProperty.dashStreamInfo: 'dash-stream-info',
};

static const Map<String, DashPlayerProperty> _dashPlayerPropertyReverseMap =
<String, DashPlayerProperty>{
'max-bandwidth': DashPlayerProperty.maxBandWidth,
'mpegh-metadata': DashPlayerProperty.mpeghMetadata,
'dash-stream-info': DashPlayerProperty.dashStreamInfo,
};
}
20 changes: 20 additions & 0 deletions packages/video_player_avplay/lib/video_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,26 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
return _videoPlayerPlatform.setDisplayMode(_playerId, displayMode);
}

/// Set dashplusplayer properties
Future<bool> setData(Map<DashPlayerProperty, Object> data) async {
if (_isDisposedOrNotInitialized) {
return false;
}

return _videoPlayerPlatform.setData(playerId, data);
}

/// Get dashplusplayer properties
Future<Map<DashPlayerProperty, Object>> getData(
Set<DashPlayerProperty> keys,
) async {
if (_isDisposedOrNotInitialized) {
return <DashPlayerProperty, Object>{};
}

return _videoPlayerPlatform.getData(playerId, keys);
}

/// Sets the playback speed of [this].
///
/// [speed] indicates a speed value with different platforms accepting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,19 @@ abstract class VideoPlayerPlatform extends PlatformInterface {
throw UnimplementedError('setDisplayMode() has not been implemented.');
}

/// Set dashplayer properties.
Future<bool> setData(int playerId, Map<DashPlayerProperty, Object> data) {
throw UnimplementedError('setData() has not been implemented.');
}

/// Get dashplayer properties.
Future<Map<DashPlayerProperty, Object>> getData(
int playerId,
Set<DashPlayerProperty> keys,
) {
throw UnimplementedError('getData() has not been implemented.');
}

/// Set streamingengine property.
Future<void> setStreamingProperty(
int playerId,
Expand Down Expand Up @@ -412,6 +425,18 @@ enum DisplayMode {
dstRoiAutoAspectRatio,
}

/// The different types of dash player properties that can be set on the player.
enum DashPlayerProperty {
/// Max band width of dash player, the value is int type.
maxBandWidth,

/// MPEG-H matadata of dash player, the vaule is String type.
mpeghMetadata,

/// Dash player stream info, the value is string type.
dashStreamInfo,
}

/// Event emitted from the platform implementation.
@immutable
class VideoEvent {
Expand Down
14 changes: 14 additions & 0 deletions packages/video_player_avplay/pigeons/messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,18 @@ class DisplayModeMessage {
int displayMode;
}

class DataKeyMessage {
DataKeyMessage(this.playerId, this.data);
int playerId;
List<String?> data;
}

class DataMapMessage {
DataMapMessage(this.playerId, this.data);
int playerId;
Map<Object?, Object?> data;
}

@HostApi()
abstract class VideoPlayerAvplayApi {
void initialize();
Expand All @@ -156,4 +168,6 @@ abstract class VideoPlayerAvplayApi {
void setStreamingProperty(StreamingPropertyMessage msg);
bool setDisplayRotate(RotationMessage msg);
bool setDisplayMode(DisplayModeMessage msg);
bool setData(DataMapMessage msg);
DataMapMessage getData(DataKeyMessage msg);
}
2 changes: 1 addition & 1 deletion packages/video_player_avplay/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
pigeon: ^10.0.0
pigeon: ^22.7.2
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,10 @@ PLUS_PLAYER_EXPORT bool GetVirtualRscId(PlusplayerRef player,
const plusplayer::RscType type,
int* virtual_id);

PLUS_PLAYER_EXPORT bool SetData(PlusplayerRef player, const std::string data);

PLUS_PLAYER_EXPORT bool GetData(PlusplayerRef player, std::string& data);

PLUS_PLAYER_EXPORT void RegisterListener(PlusplayerRef player,
PlusplayerListener* listener,
void* user_data);
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions packages/video_player_avplay/tizen/src/media_player.cc
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ int MediaPlayer::OnDrmUpdatePsshData(drm_init_data_type init_type, void *data,
}

bool MediaPlayer::SetDisplayRotate(int64_t rotation) {
LOG_INFO("[MediaPlayer] rotation: %d", rotation);
LOG_INFO("[MediaPlayer] rotation: %lld", rotation);
int ret = player_set_display_rotation(
player_, static_cast<player_display_rotation_e>(rotation));
if (ret != PLAYER_ERROR_NONE) {
Expand All @@ -746,7 +746,7 @@ bool MediaPlayer::SetDisplayRotate(int64_t rotation) {
return true;
}
bool MediaPlayer::SetDisplayMode(int64_t display_mode) {
LOG_INFO("[MediaPlayer] display_mode: %d", display_mode);
LOG_INFO("[MediaPlayer] display_mode: %lld", display_mode);
if (display_mode > PLAYER_DISPLAY_MODE_NUM) {
LOG_ERROR("[MediaPlayer] display mode out of range");
return false;
Expand Down
Loading
Loading