Results 1 to 4 of 4

Thread: Render LibVLC video into QWidget on Android

  1. #1
    Join Date
    Feb 2011
    Posts
    354
    Thanks
    17
    Thanked 27 Times in 24 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows

    Default Render LibVLC video into QWidget on Android

    I have been trying to create a simple Qt-based Android application to play video files using LibVLC. It partially works: files are opened and played, I can hear the sound, but no video is displayed.

    I tried it different ways:
    Qt Code:
    1. libvlc_media_player_set_xwindow(player, widget->winId())
    To copy to clipboard, switch view to plain text mode 
    Simply does nothing.

    Qt Code:
    1. libvlc_media_player_set_hwnd(player, (void*)widget->winId())
    To copy to clipboard, switch view to plain text mode 
    Seems to work only on Windows OS.

    Qt Code:
    1. libvlc_media_player_set_android_context(player, (void*)widget->winId())
    To copy to clipboard, switch view to plain text mode 
    Crashes with the following:
    Qt Code:
    1. E art : JNI ERROR (app bug): attempt to use stale weak global reference 0x3 (should be 0x100003)
    2. F art : art/runtime/java_vm_ext.cc:410] JNI DETECTED ERROR IN APPLICATION: use of deleted weak global reference 0x3
    3. F art : art/runtime/java_vm_ext.cc:410] "AWindowHandler" prio=5 tid=16 Runnable
    4. F art : art/runtime/java_vm_ext.cc:410] | group="main" sCount=0 dsCount=0 obj=0x1326a0a0 self=0x9d7cfc00
    5. F art : art/runtime/java_vm_ext.cc:410] | sysTid=16347 nice=0 cgrp=default sched=0/0 handle=0x97cc1930
    6. F art : art/runtime/java_vm_ext.cc:410] | state=R schedstat=( 1138230 0 1 ) utm=0 stm=0 core=0 HZ=100
    7. F art : art/runtime/java_vm_ext.cc:410] | stack=0x97bc5000-0x97bc7000 stackSize=1014KB
    8. F art : art/runtime/java_vm_ext.cc:410] | held mutexes= "mutator lock"(shared held)
    9. F art : art/runtime/java_vm_ext.cc:410] native: #00 pc 00371839 /system/lib/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, int, char const*, art::ArtMethod*, void*)+160)
    10. F art : art/runtime/java_vm_ext.cc:410] native: #01 pc 00350ea7 /system/lib/libart.so (art::Thread::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const+150)
    11. F art : art/runtime/java_vm_ext.cc:410] native: #02 pc 0025a8a5 /system/lib/libart.so (art::JavaVMExt::JniAbort(char const*, char const*)+740)
    12. F art : art/runtime/java_vm_ext.cc:410] native: #03 pc 0025affb /system/lib/libart.so (art::JavaVMExt::JniAbortF(char const*, char const*, ...)+74)
    13. F art : art/runtime/java_vm_ext.cc:410] native: #04 pc 00351c69 /system/lib/libart.so (art::Thread::DecodeJObject(_jobject*) const+708)
    14. F art : art/runtime/java_vm_ext.cc:410] native: #05 pc 001013c1 /system/lib/libart.so (art::ScopedCheck::Check(art::ScopedObjectAccess&, bool, char const*, art::JniValueType*) (.constprop.95)+908)
    15. F art : art/runtime/java_vm_ext.cc:410] native: #06 pc 00108f6f /system/lib/libart.so (art::CheckJNI::GetObjectClass(_JNIEnv*, _jobject*)+386)
    16. F art : art/runtime/java_vm_ext.cc:410] native: #07 pc 001fb3c5 /data/app/org.qtproject.example.testvlc-1/lib/arm/libvlc.so (???)
    17. F art : art/runtime/java_vm_ext.cc:410] (no managed stack frames)
    18. F art : art/runtime/java_vm_ext.cc:410]
    19. F art : art/runtime/runtime.cc:370] Runtime aborting...
    20. F art : art/runtime/runtime.cc:370] Aborting thread:
    21. F art : art/runtime/runtime.cc:370] "AWindowHandler" prio=5 tid=16 Native
    22. F art : art/runtime/runtime.cc:370] | group="" sCount=0 dsCount=0 obj=0x1326a0a0 self=0x9d7cfc00
    23. F art : art/runtime/runtime.cc:370] | sysTid=16347 nice=0 cgrp=default sched=0/0 handle=0x97cc1930
    24. F art : art/runtime/runtime.cc:370] | state=R schedstat=( 23070571 3691459 17 ) utm=1 stm=1 core=3 HZ=100
    25. F art : art/runtime/runtime.cc:370] | stack=0x97bc5000-0x97bc7000 stackSize=1014KB
    26. F art : art/runtime/runtime.cc:370] | held mutexes= "abort lock"
    27. F art : art/runtime/runtime.cc:370] native: #00 pc 00371839 /system/lib/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, int, char const*, art::ArtMethod*, void*)+160)
    28. F art : art/runtime/runtime.cc:370] native: #01 pc 00350ea7 /system/lib/libart.so (art::Thread::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const+150)
    29. F art : art/runtime/runtime.cc:370] native: #02 pc 00333ad7 /system/lib/libart.so (art::AbortState::DumpThread(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, art::Thread*) const+26)
    30. F art : art/runtime/runtime.cc:370] native: #03 pc 00333d6f /system/lib/libart.so (art::Runtime::Abort()+562)
    31. F art : art/runtime/runtime.cc:370] native: #04 pc 000f471b /system/lib/libart.so (art::LogMessage::~LogMessage()+2226)
    32. F art : art/runtime/runtime.cc:370] native: #05 pc 0025abcf /system/lib/libart.so (art::JavaVMExt::JniAbort(char const*, char const*)+1550)
    33. F art : art/runtime/runtime.cc:370] native: #06 pc 0025affb /system/lib/libart.so (art::JavaVMExt::JniAbortF(char const*, char const*, ...)+74)
    34. F art : art/runtime/runtime.cc:370] native: #07 pc 00351c69 /system/lib/libart.so (art::Thread::DecodeJObject(_jobject*) const+708)
    35. F art : art/runtime/runtime.cc:370] native: #08 pc 001013c1 /system/lib/libart.so (art::ScopedCheck::Check(art::ScopedObjectAccess&, bool, char const*, art::JniValueType*) (.constprop.95)+908)
    36. F art : art/runtime/runtime.cc:370] native: #09 pc 00108f6f /system/lib/libart.so (art::CheckJNI::GetObjectClass(_JNIEnv*, _jobject*)+386)
    37. F art : art/runtime/runtime.cc:370] native: #10 pc 001fb3c5 /data/app/org.qtproject.example.testvlc-1/lib/arm/libvlc.so (???)
    38. F art : art/runtime/runtime.cc:370] (no managed stack frames)
    39. F art : art/runtime/runtime.cc:370] Dumping all threads without appropriate locks held: thread list lock mutator lock
    40. F art : art/runtime/runtime.cc:370] All threads:
    41. F art : art/runtime/runtime.cc:370] DALVIK THREADS (16):
    42. F art : art/runtime/runtime.cc:370] "AWindowHandler" prio=5 tid=16 Runnable
    43. F art : art/runtime/runtime.cc:370] | group="" sCount=0 dsCount=0 obj=0x1326a0a0 self=0x9d7cfc00
    44. F art : art/runtime/runtime.cc:370] | sysTid=16347 nice=0 cgrp=default sched=0/0 handle=0x97cc1930
    45. F art : art/runtime/runtime.cc:370] | state=R schedstat=( 46021872 5266408 44 ) utm=1 stm=3 core=3 HZ=100
    46. F art : art/runtime/runtime.cc:370] | stack=0x97bc5000-0x97bc7000 stackSize=1014KB
    47. F art : art/runtime/runtime.cc:370] | held mutexes= "abort lock" "mutator lock"(shared held)
    48. F art : art/runtime/runtime.cc:370] native: #00 pc 00371839 /system/lib/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, int, char const*, art::ArtMethod*, void*)+160)
    49. F art : art/runtime/runtime.cc:370] native: #01 pc 00350ea7 /system/lib/libart.so (art::Thread::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const+150)
    50. F art : art/runtime/runtime.cc:370] native: #02 pc 0035adab /system/lib/libart.so (art::DumpCheckpoint::Run(art::Thread*)+442)
    51. F art : art/runtime/runtime.cc:370] native: #03 pc 0035b969 /system/lib/libart.so (art::ThreadList::RunCheckpoint(art::Closure*)+212)
    52. F art : art/runtime/runtime.cc:370] native: #04 pc 0035be97 /system/lib/libart.so (art::ThreadList::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&)+142)
    53. F art : art/runtime/runtime.cc:370] native: #05 pc 00333ce5 /system/lib/libart.so (art::Runtime::Abort()+424)
    54. F art : art/runtime/runtime.cc:370] native: #06 pc 000f471b /system/lib/libart.so (art::LogMessage::~LogMessage()+2226)
    55. F art : art/runtime/runtime.cc:370] native: #07 pc 0025abcf /system/lib/libart.so (art::JavaVMExt::JniAbort(char const*, char const*)+1550)
    56. F art : art/runtime/runtime.cc:370] native: #08 pc 0025affb /system/lib/libart.so (art::JavaVMExt::JniAbortF(char const*, char const*, ...)+74)
    57. F art : art/runtime/runtime.cc:370] native: #09 pc 00351c69 /system/lib/libart.so (art::Thread::DecodeJObject(_jobject*) const+708)
    58. F art : art/runtime/runtime.cc:370] native: #10 pc 001013c1 /system/lib/libart.so (art::ScopedCheck::Check(art::ScopedObjectAccess&, bool, char const*, art::JniValueType*) (.constprop.95)+908)
    59. F art : art/runtime/runtime.cc:370] native: #11 pc 00108f6f /system/lib/libart.so (art::CheckJNI::GetObjectClass(_JNIEnv*, _jobject*)+386)
    60. F art : art/runtime/runtime.cc:370] native: #12 pc 001fb3c5 /data/app/org.qtproject.example.testvlc-1/lib/arm/libvlc.so (???)
    61. F art : art/runtime/runtime.cc:370] (no managed stack frames)
    62. F art : art/runtime/runtime.cc:370]
    63. ...
    64. F libc : Fatal signal 6 (SIGABRT), code -6 in tid 16347 (AWindowHandler)
    To copy to clipboard, switch view to plain text mode 

    I guess, that is because it expects some Java window.

    Does anybody know how to set up video output using Qt Widget?
    Magicians do not exist

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Render LibVLC video into QWidget on Android

    Quote Originally Posted by mentalmushroom View Post
    I have been trying to create a simple Qt-based Android application to play video files using LibVLC. It partially works: files are opened and played, I can hear the sound, but no video is displayed.
    Have you tried using QtMultimedia instead and letting it handle the system integration?

    Quote Originally Posted by mentalmushroom View Post
    I tried it different ways:
    Qt Code:
    1. libvlc_media_player_set_xwindow(player, widget->winId())
    To copy to clipboard, switch view to plain text mode 
    Simply does nothing.
    This is for an X Window, a window on an X11 system. Android does not run X11.

    Quote Originally Posted by mentalmushroom View Post
    Qt Code:
    1. libvlc_media_player_set_hwnd(player, (void*)widget->winId())
    To copy to clipboard, switch view to plain text mode 
    Seems to work only on Windows OS.
    Yes, as this is for a Windows window, a window on a Windows system. Android does not run Windows.

    Quote Originally Posted by mentalmushroom View Post
    Qt Code:
    1. libvlc_media_player_set_android_context(player, (void*)widget->winId())
    To copy to clipboard, switch view to plain text mode 
    "android_context" might not be a window handle.
    Have you had a look at the VLC code? As far as I know it uses Qt for its UI, so it should have code that calls this.

    Quote Originally Posted by mentalmushroom View Post
    Does anybody know how to set up video output using Qt Widget?
    QVideoWidget?

    Cheers,
    _

  3. #3
    Join Date
    Feb 2011
    Posts
    354
    Thanks
    17
    Thanked 27 Times in 24 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows

    Default Re: Render LibVLC video into QWidget on Android

    Have you tried using QtMultimedia instead and letting it handle the system integration?
    I'll consider using QtMultimedia instead of LibVLC. For this sample it would be enough. But I have a quite big project based on VLC API and in future I'm planning to create the android version. At least I'm curious how to do that with Libvlc+Qt.

    "android_context" might not be a window handle.
    Yep, you are right. After digging into libvlc-android-demo code, I realized that it's an object of AWindowNativeHandler class. Unfortunately, it is in Java and the implementation relies on Surface/SurfaceView and SurfaceHolder classes, so I don't have any idea how to do that in C++/Qt.

    Have you had a look at the VLC code? As far as I know it uses Qt for its UI, so it should have code that calls this.
    VLC source is complicated, but it seems they use Qt only for desktop GUI.

    QVideoWidget?
    How do I pass it to libvlc?
    Magicians do not exist

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Render LibVLC video into QWidget on Android

    Quote Originally Posted by mentalmushroom View Post
    I'll consider using QtMultimedia instead of LibVLC. For this sample it would be enough. But I have a quite big project based on VLC API and in future I'm planning to create the android version. At least I'm curious how to do that with Libvlc+Qt.
    I see, that's a different use case then than simply playing video files.

    Quote Originally Posted by mentalmushroom View Post
    Yep, you are right. After digging into libvlc-android-demo code, I realized that it's an object of AWindowNativeHandler class. Unfortunately, it is in Java and the implementation relies on Surface/SurfaceView and SurfaceHolder classes, so I don't have any idea how to do that in C++/Qt.
    Then you might have to provide the necessary adapters in Java.
    Probably a good idea to look at the code of the Qt Android platform module to see how it deals with native surface types.

    Quote Originally Posted by mentalmushroom View Post
    VLC source is complicated, but it seems they use Qt only for desktop GUI.
    I see, I thought they were using it across platforms.

    https://quality.kdab.com/browse/AVIBIT-703
    How do I pass it to libvlc?[/QUOTE]
    The Android backend is probably using something other than VLC.

    Cheers,
    _

Similar Threads

  1. Play RTMP in libvlc (video in QWidget)
    By braders2 in forum Qt Programming
    Replies: 15
    Last Post: 6th January 2014, 20:59
  2. How to render custom video data?
    By commerce1010 in forum Newbie
    Replies: 0
    Last Post: 15th October 2012, 15:55
  3. Replies: 1
    Last Post: 3rd March 2011, 11:41
  4. Replies: 13
    Last Post: 26th November 2010, 08:23
  5. Render QWidget within QGLWidget
    By crazymonkey in forum Newbie
    Replies: 29
    Last Post: 26th September 2010, 13:54

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.