-
Notifications
You must be signed in to change notification settings - Fork 19
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
Texture api change #82
Texture api change #82
Conversation
The video plugin was also briefly tested with the following code. VideoPlayer::VideoPlayer(flutter::PluginRegistrar *pluginRegistrar,
FlutterTextureRegistrar *textureRegistrar,
const std::string &uri, VideoPlayerOptions &options) {
isInitialized_ = false;
textureRegistrar_ = textureRegistrar;
LOG_INFO("[VideoPlayer] register texture");
textureId_ = FlutterRegisterExternalTexture(textureRegistrar_,TizenTextureType::MediaPacket);
...
void VideoPlayer::onVideoFrameDecoded(media_packet_h packet, void *data) {
VideoPlayer *player = (VideoPlayer *)data;
// tbm_surface_h surface;
// int ret = media_packet_get_tbm_surface(packet, &surface);
// if (ret != MEDIA_PACKET_ERROR_NONE) {
// LOG_ERROR(
// "[VideoPlayer.onVideoFrameDecoded] media_packet_get_tbm_surface "
// "failed, error: %d",
// ret);
// media_packet_destroy(packet);
// return;
// }
FlutterMarkExternalTextureFrameAvailable(player->textureRegistrar_,
player->textureId_, packet);
// media_packet_destroy(packet);
}
|
It looks like a kind of pool is applied to the packet related API(at least |
f6ca6e3
to
aab41e9
Compare
I'm not sure if it's a good way, it can bypass using tbm internal APIs, but, it's specifically for media scenario, texture implementation is supposed to be common. |
Does this mean you think we should accept one type? Could you explain a little bit more about what you're worried about? |
|
||
static void UnmarkMediaPacketToUse(void* surface) { | ||
FT_ASSERT(surface); | ||
media_packet_destroy((media_packet_h)surface); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think media_packet_ref should be called to prevent this handle from destroy. The same thing happen for tbm surface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little confusing... you think calling media_packet_destroy
at here is problem?
Is it correct that I understand? Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, if you call media_packet_destroy directly, that media handle may be really destroyed, media player need to allocate another media handle, but if you call media_packet_ref when mark and call media_packet_destroy when unmark, that handle won't be really destroyed, media player may reuse it later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whatever External texture sources were used, it now seems only Tizen embedder is responsible for destroy them.
I think this is a good approach. Now we don't need to use ref/unref anymore.
I mean the implementation is supposed to be common, not only for media packet, on the other hand, media packet can only handle mmplayer case, there are other cases such as webview, can webview use media packet too? |
Please rebase |
I totally agree with you !
Um... There are currently 3 cases where we use external textures... 2 of 3 are getting data through media packets. I just want to add it for convenience. Webview will continue to use tbm. |
I checked media_packet and muse_player source code, it turns out that mmplayer won't reuse tbm_surface in every frame_cb(), it will create a new tbm surface for every frame(I have suggested them to reuse...), everytime frame_cb() is called, a new media_packet handler is created and a new tbm surface is attached, when media_packet_destroy is called, both media_packet and tbm surface will be destroyed. So, I suggest:
|
I strongly support your suggestion. 💪 @flutter-tizen/maintainers plz, comment on this suggestion. Especially, who use external textures api! |
Just a side note from an API design perspective:
If we're to make breaking changes in our texture APIs, that is, if we're to add a new API or change existing ones, I think this is a good time to organize the overall API set cleanly. As you may remember, we unfortunately didn't do that during the last Flutter 2.0 upgrade. We have these two sets of texture APIs in and we need to remove duplicates (such as Common
Tizen-only
Note that the names and structure of the above Tizen-only APIs are tentative and can be changed as you prefer. |
* Add interface for media_packet_h Signed-off-by: MuHong Byun <mh.byun@samsung.com>
aab41e9
to
8b98607
Compare
@swift-kim That's a good idea. I'll check it out and give my opinion. 👀 |
@flutter-tizen/maintainers @xuelian-bai @swift-kim |
I'll close this PR when @xiaowei-guan 's patch is ready. |
Continued on #86 |
To build, you need:
https://github.com/flutter-tizen/tizen_tools/pull/12
tbm sample:
flutter-tizen/plugins#89
media_packet sample:
flutter-tizen/plugins#90