Skip to content

Commit

Permalink
[recorder] Support kMetadataBufferTypeNativeHandleSource for older HA…
Browse files Browse the repository at this point in the history
…Ls. JB#39862
  • Loading branch information
Andrew Branson committed Jan 31, 2018
1 parent 0140497 commit 01bc7f9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
20 changes: 14 additions & 6 deletions droidmediacamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,13 +400,21 @@ bool droid_media_camera_store_meta_data_in_buffers(DroidMediaCamera *camera, boo
#if ANDROID_MAJOR < 7
return camera->m_camera->storeMetaDataInBuffers(enabled) == android::NO_ERROR;
#else
if (android::OK == camera->m_camera->setVideoBufferMode(
android::hardware::ICamera::VIDEO_BUFFER_MODE_BUFFER_QUEUE)) {
ALOGI("Recording in buffer queue mode");
return true;
} else {
return false;
if (enabled) {
if (android::OK == camera->m_camera->setVideoBufferMode(
android::hardware::ICamera::VIDEO_BUFFER_MODE_BUFFER_QUEUE)) {
ALOGI("Recording in buffer queue mode");
return true;
} else if (android::OK == camera->m_camera->setVideoBufferMode(
android::hardware::ICamera::VIDEO_BUFFER_MODE_DATA_CALLBACK_METADATA)) {
ALOGI("Recording in callback metadata mode");
return true;
}
}
camera->m_camera->setVideoBufferMode(
android::hardware::ICamera::VIDEO_BUFFER_MODE_DATA_CALLBACK_YUV);
ALOGI("Recording in callback yuv mode");
return !enabled; // false if metadata mode was requested.
#endif
}

Expand Down
6 changes: 4 additions & 2 deletions droidmediacodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ class DroidMediaCodecBuilder {

#if ANDROID_MAJOR >= 7
if (m_enc->meta_data) {
format->setInt32("android._input-metadata-buffer-type", android::kMetadataBufferTypeANWBuffer);
format->setInt32("android._input-metadata-buffer-type", m_enc->meta_data);
format->setInt32("android._store-metadata-in-buffers-output", false);
}
format->setInt32("android._using-recorder", 1);
Expand All @@ -416,7 +416,9 @@ class DroidMediaCodecBuilder {
android::sp<android::AMessage> format = new android::AMessage();
format->setString("mime", mime);
ALOGW("Creating audio encoder for %s", mime);
format->setInt32("aac-profile", OMX_AUDIO_AACObjectLC);
if (!strcmp (mime, android::MEDIA_MIMETYPE_AUDIO_AAC)) {
format->setInt32("aac-profile", OMX_AUDIO_AACObjectLC);
}

int32_t maxinput, channels, samplerate, bitrate;
if (md->findInt32(android::kKeyMaxInputSize, &maxinput)) {
Expand Down
2 changes: 1 addition & 1 deletion droidmediacodec.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ typedef struct {

int32_t color_format;
int32_t bitrate;
bool meta_data;
int32_t meta_data;
int32_t stride;
int32_t slice_height;
int32_t max_input_size;
Expand Down

0 comments on commit 01bc7f9

Please sign in to comment.