Skip to content

[video_player_videohole]How to call a callback which allow app do drm license request? #506

Closed
@hyue7

Description

@hyue7

Hi,all!
About this requirement:
flutter-tizen/flutter-tizen#217 (comment)
We now need to call a callback in app, this callback can request drm license on its own and return license back to player, and then player use the return result to get license key.
For example:
The dart callback in app will like this:

Future<Uint8List> _getLicense(Uint8List challenge) async {
    ... requesting the license (making network requests to license server etc)

    return licensePayload;
}

player(in this file) will call this callback like this:

int DrmManager::OnChallengeData(void *session_id, int msg_type, void *msg, int msg_len, void *user_data){
...
response = _getLicense(challenge_data);
...
}

This process must be synchronized.

I have tried several ways to implement it but all have some problems.
1. Use methodchannel
channel->InvokeMethod("drm.getlicense", std::move(arguments),std::move(result_handler));
I tried used this asynchronous method to call the callback, and then lock the thread and wait for the return result(return result is necessary). But this will lead to the main thread locked, the result cannot be received. Because InvokeMethod and main function are on the same thread.The main function locked, InvokeMethod cannot go on.
2. Use FFI

--dart code--
FFI_calc calcFunc = nativeApi.lookupFunction<Native_calc, FFI_calc>("GetLicense");
--C code--
FLUTTER_PLUGIN_EXPORT void GetLicense(int (*callback)());

Use FFI to call the dart function, because of the dart isolate, doing a callback from another thread is not supported. According to this.
When I use the callback in another thread(plugin thread), it will occur an error: Cannot invoke native callback outside an isolate. There is no particularly good solution for this problem.

Do you have any good way to implement this requirement? :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions