Skip to content

Commit 1bc1b8a

Browse files
theandi666Android (Google) Code Review
authored andcommitted
Merge "Make sure crop rect information is visible from java." into jb-dev
2 parents 4fe5ebc + b842599 commit 1bc1b8a

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

media/jni/android_media_Utils.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,19 @@ static jobject makeByteBufferObject(
125125
return byteBufObj;
126126
}
127127

128+
static void SetMapInt32(
129+
JNIEnv *env, jobject hashMapObj, jmethodID hashMapPutID,
130+
const char *key, int32_t value) {
131+
jstring keyObj = env->NewStringUTF(key);
132+
jobject valueObj = makeIntegerObject(env, value);
133+
134+
jobject res = env->CallObjectMethod(
135+
hashMapObj, hashMapPutID, keyObj, valueObj);
136+
137+
env->DeleteLocalRef(valueObj); valueObj = NULL;
138+
env->DeleteLocalRef(keyObj); keyObj = NULL;
139+
}
140+
128141
status_t ConvertMessageToMap(
129142
JNIEnv *env, const sp<AMessage> &msg, jobject *map) {
130143
jclass hashMapClazz = env->FindClass("java/util/HashMap");
@@ -205,6 +218,41 @@ status_t ConvertMessageToMap(
205218
break;
206219
}
207220

221+
case AMessage::kTypeRect:
222+
{
223+
int32_t left, top, right, bottom;
224+
CHECK(msg->findRect(key, &left, &top, &right, &bottom));
225+
226+
SetMapInt32(
227+
env,
228+
hashMap,
229+
hashMapPutID,
230+
StringPrintf("%s-left", key).c_str(),
231+
left);
232+
233+
SetMapInt32(
234+
env,
235+
hashMap,
236+
hashMapPutID,
237+
StringPrintf("%s-top", key).c_str(),
238+
top);
239+
240+
SetMapInt32(
241+
env,
242+
hashMap,
243+
hashMapPutID,
244+
StringPrintf("%s-right", key).c_str(),
245+
right);
246+
247+
SetMapInt32(
248+
env,
249+
hashMap,
250+
hashMapPutID,
251+
StringPrintf("%s-bottom", key).c_str(),
252+
bottom);
253+
break;
254+
}
255+
208256
default:
209257
break;
210258
}

0 commit comments

Comments
 (0)