Skip to content
Merged
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
47 changes: 47 additions & 0 deletions libs/ohos/media_kit_libs_ohos/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.build/
.buildlog/
.history
.svn/
.swiftpm/
migrate_working_dir/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.pub-cache/
.pub/
/build/

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

/node_modules
/oh_modules
/.preview
/build
/.cxx
/.test
30 changes: 30 additions & 0 deletions libs/ohos/media_kit_libs_ohos/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: "aed8f5e4a84a99c5832fedb8ea11bf030644c8cb"
channel: "[user-branch]"

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: aed8f5e4a84a99c5832fedb8ea11bf030644c8cb
base_revision: aed8f5e4a84a99c5832fedb8ea11bf030644c8cb
- platform: ohos
create_revision: aed8f5e4a84a99c5832fedb8ea11bf030644c8cb
base_revision: aed8f5e4a84a99c5832fedb8ea11bf030644c8cb

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
3 changes: 3 additions & 0 deletions libs/ohos/media_kit_libs_ohos/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 1.0.0

- Initial release
11 changes: 11 additions & 0 deletions libs/ohos/media_kit_libs_ohos/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# [package:media_kit_libs_ohos](https://github.com/media-kit/media-kit)

[![](https://img.shields.io/discord/1079685977523617792?color=33cd57&label=Discord&logo=discord&logoColor=discord)](https://discord.gg/h7qf2R9n57) [![Github Actions](https://github.com/media-kit/media-kit/actions/workflows/ci.yml/badge.svg)](https://github.com/media-kit/media-kit/actions/workflows/ci.yml)

GNU/Linux dependency package for [`package:media_kit`](https://github.com/media-kit/media-kit). Necessary for initialization.

## License

Copyright © 2021 & onwards, Hitesh Kumar Saini <<saini123hitesh@gmail.com>>

This project & the work under this repository is governed by MIT license that can be found in the [LICENSE](./LICENSE) file.
28 changes: 28 additions & 0 deletions libs/ohos/media_kit_libs_ohos/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml

linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at https://dart.dev/lints.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
10 changes: 10 additions & 0 deletions libs/ohos/media_kit_libs_ohos/example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## Installation

Add in your `pubspec.yaml`:

```yaml
dependencies:
media_kit_libs_ohos: ^1.0.0
```
This will automatically invoke the necessary initialization code.
10 changes: 10 additions & 0 deletions libs/ohos/media_kit_libs_ohos/ohos/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/node_modules
/oh_modules
/local.properties
/.preview
/.idea
/build
/.cxx
/.test
**/BuildProfile.ets
**/oh-package-lock.json5
14 changes: 14 additions & 0 deletions libs/ohos/media_kit_libs_ohos/ohos/build-profile.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"apiType": "stageMode",
"buildOption": {
"externalNativeOptions": {
"path": "./src/main/cpp/CMakeLists.txt",
"abiFilters": ["arm64-v8a"],
}
},
"targets": [
{
"name": "default"
}
]
}
6 changes: 6 additions & 0 deletions libs/ohos/media_kit_libs_ohos/ohos/hvigorfile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { harTasks } from '@ohos/hvigor-ohos-plugin';

export default {
system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
}
2 changes: 2 additions & 0 deletions libs/ohos/media_kit_libs_ohos/ohos/index.ets
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import MediaKitLibsOhosPlugin from "./src/main/ets/MediaKitLibsOhosPlugin";
export default MediaKitLibsOhosPlugin;
8 changes: 8 additions & 0 deletions libs/ohos/media_kit_libs_ohos/ohos/oh-package.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "media_kit_libs_ohos",
"version": "1.0.0",
"description": "Please describe the basic information.",
"author": "",
"license": "Apache-2.0",
"dependencies": {}
}
88 changes: 88 additions & 0 deletions libs/ohos/media_kit_libs_ohos/ohos/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
cmake_minimum_required(VERSION 3.15)

# ------------------------------------------------------------------------------
function(download_and_verify url sha locationForArchive)
# Check if the archive exists.
if(EXISTS "${locationForArchive}")
file(SHA256 "${locationForArchive}" ARCHIVE_SHA)

# If SHA256 doesn't match, delete the archive to download again.
if(NOT sha STREQUAL ARCHIVE_SHA)
file(REMOVE "${locationForArchive}")
message(STATUS "MD5 mismatch. File deleted.")
endif()
endif()

# Download the archive if it doesn't exist.
if(NOT EXISTS "${locationForArchive}")
message(STATUS "Downloading archive from ${url}...")
file(DOWNLOAD "${url}" "${locationForArchive}")
message(STATUS "Downloaded archive to ${locationForArchive}.")

# Verify SHA256 of the newly downloaded file.
file(SHA256 "${locationForArchive}" ARCHIVE_SHA)

if(sha STREQUAL ARCHIVE_SHA)
message(STATUS "${locationForArchive} Verification successful.")
else()
message(FATAL_ERROR "${locationForArchive} Integrity check failed, please try to re-build project again.")
endif()
endif()
endfunction()

function(check_directory_exists_and_not_empty dir result_var)
# Check if the directory exists
if(EXISTS "${dir}")
# Check if the directory is not empty
file(GLOB dir_contents "${dir}/*")

if(dir_contents)
set(${result_var} TRUE PARENT_SCOPE)
else()
set(${result_var} FALSE PARENT_SCOPE)
message(STATUS "Directory ${dir} exists but is empty!")
endif()
else()
set(${result_var} FALSE PARENT_SCOPE)
message(STATUS "Directory ${dir} does not exist!")
endif()
endfunction()

# libmpv archive containing the pre-built shared libraries.
set(LIBMPV "libmpv_aarch64.zip")

# Download URL & SHA256 hash of the libmpv archive.
set(LIBMPV_URL "https://github.com/ErBWs/libmpv-ohos-build/releases/download/20251110/${LIBMPV}")
set(LIBMPV_SHA "5e9c41ef80996c6691f4d860c24278c43933511559d71683f24488a2b5bd6d7d")

# Download location of the libmpv archive.
set(LIBMPV_ARCHIVE "${CMAKE_CURRENT_SOURCE_DIR}/${LIBMPV}")
set(LIBMPV_SRC "${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/arm64-v8a/")

download_and_verify(
${LIBMPV_URL}
${LIBMPV_SHA}
${LIBMPV_ARCHIVE}
)

check_directory_exists_and_not_empty(${LIBMPV_SRC} LIBMPV_SRC_VALID)

# Extract the libmpv archive.
if(NOT LIBMPV_SRC_VALID)
message(STATUS "Extracting ${LIBMPV}...")
make_directory("${LIBMPV_SRC}")
add_custom_target("LIBMPV_EXTRACT" ALL)
add_custom_command(
TARGET "LIBMPV_EXTRACT"
COMMAND "${CMAKE_COMMAND}" -E tar -xf "${LIBMPV_ARCHIVE}"
WORKING_DIRECTORY "${LIBMPV_SRC}"
)
endif()
# ------------------------------------------------------------------------------

project(mediakit_libs_ohos)

set(LIBS
${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/arm64-v8a/libmpv.so.2)

link_libraries(DART_SHARED_LIB ${LIBS})
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {
FlutterPlugin,
FlutterPluginBinding,
} from "@ohos/flutter_ohos";

export default class MediaKitLibsOhosPlugin implements FlutterPlugin {
getUniqueClassName(): string {
return "MediaKitLibsOhosPlugin"
}

onAttachedToEngine(binding: FlutterPluginBinding): void {
}

onDetachedFromEngine(binding: FlutterPluginBinding): void {
}
}
13 changes: 13 additions & 0 deletions libs/ohos/media_kit_libs_ohos/ohos/src/main/module.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"module": {
"name": "media_kit_libs_ohos",
"type": "har",
"deviceTypes": [
"phone",
"tablet",
"2in1",
"car",
"tv"
]
}
}
24 changes: 24 additions & 0 deletions libs/ohos/media_kit_libs_ohos/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: media_kit_libs_ohos
description: HarmonyOS dependency package for package:media_kit. Necessary for initialization.
version: 1.0.0
homepage: https://github.com/media-kit/media-kit.git
repository: https://github.com/media-kit/media-kit.git

environment:
sdk: ">=2.17.0 <4.0.0"
flutter: ">=3.0.0"

dependencies:
flutter:
sdk: flutter

dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^5.0.0

flutter:
plugin:
platforms:
ohos:
pluginClass: MediaKitLibsOhosPlugin
10 changes: 6 additions & 4 deletions libs/universal/media_kit_libs_video/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ environment:
flutter: ">=3.7.0"

dependencies:
media_kit_libs_android_video:
media_kit_libs_android_video:
path: ../../android/media_kit_libs_android_video
media_kit_libs_ios_video:
path: ../../ios/media_kit_libs_ios_video
media_kit_libs_macos_video:
media_kit_libs_macos_video:
path: ../../macos/media_kit_libs_macos_video
media_kit_libs_windows_video:
media_kit_libs_windows_video:
path: ../../windows/media_kit_libs_windows_video
media_kit_libs_linux:
media_kit_libs_linux:
path: ../../linux/media_kit_libs_linux
media_kit_libs_ohos:
path: ../../ohos/media_kit_libs_ohos
2 changes: 2 additions & 0 deletions libs/universal/media_kit_libs_video/pubspec_overrides.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ dependency_overrides:
path: ../../macos/media_kit_libs_macos_video
media_kit_libs_windows_video:
path: ../../windows/media_kit_libs_windows_video
media_kit_libs_ohos:
path: ../../ohos/media_kit_libs_ohos
2 changes: 2 additions & 0 deletions media_kit/lib/src/media_kit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ abstract class MediaKit {
nativeEnsureInitialized(libmpv: libmpv);
} else if (UniversalPlatform.isAndroid) {
nativeEnsureInitialized(libmpv: libmpv);
} else if (UniversalPlatform.operatingSystem == 'ohos') {
nativeEnsureInitialized(libmpv: libmpv);
} else if (UniversalPlatform.isWeb) {
webEnsureInitialized(libmpv: libmpv);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final bool isExecmemRestricted = _checkIfExecmemRestricted();
/// Checks if creating new anonymous executable memory mappings is blocked by the system.
/// Only applies to Linux-based systems, since Dart doesn't use them for [NativeCallback]s on Fuchsia and Apple systems.
bool _checkIfExecmemRestricted() {
if (Platform.isLinux || Platform.isAndroid) {
if (Platform.isLinux || Platform.isAndroid || Platform.operatingSystem == 'ohos') {
try {
final libs = DynamicLibrary.process();
final mmap = libs.lookupFunction<MmapFunctionNative, MmapFunctionDart>(
Expand Down
5 changes: 5 additions & 0 deletions media_kit/lib/src/player/native/core/native_library.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ abstract class NativeLibrary {
'android': [
'libmpv.so',
],
'ohos': [
'libmpv.so.2',
],
}[Platform.operatingSystem];
if (names != null) {
// Try to load the dynamic library from the system using [DynamicLibrary.open].
Expand All @@ -88,6 +91,8 @@ abstract class NativeLibrary {
'Cannot find Mpv.framework/Mpv. Please ensure it\'s presence in the Frameworks folder of the application.',
'android':
'Cannot find libmpv.so. Please ensure it\'s presence in the APK.',
'ohos':
'Cannot find libmpv.so.2. Please ensure it\'s presence in the HAP.',
}[Platform.operatingSystem]!,
);
}
Expand Down
Loading
Loading