Commit d25c94cb authored by mcasas@chromium.org's avatar mcasas@chromium.org

Add GetDeviceSupportedFormats to Android VideoCapture.java.

The |formats| Java Array is sent to native where is pushed into
the C++ |formats| array. This is easier than to pass data types
to and from Java.

VideoCapture.CaptureCapability modified to match C++ equivalent
VideoCaptureFormat [1]. Added mPixelFormat to it. Internal logic
adapted to keep capture format in that class too. Some internal
allocate() logic is passed from iterator to Java foreach loop.



[1] https://code.google.com/p/chromium/codesearch#chromium/src/media/video/capture/video_capture_types.h&sq=package:chromium&l=37&type=cs

BUG=309554

Review URL: https://codereview.chromium.org/135213005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@251857 0039d316-1c4b-4281-b951-d872f2087c98
parent d36368e1
......@@ -56,8 +56,43 @@ void VideoCaptureDevice::GetDeviceNames(Names* device_names) {
// static
void VideoCaptureDevice::GetDeviceSupportedFormats(const Name& device,
VideoCaptureFormats* formats) {
NOTIMPLEMENTED();
VideoCaptureFormats* capture_formats) {
int id;
if (!base::StringToInt(device.id(), &id))
return;
JNIEnv* env = AttachCurrentThread();
base::android::ScopedJavaLocalRef<jobjectArray> collected_formats =
Java_VideoCapture_getDeviceSupportedFormats(env, id);
if (collected_formats.is_null())
return;
jsize num_formats = env->GetArrayLength(collected_formats.obj());
for (int i = 0; i < num_formats; ++i) {
base::android::ScopedJavaLocalRef<jobject> format(
env, env->GetObjectArrayElement(collected_formats.obj(), i));
VideoPixelFormat pixel_format = media::PIXEL_FORMAT_UNKNOWN;
switch (media::Java_CaptureFormat_getPixelFormat(env, format.obj())) {
case VideoCaptureDeviceAndroid::ANDROID_IMAGEFORMAT_YV12:
pixel_format = media::PIXEL_FORMAT_YV12;
break;
case VideoCaptureDeviceAndroid::ANDROID_IMAGEFORMAT_NV21:
pixel_format = media::PIXEL_FORMAT_NV21;
break;
default:
break;
}
VideoCaptureFormat capture_format(
gfx::Size(media::Java_CaptureFormat_getWidth(env, format.obj()),
media::Java_CaptureFormat_getHeight(env, format.obj())),
media::Java_CaptureFormat_getFramerate(env, format.obj()),
pixel_format);
capture_formats->push_back(capture_format);
DVLOG(1) << device.name() << " resolution: "
<< capture_format.frame_size.ToString() << ", fps: "
<< capture_format.frame_rate << ", pixel format: "
<< capture_format.pixel_format;
}
}
const std::string VideoCaptureDevice::Name::GetModel() const {
......
......@@ -23,6 +23,13 @@ namespace media {
// but only VideoCaptureManager would change their value.
class MEDIA_EXPORT VideoCaptureDeviceAndroid : public VideoCaptureDevice {
public:
// Automatically generated enum to interface with Java world.
enum AndroidImageFormat {
#define DEFINE_ANDROID_IMAGEFORMAT(name, value) name = value,
#include "media/video/capture/android/imageformat_list.h"
#undef DEFINE_ANDROID_IMAGEFORMAT
};
virtual ~VideoCaptureDeviceAndroid();
static VideoCaptureDevice* Create(const Name& device_name);
......@@ -48,13 +55,6 @@ class MEDIA_EXPORT VideoCaptureDeviceAndroid : public VideoCaptureDevice {
kError // Hit error. User needs to recover by destroying the object.
};
// Automatically generated enum to interface with Java world.
enum AndroidImageFormat {
#define DEFINE_ANDROID_IMAGEFORMAT(name, value) name = value,
#include "media/video/capture/android/imageformat_list.h"
#undef DEFINE_ANDROID_IMAGEFORMAT
};
explicit VideoCaptureDeviceAndroid(const Name& device_name);
bool Init();
VideoPixelFormat GetColorspace();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment