Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Unified Diff: media/video/capture/android/video_capture_device_android.cc

Issue 23903032: Move NV21 colorspace treatment from VideoCapture java to C++ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed unused GetIntField in VCDA; protected nv21_intermediate_buffer allocation in VCC Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/video/capture/android/video_capture_device_android.cc
diff --git a/media/video/capture/android/video_capture_device_android.cc b/media/video/capture/android/video_capture_device_android.cc
index 152cfda08756a0c48ac217be9032789306f4ba35..a79612b6c66768d2427208a08b8d78e55ed76338 100644
--- a/media/video/capture/android/video_capture_device_android.cc
+++ b/media/video/capture/android/video_capture_device_android.cc
@@ -21,19 +21,6 @@ using base::android::MethodID;
using base::android::JavaRef;
using base::android::ScopedJavaLocalRef;
-namespace {
-
-int GetIntField(JNIEnv* env,
- const JavaRef<jclass>& clazz,
- const JavaRef<jobject>& instance,
- const char* field_name) {
- jfieldID field = GetFieldID(env, clazz, field_name, "I");
- jint int_value = env->GetIntField(instance.obj(), field);
- return int_value;
-}
-
-} // namespace
-
namespace media {
// static
@@ -151,7 +138,8 @@ void VideoCaptureDeviceAndroid::Allocate(
Java_VideoCapture_queryHeight(env, j_capture_.obj());
current_settings_.frame_rate =
Java_VideoCapture_queryFrameRate(env, j_capture_.obj());
- current_settings_.color = PIXEL_FORMAT_YV12;
+ current_settings_.color = GetColorspace();
+ DCHECK_NE(current_settings_.color, media::PIXEL_FORMAT_UNKNOWN);
CHECK(current_settings_.width > 0 && !(current_settings_.width % 2));
CHECK(current_settings_.height > 0 && !(current_settings_.height % 2));
@@ -256,6 +244,27 @@ void VideoCaptureDeviceAndroid::OnFrameAvailable(
env->ReleaseByteArrayElements(data, buffer, JNI_ABORT);
}
+VideoPixelFormat VideoCaptureDeviceAndroid::GetColorspace() {
+ JNIEnv* env = AttachCurrentThread();
+ jclass cls = env->FindClass("android/graphics/ImageFormat");
+
+ int current_capture_colorspace =
+ Java_VideoCapture_getColorspace(env, j_capture_.obj());
+ if (current_capture_colorspace ==
Jói 2013/09/10 16:31:18 With all the continuation indents, I think this if
mcasas 2013/09/11 09:03:28 Done.
+ env->GetStaticIntField(cls, env->GetStaticFieldID(cls, "YV12", "I")))
+ return media::PIXEL_FORMAT_YV12;
+ else if (current_capture_colorspace ==
+ env->GetStaticIntField(cls, env->GetStaticFieldID(cls, "NV21", "I")))
+ return media::PIXEL_FORMAT_NV21;
+ else if (current_capture_colorspace ==
+ env->GetStaticIntField(cls, env->GetStaticFieldID(cls, "YUY2", "I")))
+ return media::PIXEL_FORMAT_YUY2;
+ else
+ // NOTE(mcasas): Other formats include NV16, JPEG, RGB565, and are not
+ // supported see http://goo.gl/iPbdYj .
+ return media::PIXEL_FORMAT_UNKNOWN;
+}
+
void VideoCaptureDeviceAndroid::SetErrorState(const std::string& reason) {
LOG(ERROR) << "VideoCaptureDeviceAndroid::SetErrorState: " << reason;
{

Powered by Google App Engine
This is Rietveld 408576698