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

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: Try again uploading - didn't work :( 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..6cbd2938e60e63f89f42c82aa346fa3ee38ad067 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();
+ int current_capture_colorspace =
+ Java_VideoCapture_getColorspace(env, j_capture_.obj());
+ switch (current_capture_colorspace){
+ case ANDROID_IMAGEFORMAT_YV12:
+ return media::PIXEL_FORMAT_YV12;
+ case ANDROID_IMAGEFORMAT_NV21:
+ return media::PIXEL_FORMAT_NV21;
+ case ANDROID_IMAGEFORMAT_YUY2:
+ return media::PIXEL_FORMAT_YUY2;
+ case ANDROID_IMAGEFORMAT_NV16:
+ case ANDROID_IMAGEFORMAT_JPEG:
+ case ANDROID_IMAGEFORMAT_RGB_565:
+ case ANDROID_IMAGEFORMAT_UNKNOWN:
+ // NOTE(mcasas): NV16, JPEG, RGB565 not supported in VideoFormatPixel.
Ami GONE FROM CHROMIUM 2013/09/12 17:03:16 indent is strange :)
mcasas 2013/09/16 08:43:02 Done.
+ default:
Ami GONE FROM CHROMIUM 2013/09/12 17:03:16 omitting the default case will let the compiler wa
mcasas 2013/09/16 08:43:02 Problem is: is not an enum :( but an integer; we n
+ 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