[Camera][gonk-kk] Porting GonkCameraHwMgr

RESOLVED DUPLICATE of bug 959505

Status

Firefox OS
General
RESOLVED DUPLICATE of bug 959505
4 years ago
4 years ago

People

(Reporter: seinlin, Assigned: schiu)

Tracking

unspecified
1.4 S2 (28feb)
x86_64
Gonk (Firefox OS)
Dependency tree / graph

Firefox Tracking Flags

(blocking-b2g:1.4+)

Details

(Whiteboard: [CR 608289])

Attachments

(2 attachments)

(Reporter)

Description

4 years ago
GonkCameraHwMgr is compiled failed in gonk-kk.
(Reporter)

Updated

4 years ago
Blocks: 943278

Updated

4 years ago
Assignee: nobody → vliu
(Assignee)

Updated

4 years ago
Depends on: 959505
(Assignee)

Comment 1

4 years ago
Created attachment 8359655 [details] [diff] [review]
GonkCameraHwMgr.diff
Attachment #8359655 - Flags: review?(sotaro.ikeda.g)
Attachment #8359655 - Flags: review?(pchang)
(Assignee)

Updated

4 years ago
Assignee: vliu → schiu
(Assignee)

Comment 2

4 years ago
Due to the interface change of Camera(frameworks/av/include/camera/Camera.h) in KitKat, I seperate the preview target setting function accroding to API version.

Comment 3

4 years ago
I am trying this change but getting the header file not found issue.

In file included from /test/moz/B2G/gecko/dom/camera/GonkCameraHwMgr.h:29:0,
                 from /test/moz/B2G/gecko/dom/camera/GonkRecorder.h:21,
                 from /test/moz/B2G/gecko/dom/camera/GonkCameraControl.h:28,
                 from /test/moz/B2G/gecko/dom/camera/GonkCameraHwMgr.cpp:22:
../../dist/include/GonkNativeWindow.h:17:33: fatal error: GonkNativeWindowJB.h: No such file or directory
compilation terminated.

Comment 4

4 years ago
Created attachment 8359683 [details] [diff] [review]
moz_build.diff

small change in moz.build in natvie window folder to include the header files.
(Assignee)

Comment 5

4 years ago
(In reply to vijayanand.hongal from comment #3)
> I am trying this change but getting the header file not found issue.
> 
> In file included from /test/moz/B2G/gecko/dom/camera/GonkCameraHwMgr.h:29:0,
>                  from /test/moz/B2G/gecko/dom/camera/GonkRecorder.h:21,
>                  from /test/moz/B2G/gecko/dom/camera/GonkCameraControl.h:28,
>                  from /test/moz/B2G/gecko/dom/camera/GonkCameraHwMgr.cpp:22:
> ../../dist/include/GonkNativeWindow.h:17:33: fatal error:
> GonkNativeWindowJB.h: No such file or directory
> compilation terminated.

Please apply the patch of #959505 first, the patch fixed all compilation error above.

Comment 6

4 years ago
Applying the patch from #959505, the build was clean and was able to flash the built image on nexus-4.
Comment on attachment 8359655 [details] [diff] [review]
GonkCameraHwMgr.diff

Review of attachment 8359655 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good.
Attachment #8359655 - Flags: review?(sotaro.ikeda.g) → review+

Updated

4 years ago
Attachment #8359655 - Flags: review?(pchang) → review+

Comment 8

4 years ago
should the MOZ_B2G_CAMERA=1 inclusion in /b2g/gecko/configure.in for Android version 19, be added as patch for this bug ?

Without this change, the camera did not work, when i tested the image by flashing on nexus-4.

---------------------------------
--- a/configure.in
+++ b/configure.in
@@ -248,7 +248,7 @@ if test -n "$gonkdir" ; then
         ;;
     19)
         GONK_INCLUDES="-I$gonkdir/frameworks/native/include -I$gonkdir/frameworks/av/include -I$gonkdir/frameworks/av/include/media -I$gonkdir/frameworks/av/include/camera -I$gonkdir/frameworks/native/include/media/openmax -I$gonkdir/frameworks/av/media/libstagefright/include"
-
+        MOZ_B2G_CAMERA=1
         ;;
     *)
         AC_MSG_ERROR([Unsupported platform version: $ANDROID_VERSION])
---------------------------------

Comment 9

4 years ago
I had some conclusions for porting camera on kit-kat. 

For Nexus-4:
With the patches on Bug 595505 and Comment on attachment 8359655 [details] [diff] [review], plus the modifications in below.

diff --git a/configure.in b/configure.in
index 2fa5df0..58612a8 100644
--- a/configure.in
+++ b/configure.in
@@ -249,8 +249,11 @@ if test -n "$gonkdir" ; then
         AC_SUBST(MOZ_OMX_ENCODER)
         ;;
     19)
-        GONK_INCLUDES="-I$gonkdir/frameworks/native/include"
+        GONK_INCLUDES="-I$gonkdir/frameworks/native/include -I$gonkdir/frameworks/av/include -I$gonkdir/frameworks/av/include/media -I$gonkdir/frameworks/av/include/camera -I$gonkdir/framew
         MOZ_NFC=1
+        MOZ_OMX_DECODER=1
+        MOZ_OMX_ENCODER=1
+        MOZ_B2G_CAMERA=1
 
diff --git a/widget/gonk/nativewindow/FakeSurfaceComposer.cpp b/widget/gonk/nativewindow/FakeSurfaceComposer.cpp
index fddd6b9..82297ae 100644
--- a/widget/gonk/nativewindow/FakeSurfaceComposer.cpp
+++ b/widget/gonk/nativewindow/FakeSurfaceComposer.cpp
@@ -59,6 +59,12 @@ sp<IBinder> FakeSurfaceComposer::createDisplay(const String8& displayName,
     return nullptr;
 }

+#if ANDROID_VERSION >= 19
+void FakeSurfaceComposer::destroyDisplay(const sp<IBinder>& display)
+{
+}
+#endif
+
 sp<IBinder> FakeSurfaceComposer::getBuiltInDisplay(int32_t id) {
     return nullptr;
 }
@@ -91,6 +97,15 @@ status_t FakeSurfaceComposer::captureScreen(const sp<IBinder>& display,
     return INVALID_OPERATION;
 }

+#if ANDROID_VERSION >= 19
+status_t FakeSurfaceComposer::captureScreen(const sp<IBinder>& display,
+    const sp<IGraphicBufferProducer>& producer,
+    uint32_t reqWidth, uint32_t reqHeight,
+    uint32_t minLayerZ, uint32_t maxLayerZ) {
+    return INVALID_OPERATION;
+}
+#endif
+
 void FakeSurfaceComposer::blank(const sp<IBinder>& display) {
 }

Based on the above, camera can preview and take picture. But for video recording, we also need the patch of bug  910498 for working on video recording. 

For Nexus-5:
The all patches needed by Nexus-4 are also need by Nexus5. Besides these, there is also a patch needed below.

diff --git a/widget/gonk/nativewindow/GonkBufferQueue.cpp b/widget/gonk/nativewindow/GonkBufferQueue.cpp
index 865cb66..8473683 100755
--- a/widget/gonk/nativewindow/GonkBufferQueue.cpp
+++ b/widget/gonk/nativewindow/GonkBufferQueue.cpp
@@ -232,6 +232,9 @@ int GonkBufferQueue::query(int what, int* outValue)
     case NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND:
         value = (mQueue.size() >= 2);
         break;
+    case NATIVE_WINDOW_CONSUMER_USAGE_BITS:
+        value = mConsumerUsageBits;
+        break;
     default:
         return BAD_VALUE;
     }
@@ -264,8 +267,13 @@ status_t GonkBufferQueue::requestBuffer(int slot, sp<GraphicBuffer>* buf) {
     return NO_ERROR;
 }

After that, Camera on Nexus-5 can preview and take picture. But even so, there is still has problem on video recording. The thing is when playing the recorded file, the video got splashing. From log tracking, I found the parameter eColorFormat is different from Nexus-4

     Nexus-4 : eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar
     Nexus-5 : eColorFormat = OMX_QCOM_COLOR_FormatYUV420PackedSemiPlanar32m

I tried to find the whole environment and couldn't find anywhere to set this. @mvines, can you help me to figure it out? Thanks
Flags: needinfo?(mvines)

Comment 10

4 years ago
If you take the latest code, the destroyDisplay method is already added. 
Its only that method should be added under ANDROID_VERSION 19 #if block.

+#if ANDROID_VERSION >= 19
+void FakeSurfaceComposer::destroyDisplay(const sp<IBinder>& display)
{
}
+#endif

              Or

Since the method signature has virtual, the dummy/empty definitions in cpp file can be removed.


Even for the captureScreen virtual method, since the return statement has INVALID_OPERATION, the code could be as below:

+#if ANDROID_VERSION >= 19
status_t FakeSurfaceComposer::captureScreen(const sp<IBinder>& display,
        const sp<IGraphicBufferProducer>& producer,
        uint32_t reqWidth, uint32_t reqHeight,
        uint32_t minLayerZ, uint32_t maxLayerZ,
        bool isCpuConsumer) {
    return INVALID_OPERATION;
}
+#endif

Comment 11

4 years ago
Also the usage of flags :

+        MOZ_OMX_DECODER=1


I have not included in my changes and was still able to capture the photos and preview them.

For the video capture, still the patch from bug 910498 needs to used.

The changes in configure.in to enable decoder and camera are being updated as per the bug 959505.

Comment 12

4 years ago
(In reply to vijayanand.hongal from comment #11)
> Also the usage of flags :
> 
> +        MOZ_OMX_DECODER=1
> 
> 
> I have not included in my changes and was still able to capture the photos
> and preview them.
> 
> For the video capture, still the patch from bug 910498 needs to used.
> 
> The changes in configure.in to enable decoder and camera are being updated
> as per the bug 959505.

Thanks for the clarification. Actually I didn't too much detail to check every MOZ_OMX_XXX in configure.in. I just move the settings in 17|18) and lets the build pass.

Updated

4 years ago
Flags: needinfo?(mvines)
blocking-b2g: --- → 1.4+

Updated

4 years ago
Whiteboard: [CR 608289]
Blocks: 976427

Updated

4 years ago
Target Milestone: --- → 1.4 S2 (28feb)
Do we need a review on the build config change to move forward and land that?
Flags: needinfo?(vliu)

Comment 14

4 years ago
I think the patch in bug 959505 includes all build config for porting kk. We don't need to review any modification in this bug. 

Actually I had ever reviewed the build config part. It is fine to me. These build configurations also works for Nexus-4 and Nexus-5 separately.
Flags: needinfo?(vliu)
(Assignee)

Comment 15

4 years ago
The bug now can be covered with bug#959505. Hence change the status to duplicated.
Status: NEW → RESOLVED
Last Resolved: 4 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 959505
You need to log in before you can comment on or make changes to this bug.