Dump media.camera分析

我們想查看camera 相關(guān)的一些基本配置信息,可以dump media.camera來查看:

adb shell dump media.camera > camera.txt
一. 查看相機支持的preview size和picture size

在dump結(jié)果中,搜索android.scaler.availableStreamConfigurations,出來的結(jié)果列表形式如下:

 android.scaler.availableStreamConfigurations (d000a): int32[516]
    [34 1920 1080 OUTPUT ]

其中,第1個參數(shù)為format,第2個參數(shù)為width,第3個參數(shù)為height,第4個參數(shù)為streamType(preview看OUTPUT類型)。

主要的format為:

HAL_PIXEL_FORMAT_RAW16 = 32;

HAL_PIXEL_FORMAT_BLOB = 33;

HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED = 34;

HAL_PIXEL_FORMAT_YCbCr_420_888 = 35;

HAL_PIXEL_FORMAT_RAW_OPAQUE = 36;

HAL_PIXEL_FORMAT_RAW10 = 37;

HAL_PIXEL_FORMAT_RAW12 = 38;

HAL_PIXEL_FORMAT_BLOB表示是jpeg stream,對應的size即平時所說的picture size; HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED表示preview stream,對應的size即平時所說的preview size.

例如,[34 1920 1080 OUTPUT ]表示preview size支持1920x1080. [33 1280 720 OUTPUT ]表示picture size支持1280x720.

所以availableStreamConfigurations的輸出結(jié)果中,所有format=34且streamType=OUTPUT的size即為相機支持的preview size.

同理,所有format=33且streamType=OUTPUT的size即為相機支持的picture size.

二、查看相機支持的FPS

在dump結(jié)果中,搜索android.control.aeAvailableTargetFpsRanges,出來的結(jié)果列表形式如下:

 android.control.aeAvailableTargetFpsRanges (10014): int32[8]
    [15 15 15 30 ]
    [30 30 30 30 ]

數(shù)據(jù)中每2個一組構(gòu)成一個FPSRange,其中第1個為FPSRange的下限,第2個為FPSRange的上限。

三.查看當前打開的相機及其設置

在dump結(jié)果,搜索CameraDeviceClient,出來的結(jié)果類似:

Number of camera devices: 7
Number of normal camera devices: 3
    Device 0 maps to "0"
    Device 1 maps to "1"
    Device 2 maps to "2"
Active Camera Clients:
[
(Camera ID: 0, Cost: 100, PID: 13723, Score: 0, State: 2User Id: 0, 
Client Package Name: com.jingdong.app.mall, Conflicting Client Devices: {6, })
]
Allowed user IDs: 0

要查看相機當前的設置,只需在該client的“Dumping camera metadata array”中根據(jù)對應的key搜索即可。

例如:查看相機當前設置的FPS

在dump結(jié)果中,搜索android.control.aeTargetFpsRange,出來的結(jié)果即為當前的FPSRange.

 android.control.aeTargetFpsRange (10005): int32[2]
          [15 30 ]

例如,[15 30 ]表示當前設定的FPSRange為[15 30 ].

四.查看相機當前設置的preview size和picture size

在dump結(jié)果中,搜索Stream configuration,Stream configuration的輸出類似:

 Stream[0]: Output
      Consumer name: SurfaceView - com.jingdong.app.mall/com.jd.lib.scan.lib.zxing.client.android.CaptureActivity#0
      State: 4
      Dims: 720 x 480, format 0x22, dataspace 0x0
      Max size: 0
      Combined usage: 133376, max HAL buffers: 8
      Frames produced: 69, last timestamp: 850646358680 ns
      Total buffers: 9, currently dequeued: 5
      DequeueBuffer latency histogram: (74) samples
        5     10     15     20     25     30     35     40     45    inf (max ms)
     100.00   0.00   0.00   0.00   0.00   0.00   0.00   0.00   0.00   0.00 (%)

    Stream[1]: Output
      Consumer name: Camera2-JpegConsumer
      State: 4
      Dims: 720 x 480, format 0x21, dataspace 0x8c20000
      Max size: 778507
      Combined usage: 131075, max HAL buffers: 8
      Frames produced: 0, last timestamp: 0 ns
      Total buffers: 9, currently dequeued: 0

    Stream[2]: Output
      Consumer name: Camera2-CallbackConsumer
      State: 4
      Dims: 720 x 480, format 0x23, dataspace 0x8c20000
      Max size: 0
      Combined usage: 131075, max HAL buffers: 8
      Frames produced: 66, last timestamp: 850613073471 ns
      Total buffers: 14, currently dequeued: 6
      DequeueBuffer latency histogram: (72) samples

其中stream 0的format為0x22=34,這個即為preview stream,其size為720 x 480.
其中stream 1的format為0x21=33,這個即為jpeg stream,其size為720 x 480.

附錄:

------- CameraService.cpp

status_t CameraService::dump(int fd, const Vector<String16>& args) {
    ATRACE_CALL();

    if (checkCallingPermission(String16("android.permission.DUMP")) == false) {
        dprintf(fd, "Permission Denial: can't dump CameraService from pid=%d, uid=%d\n",
                getCallingPid(),
                getCallingUid());
        return NO_ERROR;
    }
    bool locked = tryLock(mServiceLock);
    // failed to lock - CameraService is probably deadlocked
    if (!locked) {
        dprintf(fd, "!! CameraService may be deadlocked !!\n");
    }

    if (!mInitialized) {
        dprintf(fd, "!! No camera HAL available !!\n");

        // Dump event log for error information
        dumpEventLog(fd);

        if (locked) mServiceLock.unlock();
        return NO_ERROR;
    }
    dprintf(fd, "\n== Service global info: ==\n\n");
    dprintf(fd, "Number of camera devices: %d\n", mNumberOfCameras);
    dprintf(fd, "Number of normal camera devices: %zu\n", mNormalDeviceIds.size());
    for (size_t i = 0; i < mNormalDeviceIds.size(); i++) {
        dprintf(fd, "    Device %zu maps to \"%s\"\n", i, mNormalDeviceIds[i].c_str());
    }
    String8 activeClientString = mActiveClientManager.toString();
    dprintf(fd, "Active Camera Clients:\n%s", activeClientString.string());
    dprintf(fd, "Allowed user IDs: %s\n", toString(mAllowedUsers).string());

    dumpEventLog(fd);

    bool stateLocked = tryLock(mCameraStatesLock);
    if (!stateLocked) {
        dprintf(fd, "CameraStates in use, may be deadlocked\n");
    }

    int argSize = args.size();
    for (int i = 0; i < argSize; i++) {
        if (args[i] == TagMonitor::kMonitorOption) {
            if (i + 1 < argSize) {
                mMonitorTags = String8(args[i + 1]);
            }
            break;
        }
    }

    for (auto& state : mCameraStates) {
        String8 cameraId = state.first;

        dprintf(fd, "== Camera device %s dynamic info: ==\n", cameraId.string());

        CameraParameters p = state.second->getShimParams();
        if (!p.isEmpty()) {
            dprintf(fd, "  Camera1 API shim is using parameters:\n        ");
            p.dump(fd, args);
        }

        auto clientDescriptor = mActiveClientManager.get(cameraId);
        if (clientDescriptor != nullptr) {
            dprintf(fd, "  Device %s is open. Client instance dump:\n",
                    cameraId.string());
            dprintf(fd, "    Client priority score: %d state: %d\n",
                    clientDescriptor->getPriority().getScore(),
                    clientDescriptor->getPriority().getState());
            dprintf(fd, "    Client PID: %d\n", clientDescriptor->getOwnerId());

            auto client = clientDescriptor->getValue();
            dprintf(fd, "    Client package: %s\n",
                    String8(client->getPackageName()).string());

            client->dumpClient(fd, args);
        } else {
            dprintf(fd, "  Device %s is closed, no client instance\n",
                    cameraId.string());
        }

    }

*本人從事Android Camera相關(guān)開發(fā)已有5年,
*目前在深圳上班,
*小伙伴記得點我頭像,看【個人介紹】進行關(guān)注哦,希望和更多的小伙伴一起交流 ~
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容