Loading camera/CameraMetadata.cpp +109 −1 Original line number Diff line number Diff line Loading @@ -20,8 +20,9 @@ #include <utils/Log.h> #include <utils/Errors.h> #include <camera/CameraMetadata.h> #include <binder/Parcel.h> #include <camera/CameraMetadata.h> #include <camera/VendorTagDescriptor.h> namespace android { Loading Loading @@ -277,6 +278,18 @@ status_t CameraMetadata::update(uint32_t tag, return updateImpl(tag, (const void*)string.string(), string.size() + 1); } status_t CameraMetadata::update(const camera_metadata_ro_entry &entry) { status_t res; if (mLocked) { ALOGE("%s: CameraMetadata is locked", __FUNCTION__); return INVALID_OPERATION; } if ( (res = checkType(entry.tag, entry.type)) != OK) { return res; } return updateImpl(entry.tag, (const void*)entry.data.u8, entry.count); } status_t CameraMetadata::updateImpl(uint32_t tag, const void *data, size_t data_count) { status_t res; Loading Loading @@ -681,4 +694,99 @@ void CameraMetadata::swap(CameraMetadata& other) { mBuffer = otherBuf; } status_t CameraMetadata::getTagFromName(const char *name, const VendorTagDescriptor* vTags, uint32_t *tag) { if (name == nullptr || tag == nullptr) return BAD_VALUE; size_t nameLength = strlen(name); const SortedVector<String8> *vendorSections; size_t vendorSectionCount = 0; if (vTags != NULL) { vendorSections = vTags->getAllSectionNames(); vendorSectionCount = vendorSections->size(); } // First, find the section by the longest string match const char *section = NULL; size_t sectionIndex = 0; size_t sectionLength = 0; size_t totalSectionCount = ANDROID_SECTION_COUNT + vendorSectionCount; for (size_t i = 0; i < totalSectionCount; ++i) { const char *str = (i < ANDROID_SECTION_COUNT) ? camera_metadata_section_names[i] : (*vendorSections)[i - ANDROID_SECTION_COUNT].string(); ALOGV("%s: Trying to match against section '%s'", __FUNCTION__, str); if (strstr(name, str) == name) { // name begins with the section name size_t strLength = strlen(str); ALOGV("%s: Name begins with section name", __FUNCTION__); // section name is the longest we've found so far if (section == NULL || sectionLength < strLength) { section = str; sectionIndex = i; sectionLength = strLength; ALOGV("%s: Found new best section (%s)", __FUNCTION__, section); } } } // TODO: Make above get_camera_metadata_section_from_name ? if (section == NULL) { return NAME_NOT_FOUND; } else { ALOGV("%s: Found matched section '%s' (%zu)", __FUNCTION__, section, sectionIndex); } // Get the tag name component of the name const char *nameTagName = name + sectionLength + 1; // x.y.z -> z if (sectionLength + 1 >= nameLength) { return BAD_VALUE; } // Match rest of name against the tag names in that section only uint32_t candidateTag = 0; if (sectionIndex < ANDROID_SECTION_COUNT) { // Match built-in tags (typically android.*) uint32_t tagBegin, tagEnd; // [tagBegin, tagEnd) tagBegin = camera_metadata_section_bounds[sectionIndex][0]; tagEnd = camera_metadata_section_bounds[sectionIndex][1]; for (candidateTag = tagBegin; candidateTag < tagEnd; ++candidateTag) { const char *tagName = get_camera_metadata_tag_name(candidateTag); if (strcmp(nameTagName, tagName) == 0) { ALOGV("%s: Found matched tag '%s' (%d)", __FUNCTION__, tagName, candidateTag); break; } } if (candidateTag == tagEnd) { return NAME_NOT_FOUND; } } else if (vTags != NULL) { // Match vendor tags (typically com.*) const String8 sectionName(section); const String8 tagName(nameTagName); status_t res = OK; if ((res = vTags->lookupTag(tagName, sectionName, &candidateTag)) != OK) { return NAME_NOT_FOUND; } } *tag = candidateTag; return OK; } }; // namespace android camera/VendorTagDescriptor.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -280,8 +280,8 @@ status_t VendorTagDescriptor::writeToParcel(Parcel* parcel) const { return res; } SortedVector<String8> VendorTagDescriptor::getAllSectionNames() const { return mSections; const SortedVector<String8>* VendorTagDescriptor::getAllSectionNames() const { return &mSections; } status_t VendorTagDescriptor::lookupTag(String8 name, String8 section, /*out*/uint32_t* tag) const { Loading camera/aidl/android/hardware/camera2/ICameraDeviceUser.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -121,4 +121,6 @@ interface ICameraDeviceUser void tearDown(int streamId); void prepare2(int maxCount, int streamId); void setDeferredConfiguration(int streamId, in OutputConfiguration outputConfiguration); } camera/camera2/CaptureRequest.cpp +18 −23 Original line number Diff line number Diff line Loading @@ -37,7 +37,7 @@ status_t CaptureRequest::readFromParcel(const Parcel* parcel) { mMetadata.clear(); mSurfaceList.clear(); status_t err; status_t err = OK; if ((err = mMetadata.readFromParcel(parcel)) != OK) { ALOGE("%s: Failed to read metadata from parcel", __FUNCTION__); Loading Loading @@ -65,19 +65,16 @@ status_t CaptureRequest::readFromParcel(const Parcel* parcel) { } // Surface.writeToParcel const char16_t* name = parcel->readString16Inplace(&len); ALOGV("%s: Read surface name = %s", __FUNCTION__, name != NULL ? String8(name).string() : "<null>"); sp<IBinder> binder(parcel->readStrongBinder()); ALOGV("%s: Read surface binder = %p", __FUNCTION__, binder.get()); view::Surface surfaceShim; if ((err = surfaceShim.readFromParcel(parcel)) != OK) { ALOGE("%s: Failed to read output target Surface %d from parcel: %s (%d)", __FUNCTION__, i, strerror(-err), err); return err; } sp<Surface> surface; if (binder != NULL) { sp<IGraphicBufferProducer> gbp = interface_cast<IGraphicBufferProducer>(binder); surface = new Surface(gbp); if (surfaceShim.graphicBufferProducer != NULL) { surface = new Surface(surfaceShim.graphicBufferProducer); } mSurfaceList.push_back(surface); Loading @@ -99,7 +96,7 @@ status_t CaptureRequest::writeToParcel(Parcel* parcel) const { return BAD_VALUE; } status_t err; status_t err = OK; if ((err = mMetadata.writeToParcel(parcel)) != OK) { return err; Loading @@ -111,20 +108,18 @@ status_t CaptureRequest::writeToParcel(Parcel* parcel) const { parcel->writeInt32(size); for (int32_t i = 0; i < size; ++i) { sp<Surface> surface = mSurfaceList[i]; sp<IBinder> binder; if (surface != 0) { binder = IInterface::asBinder(surface->getIGraphicBufferProducer()); } // not sure if readParcelableArray does this, hard to tell from source parcel->writeString16(String16("android.view.Surface")); // Surface.writeToParcel parcel->writeString16(String16("unknown_name")); // Surface.nativeWriteToParcel parcel->writeStrongBinder(binder); view::Surface surfaceShim; surfaceShim.name = String16("unknown_name"); surfaceShim.graphicBufferProducer = mSurfaceList[i]->getIGraphicBufferProducer(); if ((err = surfaceShim.writeToParcel(parcel)) != OK) { ALOGE("%s: Failed to write output target Surface %d to parcel: %s (%d)", __FUNCTION__, i, strerror(-err), err); return err; } } parcel->writeInt32(mIsReprocess ? 1 : 0); Loading camera/camera2/OutputConfiguration.cpp +59 −5 Original line number Diff line number Diff line Loading @@ -42,9 +42,24 @@ int OutputConfiguration::getSurfaceSetID() const { return mSurfaceSetID; } int OutputConfiguration::getSurfaceType() const { return mSurfaceType; } int OutputConfiguration::getWidth() const { return mWidth; } int OutputConfiguration::getHeight() const { return mHeight; } OutputConfiguration::OutputConfiguration() : mRotation(INVALID_ROTATION), mSurfaceSetID(INVALID_SET_ID) { mSurfaceSetID(INVALID_SET_ID), mSurfaceType(SURFACE_TYPE_UNKNOWN), mWidth(0), mHeight(0) { } OutputConfiguration::OutputConfiguration(const Parcel& parcel) : Loading @@ -70,18 +85,48 @@ status_t OutputConfiguration::readFromParcel(const Parcel* parcel) { return err; } int surfaceType = SURFACE_TYPE_UNKNOWN; if ((err = parcel->readInt32(&surfaceType)) != OK) { ALOGE("%s: Failed to read surface type from parcel", __FUNCTION__); return err; } int width = 0; if ((err = parcel->readInt32(&width)) != OK) { ALOGE("%s: Failed to read surface width from parcel", __FUNCTION__); return err; } int height = 0; if ((err = parcel->readInt32(&height)) != OK) { ALOGE("%s: Failed to read surface height from parcel", __FUNCTION__); return err; } view::Surface surfaceShim; if ((err = surfaceShim.readFromParcel(parcel)) != OK) { // Read surface failure for deferred surface configuration is expected. if (surfaceType == SURFACE_TYPE_SURFACE_VIEW || surfaceType == SURFACE_TYPE_SURFACE_TEXTURE) { ALOGV("%s: Get null surface from a deferred surface configuration (%dx%d)", __FUNCTION__, width, height); err = OK; } else { ALOGE("%s: Failed to read surface from parcel", __FUNCTION__); return err; } } mGbp = surfaceShim.graphicBufferProducer; mRotation = rotation; mSurfaceSetID = setID; mSurfaceType = surfaceType; mWidth = width; mHeight = height; ALOGV("%s: OutputConfiguration: bp = %p, name = %s, rotation = %d, setId = %d", __FUNCTION__, mGbp.get(), String8(surfaceShim.name).string(), mRotation, mSurfaceSetID); ALOGV("%s: OutputConfiguration: bp = %p, name = %s, rotation = %d, setId = %d," "surfaceType = %d", __FUNCTION__, mGbp.get(), String8(surfaceShim.name).string(), mRotation, mSurfaceSetID, mSurfaceType); return err; } Loading @@ -104,6 +149,15 @@ status_t OutputConfiguration::writeToParcel(Parcel* parcel) const { err = parcel->writeInt32(mSurfaceSetID); if (err != OK) return err; err = parcel->writeInt32(mSurfaceType); if (err != OK) return err; err = parcel->writeInt32(mWidth); if (err != OK) return err; err = parcel->writeInt32(mHeight); if (err != OK) return err; view::Surface surfaceShim; surfaceShim.name = String16("unknown_name"); // name of surface surfaceShim.graphicBufferProducer = mGbp; Loading Loading
camera/CameraMetadata.cpp +109 −1 Original line number Diff line number Diff line Loading @@ -20,8 +20,9 @@ #include <utils/Log.h> #include <utils/Errors.h> #include <camera/CameraMetadata.h> #include <binder/Parcel.h> #include <camera/CameraMetadata.h> #include <camera/VendorTagDescriptor.h> namespace android { Loading Loading @@ -277,6 +278,18 @@ status_t CameraMetadata::update(uint32_t tag, return updateImpl(tag, (const void*)string.string(), string.size() + 1); } status_t CameraMetadata::update(const camera_metadata_ro_entry &entry) { status_t res; if (mLocked) { ALOGE("%s: CameraMetadata is locked", __FUNCTION__); return INVALID_OPERATION; } if ( (res = checkType(entry.tag, entry.type)) != OK) { return res; } return updateImpl(entry.tag, (const void*)entry.data.u8, entry.count); } status_t CameraMetadata::updateImpl(uint32_t tag, const void *data, size_t data_count) { status_t res; Loading Loading @@ -681,4 +694,99 @@ void CameraMetadata::swap(CameraMetadata& other) { mBuffer = otherBuf; } status_t CameraMetadata::getTagFromName(const char *name, const VendorTagDescriptor* vTags, uint32_t *tag) { if (name == nullptr || tag == nullptr) return BAD_VALUE; size_t nameLength = strlen(name); const SortedVector<String8> *vendorSections; size_t vendorSectionCount = 0; if (vTags != NULL) { vendorSections = vTags->getAllSectionNames(); vendorSectionCount = vendorSections->size(); } // First, find the section by the longest string match const char *section = NULL; size_t sectionIndex = 0; size_t sectionLength = 0; size_t totalSectionCount = ANDROID_SECTION_COUNT + vendorSectionCount; for (size_t i = 0; i < totalSectionCount; ++i) { const char *str = (i < ANDROID_SECTION_COUNT) ? camera_metadata_section_names[i] : (*vendorSections)[i - ANDROID_SECTION_COUNT].string(); ALOGV("%s: Trying to match against section '%s'", __FUNCTION__, str); if (strstr(name, str) == name) { // name begins with the section name size_t strLength = strlen(str); ALOGV("%s: Name begins with section name", __FUNCTION__); // section name is the longest we've found so far if (section == NULL || sectionLength < strLength) { section = str; sectionIndex = i; sectionLength = strLength; ALOGV("%s: Found new best section (%s)", __FUNCTION__, section); } } } // TODO: Make above get_camera_metadata_section_from_name ? if (section == NULL) { return NAME_NOT_FOUND; } else { ALOGV("%s: Found matched section '%s' (%zu)", __FUNCTION__, section, sectionIndex); } // Get the tag name component of the name const char *nameTagName = name + sectionLength + 1; // x.y.z -> z if (sectionLength + 1 >= nameLength) { return BAD_VALUE; } // Match rest of name against the tag names in that section only uint32_t candidateTag = 0; if (sectionIndex < ANDROID_SECTION_COUNT) { // Match built-in tags (typically android.*) uint32_t tagBegin, tagEnd; // [tagBegin, tagEnd) tagBegin = camera_metadata_section_bounds[sectionIndex][0]; tagEnd = camera_metadata_section_bounds[sectionIndex][1]; for (candidateTag = tagBegin; candidateTag < tagEnd; ++candidateTag) { const char *tagName = get_camera_metadata_tag_name(candidateTag); if (strcmp(nameTagName, tagName) == 0) { ALOGV("%s: Found matched tag '%s' (%d)", __FUNCTION__, tagName, candidateTag); break; } } if (candidateTag == tagEnd) { return NAME_NOT_FOUND; } } else if (vTags != NULL) { // Match vendor tags (typically com.*) const String8 sectionName(section); const String8 tagName(nameTagName); status_t res = OK; if ((res = vTags->lookupTag(tagName, sectionName, &candidateTag)) != OK) { return NAME_NOT_FOUND; } } *tag = candidateTag; return OK; } }; // namespace android
camera/VendorTagDescriptor.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -280,8 +280,8 @@ status_t VendorTagDescriptor::writeToParcel(Parcel* parcel) const { return res; } SortedVector<String8> VendorTagDescriptor::getAllSectionNames() const { return mSections; const SortedVector<String8>* VendorTagDescriptor::getAllSectionNames() const { return &mSections; } status_t VendorTagDescriptor::lookupTag(String8 name, String8 section, /*out*/uint32_t* tag) const { Loading
camera/aidl/android/hardware/camera2/ICameraDeviceUser.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -121,4 +121,6 @@ interface ICameraDeviceUser void tearDown(int streamId); void prepare2(int maxCount, int streamId); void setDeferredConfiguration(int streamId, in OutputConfiguration outputConfiguration); }
camera/camera2/CaptureRequest.cpp +18 −23 Original line number Diff line number Diff line Loading @@ -37,7 +37,7 @@ status_t CaptureRequest::readFromParcel(const Parcel* parcel) { mMetadata.clear(); mSurfaceList.clear(); status_t err; status_t err = OK; if ((err = mMetadata.readFromParcel(parcel)) != OK) { ALOGE("%s: Failed to read metadata from parcel", __FUNCTION__); Loading Loading @@ -65,19 +65,16 @@ status_t CaptureRequest::readFromParcel(const Parcel* parcel) { } // Surface.writeToParcel const char16_t* name = parcel->readString16Inplace(&len); ALOGV("%s: Read surface name = %s", __FUNCTION__, name != NULL ? String8(name).string() : "<null>"); sp<IBinder> binder(parcel->readStrongBinder()); ALOGV("%s: Read surface binder = %p", __FUNCTION__, binder.get()); view::Surface surfaceShim; if ((err = surfaceShim.readFromParcel(parcel)) != OK) { ALOGE("%s: Failed to read output target Surface %d from parcel: %s (%d)", __FUNCTION__, i, strerror(-err), err); return err; } sp<Surface> surface; if (binder != NULL) { sp<IGraphicBufferProducer> gbp = interface_cast<IGraphicBufferProducer>(binder); surface = new Surface(gbp); if (surfaceShim.graphicBufferProducer != NULL) { surface = new Surface(surfaceShim.graphicBufferProducer); } mSurfaceList.push_back(surface); Loading @@ -99,7 +96,7 @@ status_t CaptureRequest::writeToParcel(Parcel* parcel) const { return BAD_VALUE; } status_t err; status_t err = OK; if ((err = mMetadata.writeToParcel(parcel)) != OK) { return err; Loading @@ -111,20 +108,18 @@ status_t CaptureRequest::writeToParcel(Parcel* parcel) const { parcel->writeInt32(size); for (int32_t i = 0; i < size; ++i) { sp<Surface> surface = mSurfaceList[i]; sp<IBinder> binder; if (surface != 0) { binder = IInterface::asBinder(surface->getIGraphicBufferProducer()); } // not sure if readParcelableArray does this, hard to tell from source parcel->writeString16(String16("android.view.Surface")); // Surface.writeToParcel parcel->writeString16(String16("unknown_name")); // Surface.nativeWriteToParcel parcel->writeStrongBinder(binder); view::Surface surfaceShim; surfaceShim.name = String16("unknown_name"); surfaceShim.graphicBufferProducer = mSurfaceList[i]->getIGraphicBufferProducer(); if ((err = surfaceShim.writeToParcel(parcel)) != OK) { ALOGE("%s: Failed to write output target Surface %d to parcel: %s (%d)", __FUNCTION__, i, strerror(-err), err); return err; } } parcel->writeInt32(mIsReprocess ? 1 : 0); Loading
camera/camera2/OutputConfiguration.cpp +59 −5 Original line number Diff line number Diff line Loading @@ -42,9 +42,24 @@ int OutputConfiguration::getSurfaceSetID() const { return mSurfaceSetID; } int OutputConfiguration::getSurfaceType() const { return mSurfaceType; } int OutputConfiguration::getWidth() const { return mWidth; } int OutputConfiguration::getHeight() const { return mHeight; } OutputConfiguration::OutputConfiguration() : mRotation(INVALID_ROTATION), mSurfaceSetID(INVALID_SET_ID) { mSurfaceSetID(INVALID_SET_ID), mSurfaceType(SURFACE_TYPE_UNKNOWN), mWidth(0), mHeight(0) { } OutputConfiguration::OutputConfiguration(const Parcel& parcel) : Loading @@ -70,18 +85,48 @@ status_t OutputConfiguration::readFromParcel(const Parcel* parcel) { return err; } int surfaceType = SURFACE_TYPE_UNKNOWN; if ((err = parcel->readInt32(&surfaceType)) != OK) { ALOGE("%s: Failed to read surface type from parcel", __FUNCTION__); return err; } int width = 0; if ((err = parcel->readInt32(&width)) != OK) { ALOGE("%s: Failed to read surface width from parcel", __FUNCTION__); return err; } int height = 0; if ((err = parcel->readInt32(&height)) != OK) { ALOGE("%s: Failed to read surface height from parcel", __FUNCTION__); return err; } view::Surface surfaceShim; if ((err = surfaceShim.readFromParcel(parcel)) != OK) { // Read surface failure for deferred surface configuration is expected. if (surfaceType == SURFACE_TYPE_SURFACE_VIEW || surfaceType == SURFACE_TYPE_SURFACE_TEXTURE) { ALOGV("%s: Get null surface from a deferred surface configuration (%dx%d)", __FUNCTION__, width, height); err = OK; } else { ALOGE("%s: Failed to read surface from parcel", __FUNCTION__); return err; } } mGbp = surfaceShim.graphicBufferProducer; mRotation = rotation; mSurfaceSetID = setID; mSurfaceType = surfaceType; mWidth = width; mHeight = height; ALOGV("%s: OutputConfiguration: bp = %p, name = %s, rotation = %d, setId = %d", __FUNCTION__, mGbp.get(), String8(surfaceShim.name).string(), mRotation, mSurfaceSetID); ALOGV("%s: OutputConfiguration: bp = %p, name = %s, rotation = %d, setId = %d," "surfaceType = %d", __FUNCTION__, mGbp.get(), String8(surfaceShim.name).string(), mRotation, mSurfaceSetID, mSurfaceType); return err; } Loading @@ -104,6 +149,15 @@ status_t OutputConfiguration::writeToParcel(Parcel* parcel) const { err = parcel->writeInt32(mSurfaceSetID); if (err != OK) return err; err = parcel->writeInt32(mSurfaceType); if (err != OK) return err; err = parcel->writeInt32(mWidth); if (err != OK) return err; err = parcel->writeInt32(mHeight); if (err != OK) return err; view::Surface surfaceShim; surfaceShim.name = String16("unknown_name"); // name of surface surfaceShim.graphicBufferProducer = mGbp; Loading